Problems receiving data with latest BLE extension

Hello Evan

I am developing an app to send and read serial data from a peripheral BLE device. Everything I send from the app to the periph. arrives perfectly with no problems. But receiving simple strings, bytes etc. is a true problem since every now and then the data arrives incomplete. In this case the first few bytes are missing. Sometimes even only the last byte is present. If I send just 1 char this does not happen. Same is with integers, bytes etc. The higher the repetition rate, the higher the error rate. I need to receive 3 packets of 20 bytes / sec.

There must be some issue with the RX buffer or do I missunderstand something?
Thank you for your help.

Best regards
Jürgen

In Bluetooth low energy versions 4.x, the data payload in a packet is max 23 bytes. Odds are if you are trying to send more than that in one go over the link, then you're going to run into problems. This could happen on either side of the link, depending on your hardware, especially if the serial link on the peripheral side is buffering the content as well. Are you using the Read calls or Register calls to get the data? Register might give you a better success rate since the Android OS will raise the event when it receives new data rather than polling with Read, where you might lose data if you don't poll fast enough.

Thanks for your answer.
I am using register calls to receive data.
The payload cannot be the problem. Even if I send only 4 to 10 bytes in one package with a repetition frequency of 3 Hz every now and then the first bytes are just missing. Only the last byte is always! present.
So if I send the word "Hello". I get "ello", "llo" or "o" in 5 of 100 transmissions.
The other direction works 100%. If I send bytes or strings from the app to the peripheral this problem does not occur.
This might be an internal buffering issue?

We need to see details in order to help Jurgen.
Android device make and model; Show us your Blocks.
BLE device - is this a microcontroller? Details please, including it's script (rename the script file extension to .txt).

,,,, and Bluetooth version of both items of hardware.

Hello,

I will send you the blocks and code later.

Here the hardware specs:.

Android is Version 12 on a SM-G998B-DS.
BT 5.0

I tested with 2 different devices to find out if this problem comes from the controller side:

  • Adafruit Bluefruit M0 with nordic NRF51 chip. BT version 4.0

  • commercially available BLE to RS232 adapter with PAN172x chip. BT version 4.0 using a simple terminal software @ 19200 bps.

The problem occurs no matter which device I use.

Well, that's actually a good thing - if it only happened with the Bluefruit we might of had a big struggle to fix the issue. It seems everyone who uses the Bluefruit boards has difficulty working with them (with App Inventor).

Please post them here.
If your data is simply too large, it may be possible to increase the MTU (maximum transmission unit) on the device and in the App.

Hi,

It seems that the problem does not occur anymore in the finished app. Probably this is due to intensive data processing after each received data package which gives the devices enough time to empty the buffers :grin:
Thank you anyway for your help.

1 Like

hi,
i have same issue .. so what is the difference in the finished app? what was the reason .. did u need to add delay ? where, when?
thanks