ESP-IDF : Bluetooth remove bonded devices

When Bluetooth stack is enabled in ESP-IDF, the default behavior is to connect to previously connected Bluetooth device. We can reset (erase) all the bonded devices data to disable this behavior.

There is no direct API available from IDF, we need to get list of bonded devices and remove each one by looping over the list.

There are multiple strategies for implementing a reset button in end user product.

Start a separate task and check for a button press in while(1) loop. One more efficient way would be to use a counting semaphore. We can configure an interrupt on the button IO line and increment semaphore in the ISR. Our Bluetooth reset task will be waiting on this semaphore to run the bluetooth reset logic.

Add a Comment

Your email address will not be published. Required fields are marked *