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

Data loss while sending large data by notifications with custom BLE service

Hello everyone,

A nRF52832 with SDK 15.0 was used for my application. I am trying to send a large amount of data via BLE with a custom BLE service. I extended MTU size so that it can meet my demand in both Client and Server. My Android app was developed to get the data. To check whether data sent by BLE device are lost or not, I added an index after a data package of 48-byte long. The following image is about index I got. 

There are 1, 2 or even 3 packages lost during data transmission. In this case, I tried to set the value of interval connection as low as possible (9ms). If I increased this interval as I have tested (24ms), there are more data packages lost.

Interestingly, if I use NUS BLE service instead and UART Android app to collect data,  this issue didn't happen and I can send up to 60 byte data per package without data loss. I double-checked my update data in custom BLE service, it is similar to that in NUS BLE service. 

Thus, are there any suggestion for me to solve this issue on the custom BLE service?

Thanks!

Parents
  • Ah-ha! You raise an interesting question. The Nordic Uart Service (NUS BLE Service) is not the same as the code you have above - the transfer of data from the Peripheral to the Central in NUS uses a Write Request, which requires an acknowledgement and therefore can only occur once every Connection Interval. The code you are using above uses a Write Command, which does not require an acknowledgement and can therefore be significantly faster with multiple packets possible in a Connection Interval. Note the NUS uses Write Command when the Central sends data to the Peripheral; Write Request is only Peripheral to Central in NUS.

    Does it matter? Well I didn't think so, as the handshake indicating packet success should occur at the LL level, but maybe that is not the case. In this post I asked about basically the same thing, and got a good response from martinbl which I recommend you read.

  • the transfer of data from the Peripheral to the Central in NUS uses a Write Request

    I don't think so as it uses notification to transmit data. I quoted what Martinbl answered in your post: The NUS peripheral example on the other hand, uses notifications. It is done with the function sd_ble_gatts_hvx() and happens in the function ble_nus_string_send() at the bottom of the file ble_nus.c.

    Btw, this post and this one mentioned about this term NRF_SDH_BLE_GAP_DATA_LENGTH which negotiates the BLE GAP data exchange. My project has been set this term with value of 27, I'll increase this and see what happens.

  • Good point. I have the following

    #ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
    #define NRF_SDH_BLE_GAP_DATA_LENGTH 251
    #endif

Reply Children
Related