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

BLE Pairing and binding

use nrf52810

nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_uart\pca10040e

How to initiate pairing and binding?

Thanks!

  • Hello,

    If you look at the ble_app_gls example from the SDK\examples\ble_peripheral\ble_app_gls, this example will show you how to use the peer manager to pair and bond with a pairing key.

    There are quite a few files that you need to add in, so be patient. Add the peer manager files that are used in the ble_app_gls example, compile, and check what functions/header files that are missing. When it says that some functions are missing, look in the ble_app_gls example in what file that function is defined in, and add that file. You probably also need to add some defines from sdk_config.h. It is typically the guards that enables the modules that you add in. 

    Let me know if you are stuck somewhere.

    Best Regards,

    Edvin

  • I use SDK\examples\ble_peripheral\ble_app_gls,this example.

    After my pairing and binding is successful, the phone deletes the pairing information.

    Pairing the phone again will prompt NRF52810(Nordic_Glucose) to refuse to pair.

    What should i modify?

  • Do you actively delete the bonding information on the phone side? Or does it happen "automatically"? How do you determine that it is deleted?

    It is possible to tell the nRF to accept pairing with already paired devices, so you could do that, but that doesn't change the behavior of the phone. You would then have to pair every time you connect to the mobile phone.

    Does it happen on other phones as well? Or only that model in particular?

    When an already bonded device asks for a connection without the previous bonding data, the PM_EVT_CONN_SEC_CONFIG_REQ should occur. As you see in the description of this event, it says:

    /**< @brief The peer (central) has requested pairing, but a bond already exists with that peer. Reply by calling @ref pm_conn_sec_config_reply before the event handler returns. If no reply is sent, a default is used. */

    This means that if this event is not handled, the pairing will be denied. What you need to call in this event is pm_conn_sec_config_reply(); with:

    pm_conn_sec_config_t * p_conn_sec_config, where pm_conn_sec_config.allow_repairing = true;

    But again, this only solves half of your issue. It doesn't explain why the phone deletes the bonding data in the first place.

    Best regards,

    Edvin

  • xixili said:
    I actively delete my phone's Bluetooth pairing.

     Ok. Why do you do that? 

    And if you do that, did you try the approach that I mentioned in my previous reply? I see that you get the event, but you have to do the function call that I proposed. Right now you are doing nothing.

    I don't know exactly what causes the "Fatal error", but try to define DEBUG in your preprocessor defines. It should then print what APP_ERROR_CHECK(err_code) that received an err_code != 0.

    BR,

    Edvin

Related