nRF5 SDK v17.0.2
Modules | Data Structures | Macros | Typedefs | Functions
LED Button Service Server

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 BLE_LBS_DEF(_name)
 Macro for defining a ble_lbs instance. More...
 
#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 )(uint16_t conn_handle, 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_evt_t const *p_ble_evt, void *p_context)
 Function for handling the application's BLE stack events. More...
 
uint32_t ble_lbs_on_button_change (uint16_t conn_handle, 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 register this module as BLE event observer using the NRF_SDH_BLE_OBSERVER macro. Example:

Macro Definition Documentation

#define BLE_LBS_DEF (   _name)

Macro for defining a ble_lbs instance.

Parameters
_nameName of the instance.
#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_lbsLED 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_initInformation needed to initialize the service.
Return values
NRF_SUCCESSIf the service was initialized successfully. Otherwise, an error code is returned.
void ble_lbs_on_ble_evt ( ble_evt_t const *  p_ble_evt,
void *  p_context 
)

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_ble_evtEvent received from the BLE stack.
[in]p_contextLED Button Service structure.
uint32_t ble_lbs_on_button_change ( uint16_t  conn_handle,
ble_lbs_t p_lbs,
uint8_t  button_state 
)

Function for sending a button state notification.

'

Parameters
[in]conn_handleHandle of the peripheral connection to which the button state notification will be sent.
[in]p_lbsLED Button Service structure.
[in]button_stateNew button state.
Return values
NRF_SUCCESSIf the notification was sent successfully. Otherwise, an error code is returned.

Documentation feedback | Developer Zone | Subscribe | Updated