SmartSnippets DA1459x SDK
Files | Data Structures | Typedefs | Enumerations | Functions

Battery service client. More...

Files

file  bas_client.h
 Battery Service Client header file.
 

Data Structures

struct  bas_client_callbacks_t
 

Typedefs

typedef void(* bas_client_read_battery_level_completed_cb_t) (ble_client_t *bas_client, att_error_t status, uint8_t level)
 Read battery level completed callback. More...
 
typedef void(* bas_client_set_event_state_completed_cb_t) (ble_client_t *bas_client, bas_client_event_t event, att_error_t status)
 Set event state completed callback. More...
 
typedef void(* bas_client_get_event_state_completed_cb_t) (ble_client_t *bas_client, bas_client_event_t event, att_error_t status, bool enabled)
 Get event state completed callback. More...
 
typedef void(* bas_client_battery_level_notif_cb_t) (ble_client_t *bas_client, uint8_t level)
 

Enumerations

enum  bas_client_event_t { BAS_CLIENT_EVENT_BATTERY_LEVEL_NOTIFY = 0x01 }
 
enum  bas_client_cap_t { BAS_CLIENT_CAP_BATTERY_LEVEL_NOTIFICATION = 0x01 }
 

Functions

ble_client_tbas_client_init (const bas_client_callbacks_t *cb, const ble_evt_gattc_browse_svc_t *evt)
 Register BAS Client instance. More...
 
bas_client_cap_t bas_client_get_capabilities (ble_client_t *bas_client)
 Get BAS Client capabilities. More...
 
bool bas_client_read_battery_level (ble_client_t *bas_client)
 Read of battery level. More...
 
bool bas_client_set_event_state (ble_client_t *bas_client, bas_client_event_t event, bool enable)
 Set event state. More...
 
bool bas_client_get_event_state (ble_client_t *bas_client, bas_client_event_t event)
 Get event state. More...
 

Detailed Description

Battery service client.

Typedef Documentation

◆ bas_client_battery_level_notif_cb_t

typedef void(* bas_client_battery_level_notif_cb_t) (ble_client_t *bas_client, uint8_t level)

Battery level notification callback

Called when battery level notification has been received

Parameters
[in]bas_clientBAS Client instance
[in]levelbattery level

◆ bas_client_get_event_state_completed_cb_t

typedef void(* bas_client_get_event_state_completed_cb_t) (ble_client_t *bas_client, bas_client_event_t event, att_error_t status, bool enabled)

Get event state completed callback.

Called When particular characteristic's event state has been returned by server

Parameters
[in]bas_clientBAS Client instance
[in]eventEvent type
[in]statusATT status of operation
[in]enabledState flag

◆ bas_client_read_battery_level_completed_cb_t

typedef void(* bas_client_read_battery_level_completed_cb_t) (ble_client_t *bas_client, att_error_t status, uint8_t level)

Read battery level completed callback.

It is called when read response is received from server.

Parameters
[in]bas_clientBAS Client instance
[in]statusATT status of operation
[in]levelbattery level

◆ bas_client_set_event_state_completed_cb_t

typedef void(* bas_client_set_event_state_completed_cb_t) (ble_client_t *bas_client, bas_client_event_t event, att_error_t status)

Set event state completed callback.

Called When particular characteristic's event state has been set

Parameters
[in]bas_clientBAS Client instance
[in]eventEvent type
[in]statusATT status of operation

Enumeration Type Documentation

◆ bas_client_cap_t

Capabilities (supported characteristics)

Enumerator
BAS_CLIENT_CAP_BATTERY_LEVEL_NOTIFICATION 

Battery level characteristic supports notifications

◆ bas_client_event_t

Characteristics containing CCC descriptors - may be configured for notifications or indications

Enumerator
BAS_CLIENT_EVENT_BATTERY_LEVEL_NOTIFY 

Battery level notifications

Function Documentation

◆ bas_client_get_capabilities()

bas_client_cap_t bas_client_get_capabilities ( ble_client_t bas_client)

Get BAS Client capabilities.

Function returns bit mask with BAS Client capabilities.

Parameters
[in]bas_clientclient instance
Returns
capabilities bitmask

◆ bas_client_get_event_state()

bool bas_client_get_event_state ( ble_client_t bas_client,
bas_client_event_t  event 
)

Get event state.

Functions reads CCC descriptor of given characteristic.

Parameters
[in]bas_clientclient instance
[in]eventevent type
Returns
true if read request to CCC descriptor has been sent successfully, false otherwise.

◆ bas_client_init()

ble_client_t* bas_client_init ( const bas_client_callbacks_t cb,
const ble_evt_gattc_browse_svc_t evt 
)

Register BAS Client instance.

Function registers BAS Client

Parameters
[in]cbapplication callbacks
[in]evtbrowse svc event with Battery Service details
Returns
client instance

◆ bas_client_read_battery_level()

bool bas_client_read_battery_level ( ble_client_t bas_client)

Read of battery level.

Function trigger read of battery level.

Parameters
[in]bas_clientclient instance
Returns
true if read request has been sent successfully, false otherwise.

◆ bas_client_set_event_state()

bool bas_client_set_event_state ( ble_client_t bas_client,
bas_client_event_t  event,
bool  enable 
)

Set event state.

Function set event state for given characteristic

Parameters
[in]bas_clientclient instance
[in]eventevent type
[in]enableenable/disable flag
Returns
true if write request to CCC descriptor has been sent successfully, false otherwise.