Bluetooth: Peripheral Bond Management Service (BMS)

The peripheral BMS sample demonstrates how to use the GATT Bond Management Service (BMS).

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nRF52 DK

PCA10040

nrf52dk

nrf52dk/nrf52832

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

The sample also requires a Bluetooth® Low Energy dongle and nRF Connect for Desktop.

Overview

When connected, the sample waits for the client’s requests to perform any bond-deleting operation.

It supports up to two simultaneous client connections.

User interface

LED 1:

Blinks, toggling on/off every second, when the main loop is running and the device is advertising.

LED 2:

Lit when connected.

Building and running

This sample can be found under samples/bluetooth/peripheral_bms in the nRF Connect SDK folder structure.

To build the sample, follow the instructions in Configuring and building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Connect to the kit that runs this sample with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.

  2. Reset the kit.

  3. Start nRF Connect for Desktop.

  4. Open the Bluetooth Low Energy app and select the connected device that is used for communication.

  5. Connect to the device from the app. The device is advertising as “Nordic_BMS”.

  6. Bind with the device:

    1. Click the Settings button for the device in the app.

    2. Select Pair.

    3. Select Keyboard and display in the IO capabilities setting.

    4. Select Perform Bonding.

    5. Click Pair.

  7. Check the logs to verify that the connection security is updated.

  8. Disconnect the device in nRF Connect.

  9. Reconnect again and verify that the connection security is updated automatically.

  10. Verify that the Feature Characteristic of the Bond Management Service displays 10 08 02. This means that the following features are supported:

    • Deletion of the bonds for the current connection of the requesting device.

    • Deletion of all bonds on the Server with the Authorization Code.

    • Deletion of all bonds on the Server except the ones of the requesting device with the Authorization Code.

  11. Write 03 to the Bond Management Service Control Point Characteristic. 03 is the command to delete the current bond.

  12. Disconnect the device to trigger the bond deletion procedures.

  13. Reconnect the devices and verify that the connection security is not updated.

  14. Bond both devices again.

  15. Write 06 41 42 43 44 to the Bond Management Service Control Point Characteristic. 06 is the command to delete all bonds on the Server, followed by the authorization code “ABCD”.

  16. Disconnect the device to trigger the bond deletion procedures.

  17. Reconnect the devices again and verify that the connection security is not updated.

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following Zephyr libraries:

  • include/zephyr/types.h

  • lib/libc/minimal/include/errno.h

  • include/sys/printk.h

  • GPIO Interface

  • API:

    • include/bluetooth/bluetooth.h

    • include/bluetooth/conn.h

    • include/bluetooth/uuid.h

    • include/bluetooth/gatt.h