LED Button Service (LBS)

The GATT LED Button Service (LBS) is a custom service that receives information about the state of an LED and sends notifications when a button changes its state.

The LBS Service is used in the Bluetooth: Peripheral LBS sample.

Service UUID

The 128-bit vendor-specific service UUID is 00001523-1212-EFDE-1523-785FEABCD123.

Characteristics

This service has two characteristics.

Button Characteristic (00001524-1212-EFDE-1523-785FEABCD123)

Notify:
Enable notifications for the Button Characteristic to receive button data from the application.
Read:
Read button data from the application.

LED Characteristic (00001525-1212-EFDE-1523-785FEABCD123)

Write:
Write data to the LED Characteristic to change the LED state.

API documentation

Header file: include/lbs.h
Source file: subsys/bluetooth/services/lbs.c
group bt_gatt_lbs

API for the LED Button Service (LBS).

Defines

LBS_UUID_SERVICE

LBS Service UUID.

LBS_UUID_BUTTON_CHAR

Button Characteristic UUID.

LBS_UUID_LED_CHAR

LED Characteristic UUID.

Typedefs

typedef void (*led_cb_t)(const bool led_state)

Callback type for when an LED state change is received.

typedef bool (*button_cb_t)(void)

Callback type for when the button state is pulled.

Functions

int bt_gatt_lbs_init(struct bt_gatt_lbs_cb *callbacks)

Initialize the LBS Service.

This function registers a BLE service with two characteristics: Button and LED. Enable notifications for the Button Characteristic to let a connected BLE unit know when the button state changes. Write to the LED Characteristic to change the state of the LED on the board.

Parameters
  • callbacks: Struct containing pointers to callback functions used by the service. This pointer can be NULL if no callback functions are defined.
Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

int bt_gatt_lbs_send_button_state(bool button_state)

Send the button state.

This function sends a binary state, typically the state of a button, to the connected BLE unit.

Parameters
  • button_state: The state of the button.
Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

struct bt_gatt_lbs_cb
#include <lbs.h>

Callback struct used by the LBS Service.

Public Members

led_cb_t led_cb

LED state change callback.

button_cb_t button_cb

Button read callback.