The example found in the forum unfortunately does not work for me :-(
It displays the contents and size of the buffer correctly, but the length of the data is already 0, so of course I can't read the bytes one by one either.
B4X:
Sub AStream_NewData (buffer() As Byte )
Dim be(10) As Object 'used as a storage buffer. Can be a global variable
Dim data() As Object = ser.ConvertBytesToArray(buffer, be)
Log("NewData: ", buffer)
astream.Write("Echo from ESP32: ")
astream.Write(buffer)
bt.Stream.Flush
a = buffer.Length
Log(a)
Log(data.Length)
Log("-")
Log(data(0))
Log(data(1))
Log(data(2))
Log("---")
End Sub
I misunderstood the serializer, I don't need it, since the buffer can also be read simply byte by byte.
Thanks for the help!
B4X:
Sub AStream_NewData (buffer() As Byte )
'' Dim be(10) As Object 'used as a storage buffer. Can be a global variable
'' Dim data() As Object = ser.ConvertBytesToArray(buffer, be)
Log("NewData: ", buffer)
astream.Write("Echo from ESP32: ")
astream.Write(buffer)
bt.Stream.Flush
a = buffer.Length
Log(a)
'' Log(data.Length)
Log("-")
Log(buffer(0))
Log(buffer(1))
Log(buffer(2))
Log("---")
End Sub