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

How to delete the bond info when connected with 51822

Hi nordic engineer:

I want to know the right process to delete the bonds when the device connected.

There is a button used for bonding. When it pressing by more than 3 seconds, it should go into a bond process, no matter it was connected or not.
I got a app_error_handler() under connected.
Here is my operation:
                            app_sched_execute();
                            power_manage();
			if(bind_info_clear == true)
			{
				err_code=sd_softdevice_disable();
				APP_ERROR_CHECK(err_code);
				// Re-initialize
				bond_manager_init();
				ble_stack_init();
				advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE);
				advertising_start();
				bind_info_clear = false;
			}
 
It must stop the ble first so I disable the softdevie(is it correct?), then delete the bond flash, and re-init the ble stack to enable the softdevice(or need to call sd_softdevice_enable()?), after that, re-start the advertising...
I am confuse on how to disconnect the ble and stop it when doing the flash operation.

If there is any example for this application should be better...

Thanks. Jim

Parents
  • Hi Morten,

    Thanks for your answer.
    
    I prefer to use the second way for the ram would be cleaned while reset.
    
    But, when call the sd_ble_gap_disconnect() as follow, it still got the HardFault by simulating.
    

    [i] if(bind_info_clear == true) { BLE_GAP_DISCONNECT(); }[/i]

    and BLE_GAP_DISCONNECT() define as:
    

    [i]#define BLE_GAP_DISCONNECT()
    do
    {
    uint32_t err_code;
    uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID;
    err_code = sd_ble_gap_disconnect(m_conn_handle,
    BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    }while(0)[/i]

    Is there anything wrong?
    
  • Hi Morten,

    What you said is correct.
    I can't find what the proper conn_handle is from the SDK document. Could you show me what value is correct?
    
Reply Children
No Data
Related