1
1
/*
2
+ * Copyright (c) 2024 Demant A/S
2
3
* Copyright (c) 2018 Nordic Semiconductor ASA
3
4
* Copyright (c) 2016 Intel Corporation
4
5
*
19
20
*/
20
21
21
22
#include <stdint.h>
23
+ #include <zephyr/sys/util.h>
22
24
23
25
#ifdef __cplusplus
24
26
extern "C" {
25
27
#endif
26
28
29
+ /**
30
+ * @brief Battery Level Status Characteristic flags.
31
+ *
32
+ * Enumeration for the flags indicating the presence
33
+ * of various fields in the Battery Level Status characteristic.
34
+ */
35
+ enum bt_bas_bls_flags {
36
+ /** Bit indicating that the Battery Level Status identifier is present. */
37
+ BT_BAS_BLS_FLAG_IDENTIFIER_PRESENT = BIT (0 ),
38
+
39
+ /** Bit indicating that the Battery Level is present. */
40
+ BT_BAS_BLS_FLAG_BATTERY_LEVEL_PRESENT = BIT (1 ),
41
+
42
+ /** Bit indicating that additional status information is present. */
43
+ BT_BAS_BLS_FLAG_ADDITIONAL_STATUS_PRESENT = BIT (2 ),
44
+ };
45
+
46
+ /** @brief Battery Present Status
47
+ *
48
+ * Enumeration for the presence of the battery.
49
+ */
50
+ enum bt_bas_bls_battery_present {
51
+ /** Battery is not present. */
52
+ BT_BAS_BLS_BATTERY_NOT_PRESENT = 0 ,
53
+
54
+ /** Battery is present. */
55
+ BT_BAS_BLS_BATTERY_PRESENT = 1
56
+ };
57
+
58
+ /** @brief Wired External Power Source Status
59
+ *
60
+ * Enumeration for the status of the wired external power source.
61
+ */
62
+ enum bt_bas_bls_wired_power_source {
63
+ /** Wired external power source is not connected. */
64
+ BT_BAS_BLS_WIRED_POWER_NOT_CONNECTED = 0 ,
65
+
66
+ /** Wired external power source is connected. */
67
+ BT_BAS_BLS_WIRED_POWER_CONNECTED = 1 ,
68
+
69
+ /** Wired external power source status is unknown. */
70
+ BT_BAS_BLS_WIRED_POWER_UNKNOWN = 2
71
+ };
72
+
73
+ /** @brief Wireless External Power Source Status
74
+ *
75
+ * Enumeration for the status of the wireless external power source.
76
+ */
77
+ enum bt_bas_bls_wireless_power_source {
78
+ /** Wireless external power source is not connected. */
79
+ BT_BAS_BLS_WIRELESS_POWER_NOT_CONNECTED = 0 ,
80
+
81
+ /** Wireless external power source is connected. */
82
+ BT_BAS_BLS_WIRELESS_POWER_CONNECTED = 1 ,
83
+
84
+ /** Wireless external power source status is unknown. */
85
+ BT_BAS_BLS_WIRELESS_POWER_UNKNOWN = 2
86
+ };
87
+
88
+ /** @brief Battery Charge State
89
+ *
90
+ * Enumeration for the charge state of the battery.
91
+ */
92
+ enum bt_bas_bls_battery_charge_state {
93
+ /** Battery charge state is unknown. */
94
+ BT_BAS_BLS_CHARGE_STATE_UNKNOWN = 0 ,
95
+
96
+ /** Battery is currently charging. */
97
+ BT_BAS_BLS_CHARGE_STATE_CHARGING = 1 ,
98
+
99
+ /** Battery is discharging actively. */
100
+ BT_BAS_BLS_CHARGE_STATE_DISCHARGING_ACTIVE = 2 ,
101
+
102
+ /** Battery is discharging but inactive. */
103
+ BT_BAS_BLS_CHARGE_STATE_DISCHARGING_INACTIVE = 3
104
+ };
105
+
106
+ /** @brief Battery Charge Level
107
+ *
108
+ * Enumeration for the level of charge in the battery.
109
+ */
110
+ enum bt_bas_bls_battery_charge_level {
111
+ /** Battery charge level is unknown. */
112
+ BT_BAS_BLS_CHARGE_LEVEL_UNKNOWN = 0 ,
113
+
114
+ /** Battery charge level is good. */
115
+ BT_BAS_BLS_CHARGE_LEVEL_GOOD = 1 ,
116
+
117
+ /** Battery charge level is low. */
118
+ BT_BAS_BLS_CHARGE_LEVEL_LOW = 2 ,
119
+
120
+ /** Battery charge level is critical. */
121
+ BT_BAS_BLS_CHARGE_LEVEL_CRITICAL = 3
122
+ };
123
+
124
+ /** @brief Battery Charge Type
125
+ *
126
+ * Enumeration for the type of charging applied to the battery.
127
+ */
128
+ enum bt_bas_bls_battery_charge_type {
129
+ /** Battery charge type is unknown or not charging. */
130
+ BT_BAS_BLS_CHARGE_TYPE_UNKNOWN = 0 ,
131
+
132
+ /** Battery is charged using constant current. */
133
+ BT_BAS_BLS_CHARGE_TYPE_CONSTANT_CURRENT = 1 ,
134
+
135
+ /** Battery is charged using constant voltage. */
136
+ BT_BAS_BLS_CHARGE_TYPE_CONSTANT_VOLTAGE = 2 ,
137
+
138
+ /** Battery is charged using trickle charge. */
139
+ BT_BAS_BLS_CHARGE_TYPE_TRICKLE = 3 ,
140
+
141
+ /** Battery is charged using float charge. */
142
+ BT_BAS_BLS_CHARGE_TYPE_FLOAT = 4
143
+ };
144
+
145
+ /** @brief Charging Fault Reason
146
+ *
147
+ * Enumeration for the reasons of charging faults.
148
+ */
149
+ enum bt_bas_bls_charging_fault_reason {
150
+ /** No charging fault. */
151
+ BT_BAS_BLS_FAULT_REASON_NONE = 0 ,
152
+
153
+ /** Charging fault due to battery issue. */
154
+ BT_BAS_BLS_FAULT_REASON_BATTERY = BIT (0 ),
155
+
156
+ /** Charging fault due to external power source issue. */
157
+ BT_BAS_BLS_FAULT_REASON_EXTERNAL_POWER = BIT (1 ),
158
+
159
+ /** Charging fault for other reasons. */
160
+ BT_BAS_BLS_FAULT_REASON_OTHER = BIT (2 )
161
+ };
162
+
163
+ /** @brief Service Required Status
164
+ *
165
+ * Enumeration for whether the service is required.
166
+ */
167
+ enum bt_bas_bls_service_required {
168
+ /** Service is not required. */
169
+ BT_BAS_BLS_SERVICE_REQUIRED_FALSE = 0 ,
170
+
171
+ /** Service is required. */
172
+ BT_BAS_BLS_SERVICE_REQUIRED_TRUE = 1 ,
173
+
174
+ /** Service requirement is unknown. */
175
+ BT_BAS_BLS_SERVICE_REQUIRED_UNKNOWN = 2
176
+ };
177
+
178
+ /** @brief Battery Fault Status
179
+ *
180
+ * Enumeration for the fault status of the battery.
181
+ */
182
+ enum bt_bas_bls_battery_fault {
183
+ /** No battery fault. */
184
+ BT_BAS_BLS_BATTERY_FAULT_NO = 0 ,
185
+
186
+ /** Battery fault present. */
187
+ BT_BAS_BLS_BATTERY_FAULT_YES = 1
188
+ };
189
+
27
190
/** @brief Read battery level value.
28
191
*
29
192
* Read the characteristic value of the battery level
@@ -43,6 +206,81 @@ uint8_t bt_bas_get_battery_level(void);
43
206
*/
44
207
int bt_bas_set_battery_level (uint8_t level );
45
208
209
+ /**
210
+ * @brief Set the battery present status.
211
+ *
212
+ * @param present The battery present status to set.
213
+ */
214
+ void bt_bas_bls_set_battery_present (enum bt_bas_bls_battery_present present );
215
+
216
+ /**
217
+ * @brief Set the wired external power source status.
218
+ *
219
+ * @param source The wired external power source status to set.
220
+ */
221
+ void bt_bas_bls_set_wired_external_power_source (enum bt_bas_bls_wired_power_source source );
222
+
223
+ /**
224
+ * @brief Set the wireless external power source status.
225
+ *
226
+ * @param source The wireless external power source status to set.
227
+ */
228
+ void bt_bas_bls_set_wireless_external_power_source (enum bt_bas_bls_wireless_power_source source );
229
+
230
+ /**
231
+ * @brief Set the battery charge state.
232
+ *
233
+ * @param state The battery charge state to set.
234
+ */
235
+ void bt_bas_bls_set_battery_charge_state (enum bt_bas_bls_battery_charge_state state );
236
+
237
+ /**
238
+ * @brief Set the battery charge level.
239
+ *
240
+ * @param level The battery charge level to set.
241
+ */
242
+ void bt_bas_bls_set_battery_charge_level (enum bt_bas_bls_battery_charge_level level );
243
+
244
+ /**
245
+ * @brief Set the battery charge type.
246
+ *
247
+ * @param type The battery charge type to set.
248
+ */
249
+ void bt_bas_bls_set_battery_charge_type (enum bt_bas_bls_battery_charge_type type );
250
+
251
+ /**
252
+ * @brief Set the charging fault reason.
253
+ *
254
+ * @param reason The charging fault reason to set.
255
+ */
256
+ void bt_bas_bls_set_charging_fault_reason (enum bt_bas_bls_charging_fault_reason reason );
257
+
258
+ /**
259
+ * @brief Set the identifier of the battery.
260
+ *
261
+ * kconfig_dep{CONFIG_BT_BAS_BLS_IDENTIFIER_PRESENT}
262
+ *
263
+ * @param identifier Identifier to set.
264
+ */
265
+ void bt_bas_bls_set_identifier (uint16_t identifier );
266
+
267
+ /**
268
+ * @brief Set the service required status.
269
+ *
270
+ * kconfig_dep{CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT}
271
+ *
272
+ * @param value Service required status to set.
273
+ */
274
+ void bt_bas_bls_set_service_required (enum bt_bas_bls_service_required value );
275
+
276
+ /**
277
+ * @brief Set the battery fault status.
278
+ *
279
+ * kconfig_dep{CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT}
280
+ *
281
+ * @param value Battery fault status to set.
282
+ */
283
+ void bt_bas_bls_set_battery_fault (enum bt_bas_bls_battery_fault value );
46
284
47
285
#ifdef __cplusplus
48
286
}
0 commit comments