LED Button Service Server module.
More...
|
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...
|
|
|
#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 |
|
|
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) |
|
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:
#define BLE_LBS_DEF |
( |
|
_name | ) |
|
Macro for defining a ble_lbs instance.
- Parameters
-
_name | Name of the instance. |
Value:{0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, \
0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00}
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_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_evt | Event received from the BLE stack. |
[in] | p_context | LED 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_handle | Handle of the peripheral connection to which the button state notification will be sent. |
[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. |