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

[ANCS] pairing problem

Hi everybody!

I am working on ANCS and I found a problem that: At the first time I connect my Iphone to the dev kit, the pair request appeared on the Iphone. If I ignore the pair request, I cannot connect to the dev kit in the next time. In my case, to connect my iphone to the dev kit (for the next time) I have to erase the firmware and upload new firmware using nrfstudio.

Is there any way to solve it without erase firmware ?

Thank you very much.

  • Hello.

    When the iphone does not respond to the pairing request from the dev kit, the dev kit will get a timeout. It seems like this timeout lead to your device hanging.

    • Does it work if you just reset the board with the reset button?
    • Have you defined DEBUG as a linker flag?
    • Which SDK are you working from?
    • See this thread about debugging the error handler.

    In the ancs example, main.c line 609:

     case BLE_GATTS_EVT_TIMEOUT:
                 printf("Timeout.\n\r");
                 // Disconnect on GATT Server and Client time-out events.
                 err_code = sd_ble_gap_disconnect(m_conn_handle,
                                                  BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                 APP_ERROR_CHECK(err_code);
                 break;
    

    This is probably what is happening.

    UPDATE 1:

    I have reproduced the behavior, and found the following:

    Ignoring the timeout causes the BLE event BLE_GAP_EVT_AUTH_STATUS, which is handled in the device manager. The device manager will create a dm-event with the event id DM_EVT_SECURITY_SETUP_COMPLETE. Since the authorization failed, the event_result is set to BLE_GAP_SEC_STATUS_TIMEOUT, which has the value 1. The device manager passes this event to the main application with the callback function device_manager_evt_handler, which calls

    APP_ERROR_CHECK(event_result);
    

    Since event_result is 1, the error handler will stop the application and do error handling. See the thread linked above for error handler debugging. The solution will be to filter out the event caused by ignoring the pairing.

    if (p_evt->event_id != DM_EVT_SECURITY_SETUP_COMPLETE){
        APP_ERROR_CHECK(event_result);
    }
    

    The device will now handle the disconnect, and start advertising

    -Anders

  • Thank you very much for your reply. I am not sure the dev kit will get time out because the text "Time out" does not display on the Termite.

    • And it does not work when I press reset button.
    • The SDK is nRF51_SDK_9.0.0_2e23562.
    • I do not use DEBUG as a linker flag
Related