Cenny Active Member Licensed User Longtime User Jun 10, 2015 #1 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
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 Longtime User Jun 10, 2015 #2 Code: Copy Dim bc As ByteConverter Sbuffer = bc.StringToBytes( data_string ,"UTF8") AStream.Write(Sbuffer) and back: Code: Copy Dim st As String st = BytesToString(buffer, 0, buffer.Length, "UTF8") Upvote 0
Code: Copy Dim bc As ByteConverter Sbuffer = bc.StringToBytes( data_string ,"UTF8") AStream.Write(Sbuffer) and back: Code: Copy Dim st As String st = BytesToString(buffer, 0, buffer.Length, "UTF8")
Erel B4X founder Staff member Licensed User Longtime User Jun 10, 2015 #3 Note that you can also convert a string to bytes with: Code: Copy buffer = data_string.GetBytes("UTF8") 'this is also possible: "some text".GetBytes("UTF8") Upvote 0
Note that you can also convert a string to bytes with: Code: Copy buffer = data_string.GetBytes("UTF8") 'this is also possible: "some text".GetBytes("UTF8")
Cenny Active Member Licensed User Longtime User Jun 10, 2015 #4 derez said: Code: Copy Dim bc As ByteConverter Sbuffer = bc.StringToBytes( data_string ,"UTF8") AStream.Write(Sbuffer) and back: Code: Copy Dim st As String st = BytesToString(buffer, 0, buffer.Length, "UTF8") Click to expand... Thanks for your reaction, but this is all about strings. Is there something for numbers as wel? Upvote 0
derez said: Code: Copy Dim bc As ByteConverter Sbuffer = bc.StringToBytes( data_string ,"UTF8") AStream.Write(Sbuffer) and back: Code: Copy Dim st As String st = BytesToString(buffer, 0, buffer.Length, "UTF8") Click to expand... Thanks for your reaction, but this is all about strings. Is there something for numbers as wel?
Erel B4X founder Staff member Licensed User Longtime User Jun 10, 2015 #5 Code: Copy AStream.Write(Array As Byte(1,2, 250, 200, 0xEA)) 'it will work correctly Upvote 0