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
include/lbs.h
subsys/bluetooth/services/lbs.c
- group bt_lbs
API for the LED Button Service (LBS).
Defines
-
BT_UUID_LBS_VAL
LBS Service UUID.
-
BT_UUID_LBS_BUTTON_VAL
Button Characteristic UUID.
-
BT_UUID_LBS_LED_VAL
LED Characteristic UUID.
-
BT_UUID_LBS
-
BT_UUID_LBS_BUTTON
-
BT_UUID_LBS_LED
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_lbs_init(struct bt_lbs_cb *callbacks)
Initialize the LBS Service.
This function registers a GATT service with two characteristics: Button and LED. Send notifications for the Button Characteristic to let connected peers know when the button state changes. Write to the LED Characteristic to change the state of the LED on the board.
- Parameters
callbacks – [in] Struct containing pointers to callback functions used by the service. This pointer can be NULL if no callback functions are defined.
- Return values
0 – If the operation was successful. Otherwise, a (negative) error code is returned.
-
int bt_lbs_send_button_state(bool button_state)
Send the button state.
This function sends a binary state, typically the state of a button, to all connected peers.
- Parameters
button_state – [in] The state of the button.
- Return values
0 – If the operation was successful. Otherwise, a (negative) error code is returned.
-
struct bt_lbs_cb
- #include <lbs.h>
Callback struct used by the LBS Service.
Public Members
-
button_cb_t button_cb
Button read callback.
-
button_cb_t button_cb
-
BT_UUID_LBS_VAL