nRF52832 pm_conn_secure() return 0x3002

I have implemented bonding mechanism in nRF52832 firmware. But when I request nRF Connect to connect nRF52832 second time. nRF52832 pm_conn_secure() return 0x3002 and nRF Connect log message shows "authentication failed with status BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP".

nRF52832 log messages:

 0> <info> app: Version 1.0.0
 0>
 0> <info> app: ========| flash info |========
 0> <info> app: erase unit:   4096 bytes
 0> <info> app: program unit: 4 bytes
 0> <info> app: end address: 0x7FFFF
 0> <info> app: ==============================
 0> <info> app_timer: RTC: initialized.
 0> <debug> app: NOR_DATA_PERIOD=819
 0>
 0> <debug> app: NOR_RECORD_PERIOD=8192
 0>
 0> <info> app: bsp_button_longkey_handler 0.
 0> <warning> app: Battery volage 102mV is too low
 0>
 0> <warning> app: Battery volage 8mV is too low
 0>
 0> <info> app: Reg 9 A
 0> <info> app: bsp_button_longkey_handler 1.
 0> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
 0> <info> app: BLE_GAP_EVT_CONNECTED
 0>
 0> <debug> app: state=1
 0>
 0> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
 0> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
 0>
 0> <info> app: PM_EVT_CONN_SEC_SUCCEEDED
 0>
 0> <info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 2.
 0> <info> app: BLE_GAP_EVT_AUTH_STATUS
 0>
 0> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
 0>
 0> <info> app: PM_EVT_CONN_SEC_SUCCEEDED
 0>
 0> <info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
 0> <info> app: BLE_GAP_EVT_AUTH_STATUS
 0>
 0> <info> app: BLE_GAP_EVT_DISCONNECTED
 0>
 0> <debug> app: state=0
 0>
 0> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
 0> <info> app: PM_EVT_BONDED_PEER_CONNECTED
 0>
 0> <info> app: BLE_GAP_EVT_CONNECTED
 0>
 0> <debug> app: state=1
 0>
 0> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
 0> <info> app: PM_EVT_CONN_SEC_CONFIG_REQ
 0>
 0> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
 0>
 0> <info> app: PM_EVT_CONN_SEC_FAILED
 0>
 0> <info> app: Faield to secure connection with handle 00.
 0> <info> app: BLE_GAP_EVT_AUTH_STATUS
 0>
 0> <warning> app: sd_ble_gap_disconnect() failed, errCode=0x8
 0>
 0> <info> app: BLE_GAP_EVT_DISCONNECTED
 0>
 0> <debug> app: state=0
 0>
 0> <debug> app: _securityRequestHandler
 0>
 0> <warning> peer_manager: pm_conn_secure() e
 0>
 0> <warning> peer_manager: pm_conn_secure() return 0x3002
 0>
 0> <warning> app: pm_conn_secure() failed
 0>

nRF Connect log messages:

