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

Advice on doing several characteristic writes in a row as fast as possible ?

Hello Nordic team, 

I'm currently working on a project on a nrf52840 DK with the SDK 15.3.0.

As central role, I have an external component that sends big chunks of data to be written in the peripheral device characteristic. 

The chunks size are about 512 bytes and the characteristic to write the data in has a maximum size of 20 bytes. 

To send the data I'm using a function similar to the uart client example :  ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, uint16_t length).

My current idea to implement this is to add a FIFO to buffer the incomming data and do multiple calls to ble_nus_c_string_send to send all the data every time the sd_ble_gattc_write() returns the  BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event to empty the FIFO.

Is this the best way to achieve my purpose or do you suggest another way to do this ? I need the data to be sent the fastest it can.

I have seen in the SDK some code about Queued Writes module https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fgroup__nrf__ble__qwr__config.html

Would this be a good way to realize this ? 

Thanks in advance,

Aloïs KYROU.

Parents
  • Hi Aloïs,

    Please have a look at the attached example below. I based it on the ble_app_uart_c example in sdk 15.3.0 and added a ring buffer to queue write commands in the app in order to handle any "no resource" error from the send API. 

    ble_app_uart_c_mod.zip

    Note: the timer instance used to process the buffer in this example is not really necessary, and the project is configured for 52832 so you should copy the source code to a 52840 project before you try it. 

Reply
  • Hi Aloïs,

    Please have a look at the attached example below. I based it on the ble_app_uart_c example in sdk 15.3.0 and added a ring buffer to queue write commands in the app in order to handle any "no resource" error from the send API. 

    ble_app_uart_c_mod.zip

    Note: the timer instance used to process the buffer in this example is not really necessary, and the project is configured for 52832 so you should copy the source code to a 52840 project before you try it. 

Children
Related