Missing characters in Bluetooth streams

Chris_Moulding

Member
Licensed User
Longtime User
I'm writing an app that reads text data sent via Bluetooth from a radio terminal node controller.

Sometimes the first character or two in the stream are missing.

I'm assembling the string using Async NewData with BytestoString with Stringbuilder and 99.9% of the time it's OK but the missing characters are causing problems as the link has to be error free.

I find that if the Bluetooth link is strong it's 100% but if the link is weak then the errors start to appear.

Is there any way around this?

Is there any way to measure the signal strength or link quality of the Bluetooth link? I could then pause string processing when the Bluetooth signal is weak. I know that a Bluetooth RSSI isn't included in Android yet but is there any alternative way to get an idea of signal strength?

Thanks,

Chris
 

Stulish

Active Member
Licensed User
Longtime User
The other way is to use a checksum, so the program sending the stream sends a check sum, if the receiving unit has a checksum error it either asks for it to be sent again or the program sending waits for a 'received ok' message.

This will always be a problem with wireless coms, thus you need some sort of flow control.

Not sure if this helps at all.

Regards

Stu
 
Upvote 0

Chris_Moulding

Member
Licensed User
Longtime User
Thanks for the replies.

I'll look at adding a checksum to the firmware of the radio controller. I was hoping to avoid that!

I'll also take a look at AsyncStreamsText.

Thanks again,

Chris
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
This will always be a problem with wireless coms, thus you need some sort of flow control.
I am not so sure about that statement. If you have a stable connection there should be not need for checksums or other flow control if your code knows "what" (how many numbers, for example) is being sent and received (this automatically is kind of flow control). I realized when transmission was unstable the reason were cold joints. Having cured the hardware problems the transmission works seemless both ways without additional flow control. It's running like a clock- for hours, amazingly. Using Serial, Textreader. Asyncstreams I did not get working reasonably.
Regards, positrom2
 
Last edited:
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
I have worked with BT for a while and when the signal and hardware are fine everything is great.

I have also found as you move out of range and the signal drops off then you can encounter problems.

I generally use a checksum the main reason for the this is to ensure the data integrity. My recieve app knows what to expect as in the format of the serial stream but does not know the exact content. for example if the serial stream sends %start,1111,2222,3333,4444,CRLF the app knows to look for the '%start' and a CRLF to find the info and it will know there are 4 fields (this is not always the case), the 1's, 2's, 3's amd 4's could be any numbers if the wrong number is received then your app could do any number of odd things, by using a checksum the app will know that the data is corrupt and thus not use it or ask for it again.

as Positrom said flow control is not needed if everything (environment and hardware) are all good, but i find it is an extra layer to ensure correct operation.

Regards

Stu
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…