bas_c.h
Go to the documentation of this file.
1
57 #ifndef __BAS_C_H__
58 #define __BAS_C_H__
59
60 #include "gr55xx_sys.h"
61 #include "ble_prf_types.h"
62 #include "custom_config.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
70 #define BAS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS)
79 typedef enum
80 {
81 BAS_C_EVT_INVALID,
82 BAS_C_EVT_DISCOVERY_COMPLETE,
83 BAS_C_EVT_DISCOVERY_FAIL,
84 BAS_C_EVT_BAT_LEVEL_NTF_SET_SUCCESS,
85 BAS_C_EVT_BAT_LEVEL_NTF_SET_ERR,
86 BAS_C_EVT_BAT_LEVE_RECEIVE,
87 } bas_c_evt_type_t;
95 typedef struct
96 {
97 uint16_t bas_srvc_start_handle;
98 uint16_t bas_srvc_end_handle;
99 uint16_t bas_bat_level_handle;
100 uint16_t bas_bat_level_cccd_handle;
101 uint16_t bas_bat_level_pres_handle;
102 } bas_c_handles_t;
103
105 typedef struct
106 {
107 uint8_t conn_idx;
108 bas_c_evt_type_t evt_type;
109 uint8_t bat_level;
110 } bas_c_evt_t;
118 typedef void (*bas_c_evt_handler_t)(bas_c_evt_t *p_evt);
134 sdk_err_t bas_client_init(bas_c_evt_handler_t evt_handler);
135
145 sdk_err_t bas_c_disc_srvc_start(uint8_t conn_idx);
146
157 sdk_err_t bas_c_bat_level_notify_set(uint8_t conn_idx, bool is_enable);
158
168 sdk_err_t bas_c_bat_level_read(uint8_t conn_idx);
171 #endif
172
bas_c_handles_t::bas_bat_level_handle
uint16_t bas_bat_level_handle
Definition: bas_c.h:99
bas_c_handles_t::bas_bat_level_cccd_handle
uint16_t bas_bat_level_cccd_handle
Definition: bas_c.h:100
bas_c_evt_t::bat_level
uint8_t bat_level
Definition: bas_c.h:109
BAS_C_EVT_BAT_LEVEL_NTF_SET_ERR
@ BAS_C_EVT_BAT_LEVEL_NTF_SET_ERR
Definition: bas_c.h:85
bas_c_bat_level_notify_set
sdk_err_t bas_c_bat_level_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer Battery Level characteristic notify.
BAS_C_EVT_DISCOVERY_FAIL
@ BAS_C_EVT_DISCOVERY_FAIL
Definition: bas_c.h:83
gr55xx_sys.h
GR55XX System API.
bas_c_handles_t::bas_srvc_end_handle
uint16_t bas_srvc_end_handle
Definition: bas_c.h:98
bas_c_evt_t::evt_type
bas_c_evt_type_t evt_type
Definition: bas_c.h:108
bas_c_handles_t::bas_bat_level_pres_handle
uint16_t bas_bat_level_pres_handle
Definition: bas_c.h:101
bas_c_evt_t::conn_idx
uint8_t conn_idx
Definition: bas_c.h:107
bas_c_bat_level_read
sdk_err_t bas_c_bat_level_read(uint8_t conn_idx)
Read Battery Level characteristic value.
BAS_C_EVT_INVALID
@ BAS_C_EVT_INVALID
Definition: bas_c.h:81
bas_c_evt_type_t
bas_c_evt_type_t
Battery Service Client event type.
Definition: bas_c.h:80
BAS_C_EVT_DISCOVERY_COMPLETE
@ BAS_C_EVT_DISCOVERY_COMPLETE
Definition: bas_c.h:82
ble_prf_types.h
Profile/Service Common Types.
bas_c_disc_srvc_start
sdk_err_t bas_c_disc_srvc_start(uint8_t conn_idx)
Discovery Battery Service on peer.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
bas_c_evt_t
Battery Service Client event.
Definition: bas_c.h:106
bas_client_init
sdk_err_t bas_client_init(bas_c_evt_handler_t evt_handler)
Register BAS Client event handler.
BAS_C_EVT_BAT_LEVE_RECEIVE
@ BAS_C_EVT_BAT_LEVE_RECEIVE
Definition: bas_c.h:86
bas_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: bas_c.h:96
bas_c_evt_handler_t
void(* bas_c_evt_handler_t)(bas_c_evt_t *p_evt)
Battery Service Client event handler type.
Definition: bas_c.h:118
bas_c_handles_t::bas_srvc_start_handle
uint16_t bas_srvc_start_handle
Definition: bas_c.h:97
BAS_C_EVT_BAT_LEVEL_NTF_SET_SUCCESS
@ BAS_C_EVT_BAT_LEVEL_NTF_SET_SUCCESS
Definition: bas_c.h:84