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

Queuing and sending logged sensor data over BLE

Hello,

I need to send logged sensor data in external 4MB flash to a phone via BLE. 

I am using a nRF52840 based module on a custom PCB. I am using SDK v14.2.

I am using the Queue module to read logged data from in the flash and store it in a queue, which I then send to the phone via a suitable GATT characteristic.

My code is something like this:

  • In the main(), inside a while loop, I have 2 functions queue_log() ans send_log().
  • In queue_log() I read from flash and store in a queue. The type stored in the queue is a 12 byte structure.
  • In send_log(), I send the each of the values stored in the queue as a 12 byte each GATT characteristic using sd_ble_gatts_hvx().

But I am facing some issues. How best can I achieve this, considering that I need to send every value I store in the queue, hence I cannot overwrite the queue. 

If I use NRF_QUEUE_MODE_NO_OVERFLOW ,I get a  NRF_ERROR_NO_MEM, meaning that the queue is full.

What queue size should I use, considering that I might have upto 4MB of data to send? 

And what scheme can I use to queue up and send this data?

Thanks

  • Hi,

    Queue size: You are reading from external flash, and sending data over BLE as quickly as possible. The goal of the queue would then be to have a buffer of data that is ready to be sent, so that send_log() is never starved (never have to wait for data to be fetched from the external flash.) It depends on the speed, jitter and latency of reading from the external flash, and you may experience that a very short queue is enough.

    As the total amount of data is several times the amount of available RAM, increasing the queue size will never solve the issue of reading from flash faster than sending over BLE. If you get NRF_ERROR_NO_MEM you should wait until there is space in the queue again and then retry the flash read. You need to throttle the flash reads this way, so that they will not over time read more data from flash than what is sent out over BLE.

    Regards,
    Terje

Related