MT2523 API Reference  LinkIt SDK v4

This section manages the read/write events of Battery Level Characteristic from a peer device and provides API to send notification to the peer device when the battery state changes. More...

Overview

This section manages the read/write events of Battery Level Characteristic from a peer device and provides API to send notification to the peer device when the battery state changes.

Terms and Acronyms

Terms Details
BAS Battery Service. This service exposes the battery state and battery level to the peer device.

How to use this module

Functions

bt_status_t ble_bas_notify_battery_level (bt_handle_t conn_handle, uint8_t battery_level)
 This function sends a notification to a peer device about the current battery level. More...
 
uint8_t ble_bas_read_callback (ble_bas_event_t event, bt_handle_t conn_handle)
 This function is a user-defined callback for the application to listen to the read event of Battery Level Characteristic and Client Configuration Characteristic Descriptor. More...
 
void ble_bas_write_callback (ble_bas_event_t event, bt_handle_t conn_handle, void *data)
 This function is a user-defined callback for the application to listen to the write event of Client Configuration Characteristic Descriptor. More...
 

Variables

const bt_gatts_service_t ble_bas_service
 

Modules

 Define
 This section defines the BAS event types.
 

Function Documentation

bt_status_t ble_bas_notify_battery_level ( bt_handle_t  conn_handle,
uint8_t  battery_level 
)

This function sends a notification to a peer device about the current battery level.

Parameters
[in]conn_handleis the connection handle.
[in]battery_levelis the current battery level.
Returns
BT_STATUS_SUCCESS, the notification is sent successfully. BT_STATUS_FAIL, the notification failed to send.
uint8_t ble_bas_read_callback ( ble_bas_event_t  event,
bt_handle_t  conn_handle 
)

This function is a user-defined callback for the application to listen to the read event of Battery Level Characteristic and Client Configuration Characteristic Descriptor.

Parameters
[in]eventis the event of type ble_bas_event_t.
[in]conn_handleis the connection handle.
Returns
the response to the read event of Battery Level Characteristic or Client Configuration Characteristic Descriptor. If the read event type is BLE_BAS_EVENT_BATTRY_LEVEL_READ, the return value is the corresponding battery level. If the read event type is BLE_BAS_EVENT_CCCD_READ, the return value is either 0 or 1.
void ble_bas_write_callback ( ble_bas_event_t  event,
bt_handle_t  conn_handle,
void *  data 
)

This function is a user-defined callback for the application to listen to the write event of Client Configuration Characteristic Descriptor.

Parameters
[in]eventis the event of type ble_bas_event_t.
[in]conn_handleis the connection handle.
[in]datais the data of write event from a remote device.
Returns
void.