13:27:42.245    Using nrf-device-lib-js version: 0.4.11
13:27:42.245    Using nrf-device-lib version: 0.11.8
13:27:42.245    Using nrfjprog DLL version: 10.15.4
13:27:42.245    Using JLink version: JLink_V7.66a
13:27:42.245    Installed JLink version does not match the provided version (V7.58b)
13:27:42.471    Updated list of uuids with data from github.com/.../v1
13:27:58.686    Selected device with s/n F092AF29DAF8
13:27:58.692    Device setup completed
13:27:58.692    Connectivity firmware version: ble-connectivity 4.1.4+Mar-11-2021-08-36-04. SoftDevice API version: 5. Baud rate: 1000000.
13:27:58.693    Opening adapter connected to COM5
13:27:59.638    Successfully opened COM5. Baud rate: 1000000. Flow control: none. Parity: none.
13:27:59.639    Reset performed on adapter COM5
13:28:00.703    Adapter connected to COM5 opened
13:28:05.416    Scan started
13:28:33.884    Connecting to device
13:28:36.201    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
13:28:36.218    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
13:28:36.488    Attribute value read, handle: 0x03, value (0x): 41-4E-43-53-32
13:28:41.264    Connection parameters updated for device E8:20:9F:75:90:08: interval 15ms, timeout 3000ms, latency: 0
13:28:45.213    Security updated, mode:1, level:3
13:29:20.448    Security updated, mode:1, level:3
13:29:20.500    Storing bond info for device E8:20:9F:75:90:08
13:29:28.505    Device closed.
13:29:39.205    Selected device with s/n F092AF29DAF8
13:29:39.209    Device setup completed
13:29:39.209    Connectivity firmware version: ble-connectivity 4.1.4+Mar-11-2021-08-36-04. SoftDevice API version: 5. Baud rate: 1000000.
13:29:39.210    Opening adapter connected to COM5
13:29:40.137    Successfully opened COM5. Baud rate: 1000000. Flow control: none. Parity: none.
13:29:40.138    Reset performed on adapter COM5
13:29:41.215    Adapter connected to COM5 opened
13:29:43.952    Scan started
13:29:52.041    Connecting to device
13:29:55.253    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
13:29:55.266    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
13:29:55.279    Authentication failed with status BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP
13:29:55.302    Disconnected from device E8:20:9F:75:90:08, reason: BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION

