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

ble_nus_string_send error codes

Hi all,

I'm sending data with ble_nus_string_send() in a loop as shown below. If it returns an error it retries until it gets NRF_SUCCESS. I'm getting an error code 0x0013. Does anyone know what this means or where in the documentation this is stated? Thanks.

			for (int i=0; i<11; i++)
			{
				err = ble_nus_string_send(&m_nus, testData, &testDataLength);
				while (err != NRF_SUCCESS)
				{
					errorCounter++;
					err = ble_nus_string_send(&m_nus, testData, &testDataLength);
					SEGGER_RTT_printf(0, "Error encountered: %04x\n", err);
				}
			}
Parents
  • Hi,

    If you are using SDK v14.x.0, and Softdevice s132 v5.0.0, you can find Global Error Codes documentation here.

    The error code 0x0013 (decimal 19) corresponds to NRF_ERROR_RESOURCES. In the source code of ble_nus_string_send(), you can see that the return value is either NRF_ERROR_INVALID_STATE. NRF_ERROR_INVALID_PARAM, or the return value from call to sd_ble_gatts_hvx().

    The documentation give the following reason for the error code:

    NRF_ERROR_RESOURCES Too many notifications queued. Wait for a BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry.

    Best regards,

    Jørgen

  • Hi Jorgen,

    Yes SDK 14 and SD S132 v5.

    Thanks for the tip. I didn't know I had to comb through the source code to find this info...I thought it would be in the online docs somewhere.

    As for the error, is it best to wait for a TX COMPLETE event upon an error? Or is it acceptable to do what I'm doing now and keep calling the function until a NRF_SUCCESS is received? I presume the latter has some undesirable overhead. Or, should we do what the comments say in ble_gatts.h and keep a count of the tx_queue_size and only call ble_nus_string_send() when there is space?

    Thanks for the help. Cheers.

Reply
  • Hi Jorgen,

    Yes SDK 14 and SD S132 v5.

    Thanks for the tip. I didn't know I had to comb through the source code to find this info...I thought it would be in the online docs somewhere.

    As for the error, is it best to wait for a TX COMPLETE event upon an error? Or is it acceptable to do what I'm doing now and keep calling the function until a NRF_SUCCESS is received? I presume the latter has some undesirable overhead. Or, should we do what the comments say in ble_gatts.h and keep a count of the tx_queue_size and only call ble_nus_string_send() when there is space?

    Thanks for the help. Cheers.

Children
No Data
Related