paring,bonding and whitelisting

Hello,

Is there examples of paring,bonding and whitelisting?

The pairing and bonding mode is static password.

It is best to have examples of the central and the peripheral.

Thank you.

  • Hi,

    If this is now on the peripheral, and you are currently advertising, you can disable advertising by calling sd_ble_gap_adv_stop() (you must pass the advertising handle to the call).

  • Hello,

    I want to konw the following questions about deleting bonding information.

    1. whether to delete bonds both on the central and on the peripheral, that is, whether both sides need to call the void delete_bonds(void).
    2. When or Where do I call the delete_bonds()? Because I find before deleting the bonds, I should disable scanning and advertising.
    3. I find many examples about deleting the bonding information ,but they all look like this.
      /**@brief Function for starting advertising.
       */
      static void advertising_start(bool erase_bonds)
      {
          if (erase_bonds == true)
          {
              delete_bonds();
              // Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
          }
          else
          {
              ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
              APP_ERROR_CHECK(err_code);
          }
      }

      How do I use something like this?

    Thank you.

  • Hi,

    Mark said:
    whether to delete bonds both on the central and on the peripheral, that is, whether both sides need to call the void delete_bonds(void).

    Yes. If you delete a bond only on one side, it will not be deleted on the other. And furthermore, any subsequent pariting attempt will by default fail. You can however allow repairing so that pairing will be allowed even if a bond with the device allready exist, see this post for details.

    Mark said:
    When or Where do I call the delete_bonds()? Because I find before deleting the bonds, I should disable scanning and advertising.

    You should only delete bonds when not connecting or connectable. In other words, disconnect any connections and stop advertising and/or scanning. This is indicated in the API documentation for pm_peers_delete().

    Mark said:
    How do I use something like this?

    This is used in the example applications to delete bonds by holding down a button and pressing reset. If the button is pressed, bonds are deleted in the start of the applicaiton, before starting to advertise. This makes sense in the example applications but how and when you should delete bonds in your application depends on your specific use case and what makes sense in your product.

  • Hello,

    I find the examples. ...\examples\ble_central\ble_app_hrs_c and ...\\examples\ble_peripheral\ble_app_hrs

    The examples include the following contents.

    I want to know how do I use these to delete the bonding information.

    Thank you.

  • Hi,

    This code is not realted to erasing the bonds itself. But these variables are set based on a button press at power on.

    If  we look at ble_app_hrs, you can see that in buttons_leds_init() p_erase_bonds which point to erase_bonds (as the pointer is provided as a parameter when then function is called), is set to 1 if the startup event is BSP_EVENT_CLEAR_BONDING_DATA). And this comes from the BSP library which is used on the DKs. This complicates thigs a bit so I would not use that in your code (it mostly makes sense on the DKs), but that it all this part does.

    Moving on, erase_bonds (which is not set based on if a button was pressed during reset or not), is passed to advertising_start() which is a function defined in this example. And if you look at the implementation there you can see that if erase_bonds is set, advertisign is not started, but instead the bonds are deleted. And in this case advertising is started in the handling of the PM_EVT_PEERS_DELETE_SUCCEEDED event.

Related