bas.h
Go to the documentation of this file.
1 
69 #ifndef __BAS_H__
70 #define __BAS_H__
71 
72 #include "gr55xx_sys.h"
73 #include "custom_config.h"
74 #include <stdbool.h>
75 #include <stdint.h>
76 
81 #define BAS_INSTANCE_MAX 1
82 #define BAS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
83  10 : CFG_MAX_CONNECTIONS)
85 #define BAS_LVL_MAX_LEN 1
92 #define BAS_CHAR_MANDATORY 0x07
93 #define BAS_CHAR_LVL_NTF_SUP 0x08
94 #define BAS_CHAR_FORMAT_SUP 0x10
95 #define BAS_CHAR_FULL 0x1f
104 typedef enum
105 {
117 typedef struct
118 {
120  uint8_t conn_idx;
121 } bas_evt_t;
129 typedef void (*bas_evt_handler_t)(bas_evt_t *p_evt);
137 typedef struct
138 {
140  uint8_t char_mask;
141  uint8_t batt_lvl;
142 } bas_init_t;
159 sdk_err_t bas_service_init(bas_init_t bas_init[],uint8_t ins_num);
160 
172 sdk_err_t bas_batt_lvl_update(uint8_t conn_idx, uint8_t ins_idx, uint8_t batt_lvl);
175 #endif
176 
BAS_EVT_NOTIFICATION_DISABLED
@ BAS_EVT_NOTIFICATION_DISABLED
Definition: bas.h:108
bas_init_t::batt_lvl
uint8_t batt_lvl
Definition: bas.h:141
bas_evt_t
Battery Service event.
Definition: bas.h:118
bas_evt_t::conn_idx
uint8_t conn_idx
Definition: bas.h:120
gr55xx_sys.h
GR55XX System API.
BAS_EVT_INVALID
@ BAS_EVT_INVALID
Definition: bas.h:106
bas_evt_handler_t
void(* bas_evt_handler_t)(bas_evt_t *p_evt)
Battery Service event handler type.
Definition: bas.h:129
bas_evt_t::evt_type
bas_evt_type_t evt_type
Definition: bas.h:119
BAS_EVT_NOTIFICATION_ENABLED
@ BAS_EVT_NOTIFICATION_ENABLED
Definition: bas.h:107
bas_service_init
sdk_err_t bas_service_init(bas_init_t bas_init[], uint8_t ins_num)
Initialize Battery Service instances and add to the DB.
bas_init_t
Battery Service init structure. This contains all options and data needed for initialization of the s...
Definition: bas.h:138
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
bas_init_t::evt_handler
bas_evt_handler_t evt_handler
Definition: bas.h:139
bas_batt_lvl_update
sdk_err_t bas_batt_lvl_update(uint8_t conn_idx, uint8_t ins_idx, uint8_t batt_lvl)
Update a Battery Level value. If notification is enabled, send it.
bas_init_t::char_mask
uint8_t char_mask
Definition: bas.h:140
bas_evt_type_t
bas_evt_type_t
Battery Service event types.
Definition: bas.h:105