-
Notifications
You must be signed in to change notification settings - Fork 731
/
esp_bas.h
521 lines (459 loc) · 28.1 KB
/
esp_bas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
/*
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C"
{
#endif
/* 16 Bit Battery Service UUID */
#define BLE_BAS_UUID16 0x180F
/* 16 Bit Battery Service Characteristic UUIDs */
#define BLE_BAS_CHR_UUID16_LEVEL 0x2A19
#define BLE_BAS_CHR_UUID16_LEVEL_STATUS 0x2BED
#define BLE_BAS_CHR_UUID16_ESTIMATED_SERVICE_DATE 0x2BEF
#define BLE_BAS_CHR_UUID16_CRITICAL_STATUS 0x2BE9
#define BLE_BAS_CHR_UUID16_ENERGY_STATUS 0x2BF0
#define BLE_BAS_CHR_UUID16_TIME_STATUS 0x2BEE
#define BLE_BAS_CHR_UUID16_HEALTH_STATUS 0x2BEA
#define BLE_BAS_CHR_UUID16_HEALTH_INFO 0x2BEB
#define BLE_BAS_CHR_UUID16_BATTERY_INFO 0x2BEC
/**
* @brief This structure represents a 24bits data type.
*/
typedef struct {
uint32_t u24: 24; /*!< A 24bits data */
} __attribute__((packed)) uint24_t;
/* Battery Service Level Status Flags Bit Masks */
#define BAS_CHR_LEVEL_STATUS_FLAGS_BM_NONE 0x00
#define BAS_CHR_LEVEL_STATUS_FLAGS_BM_IDENTIFY 0x01
#define BAS_CHR_LEVEL_STATUS_FLAGS_BM_BATTERY_LEVEL 0x02
#define BAS_CHR_LEVEL_STATUS_FLAGS_BM_ADDITIONAL_STATUS 0x04
#define BAS_CHR_LEVEL_STATUS_FLAGS_BM_RFU 0xF8
/* Battery Service Level Status Power State Bit Masks */
/* Battery Present in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_NOT 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_SET 1
/* Wired External Power Source Connected in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRED_EXTERNAL_POWER_SOURCE_NOTCONNECT 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRED_EXTERNAL_POWER_SOURCE_CONNECTED 1
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRED_EXTERNAL_POWER_SOURCE_UNKNOWN 2
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRED_EXTERNAL_POWER_SOURCE_RFU 3
/* Wireless External Power Source Connected in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRELESS_EXTERNAL_POWER_SOURCE_NOTCONNECT 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRELESS_EXTERNAL_POWER_SOURCE_CONNECTED 1
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRELESS_EXTERNAL_POWER_SOURCE_UNKNOWN 2
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_WIRELESS_EXTERNAL_POWER_SOURCE_RFU 3
/* Battery Charge State in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_STATE_UNKNOWN 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_STATE_CHARGING 1
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_STATE_DISCHARGING_ACTIVE 2
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_STATE_DISCHARGING_INACTIVE 3
/* Battery Charge Level in Power State Filed */;
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_LEVEL_UNKNOWN 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_LEVEL_GOOD 1
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_LEVEL_LOW 2
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_BATTERY_CHARGE_LEVEL_CRITICAL 3
/* Charging Type in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_UNKNOWN 0
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_CURRENT 1
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_VOLTAGE 2
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_TRICKLE 3
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_FLOAT 4
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_TYPE_RFU 5
/* Charging Fault Reason in Power State Filed */
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_FAULT_NONE 0x00
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_FAULT_BATTERY 0x01
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_FAULT_EXTERNAL_POWER_SOURCE 0x02
#define BAS_CHR_LEVEL_STATUS_POWER_STATE_CHARGE_FAULT_OTHER 0x04
/* Battery Service Level Status Additional Status Bit Masks */
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_SERVICE_FALSE 0
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_SERVICE_TRUE 1
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_SERVICE_UNKNOWN 2
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_SERVICE_RFU 3
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_BATTERY_FAULT_UNKNOWN 0
#define BAS_CHR_LEVEL_STATUS_ASSITIONAL_STATUS_BATTERY_FAULT_TRUE 1
/* Battery Service Battery Critical Status Flags Bits Masks */
#define BAS_CHR_CRITICAL_STATUS_FLAGS_BM_NONE 0x00
#define BAS_CHR_CRITICAL_STATUS_FLAGS_BM_CRITICAL_POWER_STATE 0x01
#define BAS_CHR_CRITICAL_STATUS_FLAGS_BM_IMMEDIATE_SERVICE 0x02
/* Battery Service Battery Energy Status Flags Bits Masks */
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_NONE 0x00
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_EXTERNAL_SOURCE_POWER 0x01
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_VOLTAGE 0x02
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_AVAILALBE_ENERGY 0x04
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_AVAILALBE_BATTERY_CAPACITY 0x08
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_CHARGE_RATE 0x10
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_AVAILALBE_ENERGY_LAST_CHARGE 0x20
#define BAS_CHR_ENERGY_STATUS_FLAGS_BM_RFU 0xC0
/* Battery Service Battery Time Status Flags Bits Masks */
#define BAS_CHR_TIME_STATUS_FLAGS_BM_NONE 0x00
#define BAS_CHR_TIME_STATUS_FLAGS_BM_DISCHARGED_STANDBY 0x01
#define BAS_CHR_TIME_STATUS_FLAGS_BM_RECHARGE 0x02
#define BAS_CHR_TIME_STATUS_FLAGS_BM_RFU 0xF4
/* Battery Service Battery Health Status Flags Bits Masks */
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_NONE 0x00
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_BATTERY_HEALTH_SUMMARY 0x01
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_RCYCLE_COUNT 0x02
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_CURRENT_TEMPERATURE 0x04
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_DEEP_DISCHARGE_COUNT 0x08
#define BAS_CHR_HEALTH_STATUS_FLAGS_BM_RFU 0xF0
/* Battery Service Battery Health Information Flags Bits Masks */
#define BAS_CHR_HEALTH_INFO_FLAGS_BM_NONE 0x00
#define BAS_CHR_HEALTH_INFO_FLAGS_BM_CYCLE_COUNT_DESIGNED_LIFETIME 0x01
#define BAS_CHR_HEALTH_INFO_FLAGS_BM_DESIGNED_OPERATING_TEMPERATURE 0x02
#define BAS_CHR_HEALTH_INFO_FLAGS_BM_RFU 0xFC
/* Battery Service Battery Information Flags Bits Masks */
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_NONE 0x0000
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_MANUFACTURE_DATE 0x0001
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_EXPIRATION_DATE 0x0002
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_DESIGNED_CAPACITY 0x0004
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_LOW_ENERGY 0x0008
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_CRITICAL_ENERGY 0x0010
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_CHEMISTRY 0x0020
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_NOMINAL_VOLTAGE 0x0040
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_AGGREGATION_GROUP 0x0080
#define BAS_CHR_BATTERY_INFO_FLAGS_BM_RFU 0xFF00
/* Battery Service Battery Information Feature Bits Masks */
#define BAS_CHR_BATTERY_INFO_FEATURE_BM_NONE 0x00
#define BAS_CHR_BATTERY_INFO_FEATURE_BM_REPLACE 0x01
#define BAS_CHR_BATTERY_INFO_FEATURE_BM_RECHARGE 0x02
#define BAS_CHR_BATTERY_INFO_FEATURE_BM_RFU 0xF4
/**
* @brief Battery Level Status Characteristic
*/
typedef struct {
struct {
uint8_t en_identifier: 1; /*!< Identifier Present */
uint8_t en_battery_level: 1; /*!< Battery Level Present */
uint8_t en_additional_status: 1; /*!< Additional Status Present */
uint8_t flags_reserved: 5; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Level Status */
struct {
uint16_t battery: 1; /*!< Battery Present */
uint16_t wired_external_power_source: 2; /*!< Wired External Power Source Connected: */
uint16_t wireless_external_power_source: 2; /*!< Wireless External Power Source Connected: */
uint16_t battery_charge_state: 2; /*!< Battery Charge State: */
uint16_t battery_charge_level: 2; /*!< Battery Charge Level: */
uint16_t battery_charge_type: 3; /*!< Battery Charging Type */
uint16_t charging_fault_reason: 3; /*!< Charging Fault Reason */
uint16_t power_state_reserved: 1; /*!< Reserve Feature Used */
} power_state; /*!< Power State of Battery Level Status */
uint16_t identifier; /*!< Used as an identifier for a service instance. */
uint8_t battery_level; /*!< Refer to the Battery Leve */
struct {
uint8_t service_required: 2; /*!< Service Required */
uint8_t battery_fault: 1; /*!< Battery Fault: */
uint8_t reserved: 5; /*!< Reserve Feature Used */
} additional_status; /*!< Contains additional status information such as whether or not service is required */
} __attribute__((packed)) esp_ble_bas_level_status_t;
/**
* @brief Battery Critical Status Characteristic
*/
typedef struct {
struct {
uint8_t critical_power_state: 1; /*!< Critical Power State */
uint8_t immediate_service: 1; /*!< Immediate Service Required */
uint8_t reserved: 6; /*!< Reserve Feature Used */
} status; /*!< Battery Critical Status */
} __attribute__((packed)) esp_ble_bas_critical_status_t;
/**
* @brief Battery Energy Status Characteristic
*/
typedef struct {
struct {
uint8_t en_external_source_power: 1; /*!< External Source Power Present */
uint8_t en_voltage: 1; /*!< Present Voltage Present */
uint8_t en_available_energy: 1; /*!< Available Energy Present */
uint8_t en_available_battery_capacity: 1; /*!< Available Battery Capacity Present */
uint8_t en_charge_rate: 1; /*!< Charge Rate Present */
uint8_t en_available_energy_last_charge: 1; /*!< Available Energy at Last Charge Present */
uint8_t reserved: 2; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Energy Status */
uint16_t external_source_power; /*!< The total power being consumed from an external power source */
uint16_t voltage; /*!< The present terminal voltage of the battery in volts. */
uint16_t available_energy; /*!< The available energy of the battery in kilowatt-hours in its current charge state */
uint16_t available_battery_capacity; /*!< The capacity of the battery in kilowatt-hours at full charge in its current condition */
uint16_t charge_rate; /*!< The energy flowing into the battery in watts */
uint16_t available_energy_last_charge; /*!< The available energy of the battery in kilowatt-hours in its last charge state */
} __attribute__((packed)) esp_ble_bas_energy_status_t;
/**
* @brief Battery Time Status Characteristic
*/
typedef struct {
struct {
uint8_t en_discharged_standby: 1; /*!< Time until Discharged on Standby Present */
uint8_t en_recharged: 1; /*!< Time until Recharged Present */
uint8_t reserved: 6; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Time Status */
uint24_t discharged; /*!< Estimated time in minutes until discharged */
uint24_t discharged_standby; /*!< Estimated time in minutes until discharged assuming for the remaining time the device is in standby. */
uint24_t recharged; /*!< Estimated time in minutes until recharged */
} __attribute__((packed)) esp_ble_bas_time_status_t;
/**
* @brief Battery Health Status Characteristic
*/
typedef struct {
struct {
uint8_t en_battery_health_summary: 1; /*!< Battery Health Summary Present */
uint8_t en_cycle_count: 1; /*!< Cycle Count Present */
uint8_t en_current_temperature: 1; /*!< Current Temperature Present */
uint8_t en_deep_discharge_count: 1; /*!< Deep Discharge Count Present */
uint8_t reserved: 4; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Health Status */
uint8_t battery_health_summary; /*!< Represents aggregation of the overall health of the battery */
uint16_t cycle_count; /*!< Represents the count value of charge cycles */
int8_t current_temperature; /*!< Represents the current temperature of the battery */
uint16_t deep_discharge_count; /*!< Represents the number of times the battery was completely discharged */
} __attribute__((packed)) esp_ble_bas_health_status_t;
/**
* @brief Battery Health Infomation Characteristic
*/
typedef struct {
struct {
uint8_t en_cycle_count_designed_lifetime: 1; /*!< Cycle Count Designed Lifetime Present */
uint8_t min_max_designed_operating_temperature: 1; /*!< Min and Max Designed Operating Temperature Present */
uint8_t reserved: 5; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Health Infomation */
uint16_t cycle_count_designed_lifetime; /*!< Represents the designed number of charge cycles supported by the device */
int8_t min_designed_operating_temperature; /*!< Represents the minimum designed operating temperature of the battery */
int8_t max_designed_operating_temperature; /*!< Represents the maximum designed operating temperature of the battery */
} __attribute__((packed)) esp_ble_bas_health_info_t;
/**
* @brief Battery Infomation Characteristic
*/
typedef struct {
struct {
uint16_t en_manufacture_date: 1; /*!< Battery Manufacture Date Present */
uint16_t en_expiration_date: 1; /*!< Battery Expiration Date Present */
uint16_t en_designed_capacity: 1; /*!< Battery Designed Capacity Present */
uint16_t en_low_energy: 1; /*!< Battery Low Energy Present */
uint16_t en_critical_energy: 1; /*!< Battery Critical Energy Present */
uint16_t en_chemistry: 1; /*!< Battery Chemistry Present */
uint16_t en_nominalvoltage: 1; /*!< Nominal Voltage Present */
uint16_t en_aggregation_group: 1; /*!< Battery Aggregation Group Present */
uint16_t flags_reserved: 8; /*!< Reserve Feature Used */
} flags; /*!< Flags of Battery Infomation */
struct {
uint8_t replace_able: 1; /*!< Battery Replaceable */
uint8_t recharge_able: 1; /*!< Battery Rechargeable */
uint8_t reserved: 7; /*!< Reserve Feature Used */
} features; /*!< Features of Battery Infomation */
uint24_t manufacture_date; /*!< Battery date of manufacture specified as days */
uint24_t expiration_date; /*!< Battery expiration date specified as days */
uint16_t designed_capacity; /*!< The capacity of the battery in kilowatt-hours at full charge in original (new) condition. */
uint16_t low_energy; /*!< The battery energy value in kilowatt-hours when the battery is low */
uint16_t critical_energy; /*!< The battery energy value in kilowatt-hours when the battery is critical. */
uint8_t chemistry; /*!< The value of battery chemistry */
uint16_t nominalvoltage; /*!< Nominal voltage of the battery in units of volts */
uint8_t aggregation_group; /*!< Indicates the Battery Aggregation Group to which this instance of the battery service is associated */
} __attribute__((packed)) esp_ble_bas_battery_info_t;
/**
* @brief Battery Service
*/
typedef struct {
uint8_t battery_level; /*!< The charge level of a battery */
esp_ble_bas_level_status_t level_status; /*!< The power state of a battery */
uint24_t estimated_service_date; /*!< The estimated date when replacement or servicing is required. */
esp_ble_bas_critical_status_t critical_status; /*!< The device will possibly not function as expected due to low energy or service required */
esp_ble_bas_energy_status_t energy_status; /*!< Details about the energy status of the battery */
esp_ble_bas_time_status_t time_status; /*!< Time estimates for discharging and charging */
esp_ble_bas_health_status_t health_status; /*!< Several aspects of battery health */
esp_ble_bas_health_info_t health_info; /*!< The health of a battery */
esp_ble_bas_battery_info_t battery_info; /*!< The physical characteristics of a battery in the context of the battery’s connection in a device */
} __attribute__((packed)) esp_ble_bas_data_t;
/**
* @brief Get the current battery level of the device.
*
* @param[in] level The pointer to store the current battery level
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery level
*/
esp_err_t esp_ble_bas_get_battery_level(uint8_t *level);
/**
* @brief Set the current battery level of the device.
*
* @param[in] level The pointer to store the current battery level
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery level
*/
esp_err_t esp_ble_bas_set_battery_level(uint8_t *level);
/**
* @brief Get the summary information related to the battery status of the device.
*
* @param[in] status The pointer to store the the summary information related to the battery status
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery status
*/
esp_err_t esp_ble_bas_get_level_status(esp_ble_bas_level_status_t *status);
/**
* @brief Set the summary information related to the battery status of the device.
*
* @param[in] status The pointer to store the the summary information related to the battery status
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery status
*/
esp_err_t esp_ble_bas_set_level_status(esp_ble_bas_level_status_t *status);
/**
* @brief Get the current estimated date when the battery is likely to require service or replacement.
*
* @param[in] estimated_date The pointer to store the current estimated date
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery estimated date
*/
esp_err_t esp_ble_bas_get_estimated_date(uint32_t *estimated_date);
/**
* @brief Set the current estimated date when the battery is likely to require service or replacement.
*
* @param[in] estimated_date The pointer to store the current estimated date
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery estimated date
*/
esp_err_t esp_ble_bas_set_estimated_date(uint32_t *estimated_date);
/**
* @brief Get the status bits related to potential battery malfunction.
*
* @param[in] status The pointer to store the status bits related to potential battery malfunction
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery malfunction
*/
esp_err_t esp_ble_bas_get_critical_status(esp_ble_bas_critical_status_t *status);
/**
* @brief Set the status bits related to potential battery malfunction.
*
* @param[in] status The pointer to store the status bits related to potential battery malfunction
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery malfunction
*/
esp_err_t esp_ble_bas_set_critical_status(esp_ble_bas_critical_status_t *status);
/**
* @brief Get the current energy status details of the battery.
*
* @param[in] status The pointer to store the status bits related to potential battery energy
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery energy
*/
esp_err_t esp_ble_bas_get_energy_status(esp_ble_bas_energy_status_t *status);
/**
* @brief Set the current energy status details of the battery.
*
* @param[in] status The pointer to store the status bits related to potential battery energy
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery energy
*/
esp_err_t esp_ble_bas_set_energy_status(esp_ble_bas_energy_status_t *status);
/**
* @brief Get the current estimates on times for discharging and charging.
*
* @param[in] status The pointer to store the current estimates on times
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery estimates
*/
esp_err_t esp_ble_bas_get_time_status(esp_ble_bas_time_status_t *status);
/**
* @brief Set the current estimates on times for discharging and charging.
*
* @param[in] status The pointer to store the current estimates on times
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery estimates
*/
esp_err_t esp_ble_bas_set_time_status(esp_ble_bas_time_status_t *status);
/**
* @brief Get the aspects of battery health.
*
* @param[in] status The pointer to store the aspects of battery health
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery health
*/
esp_err_t esp_ble_bas_get_health_status(esp_ble_bas_health_status_t *status);
/**
* @brief Set the aspects of battery health.
*
* @param[in] status The pointer to store the aspects of battery health
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery health
*/
esp_err_t esp_ble_bas_set_health_status(esp_ble_bas_health_status_t *status);
/**
* @brief Get the static aspects of battery health.
*
* @param[in] info The pointer to store the static aspects of battery health
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery health infomation
*/
esp_err_t esp_ble_bas_get_health_info(esp_ble_bas_health_info_t *info);
/**
* @brief Set the static aspects of battery health.
*
* @param[in] info The pointer to store the static aspects of battery health
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery health infomation
*/
esp_err_t esp_ble_bas_set_health_info(esp_ble_bas_health_info_t *info);
/**
* @brief Get the physical characteristics of the battery.
*
* @param[in] info The pointer to store the physical characteristics of the battery
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery infomation
*/
esp_err_t esp_ble_bas_get_battery_info(esp_ble_bas_battery_info_t *info);
/**
* @brief Set the physical characteristics of the battery.
*
* @param[in] info The pointer to store the physical characteristics of the battery
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong battery infomation
*/
esp_err_t esp_ble_bas_set_battery_info(esp_ble_bas_battery_info_t *info);
/**
* @brief Initialization Battery Service
*
* @return
* - ESP_OK on successful
* - ESP_ERR_INVALID_ARG on wrong initialization
* - ESP_FAIL on error
*/
esp_err_t esp_ble_bas_init(void);
#ifdef __cplusplus
}
#endif