nrf ble_g9:sD GATT procedure (1)failed on connection handle 0 with error:0x00000008.

Hi

When l was using the function ble nus_c_string_send0 for datatransmission, an error occurred. The error code was 0x00000008.And at this point, the system resets.l don't want my system to reset.What should l do when l encounter this error?

sdk version:17.1.0

Parents
  • Hi,

    The error 0x00000008 is NRF_ERROR_INVALID_STATE. The most likely reason for this being returned from a call to nus_c_string_send() is that notifications is not enabled on the characteristic, and in that case, the error is returned. This is the same issue as discussed in this thread.

    By default APP_ERROR_CHECK() will reset on any errors for release builds, as that is a way to recover from otherwise unhandled errors run time. If it fits better with your application and you do not want to reset for this error you could check specifically if nus_c_string_send() returns NRF_ERROR_INVALID_STATE, and only call APP_ERROR_CHECK for the return value if it does not.

    (It is also possible to not reset on errors, but I would advice against that except for debug builds.)

  • Hi,

    After thorough debugging of the ble_nus_c_string_send() function, I identified two potential points returning 0x00000008. During execution, the function checks if (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID). If true, it returns NRF_ERROR_INVALID_STATE. However, my error did not originate here, possibly due to insufficient problem description earlier.

    The ble_nus_c_string_send() function calls nrf_ble_gq_item_add(), which subsequently invokes request_process(). The 0x00000008 error is actually generated by sd_ble_gattc_write() within request_process(). Upon this error, execution ultimately jumps to nus_error_handler() – the error callback function I specified during NUS-C initialization. Since I used APP_ERROR_HANDLER in nus_error_handler(), it triggers a system reset

    My core questions are:

    1. Can I safely ignore this error and resume sending operations?

    2. Should I instead disconnect the current BLE link and restart scanning/reconnection procedures?

Reply
  • Hi,

    After thorough debugging of the ble_nus_c_string_send() function, I identified two potential points returning 0x00000008. During execution, the function checks if (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID). If true, it returns NRF_ERROR_INVALID_STATE. However, my error did not originate here, possibly due to insufficient problem description earlier.

    The ble_nus_c_string_send() function calls nrf_ble_gq_item_add(), which subsequently invokes request_process(). The 0x00000008 error is actually generated by sd_ble_gattc_write() within request_process(). Upon this error, execution ultimately jumps to nus_error_handler() – the error callback function I specified during NUS-C initialization. Since I used APP_ERROR_HANDLER in nus_error_handler(), it triggers a system reset

    My core questions are:

    1. Can I safely ignore this error and resume sending operations?

    2. Should I instead disconnect the current BLE link and restart scanning/reconnection procedures?

Children
  • Hi,

    h_544364 said:
    Can I safely ignore this error and resume sending operations?

    In principle, yes. As far as the SoftDevice is concerned, nothing has changed so it would be as if the call never happened. (Depending on you rapplication and use case that may be OK, or you may need to digg further to understand why this happens in the first place).

    h_544364 said:
    Should I instead disconnect the current BLE link and restart scanning/reconnection procedures?

    I do not see a reason for tha tunless there is more fundamentally wrong. However, in order to accept this you should understand why this happens so that you can explicitly allow this to happen. As mentionned, normal practice is to perform a system reset for other erors that are unexpected and unhandled (as that is the only safe way to recover from an unexpected and unhandled error).

  • Hi,

    I tried ignoring this error by removing APP_ERROR_HANDLER(nrf_error), and it seemed the system could run normally. However, I’ve now encountered a new error: nrf_ble_gq: SD GATT procedure (2) failed on connection handle 0 with error: 0x00000007. I attempted to ignore this error again, but it doesn’t seem to work. When calling the sd_ble_gap_connect() function for BLE connection, it consistently returns an error. I’ve already increased the NRF_BLE_GQ_QUEUE_SIZE in sdk_config.h to 150, but this only seems to delay the occurrence of the error rather than resolve it. Regarding the 0x00000007 error, what would be your recommended solution? (I need to avoid system reboots).

    thank you

  • Hi,

    Generally, you should backtrack and understand why you get the errors instead of primarily focusing on how to handle it when it has happened. Error 0x07 is NRF_ERROR_INVALID_PARAM, so it means that you have provided an invalid set of parameters to the function call. The error does not say more than that, so you need to check that all the paramters (including all fields of configuration structs like the ble_gap_scan_params_t and ble_gap_conn_params_t instance you passed are valid.

  • Hi,

    Indeed, the 0x00000007 error occurs when calling the sd_ble_gap_connect() function. Thanks for pointing that out.

Related