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

BLE_ERROR_NO_TX_BUFFERS

Hi.

What is the best way to handle error 0x3004 on ble_nus_string_send(...)?

The issue is that i use scheduler

  • If you don't care wasting CPU time then simple while loop is fine:

    do{
      err_code = ble_nus_send_string(&m_nus, dbuf, fifo_len);
    }while(err_code == BLE_ERROR_NO_TX_BUFFERS);
    

    That will have maximum throughput. If you need to do something else while BLE stack is busy then leave function which calls ble_nus_send_string(), do other task then put in scheduler function with ble_nus_send_string() again to repeat sending old data.

  • hi, in your example there is no app_sched_execute() so i will stuck in while loop.

  • If you want scheduler to be executed while waiting for space in buffer then you have to exit function where you called ble_nus_send_string(). app_sched_execute() will be called in the loop in main(). But you need to make sure that you put at some point in scheduler function with ble_nus_send_string() to re-send data. If you want to call app_sched_execute() only because you think do{}while loop will be infinite then it is incorrect, ble_nus_send_string() will return different error if SoftDevice can't send data at all, most likely it will be disconnection error.

Related