PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Bluetooth Socket using SerialPortServiceClass_UUID - Transmission Mode - Extra Chars
Bluetooth Socket using SerialPortServiceClass_UUID - Transmission Mode - Extra Chars
Iniciado por Mark, set., 27 2014 2:42 PM - 2 respostas
Publicado em setembro, 27 2014 - 2:42 PM
I am using WinDev Mobile 19 and have a question about using Bluetooth Sockets. I am able to connect to the device without a problem. I am writing a string to the socket using SocketWrite which works fine, but, what I receive on the bluetooth device has extra information.

I found where, by default, the length of the data is sent first along with a <CRLF>. I didn't want that so I switched it to using the EOT (0x4) marker at the end (using the SocketChangeTransmissionMode function).

THE ISSUE: I am getting a 0 (0x0) after each characters in the string. So, the chars receivied after sending "zz" are:

"z" + 0x0 + "z" + 0x0 + 0x4

Can anyone tell me why I am getting the 0 after each character?

Thank you in advance!

Mark

// if no devices, leave
IF HRecNum(BTDevices)=0 THEN RETURN
sMACAddress is string = LIST_BTNames
IF LIST_BTNames <> "" THEN
IF SocketExist(sBTSocketName) = False THEN
IF SocketConnectBluetooth(sBTSocketName , "SerialPortServiceClass_UUID" , sMACAddress,2000) = False THEN
Info("Unable to connect to socket: " + sBTSocketName + " " + ErrorInfo)
RETURN
END
END
IF NOT SocketChangeTransmissionMode(sBTSocketName,SocketEndTagBuffer,EOT) THEN
Info("Unable to set socket transmission mode!")
RETURN
END
IF SocketWrite(sBTSocketName,"zz") = False THEN
Info("Unable to connect to socket: " + sBTSocketName + " " + ErrorInfo)
END

END
Publicado em setembro, 27 2014 - 7:53 PM
Hi Mark

without looking at your code, I would say that it's because you are
using a UNICODE string, where each character is stored on TWO bytes, and
where for 'normal' ascii chars, the second byte is zero.


After reading your code, I can confirm...
When you do :
> IF SocketWrite(sBTSocketName,"zz") = False THEN

"zz" is a unicode string by default..

Try doing instead
asMyString is ANSI string="zz"
IF SocketWrite(sBTSocketName,asMyString) = False THEN


Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com

On 9/27/2014 6:42 AM, Mark wrote:
I am using WinDev Mobile 19 and have a question about using Bluetooth
Sockets. I am able to connect to the device without a problem. I am
writing a string to the socket using SocketWrite which works fine, but,
what I receive on the bluetooth device has extra information.
I found where, by default, the length of the data is sent first along
with a <CRLF>. I didn't want that so I switched it to using the EOT
(0x4) marker at the end (using the SocketChangeTransmissionMode function).
THE ISSUE: I am getting a 0 (0x0) after each characters in the
string. So, the chars receivied after sending "zz" are:

"z" + 0x0 + "z" + 0x0 + 0x4

Can anyone tell me why I am getting the 0 after each character?

Thank you in advance!

Mark

// if no devices, leave
IF HRecNum(BTDevices)=0 THEN RETURN
sMACAddress is string = LIST_BTNames
IF LIST_BTNames <> "" THEN
IF SocketExist(sBTSocketName) = False THEN
IF SocketConnectBluetooth(sBTSocketName ,
"SerialPortServiceClass_UUID" , sMACAddress,2000) = False THEN
Info("Unable to connect to socket: " + sBTSocketName + " "
+ ErrorInfo)
RETURN
END
END
IF NOT
SocketChangeTransmissionMode(sBTSocketName,SocketEndTagBuffer,EOT) THEN
Info("Unable to set socket transmission mode!")
RETURN
END
IF SocketWrite(sBTSocketName,"zz") = False THEN
Info("Unable to connect to socket: " + sBTSocketName + " " +
ErrorInfo)
END

END
Publicado em setembro, 28 2014 - 1:50 PM
Thank you Fabrice! That was the issue!