I am trying to allow 2 peripherals to bond to a central, and would like to be able to use 2 push buttons to delete the bond information for either device. Is it possible to clear the persistent data selectively like this?
I am trying to allow 2 peripherals to bond to a central, and would like to be able to use 2 push buttons to delete the bond information for either device. Is it possible to clear the persistent data selectively like this?
How would you distinguish between the two devices? Button 1 deletes the first bonded? Or button 1 deletes device with ID 1? I'm assuming your are not in a connection with these centrals when you want to delete their bond?
The idea is for example I would boot the system with button 1 held. This would clear the bonding info in slot 1, and accept a new bond from a device. Button 2 would do the same thing for the other device. So basically whichever button was used to bond the device would be used to then delete that device.
Since the button is being held during bootup we could prevent them from connecting in this mode.
From the further searching I've done it seems like when I bond the device using button 1 I would need to save the address of that device as device 1. Then when I want to delete device 1 I just retrieve the address from that fixed location and delete it?
The issue I'm having is that it seems like all the context storing functions use a device handle, but if I want to delete a device without it being connected then I don't have access to the handle if I understand correctly.
I have an idea but i am not sure if this will be neat solution for you. As there are only two buttons, you can map button number to a device_handle, so when you want to delete the bond, you know which button is being pressed and hence you will also have a device handle. It will be then easy to delete the bond info.
Could this be a solution?
Button 1 is pressed to allow bonding to device x.
Wait for the bonding procedure to complete. DM_EVT_SECURITY_SETUP_COMPLETE
Use dm_handle_get() with the connection handle to get the dm handle of device x.
Tie the dm handle of device x to button 1 and store it persistently.
On boot, check if button 1 has any handle tied to it.