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

Can I bond master when conected?

In the example of hid_mouse, ble device will bond master when disconnect event happen.

I try to add this two codes to Implement my idea.

            err_code = ble_bondmngr_bonded_masters_store();
            APP_ERROR_CHECK(err_code);

But when I did this error appears

error:-559038737 ...line:783 file_name:src\ll_lm.s0.c

It must be some info lack to save when ble device bond the master.

Before func "ble_bondmngr_bonded_masters_store()" runs, what should I get from master?

Or when can I bond master (before disconnect happen)?

Best wishes!

Parents
  • I'd recommend you to read this guide thoroughly.

    As you can see from it, the bond manager will handle storing the encryption keys automatically while in a connection. However, it will not automatically store the system attributes, the CCCD values, since it can't itself know when all needed CCCDs are written. You should therefore, from your application, when you know that all needed CCCDs have been written, call the ble_bondmngr_sys_attr_store() function. If this is the first time you bond with a device, this will cause the system attributes to be written to flash, and hence allow restoration of those on any reconnection.

    However, if the system attributes have already been written, this function will return an error, and not do anything. In this case, you may want to disconnect, store bonding information and only afterwards start advertising again.

    If you take a look at the ble_app_hids_keyboard application, you can see that it does this function call on line 1110 of main.c, when notifications have been enabled in the HID service.

    Please note that the above is based on the behavior of SDK 4.4.2/S110 5.2.1. Behavior with later version may be slightly different.

Reply
  • I'd recommend you to read this guide thoroughly.

    As you can see from it, the bond manager will handle storing the encryption keys automatically while in a connection. However, it will not automatically store the system attributes, the CCCD values, since it can't itself know when all needed CCCDs are written. You should therefore, from your application, when you know that all needed CCCDs have been written, call the ble_bondmngr_sys_attr_store() function. If this is the first time you bond with a device, this will cause the system attributes to be written to flash, and hence allow restoration of those on any reconnection.

    However, if the system attributes have already been written, this function will return an error, and not do anything. In this case, you may want to disconnect, store bonding information and only afterwards start advertising again.

    If you take a look at the ble_app_hids_keyboard application, you can see that it does this function call on line 1110 of main.c, when notifications have been enabled in the HID service.

    Please note that the above is based on the behavior of SDK 4.4.2/S110 5.2.1. Behavior with later version may be slightly different.

Children
No Data
Related