Android Question Bluetooth

Cenny

Active Member
Licensed User
Hi,

Can somebody help me solving my next problem:
I want to receive a stream of 260 8 bits values in the range from 0-255 from some device via bluetooth.
Bluetooth is expecting the incoming stream to be of type byte (-128 to 127)
I was told to use the Byteconverter library, but I have no idea how.

Cenny
 

derez

Expert
Licensed User
B4X:
Dim bc As ByteConverter
Sbuffer = bc.StringToBytes( data_string ,"UTF8") 
AStream.Write(Sbuffer)
and back:
B4X:
Dim st As String
st = BytesToString(buffer, 0, buffer.Length, "UTF8")
 

Cenny

Active Member
Licensed User
B4X:
Dim bc As ByteConverter
Sbuffer = bc.StringToBytes( data_string ,"UTF8")
AStream.Write(Sbuffer)
and back:
B4X:
Dim st As String
st = BytesToString(buffer, 0, buffer.Length, "UTF8")
Thanks for your reaction, but this is all about strings.
Is there something for numbers as wel?
 
Top