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
  • The easiest way to do this is actually to just do a reset after 3 s, check the button on power up and if it's pressed, go into limited advertising mode, potentially first erasing old bond information (the latter may not be needed, as the nRF51822 is capable of having multiple bonds, but if you do, you'll have to make sure to handle the situation with full bond storage properly).

    If you don't want to reset for whatever reason, you don't really have to disable the softdevice; you can just call sd_ble_gap_disconnect() and then restart advertising with whatever parameters you want when you get the BLE_GAP_EVT_DISCONNECTED event.

Reply
  • The easiest way to do this is actually to just do a reset after 3 s, check the button on power up and if it's pressed, go into limited advertising mode, potentially first erasing old bond information (the latter may not be needed, as the nRF51822 is capable of having multiple bonds, but if you do, you'll have to make sure to handle the situation with full bond storage properly).

    If you don't want to reset for whatever reason, you don't really have to disable the softdevice; you can just call sd_ble_gap_disconnect() and then restart advertising with whatever parameters you want when you get the BLE_GAP_EVT_DISCONNECTED event.

Children
No Data
Related