bcs.h
Go to the documentation of this file.
1
59 #ifndef _BCS_H_
60 #define _BCS_H_
61
62 #include "gr55xx_sys.h"
63 #include "custom_config.h"
64 #include "ble_prf_utils.h"
65 #include <stdint.h>
66 #include <stdbool.h>
67
68
73 #define BCS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
74 10 : CFG_MAX_CONNECTIONS)
75 #define BCS_MEAS_VAL_LEN_MAX 20
76 #define BCS_FEAT_VAL_LEN_MAX 4
78 #define INDI_PAYLOAD_HEADER_LEN 3
90 #define NUM_PACKETS 2
91 #define MEAS_PACKET_FIRST 0
92 #define MEAS_PACKET_SUB 1
95 #define BCS_CACHE_MEAS_NUM_MAX 25
97 #define BCS_MEAS_UNSUCCESS 0xFFFF
104 #define BCS_CHAR_FEAT_MANDATORY 0x3F
118 enum bcs_meas_flag_bits
119 {
120 BCS_MEAS_FLAG_UNIT_SI = 0x0000,
121 BCS_MEAS_FLAG_UNIT_IMPERIAL = 0x0001,
122 BCS_MEAS_FLAG_DATE_TIME_PRESENT = 0x0002,
123 BCS_MEAS_FLAG_USER_ID_PRESENT = 0x0004,
124 BCS_MEAS_FLAG_BASAL_METABOLISM = 0x0008,
125 BCS_MEAS_FLAG_MUSCLE_PERCENTAGE = 0x0010,
126 BCS_MEAS_FLAG_MUSCLE_MASS = 0x0020,
127 BCS_MEAS_FLAG_FAT_FREE_MASS = 0x0040,
128 BCS_MEAS_FLAG_SOFT_LEAN_MASS = 0x0080,
129 BCS_MEAS_FLAG_BODY_WATER_MASS = 0x0100,
130 BCS_MEAS_FLAG_IMPEDANCE = 0x0200,
131 BCS_MEAS_FLAG_WEIGHT = 0x0400,
132 BCS_MEAS_FLAG_HEIGHT = 0x0800,
133 BCS_MEAS_FLAG_MUTI_PACKET = 0x1000,
134 };
138 typedef enum
139 {
140 /* Supported Flags */
141 BCS_FEAT_TIME_STAMP = 0x00000001,
142 BCS_FEAT_MULTI_USER = 0x00000002,
143 BCS_FEAT_BASAL_METABOLISM = 0x00000004,
144 BCS_FEAT_MUSCLE_PERCENTAGE = 0x00000008,
145 BCS_FEAT_MUSCLE_MASS = 0x00000010,
146 BCS_FEAT_FAT_FREE_MASS = 0x00000020,
147 BCS_FEAT_SOFT_LEAN_MASS = 0x00000040,
148 BCS_FEAT_BODY_WATER_MASS = 0x00000080,
149 BCS_FEAT_IMPEDANCE = 0x00000100,
150 BCS_FEAT_WEIGHT = 0x00000200,
151 BCS_FEAT_HEIGHT = 0x00000400,
153 /* Mass Resolution */
154 BCS_FEAT_MASS_RES_500G = 0x00000800,
155 BCS_FEAT_MASS_RES_200G = 0x00001000,
156 BCS_FEAT_MASS_RES_100G = 0x00001800,
157 BCS_FEAT_MASS_RES_50G = 0x00002000,
158 BCS_FEAT_MASS_RES_20G = 0x00002800,
159 BCS_FEAT_MASS_RES_10G = 0x00003000,
160 BCS_FEAT_MASS_RES_5G = 0x00003800,
162 /* Height Resolution */
163 BCS_FEAT_HEIGHT_RES_10MM = 0x00008000,
164 BCS_FEAT_HEIGHT_RES_5MM = 0x00010000,
165 BCS_FEAT_HEIGHT_RES_1MM = 0x00018000,
167 BCS_FEAT_FULL_BIT = 0x0001BFFF,
168 } bcs_feature_t;
169
171 typedef enum
172 {
173 BCS_MASS_RES_500G,
174 BCS_MASS_RES_200G,
175 BCS_MASS_RES_100G,
176 BCS_MASS_RES_50G,
177 BCS_MASS_RES_20G,
178 BCS_MASS_RES_10G,
179 BCS_MASS_RES_5G,
180 } bcs_mass_res_t;
181
183 typedef enum
184 {
185 BCS_HEIGHT_RES_10MM,
186 BCS_HEIGHT_RES_5MM,
187 BCS_HEIGHT_RES_1MM,
188 } bcs_height_res_t;
189
191 typedef enum
192 {
193 BCS_UNIT_SI,
194 BCS_UNIT_IMPERIAL,
195 } bcs_unit_t;
196
198 typedef enum
199 {
200 BCS_EVT_INVALID,
201 BCS_EVT_MEAS_INDICATION_ENABLE,
202 BCS_EVT_MEAS_INDICATION_DISABLE,
203 BCS_EVT_MEAS_INDICATION_CPLT,
204 BCS_EVT_MEAS_READ_CHARACTERISTIC,
205 } bcs_evt_type_t;
213 typedef struct
214 {
215 uint8_t time_stamp_present :1;
216 uint8_t user_id_present :1;
217 uint8_t basal_metabolism_present :1;
218 uint8_t muscle_percentage_present :1;
219 uint8_t muscle_mass_present :1;
220 uint8_t fat_free_mass_present :1;
221 uint8_t soft_lean_mass_present :1;
222 uint8_t body_water_mass_present :1;
223 uint8_t impedance_present :1;
224 uint8_t weight_present :1;
225 uint8_t height_present :1;
226 } bcs_meas_flag_t;
227
229 typedef struct
230 {
231 uint16_t body_fat_percentage;
232 prf_date_time_t time_stamp;
233 uint8_t user_id;
234 uint16_t basal_metabolism;
235 uint16_t muscle_percentage;
236 uint16_t muscle_mass;
237 uint16_t fat_free_mass;
238 uint16_t soft_lean_mass;
239 uint16_t body_water_mass;
240 uint16_t impedance;
241 uint16_t weight;
242 uint16_t height;
243 } bcs_meas_val_t;
244
246 typedef struct
247 {
248 bcs_evt_type_t evt_type;
249 uint8_t conn_idx;
250 const uint8_t *p_data;
251 uint16_t length;
252 } bcs_evt_t;
260 typedef void (*bcs_evt_handler_t)(bcs_evt_t *p_evt);
268 typedef struct
269 {
270 bcs_evt_handler_t evt_handler;
271 uint32_t feature;
272 uint8_t char_mask;
273 bcs_unit_t bcs_unit;
274 bcs_meas_flag_t bcs_meas_flags;
275 bcs_mass_res_t bcs_mass_res;
276 bcs_height_res_t bcs_height_res;
277 } bcs_init_t;
294 sdk_err_t bcs_service_init(bcs_init_t *p_bcs_init, uint16_t *p_bcs_start_handle);
295
306 sdk_err_t bcs_measurement_send(uint8_t conn_idx, bcs_meas_val_t *p_meas, uint8_t cache_num);
309 #endif
310
bcs_meas_val_t::height
uint16_t height
Definition: bcs.h:242
BCS_MEAS_FLAG_SOFT_LEAN_MASS
@ BCS_MEAS_FLAG_SOFT_LEAN_MASS
Definition: bcs.h:128
bcs_meas_flag_t::basal_metabolism_present
uint8_t basal_metabolism_present
Definition: bcs.h:217
bcs_init_t::char_mask
uint8_t char_mask
Definition: bcs.h:272
BCS_MEAS_FLAG_HEIGHT
@ BCS_MEAS_FLAG_HEIGHT
Definition: bcs.h:132
bcs_feature_t
bcs_feature_t
Body Composition Feature characteristic bit values.
Definition: bcs.h:139
BCS_MASS_RES_500G
@ BCS_MASS_RES_500G
Definition: bcs.h:173
bcs_unit_t
bcs_unit_t
BCS unit types.
Definition: bcs.h:192
bcs_evt_t::p_data
const uint8_t * p_data
Definition: bcs.h:250
bcs_init_t::bcs_meas_flags
bcs_meas_flag_t bcs_meas_flags
Definition: bcs.h:274
BCS_MEAS_FLAG_FAT_FREE_MASS
@ BCS_MEAS_FLAG_FAT_FREE_MASS
Definition: bcs.h:127
bcs_mass_res_t
bcs_mass_res_t
BCS Weight Measurement resolutions.
Definition: bcs.h:172
BCS_MEAS_FLAG_MUSCLE_PERCENTAGE
@ BCS_MEAS_FLAG_MUSCLE_PERCENTAGE
Definition: bcs.h:125
bcs_meas_flag_t::time_stamp_present
uint8_t time_stamp_present
Definition: bcs.h:215
bcs_evt_type_t
bcs_evt_type_t
Body Composition Service event type.
Definition: bcs.h:199
bcs_evt_t
Body Composition Service event.
Definition: bcs.h:247
BCS_HEIGHT_RES_10MM
@ BCS_HEIGHT_RES_10MM
Definition: bcs.h:185
BCS_MEAS_FLAG_UNIT_IMPERIAL
@ BCS_MEAS_FLAG_UNIT_IMPERIAL
Definition: bcs.h:121
gr55xx_sys.h
GR55XX System API.
bcs_init_t::bcs_mass_res
bcs_mass_res_t bcs_mass_res
Definition: bcs.h:275
bcs_service_init
sdk_err_t bcs_service_init(bcs_init_t *p_bcs_init, uint16_t *p_bcs_start_handle)
Initialize a Body Composition Service instance and add in the DB.
bcs_evt_t::evt_type
bcs_evt_type_t evt_type
Definition: bcs.h:248
BCS_MASS_RES_5G
@ BCS_MASS_RES_5G
Definition: bcs.h:179
BCS_FEAT_HEIGHT_RES_1MM
@ BCS_FEAT_HEIGHT_RES_1MM
Definition: bcs.h:165
BCS_HEIGHT_RES_5MM
@ BCS_HEIGHT_RES_5MM
Definition: bcs.h:186
bcs_meas_val_t::impedance
uint16_t impedance
Definition: bcs.h:240
BCS_MEAS_FLAG_UNIT_SI
@ BCS_MEAS_FLAG_UNIT_SI
Definition: bcs.h:120
BCS_FEAT_MASS_RES_20G
@ BCS_FEAT_MASS_RES_20G
Definition: bcs.h:158
BCS_FEAT_MASS_RES_200G
@ BCS_FEAT_MASS_RES_200G
Definition: bcs.h:155
bcs_measurement_send
sdk_err_t bcs_measurement_send(uint8_t conn_idx, bcs_meas_val_t *p_meas, uint8_t cache_num)
Send Body Composition Measurement indication.
bcs_init_t::bcs_height_res
bcs_height_res_t bcs_height_res
Definition: bcs.h:276
BCS_EVT_MEAS_INDICATION_ENABLE
@ BCS_EVT_MEAS_INDICATION_ENABLE
Definition: bcs.h:201
bcs_init_t
Body Composition Service Init variable.
Definition: bcs.h:269
bcs_meas_flag_t::fat_free_mass_present
uint8_t fat_free_mass_present
Definition: bcs.h:220
BCS_FEAT_MUSCLE_MASS
@ BCS_FEAT_MUSCLE_MASS
Definition: bcs.h:145
BCS_FEAT_MASS_RES_10G
@ BCS_FEAT_MASS_RES_10G
Definition: bcs.h:159
bcs_meas_val_t::weight
uint16_t weight
Definition: bcs.h:241
BCS_MEAS_FLAG_USER_ID_PRESENT
@ BCS_MEAS_FLAG_USER_ID_PRESENT
Definition: bcs.h:123
bcs_meas_flag_t::soft_lean_mass_present
uint8_t soft_lean_mass_present
Definition: bcs.h:221
BCS_FEAT_HEIGHT_RES_10MM
@ BCS_FEAT_HEIGHT_RES_10MM
Definition: bcs.h:163
BCS_MEAS_FLAG_MUSCLE_MASS
@ BCS_MEAS_FLAG_MUSCLE_MASS
Definition: bcs.h:126
bcs_meas_val_t::time_stamp
prf_date_time_t time_stamp
Definition: bcs.h:232
BCS_FEAT_MASS_RES_100G
@ BCS_FEAT_MASS_RES_100G
Definition: bcs.h:156
bcs_meas_val_t::muscle_mass
uint16_t muscle_mass
Definition: bcs.h:236
bcs_meas_val_t::body_water_mass
uint16_t body_water_mass
Definition: bcs.h:239
BCS_FEAT_MASS_RES_50G
@ BCS_FEAT_MASS_RES_50G
Definition: bcs.h:157
BCS_MASS_RES_200G
@ BCS_MASS_RES_200G
Definition: bcs.h:174
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
BCS_FEAT_WEIGHT
@ BCS_FEAT_WEIGHT
Definition: bcs.h:150
bcs_meas_flag_t
Body composition Measurement flag data.
Definition: bcs.h:214
BCS_FEAT_TIME_STAMP
@ BCS_FEAT_TIME_STAMP
Definition: bcs.h:141
bcs_evt_handler_t
void(* bcs_evt_handler_t)(bcs_evt_t *p_evt)
Body Composition Service event handler type.
Definition: bcs.h:260
bcs_meas_flag_t::impedance_present
uint8_t impedance_present
Definition: bcs.h:223
prf_date_time_t
The date and time structure. The packed size is 7 bytes.
Definition: ble_prf_types.h:101
bcs_meas_flag_t::muscle_percentage_present
uint8_t muscle_percentage_present
Definition: bcs.h:218
BCS_MEAS_FLAG_BASAL_METABOLISM
@ BCS_MEAS_FLAG_BASAL_METABOLISM
Definition: bcs.h:124
bcs_evt_t::conn_idx
uint8_t conn_idx
Definition: bcs.h:249
BCS_MASS_RES_10G
@ BCS_MASS_RES_10G
Definition: bcs.h:178
BCS_UNIT_SI
@ BCS_UNIT_SI
Definition: bcs.h:193
bcs_meas_flag_t::body_water_mass_present
uint8_t body_water_mass_present
Definition: bcs.h:222
BCS_FEAT_MULTI_USER
@ BCS_FEAT_MULTI_USER
Definition: bcs.h:142
BCS_FEAT_MASS_RES_5G
@ BCS_FEAT_MASS_RES_5G
Definition: bcs.h:160
bcs_meas_val_t::user_id
uint8_t user_id
Definition: bcs.h:233
BCS_FEAT_SOFT_LEAN_MASS
@ BCS_FEAT_SOFT_LEAN_MASS
Definition: bcs.h:147
BCS_FEAT_MUSCLE_PERCENTAGE
@ BCS_FEAT_MUSCLE_PERCENTAGE
Definition: bcs.h:144
BCS_MEAS_FLAG_WEIGHT
@ BCS_MEAS_FLAG_WEIGHT
Definition: bcs.h:131
BCS_UNIT_IMPERIAL
@ BCS_UNIT_IMPERIAL
Definition: bcs.h:194
BCS_EVT_MEAS_READ_CHARACTERISTIC
@ BCS_EVT_MEAS_READ_CHARACTERISTIC
Definition: bcs.h:204
BCS_MEAS_FLAG_MUTI_PACKET
@ BCS_MEAS_FLAG_MUTI_PACKET
Definition: bcs.h:133
BCS_FEAT_BASAL_METABOLISM
@ BCS_FEAT_BASAL_METABOLISM
Definition: bcs.h:143
bcs_init_t::feature
uint32_t feature
Definition: bcs.h:271
BCS_FEAT_IMPEDANCE
@ BCS_FEAT_IMPEDANCE
Definition: bcs.h:149
bcs_height_res_t
bcs_height_res_t
BCS Height Measurement resolutions.
Definition: bcs.h:184
bcs_init_t::evt_handler
bcs_evt_handler_t evt_handler
Definition: bcs.h:270
BCS_MASS_RES_50G
@ BCS_MASS_RES_50G
Definition: bcs.h:176
bcs_meas_flag_t::weight_present
uint8_t weight_present
Definition: bcs.h:224
BCS_EVT_MEAS_INDICATION_DISABLE
@ BCS_EVT_MEAS_INDICATION_DISABLE
Definition: bcs.h:202
bcs_evt_t::length
uint16_t length
Definition: bcs.h:251
ble_prf_utils.h
Profile/Service Utilities API.
bcs_meas_val_t::muscle_percentage
uint16_t muscle_percentage
Definition: bcs.h:235
BCS_FEAT_HEIGHT_RES_5MM
@ BCS_FEAT_HEIGHT_RES_5MM
Definition: bcs.h:164
bcs_meas_val_t::fat_free_mass
uint16_t fat_free_mass
Definition: bcs.h:237
BCS_MEAS_FLAG_BODY_WATER_MASS
@ BCS_MEAS_FLAG_BODY_WATER_MASS
Definition: bcs.h:129
bcs_meas_flag_t::height_present
uint8_t height_present
Definition: bcs.h:225
bcs_meas_val_t
Body composition Measurement data.
Definition: bcs.h:230
bcs_meas_val_t::body_fat_percentage
uint16_t body_fat_percentage
Definition: bcs.h:231
BCS_FEAT_MASS_RES_500G
@ BCS_FEAT_MASS_RES_500G
Definition: bcs.h:154
bcs_meas_val_t::soft_lean_mass
uint16_t soft_lean_mass
Definition: bcs.h:238
BCS_MASS_RES_20G
@ BCS_MASS_RES_20G
Definition: bcs.h:177
bcs_meas_val_t::basal_metabolism
uint16_t basal_metabolism
Definition: bcs.h:234
BCS_MEAS_FLAG_IMPEDANCE
@ BCS_MEAS_FLAG_IMPEDANCE
Definition: bcs.h:130
bcs_init_t::bcs_unit
bcs_unit_t bcs_unit
Definition: bcs.h:273
BCS_FEAT_BODY_WATER_MASS
@ BCS_FEAT_BODY_WATER_MASS
Definition: bcs.h:148
BCS_FEAT_FAT_FREE_MASS
@ BCS_FEAT_FAT_FREE_MASS
Definition: bcs.h:146
BCS_FEAT_HEIGHT
@ BCS_FEAT_HEIGHT
Definition: bcs.h:151
BCS_MEAS_FLAG_DATE_TIME_PRESENT
@ BCS_MEAS_FLAG_DATE_TIME_PRESENT
Definition: bcs.h:122
bcs_meas_flag_t::muscle_mass_present
uint8_t muscle_mass_present
Definition: bcs.h:219
bcs_meas_flag_t::user_id_present
uint8_t user_id_present
Definition: bcs.h:216
BCS_HEIGHT_RES_1MM
@ BCS_HEIGHT_RES_1MM
Definition: bcs.h:187
BCS_EVT_INVALID
@ BCS_EVT_INVALID
Definition: bcs.h:200
BCS_EVT_MEAS_INDICATION_CPLT
@ BCS_EVT_MEAS_INDICATION_CPLT
Definition: bcs.h:203
BCS_MASS_RES_100G
@ BCS_MASS_RES_100G
Definition: bcs.h:175