Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to set up BLE bonding

Dear Nordic,

we are devepoling FW based on nRF52832, SDK 17.0.2. We have 2 devices:

BLE Central with SD S332

BLE Peripheral with SD S112

We setted up an open BLE communication, the data are exchanging fine. At this development stage we need to add the bonding feature because we need a thrusted communication between central an peripheral.

Could you please suggest us some clear documentation on how to set up the peer manager link well?

There are many questions here on the forum but unfortunately there are no adequate answers for our case. Could you give us the correct links to the documentation?
Please don't tell us to use your examples, we'd rather read a guide with clear explanations rather than having to debug examples that have little documentation.

Thanks for your help!

Parents Reply Children
  • Typically when you init the services and characteristics you also define the security requirements to access them by using:

    /**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
     *
     * See @ref ble_gap_conn_sec_mode_t.
     * @{ */
    /**@brief Set sec_mode pointed to by ptr to have no access rights.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr)          do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr)               do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr)        do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr)      do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr)     do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
    /**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
    #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr)   do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
    /**@} */

    If you don't need bonding you use BLE_GAP_CONN_SEC_MODE_SET_OPEN(), if you need bonding you use BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM() or better.

  • Thanks for your reply.

    I setted BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM in the gap_params_init function but nothing changed:

    If I try to connect using nRF connect APP there is no bonding request.

    I can also read the device services and characteristic list, and I can read all the characteristics values.

    Is there something missing?

  • Maybe they have been previously bonded?

    Kenneth

  • No, i'm sure. I checked the bonded device list and it's empty.

Related