GATT Bond Management Service (BMS)

This library implements the Bond Management Service with the corresponding set of characteristics defined in the Bond Management Service Specification.

You can configure the service to support your desired feature set of bond management operations. All the BMS features in the “LE transport only” mode are supported:

  • Delete the bond of the requesting device.

  • Delete all bonds on the Server.

  • Delete all bonds on the Server except the one of the requesting device.

You can enable each feature when initializing the library.

Authorization

You can require authorization to access each BMS feature.

When required, the Client’s request to execute a bond management operation must contain the authorization code. The Server compares the code with its local version and accepts the request only if the codes match.

If you use at least one BMS feature that requires authorization, you need to provide a callback with comparison logic for the authorization codes. You can set this callback when initializing the library.

Deleting the bonds

The Server deletes bonding information on Client’s request right away when there is no active Bluetooth® Low Energy connection associated with a bond. Otherwise, the Server removes the bond for a given peer when it disconnects.

API documentation

Header file: include/bluetooth/services/bms.h
Source file: subsys/bluetooth/services/bms.c
group bt_bms

API for the Bond Management Service (BMS).

Enums

enum bt_bms_op

BMS Control Point operation codes (LE transport).

Values:

enumerator BT_BMS_OP_DEL_REQ_BOND

Initiates the procedure to delete the bond of the requesting device.

enumerator BT_BMS_OP_DEL_ALL_BONDS

Initiates the procedure to delete all bonds on the device.

enumerator BT_BMS_OP_DEL_REST_BONDS

Initiates the procedure to delete all bonds except for the one of the requesting device.

Functions

int bt_bms_init(const struct bt_bms_init_params *init_params)

Initialize the BMS Service.

Initialize the BMS Service by specifying a list of supported operations. If any operation is configured as authorized, you need to provide authorize() callback.

Parameters:
  • init_params – Initialization parameters.

Return values:

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

struct bt_bms_authorize_params
#include <bms.h>

BMS authorization callback parameters.

Public Members

enum bt_bms_op op_code

Operation code.

const uint8_t *code

Authorization Code.

uint16_t code_len

Length of Authorization Code.

struct bt_bms_cb
#include <bms.h>

BMS server callback structure.

Public Members

bool (*authorize)(struct bt_conn *conn, struct bt_bms_authorize_params *params)

Operation authorization callback

If this callback is set, support for BMS Authorization Code functionality is enabled. This function is called whenever an authorized operation is requested by the client.

Param conn:

Connection object.

Param params:

Authorization parameters.

Retval true:

If the authorization was successful.

Retval false:

Otherwise.

struct bt_bms_feature
#include <bms.h>

Bitmask of supported features.

Public Members

uint8_t supported

Support the feature.

uint8_t authorize

Enable authorization.

struct bt_bms_features
#include <bms.h>

Bitmask set of supported features.

Public Members

struct bt_bms_feature delete_all

Support the operation to delete all bonds.

struct bt_bms_feature delete_requesting

Support the operation to delete the bonds of the requesting device.

struct bt_bms_feature delete_rest

Support the operation to delete all bonds except for the bond of the requesting device.

struct bt_bms_init_params
#include <bms.h>

BMS initialization parameters.

Public Members

struct bt_bms_cb *cbs

Callbacks.

struct bt_bms_features features

Features.