This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to send long data to ble_app-uart from android?

What is the best method for sending long data to ble_app_uart from android? We tried sending data by breaking into 20 bytes chunks and used thread.sleep() between each packet. Is that the correct method of doing it? How to achieve the maximum throughput of nrf51822?

  • Hi Mukesh,

    In stead of putting the code to sleep, you can wait for the call back onCharacteristicWrite() to continue to write the next chunk.

    You can have a look at how we do it with the UART profile in the nRFToolbox here. The callback happens when the packet is queued into the TX buffer on the phone (not when the peripheral actually received the packet).

    However, we experienced some issue with Android device, that when you queue (with wait for callback) too many packets (varied on phones, from 12 to 50) without a break, the phone just hangs, no more call back.

    So you can either have a delay on every 10 packets, or you can implement a confirmation notification scheme that you send a notification from the peripheral every time you receive 10 packets for example. The central will stop after sending 10 packet and wait for the notification before it continues.

  • We tried the method that you mentioned in your reply. But we are still facing some problem. The IC is only receiving 3 packets of data (60 bytes). I think it is getting disconnected during the communication. Also we tried with 20 ms delay between 3 packets. With that delay sometimes it is not receiving the data completely. With 50ms delay it is receiving the data completely. I guess it is the problem related to the min connection interval time. How does the connection interval time is synchronised between the central and peripheral?

  • Hi Mukesh,

    Please provide a sniffer trace so we can figure out what happens over the air.

Related