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

Erase bond info

Hi,

Is there any simpler way to erase bond info by not pressing button 2?

In function advertising_init(), I set init.config.ble_adv_whitelist_enabled = false;

I am using hid mouse example in SDK 15.2 and even after disabling whitelist the bond info is not fully erased. 

What exactly happens internally after pressing button 2? Does the OS or the nrf remove bond info?

  • Hi.

    You can erase bonds where it suits you. Most examples just checks in the start up if button 2 is pressed down, and deletes any bonds if it is pressed down.

    In the \ble_peripheral\ble_app_hids_mouse example you also find a function which can delete bonds, named static void delete_bonds(void), you can just call this function to delete bonds.

    static void delete_bonds(void)
    {
        ret_code_t err_code;
    
        NRF_LOG_INFO("Erase bonds!");
    
        err_code = pm_peers_delete();
        APP_ERROR_CHECK(err_code);
    }

    This function calls pm_peers_delete() which is the function that deletes bonds.

    - Andreas

  • Hi AndreasF,

    Thank you for your reply.

    Current scenario- I connected nrf with Macbook. Removed the device & shut down the laptop. Then I connected with my Windows machine & it connected just fine. And I did not press a button to erase bond info. But I have to erase the bond info if both laptops are switched on.

    What if I do not disconnect with the previous machine and go my friend's house and try to connect to his machine? I do not want a button press. Everything should happen through firmware without human intervention. How do I implement the logic?

  • Hi.

    I've been out of office this week, so sorry for late reply.

    As I said, you can erase bonds where it suits you. If you don't erase bonds, the nRF is still bonded.

    bscdb said:

    Current scenario- I connected nrf with Macbook. Removed the device & shut down the laptop. Then I connected with my Windows machine & it connected just fine. And I did not press a button to erase bond info. But I have to erase the bond info if both laptops are switched on.

    What if I do not disconnect with the previous machine and go my friend's house and try to connect to his machine? I do not want a button press. Everything should happen through firmware without human intervention. How do I implement the logic?

     I'm a bit unsure what you mean here actually. Could you elaborate?

    - Andreas

  • In the HID mouse example you're working with, disabling the whitelist using init.config.ble_adv_whitelist_enabled = false; should prevent the device from using a whitelist for advertising, which means it shouldn't restrict connections to bonded devices only. However, if you're still observing that the bond information is not fully erased, there might be some additional steps or considerations to keep in mind.

    In the context of the nRF SDK and Bluetooth Low Energy (BLE) devices, bond information typically refers to the data stored after a successful bonding process. This data includes encryption keys that allow devices to securely communicate without pairing again.

    Pressing "button 2" is often used as a way to trigger a factory reset or an operation that clears stored data, including bond information, from the device's memory. However, the exact behavior might vary based on the application's implementation.

    Here's what typically happens internally when you press "button 2" in the context of an example like the one you mentioned:

    1. User Input Detection: The device's firmware detects the press of "button 2" by monitoring the state of the button's GPIO pin.

    2. Action Triggering: Once the press is detected, a designated function or event handler is executed. This function is responsible for performing the actions associated with clearing data, including bond information.

    3. Data Clearing: Within the function/event handler, specific actions are taken to clear the data. This might involve erasing stored bond information, resetting connection parameters, and possibly performing other device-specific tasks.

    4. Confirmation: After the data is cleared, the device might provide some visual or feedback indication to confirm that the operation was successful.

    It's important to note that the exact steps and implementation details can vary based on the application, the SDK version, and the specific requirements of the project. If you're finding that bond information is not being fully erased even after disabling the whitelist and triggering the button action, there could be various reasons for this behavior:

    • Custom Implementation: If you've made modifications to the example code or if your pokemon showdown project includes custom functionality, it's possible that there are unintended interactions affecting the bond information.

    • SDK Behavior: There could be specific SDK behavior or settings that are affecting the bond information. It's recommended to review the SDK documentation and forums to see if there are any known issues or considerations related to bond information removal.

    • Debugging: You might want to implement additional debugging mechanisms (such as printing debug messages) to understand what's happening when you press "button 2" and whether the data clearing process is being executed as intended.

    If you're having trouble getting bond information to be fully erased, consider reaching out to the Nordic Semiconductor support or developer community. They can provide guidance specific to the HID mouse example and the nRF SDK version you're using.

Related