| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Macros | Typedefs | Functions
LED Button Service Server
BLE Services

LED Button Service Server module. More...

## Modules
| LED Button Service configuration

## Data Structures
struct | ble_lbs_init_t
| LED Button Service init structure. This structure contains all options and data needed for initialization of the service. More...
struct | ble_lbs_s
| LED Button Service structure. This structure contains various status information for the service. More...

## Macros
#define | LBS_UUID_BASE
#define | LBS_UUID_SERVICE 0x1523
#define | LBS_UUID_BUTTON_CHAR 0x1524
#define | LBS_UUID_LED_CHAR 0x1525

## Typedefs
typedef struct ble_lbs_s | ble_lbs_t
typedef void(* | ble_lbs_led_write_handler_t )(ble_lbs_t *p_lbs, uint8_t new_state)

## Functions
uint32_t | ble_lbs_init (ble_lbs_t *p_lbs, const ble_lbs_init_t *p_lbs_init)
| Function for initializing the LED Button Service. More...
void | ble_lbs_on_ble_evt (ble_lbs_t *p_lbs, ble_evt_t *p_ble_evt)
| Function for handling the application's BLE stack events. More...
uint32_t | ble_lbs_on_button_change (ble_lbs_t *p_lbs, uint8_t button_state)
| Function for sending a button state notification. More...

## Detailed Description

LED Button Service Server module.

This module implements a custom LED Button Service with an LED and Button Characteristics. During initialization, the module adds the LED Button Service and Characteristics to the BLE stack database.

The application must supply an event handler for receiving LED Button Service events. Using this handler, the service notifies the application when the LED value changes.

The service also provides a function for letting the application notify the state of the Button Characteristic to connected peers.

Note
  The application must propagate BLE stack events to the LED Button Service module by calling ble_lbs_on_ble_evt() from the SoftDevice Event Handler callback.

## Macro Definition Documentation

#define LBS_UUID_BASE

Value:
{0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, \
0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00}

## Function Documentation

uint32_t ble_lbs_init | ( | ble_lbs_t * | p_lbs,
|  | const ble_lbs_init_t * | p_lbs_init
| ) |  |

Function for initializing the LED Button Service.

Parameters

  [out] | p_lbs | LED Button Service structure. This structure must be supplied by the application. It is initialized by this function and will later be used to identify this particular service instance.
  [in] | p_lbs_init | Information needed to initialize the service.

Return values

  NRF_SUCCESS | If the service was initialized successfully. Otherwise, an error code is returned.

void ble_lbs_on_ble_evt | ( | ble_lbs_t * | p_lbs,
|  | ble_evt_t * | p_ble_evt
| ) |  |

Function for handling the application's BLE stack events.

This function handles all events from the BLE stack that are of interest to the LED Button Service.

Parameters

  [in] | p_lbs | LED Button Service structure.
  [in] | p_ble_evt | Event received from the BLE stack.

uint32_t ble_lbs_on_button_change | ( | ble_lbs_t * | p_lbs,
|  | uint8_t | button_state
| ) |  |

Function for sending a button state notification.

Parameters

  [in] | p_lbs | LED Button Service structure.
  [in] | button_state | New button state.

Return values

  NRF_SUCCESS | If the notification was sent successfully. Otherwise, an error code is returned.