Bluetooth Device data stream

Rusty

Well-Known Member
Licensed User
Longtime User
Erel,
Have you ever connected via Bluetooth to a Bluetooth RS-232 device.
For example, there are devices out there such as Bluetooth heart monitoring devices and others that I need to be able to stream their data to a file via Bluetooth. If so, can you recommend a code example or reference?
The data stream is not prefixed, it is raw data bytes.
Thanks,
Rusty
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Have you ever connected via Bluetooth to a Bluetooth RS-232 device.
Yes.

You should use AsyncStream in regular mode (not prefix). This means that there is no guarantee that the messages that you receive arrive as a single packet.

However if you just want to write the received data to a file then it is quite simple.
1. Open an OutputStream with File.OpenOutput
2.
B4X:
Sub AStream_NewData (Data() As Byte)
 out.WriteBytes(Data, 0, Data.length)
 out.Flush '<- if you want the data to immediately be written
End Sub
 
Upvote 0
Top