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

Does "ble_nus_string_send" ensure that the data is transmitted, if the error_code is NRF_SUCCESS ?

I'm using nrf52832DK with seggers studio and SDK 14.2. My settings are following.

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(30, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY                   0

I have multiple slaves connected to a master. And every slave sends data only after "BLE_NUS_EVT_TX_RDY" event is generated. But I'm seeing some packets drop as I increase the number of slaves or increase the frequency of transmission.

1. My question is that if I get no error on the "ble_nus_string_send" function, does it mean that packet has been transferred to the master successfully? If not, how can the slave know that the data that it transmitted has been dropped or received by master ? I can implement some sort of handshake between master and slave but that would slow down the communication, I'm looking for some function already implemented in the stack/sdk.

2. Also what does the "sd_ble_gatts_rw_authorize_reply" function do ? Can it solve the issue in question above ?

Parents
  • Hello,

    if ble_nus_string_send() returns NRF_SUCCESS, it means that the packet is sent to the softdevice. If the link is broken, the package is not necessarily delivered, but as long as the link is up, the softdevice will continue to re-transmit the pack until it is ACKed from the central.

    BLE_GATTS_EVT_HVN_TX_COMPLETE is an event that is generated when you receive an ACK. If you want the event in your main.c file, you can add the BLE_GATTS_EVT_HVN_TX_COMPLETE event to the ble_evt_handler() function.

    If you want to transfer a large amount of data, you can queue them up using ble_nus_string_send() while it returns 0 (NRF_SUCCESS). When it returns NRF_ERROR_RESOURCES, it means that the buffer is full, and the last packet is not queued. Then you must wait for a BLE_GATTS_EVT_HVN_TX_COMPLETE event, which means that one of the packets has been ACKed, and you have space to queue another.

    Best regards,

    Edvin

Reply
  • Hello,

    if ble_nus_string_send() returns NRF_SUCCESS, it means that the packet is sent to the softdevice. If the link is broken, the package is not necessarily delivered, but as long as the link is up, the softdevice will continue to re-transmit the pack until it is ACKed from the central.

    BLE_GATTS_EVT_HVN_TX_COMPLETE is an event that is generated when you receive an ACK. If you want the event in your main.c file, you can add the BLE_GATTS_EVT_HVN_TX_COMPLETE event to the ble_evt_handler() function.

    If you want to transfer a large amount of data, you can queue them up using ble_nus_string_send() while it returns 0 (NRF_SUCCESS). When it returns NRF_ERROR_RESOURCES, it means that the buffer is full, and the last packet is not queued. Then you must wait for a BLE_GATTS_EVT_HVN_TX_COMPLETE event, which means that one of the packets has been ACKed, and you have space to queue another.

    Best regards,

    Edvin

Children
No Data
Related