Parents
  • Hi, 

    Error 0x3002 means BLE_ERROR_INVALID_CONN_HANDLE . 
    Please check how pm_conn_secure() is called. 

    I've noticed that you have opened quite a few support cases regarding the same issue on pairing. Please try to focus on one ticket. 

    I would suggest to study the example and make as few modification as possible. 

    Which device you used on the central side ? 
    Please try to capture a sniffer trace. 

  • Thanks for your help! I have fixed error 0x3002 by adding BLE_ERROR_INVALID_CONN_HANDLE checking before calling pm_conn_secure().

    static void _securityRequestHandler(void* pContext) {
        if (m_cur_conn_handle != BLE_CONN_HANDLE_INVALID) {
            const ret_code_t errCode = pm_conn_secure(m_cur_conn_handle, false);
            if (errCode != NRF_SUCCESS) {
                NRF_LOG_WARNING("pm_conn_secure() failed, errCode=0x%x\n", errCode);
                return;
            }    
        }    
    }

    But nRF Connect still can't connect to nRF52832 device with "Authentication failed with status BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP". Could you provide bonding example?

    nRF52832 log messages:

    0> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 185 bytes on connection 0x0.
     0> <info> app: PM_EVT_BONDED_PEER_CONNECTED
     0>
     0> <info> app: BLE_GAP_EVT_CONNECTED
     0>
     0> <debug> app: state=1
     0>
     0> <debug> nrf_ble_gatt: ATT MTU updated to 185 bytes on connection 0x0 (response).
     0> <debug> app: _securityRequestHandler
     0>
     0> <debug> peer_manager: pm_conn_secure() e
     0>
     0> <debug> peer_manager_sm: sm_link_secure() e
     0>
     0> <debug> peer_manager_sm: link_secure() e
     0>
     0> <debug> peer_manager_smd: smd_link_secure() e
     0>
     0> <debug> peer_manager_smd: smd_link_secure() e
     0>
     0> <debug> peer_manager_smd: link_secure_authenticate() e
     0>
     0> <debug> peer_manager_smd: link_secure_authenticate() return 0x0
     0>
     0> <debug> peer_manager_smd: smd_link_secure() return 0x0
     0>
     0> <debug> peer_manager_sm: link_secure() return 0x0
     0>
     0> <debug> peer_manager_sm: pm_conn_secure() return 0x0
     0>
     0> <warning> peer_manager: pm_conn_secure() return 0x0
     0>
     0> <debug> peer_manager_smd: smd_params_reply() e
     0>
     0> <info> app: PM_EVT_CONN_SEC_CONFIG_REQ
     0>
     0> <debug> peer_manager_smd: smd_params_reply() BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 2
     0>
     0> <debug> peer_manager_smd: smd_params_reply() return 0x0
     0>
     0> <info> app: BLE_GAP_EVT_SEC_PARAMS_REQUEST
     0>
     0> <info> app: PM_EVT_CONN_SEC_FAILED
     0> <info> app: Faield to secure connection with handle 00
     0>
     0> <info> app: BLE_GAP_EVT_AUTH_STATUS
     0>
     0> <warning> app: sd_ble_gap_disconnect() failed, errCode=0x3002
     0>
     0> <info> app: BLE_GAP_EVT_DISCONNECTED
     0>
     0> <debug> app: _gFstorageState=0
     0>
     0> <debug> app: state=0

    nRF Connect log messages:

    nRF5x
    F0:92:AF:29:DA:F8
    Generic Access
    Generic Attribute
    10:42:15.236    Using nrf-device-lib-js version: 0.4.11
    10:42:15.236    Using nrf-device-lib version: 0.11.8
    10:42:15.237    Using nrfjprog DLL version: 10.15.4
    10:42:15.237    Using JLink version: JLink_V7.66a
    10:42:15.260    Installed JLink version does not match the provided version (V7.58b)
    10:42:15.434    Updated list of uuids with data from github.com/.../v1
    10:42:17.650    Selected device with s/n F092AF29DAF8
    10:42:17.657    Device setup completed
    10:42:17.658    Connectivity firmware version: ble-connectivity 4.1.4+Mar-11-2021-08-36-04. SoftDevice API version: 5. Baud rate: 1000000.
    10:42:17.658    Opening adapter connected to COM5
    10:42:18.592    Successfully opened COM5. Baud rate: 1000000. Flow control: none. Parity: none.
    10:42:18.594    Reset performed on adapter COM5
    10:42:19.662    Adapter connected to COM5 opened
    10:42:21.285    Scan started
    10:42:28.131    Connecting to device
    10:42:30.949    Connected to device E8:20:9F:75:90:08: interval: 7.5ms, timeout: 4000ms, latency: 0
    10:42:30.973    ATT MTU updated for device E8:20:9F:75:90:08, new value is 185
    10:42:31.231    Attribute value read, handle: 0x03, value (0x): 41-4E-43-53-32
    10:42:32.469    Authentication failed with status BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP
    10:42:32.492    Disconnected from device E8:20:9F:75:90:08, reason: BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION


  • I use nRF52840 dongle on the central side. But Wireshark can't find nRF sniffer.

  • When I changing .allow_repairing to true in handing PM_EVT_CONN_SEC_CONFIG_REQ event. When I restart nRF connect. nRF connect pop up Windows for user to enter passkey at fist time. And nRF connect doesn't pop up Windows for user to enter passkey after second time. And no Authentication failed with status BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP issue. Is it good idea to change .allow_repairing to true?

    static void _pmEvtHandler(pm_evt_t const * pEvt) {
        switch (pEvt->evt_id) {
            case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                NRF_LOG_INFO("PM_EVT_CONN_SEC_CONFIG_REQ\n");
                // Reject pairing request from an already bonded peer.
                pm_conn_sec_config_t config = {.allow_repairing = true};
                pm_conn_sec_config_reply(pEvt->conn_handle, &config);
            }
            break;
        ...
    }

  • If you use the dongle on the central side , there is a big chance that the dongle didn't store bond information. 
    This will lead to the issue that the dongle will try to re-bond to the device on the next connection. 
    And if the device is already bonded, and if it has allow_repairing = false, it will return BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP . Because a re-pair is not allowed. 
    So it's correct to set allow_repairing= true if your central device can't store and reuse bond information. 

    Also , next time when you post your code/log, please put them into the Code section (Insert -> Code) 

    Please try to use the example in the SDK as the referral code. If you only do the same features as the example, you wouldn't need to modify anything outside what implemented in the example. 

Reply Children
No Data
Related