paring,bonding and whitelisting

Hello,

Is there examples of paring,bonding and whitelisting?

The pairing and bonding mode is static password.

It is best to have examples of the central and the peripheral.

Thank you.

  • Hello,

    I want to know why I finish executing this command in the central, the peripheral didn't call the command " case PM_EVT_PEERS_DELETE_SUCCEEDED:".

    ////////////Added for bonding//////////////
    /**@brief Clear bond information from persistent storage.
     */
    static void delete_bonds(void) // -Shy
    {
        ret_code_t err_code;
    
        NRF_LOG_INFO("Erase bonds");
    	
    	err_code = sd_ble_gap_disconnect(0x0000,BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    	APP_ERROR_CHECK(err_code);  
    	
        err_code = pm_peers_delete();
        APP_ERROR_CHECK(err_code);
    	
    }
    ////////////Added for bonding//////////////

    Or in what state can I call the delete_bonds()? 

    Thank you.

  • Hi,

    Did pm_peers_delete return NRF_SUCCESS? If so, you should subsequently get either a PM_EVT_PEERS_DELETE_SUCCEEDED or a PM_EVT_PEERS_DELETE_FAILED even tin your peer manager event handler. I see you currently do not check for PM_EVT_PEERS_DELETE_FAILED, so I suggest startign with checking if you get that event.

  • Hello,

    I have used the pm_evt_handler. When I finish executing the delete_bonds(), I get the PM_EVT_PEERS_DELETE_SUCCEEDED in the central. But the peripheral not. I guess the central

    and the peripheral connect after executing the delete_bonds().

    This is the debugging information of the peripheral.

    It consists of two processes. One is to connect, pair and bond.

    The Other is to delete the bonds. 

    00> <info> app_timer: RTC: initialized.
    00> 
    00> <info> app: Transmit power set successfully.
    00> 
    00> <info> app: Debug logging for UART over RTT started.
    00> 
    00> <info> app: on_adv_evt
    00> 
    00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    00> 
    00> <info> app: Connected
    00> 
    00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.
    00> 
    00> <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.
    00> 
    00> <info> app: Received BLE_GAP_EVT_AUTH_KEY_REQUEST, waiting for key_flag
    00> 
    00> <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: max_rx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_tx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_rx_time: 328
    00> 
    00> <debug> nrf_ble_gatt: max_tx_time: 328
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 
    00> <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    00> 
    00> <info> app: Data len is set to 0xF4(244)
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 
    00> <info> app: notification enabled, val=0x0001
    00> 
    00> <info> app: four_key_val == 0x0F
    00> 
    00> <info> app: sd_ble_gap_auth_key_reply
    00> 
    00> <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Bonding
    00> 
    00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
    00> 
    00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
    00> 
    00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update
    00> 
    00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Central address resolution, action: Update
    00> 
    00> <info> app: on_adv_evt
    00> 
    00> <info> app: Disconnected, reason: 0x13
    00> 
    00> <info> app: Disconnected by remote user.
    00> 
    00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    00> 
    00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
    00> 
    00> <info> app: Connected
    00> 
    00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.
    00> 
    00> <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    00> 
    00> <debug> nrf_ble_gatt: max_rx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_tx_octets: 27
    00> 
    00> <debug> nrf_ble_gatt: max_rx_time: 328
    00> 
    00> <debug> nrf_ble_gatt: max_tx_time: 328
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 
    00> <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    00> 
    00> <info> app: Data len is set to 0xF4(244)
    00> 
    00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    00> 
    00> <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 133
    00> 
    00> <info> app: notification enabled, val=0x0001
    00> 

  • Hi,

    pm_evt_handler() is a local operation. To delete the bond on the peripheral side you need to call it there as well.

  • Hello,

    I call pm_evt_handler() on the peripheral side. 

    But it doesn't respond.

    static void pm_evt_handler(pm_evt_t const * p_evt)
    {
        pm_handler_on_pm_evt(p_evt);
        pm_handler_flash_clean(p_evt);
    
        switch (p_evt->evt_id)
        {
            case PM_EVT_PEERS_DELETE_SUCCEEDED:
    						NRF_LOG_INFO("PM_EVT_PEERS_DELETE_SUCCEEDED");
    //						ret_code_t err_code = sd_ble_gap_disconnect(0x0000, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                advertising_start();
                break;
    				
    				case PM_EVT_PEERS_DELETE_FAILED:
    						NRF_LOG_INFO("PM_EVT_PEERS_DELETE_FAILED");
    						break;
    
            default:
                break;
        }
    }
    ///////////Added for bonding////////////

    Or do you mean i need to call the delete_bonds() on the peripheral side?

    I find before deleting the bonds, I should disable scanning and advertising.

    How can I implement this function?

Related