Android Question asyncstreams & bluetooth

atiaust

Active Member
Licensed User
Longtime User
Hi Erel,

I have a B4A app using a Bluetooth connection connected to an arduino board with an app written in B4R.
When I send a text massage to the Arduino board it initiates a response back to the B4A app but only the first response is recieved as one line : ie You: Recieved
all following responses appear as 2 lines ie
You: R
You: ecieved

I am using

B4X:
Sub AStream_NewData (Buffer() As Byte)
    LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
    Log("buffer lenght = " & Buffer.Length)
End Sub

I have read all the tutorials and issues relating to asyncstreams but can't see a straight forward way to fix.

Any help appreciated.

Thanks
 

atiaust

Active Member
Licensed User
Longtime User
This is a community forum. Please don't limit your questions to a single member.

This is how network communication works. You cannot rely on the message to arrive as a single "packet".

You can use AsyncStreamsText and in B4R send the byte 10 at the end of each message.
Sorry, did not mean to neglect the rest of the community.

How do I add byte 10 to the message when you can't concatenate.. I understand this is part B4R question.
 
Upvote 0
Top