wss.h
Go to the documentation of this file.
1
57 #ifndef __WSS_H__
58 #define __WSS_H__
59
60 #include "gr55xx_sys.h"
61 #include "custom_config.h"
62 #include "ble_prf_utils.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
70 #define WSS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS)
72 #define WSS_MEAS_VAL_LEN_MAX 15
73 #define WSS_CACHE_MEAS_NUM_MAX 25
74 #define WSS_FEAT_VAL_LEN_MAX 1
75 #define WSS_MEAS_UNSUCCESS 0xFFFF
81 #define WSS_CHAR_FEAT_MANDATORY 0x7F
90 enum wss_meas_flag_bits
91 {
92 WSS_MEAS_FLAG_UNIT_SI = 0x00,
93 WSS_MEAS_FLAG_UNIT_IMPERIAL = 0x01,
94 WSS_MEAS_FLAG_DATE_TIME_PRESENT = 0x02,
95 WSS_MEAS_FLAG_USER_ID_PRESENT = 0x04,
96 WSS_MEAS_FLAG_BMI_HEIGHT_PRESENT = 0x08,
97 };
98
100 typedef enum
101 {
102 /* Supported Flags */
103 WSS_FEAT_TIME_STAMP = 0x00000001,
104 WSS_FEAT_MULTI_USER = 0x00000002,
105 WSS_FEAT_BMI = 0x00000004,
107 /* Weight Measurement Resolution */
108 WSS_FEAT_MASS_RES_500G = 0x00000008,
109 WSS_FEAT_MASS_RES_200G = 0x00000010,
110 WSS_FEAT_MASS_RES_100G = 0x00000018,
111 WSS_FEAT_MASS_RES_50G = 0x00000020,
112 WSS_FEAT_MASS_RES_20G = 0x00000028,
113 WSS_FEAT_MASS_RES_10G = 0x00000030,
114 WSS_FEAT_MASS_RES_5G = 0x00000038,
116 /* Height Measurement Resolution */
117 WSS_FEAT_HEIGHT_RES_10MM = 0x00000080,
118 WSS_FEAT_HEIGHT_RES_5MM = 0x00000100,
119 WSS_FEAT_HEIGHT_RES_1MM = 0x00000180,
121 WSS_FEAT_FULL_BIT = 0x000001BF,
122 } wss_feature_t;
123
125 typedef enum
126 {
127 WSS_MASS_RES_500G,
128 WSS_MASS_RES_200G,
129 WSS_MASS_RES_100G,
130 WSS_MASS_RES_50G,
131 WSS_MASS_RES_20G,
132 WSS_MASS_RES_10G,
133 WSS_MASS_RES_5G,
134 } wss_mass_res_t;
135
137 typedef enum
138 {
139 WSS_HEIGHT_RES_10MM,
140 WSS_HEIGHT_RES_5MM,
141 WSS_HEIGHT_RES_1MM,
142 } wss_height_res_t;
143
145 typedef enum
146 {
147 WSS_UNIT_SI,
148 WSS_UNIT_IMPERIAL,
149 } wss_unit_t;
150
152 typedef enum
153 {
154 WSS_EVT_INVALID,
155 WSS_EVT_MEAS_INDICATION_ENABLE,
156 WSS_EVT_MEAS_INDICATION_DISABLE,
157 WSS_EVT_MEAS_INDICATION_CPLT,
158 WSS_EVT_MEAS_READ_CHARACTERISTIC,
159 } wss_evt_type_t;
167 typedef struct
168 {
169 uint16_t weight;
170 prf_date_time_t time_stamp;
171 uint8_t user_id;
172 uint16_t bmi;
173 uint16_t height;
174 } wss_meas_val_t;
175
177 typedef struct
178 {
179 wss_evt_type_t evt_type;
180 uint8_t conn_idx;
181 const uint8_t *p_data;
182 uint16_t length;
183 } wss_evt_t;
191 typedef void (*wss_evt_handler_t)(wss_evt_t *p_evt);
199 typedef struct
200 {
201 wss_evt_handler_t evt_handler;
202 uint32_t feature;
203 uint8_t char_mask;
204 wss_unit_t wss_unit;
205 wss_mass_res_t wss_mass_res;
206 wss_height_res_t wss_height_res;
207 bool multi_user_present;
208 bool time_stamp_present;
209 bool bmi_present;
210 } wss_init_t;
226 sdk_err_t wss_service_init(wss_init_t *p_wss_init, uint16_t *p_bcs_start_handle);
227
239 sdk_err_t wss_measurement_send(uint8_t conn_idx, wss_meas_val_t *p_meas, uint8_t cache_num);
240
243 #endif
244
wss_feature_t
wss_feature_t
Weight Scale Feature characteristic bit values.
Definition: wss.h:101
WSS_FEAT_HEIGHT_RES_1MM
@ WSS_FEAT_HEIGHT_RES_1MM
Definition: wss.h:119
WSS_UNIT_IMPERIAL
@ WSS_UNIT_IMPERIAL
Definition: wss.h:148
wss_meas_val_t::bmi
uint16_t bmi
Definition: wss.h:172
wss_init_t::multi_user_present
bool multi_user_present
Definition: wss.h:207
wss_evt_t::length
uint16_t length
Definition: wss.h:182
wss_init_t
Weight Scale Service Init variable.
Definition: wss.h:200
wss_unit_t
wss_unit_t
WSS unit types.
Definition: wss.h:146
wss_evt_t
Weight Scale Service event.
Definition: wss.h:178
wss_evt_type_t
wss_evt_type_t
Weight Scale Service event type.
Definition: wss.h:153
WSS_MEAS_FLAG_USER_ID_PRESENT
@ WSS_MEAS_FLAG_USER_ID_PRESENT
Definition: wss.h:95
WSS_MASS_RES_10G
@ WSS_MASS_RES_10G
Definition: wss.h:132
wss_meas_val_t::height
uint16_t height
Definition: wss.h:173
WSS_FEAT_MASS_RES_5G
@ WSS_FEAT_MASS_RES_5G
Definition: wss.h:114
wss_init_t::wss_height_res
wss_height_res_t wss_height_res
Definition: wss.h:206
WSS_FEAT_MASS_RES_20G
@ WSS_FEAT_MASS_RES_20G
Definition: wss.h:112
gr55xx_sys.h
GR55XX System API.
wss_init_t::wss_mass_res
wss_mass_res_t wss_mass_res
Definition: wss.h:205
wss_init_t::wss_unit
wss_unit_t wss_unit
Definition: wss.h:204
wss_meas_val_t::user_id
uint8_t user_id
Definition: wss.h:171
wss_meas_val_t::time_stamp
prf_date_time_t time_stamp
Definition: wss.h:170
WSS_FEAT_BMI
@ WSS_FEAT_BMI
Definition: wss.h:105
WSS_EVT_MEAS_INDICATION_ENABLE
@ WSS_EVT_MEAS_INDICATION_ENABLE
Definition: wss.h:155
WSS_MASS_RES_5G
@ WSS_MASS_RES_5G
Definition: wss.h:133
WSS_HEIGHT_RES_10MM
@ WSS_HEIGHT_RES_10MM
Definition: wss.h:139
WSS_EVT_MEAS_READ_CHARACTERISTIC
@ WSS_EVT_MEAS_READ_CHARACTERISTIC
Definition: wss.h:158
WSS_MASS_RES_200G
@ WSS_MASS_RES_200G
Definition: wss.h:128
wss_evt_t::p_data
const uint8_t * p_data
Definition: wss.h:181
WSS_FEAT_MASS_RES_200G
@ WSS_FEAT_MASS_RES_200G
Definition: wss.h:109
WSS_EVT_MEAS_INDICATION_CPLT
@ WSS_EVT_MEAS_INDICATION_CPLT
Definition: wss.h:157
WSS_MEAS_FLAG_DATE_TIME_PRESENT
@ WSS_MEAS_FLAG_DATE_TIME_PRESENT
Definition: wss.h:94
WSS_HEIGHT_RES_1MM
@ WSS_HEIGHT_RES_1MM
Definition: wss.h:141
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
WSS_FEAT_MASS_RES_50G
@ WSS_FEAT_MASS_RES_50G
Definition: wss.h:111
wss_init_t::char_mask
uint8_t char_mask
Definition: wss.h:203
WSS_MEAS_FLAG_UNIT_IMPERIAL
@ WSS_MEAS_FLAG_UNIT_IMPERIAL
Definition: wss.h:93
prf_date_time_t
The date and time structure. The packed size is 7 bytes.
Definition: ble_prf_types.h:101
wss_measurement_send
sdk_err_t wss_measurement_send(uint8_t conn_idx, wss_meas_val_t *p_meas, uint8_t cache_num)
Send Weight Scale Measurement indication..
WSS_EVT_MEAS_INDICATION_DISABLE
@ WSS_EVT_MEAS_INDICATION_DISABLE
Definition: wss.h:156
WSS_FEAT_MASS_RES_10G
@ WSS_FEAT_MASS_RES_10G
Definition: wss.h:113
WSS_HEIGHT_RES_5MM
@ WSS_HEIGHT_RES_5MM
Definition: wss.h:140
wss_init_t::feature
uint32_t feature
Definition: wss.h:202
wss_height_res_t
wss_height_res_t
WSS Height Measurement resolutions.
Definition: wss.h:138
WSS_EVT_INVALID
@ WSS_EVT_INVALID
Definition: wss.h:154
WSS_FEAT_MASS_RES_100G
@ WSS_FEAT_MASS_RES_100G
Definition: wss.h:110
WSS_MASS_RES_500G
@ WSS_MASS_RES_500G
Definition: wss.h:127
WSS_FEAT_HEIGHT_RES_10MM
@ WSS_FEAT_HEIGHT_RES_10MM
Definition: wss.h:117
WSS_FEAT_HEIGHT_RES_5MM
@ WSS_FEAT_HEIGHT_RES_5MM
Definition: wss.h:118
wss_init_t::time_stamp_present
bool time_stamp_present
Definition: wss.h:208
WSS_MASS_RES_100G
@ WSS_MASS_RES_100G
Definition: wss.h:129
WSS_FEAT_MASS_RES_500G
@ WSS_FEAT_MASS_RES_500G
Definition: wss.h:108
ble_prf_utils.h
Profile/Service Utilities API.
WSS_MEAS_FLAG_BMI_HEIGHT_PRESENT
@ WSS_MEAS_FLAG_BMI_HEIGHT_PRESENT
Definition: wss.h:96
wss_evt_t::evt_type
wss_evt_type_t evt_type
Definition: wss.h:179
WSS_MASS_RES_20G
@ WSS_MASS_RES_20G
Definition: wss.h:131
wss_init_t::bmi_present
bool bmi_present
Definition: wss.h:209
wss_meas_val_t::weight
uint16_t weight
Definition: wss.h:169
WSS_MASS_RES_50G
@ WSS_MASS_RES_50G
Definition: wss.h:130
wss_init_t::evt_handler
wss_evt_handler_t evt_handler
Definition: wss.h:201
wss_meas_val_t
Weight Scale Measurement data.
Definition: wss.h:168
wss_service_init
sdk_err_t wss_service_init(wss_init_t *p_wss_init, uint16_t *p_bcs_start_handle)
Initialize a Weight Scale Service instance and add in the DB.
wss_mass_res_t
wss_mass_res_t
WSS Weight Measurement resolutions.
Definition: wss.h:126
wss_evt_t::conn_idx
uint8_t conn_idx
Definition: wss.h:180
WSS_FEAT_TIME_STAMP
@ WSS_FEAT_TIME_STAMP
Definition: wss.h:103
WSS_MEAS_FLAG_UNIT_SI
@ WSS_MEAS_FLAG_UNIT_SI
Definition: wss.h:92
WSS_UNIT_SI
@ WSS_UNIT_SI
Definition: wss.h:147
wss_evt_handler_t
void(* wss_evt_handler_t)(wss_evt_t *p_evt)
Weight Scale Service event handler type.
Definition: wss.h:191
WSS_FEAT_MULTI_USER
@ WSS_FEAT_MULTI_USER
Definition: wss.h:104