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

Cancel of pairing causes app_error_handler to be called

I'm using the 8.0 SDK and an iPad with iOS8.3. I'm experiencing the same issue described here: pairing cancel cause reset

I've written my own service, however, I can reproduce the reset condition using the Blood Glucose sample application.

  1. Compile the gls sample application with DEBUG defined (this disables the NVIC_SystemReset)
  2. Using the nRF Toolbox on an iOS device, connect to your peripheral
  3. When prompted to pair, hit cancel

The peripheral will now be locked up because the app_error_handler has been called. The reset hides that something bad has happened (I thought my service was as fault).

I don't think this issue is limited to any particular service. Is there a proper way to prevent this error?

  • Hi,

    When you say cancel while pairing, then it is a failure of the authentication procedure. in the application you are using, the event callback function assumes that there will be no error in the paring sequence. This is just an example and does not handle all possible errors that could happen. If you can handle the error at line APP_ERROR_CHECK(event_result); then this app would know about this failure and handle accordingly.

    static uint32_t device_manager_evt_handler(dm_handle_t const    * p_handle,
                                               dm_event_t const     * p_event,
                                               ret_code_t        event_result)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        m_dm_handle = *p_handle;
        APP_ERROR_CHECK(event_result); //handle this
     ...
    }
    
  • Gotcha. I have modified this code like so:

    switch (event_result)
    	{
    		case BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED:
    		{
    			err_code = sd_ble_gap_disconnect(m_conn_handle , BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    			APP_ERROR_CHECK(err_code);
    			return NRF_SUCCESS;
    		}
    		default:
    			APP_ERROR_CHECK(event_result);
    	}
    

    And it is behaving as desired.

Related