hts.h
Go to the documentation of this file.
1
61 #ifndef _HTS_H_
62 #define _HTS_H_
63
64 #include "gr55xx_sys.h"
65 #include "custom_config.h"
66 #include "ble_prf_utils.h"
67 #include <stdint.h>
68 #include <stdbool.h>
69
74 #define HTS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
75 10 : CFG_MAX_CONNECTIONS)
76 #define HTS_TEM_MEAS_MAX_LEN 20
77 #define HTS_TEM_TYPE_MAX_LEN 1
78 #define HTS_INTM_TEM_MAX_LEN 20
79 #define HTS_MEAS_INTERVAL_MAX_LEN 2
80 #define HTS_MEAS_INTV_DFLT_MIN 2
81 #define HTS_MEAS_INTV_DFLT_MAX 10
88 #define HTS_CHAR_MANDATORY 0x000f
89 #define HTS_CHAR_TEM_TYPE_SUP 0x003f
90 #define HTS_CHAR_INTM_TEM_SUP 0x01c0
91 #define HTS_CHAR_MEAS_INTERVAL_SUP 0x1e00
92 #define HTS_CHAR_FULL 0x1fff
101 typedef enum
102 {
103 HTS_EVT_INVALID,
104 HTS_EVT_TEM_MEAS_INDICATION_ENABLE,
105 HTS_EVT_TEM_MEAS_INDICATION_DISABLE,
106 HTS_EVT_INTM_TEM_NOTIFICATION_ENABLE,
107 HTS_EVT_INTM_TEM_NOTIFICATION_DISABLE,
108 HTS_EVT_MEAS_INTREVAL_INDICATION_ENABLE,
109 HTS_EVT_MEAS_INTERVAL_INDICATION_DISABLE,
110 HTS_EVT_MEAS_INTERVAL_UPDATE,
111 HTS_EVT_READ_CHARACTERISTIC,
112 } hts_evt_type_t;
113
115 typedef enum
116 {
117 HTS_TEMPERATURE_CELCIUS,
118 HTS_TEMPERATURE_FAHRENHEIT,
119 } hts_temp_unit_t;
120
122 typedef enum
123 {
124 HTS_TEMPERATURE_STABLE,
125 HTS_TEMPERATURE_INTERMEDIATE,
126 } hts_temp_meas_type_t;
127
129 typedef enum
130 {
131 HTS_MEAS_FLAG_TEM_UINTS_BIT = (0x01<<0),
132 HTS_MEAS_FLAG_TIME_STAMP_BIT = (0x01<<1),
133 HTS_MEAS_FLAG_TEM_TYPE_BIT = (0x01<<2),
134 } hts_flag_bit_t;
135
137 typedef enum
138 {
139 HTS_TEMP_TYPE_ARMPIT = 0x01,
140 HTS_TEMP_TYPE_BODY,
141 HTS_TEMP_TYPE_EAR,
142 HTS_TEMP_TYPE_FINGER,
143 HTS_TEMP_TYPE_GI_TRACT,
144 HTS_TEMP_TYPE_MOUTH,
145 HTS_TEMP_TYPE_RECTUM,
146 HTS_TEMP_TYPE_TOE,
147 HTS_TEMP_TYPE_EAR_DRUM,
148 } hts_temp_meas_loc_t;
149
151 typedef enum
152 {
153 HTS_READ_CHAR_TEMP_TYPE,
154 HTS_READ_CHAR_MEAS_INTL,
155 } hts_read_characteristic_t;
163 typedef struct
164 {
165 hts_evt_type_t evt_type;
166 uint8_t conn_idx;
167 const uint8_t *p_data;
168 uint16_t length;
169 } hts_evt_t;
177 typedef void (*hts_evt_handler_t)(hts_evt_t *p_evt);
178
180 typedef prf_date_time_t hts_date_time_t;
188 typedef struct
189 {
190 int8_t exponent;
191 int32_t mantissa;
192 } ieee_float32_t;
193
195 typedef struct
196 {
197 hts_temp_meas_type_t temp_meas_type;
198 uint16_t temp_original_value;
199 ieee_float32_t temp_convert_value;
200 hts_date_time_t time_stamp;
201 hts_temp_meas_loc_t temp_type;
202 } hts_meas_val_t;
203
205 typedef struct
206 {
207 hts_evt_handler_t evt_handler;
208 uint16_t char_mask;
209 hts_temp_unit_t temperature_units;
210 bool time_stamp_present;
211 hts_temp_meas_loc_t temp_type;
212 uint16_t meas_interval;
213 uint16_t min_meas_interval_sup;
214 uint16_t max_meas_interval_sup;
215 } hts_init_t;
231 sdk_err_t hts_service_init(hts_init_t *p_hts_init);
232
243 sdk_err_t hts_measurement_send(uint8_t conn_idx, hts_meas_val_t *p_meas);
244
254 sdk_err_t hts_measurement_interval_send(uint8_t conn_idx);
257 #endif
258
hts_service_init
sdk_err_t hts_service_init(hts_init_t *p_hts_init)
Initialize a Health Thermometer Service instance and add in the DB.
HTS_TEMPERATURE_FAHRENHEIT
@ HTS_TEMPERATURE_FAHRENHEIT
Definition: hts.h:118
hts_evt_t
Health Thermometer Service event.
Definition: hts.h:164
HTS_EVT_READ_CHARACTERISTIC
@ HTS_EVT_READ_CHARACTERISTIC
Definition: hts.h:111
HTS_EVT_TEM_MEAS_INDICATION_ENABLE
@ HTS_EVT_TEM_MEAS_INDICATION_ENABLE
Definition: hts.h:104
HTS_EVT_INTM_TEM_NOTIFICATION_DISABLE
@ HTS_EVT_INTM_TEM_NOTIFICATION_DISABLE
Definition: hts.h:107
hts_evt_t::p_data
const uint8_t * p_data
Definition: hts.h:167
HTS_MEAS_FLAG_TEM_UINTS_BIT
@ HTS_MEAS_FLAG_TEM_UINTS_BIT
Definition: hts.h:131
hts_evt_t::evt_type
hts_evt_type_t evt_type
Definition: hts.h:165
hts_evt_t::length
uint16_t length
Definition: hts.h:168
hts_temp_unit_t
hts_temp_unit_t
Health Thermometer temperature unit,.
Definition: hts.h:116
ieee_float32_t::exponent
int8_t exponent
Definition: hts.h:190
hts_meas_val_t::temp_original_value
uint16_t temp_original_value
Definition: hts.h:198
HTS_TEMP_TYPE_MOUTH
@ HTS_TEMP_TYPE_MOUTH
Definition: hts.h:144
HTS_TEMP_TYPE_BODY
@ HTS_TEMP_TYPE_BODY
Definition: hts.h:140
HTS_READ_CHAR_TEMP_TYPE
@ HTS_READ_CHAR_TEMP_TYPE
Definition: hts.h:153
HTS_MEAS_FLAG_TEM_TYPE_BIT
@ HTS_MEAS_FLAG_TEM_TYPE_BIT
Definition: hts.h:133
hts_init_t::char_mask
uint16_t char_mask
Definition: hts.h:208
gr55xx_sys.h
GR55XX System API.
HTS_READ_CHAR_MEAS_INTL
@ HTS_READ_CHAR_MEAS_INTL
Definition: hts.h:154
HTS_MEAS_FLAG_TIME_STAMP_BIT
@ HTS_MEAS_FLAG_TIME_STAMP_BIT
Definition: hts.h:132
hts_measurement_send
sdk_err_t hts_measurement_send(uint8_t conn_idx, hts_meas_val_t *p_meas)
Send temperature measurement if indication or notification has been enabled.
HTS_TEMP_TYPE_FINGER
@ HTS_TEMP_TYPE_FINGER
Definition: hts.h:142
HTS_EVT_INVALID
@ HTS_EVT_INVALID
Definition: hts.h:103
hts_init_t::temp_type
hts_temp_meas_loc_t temp_type
Definition: hts.h:211
hts_date_time_t
prf_date_time_t hts_date_time_t
Health Thermometer Service date time type.
Definition: hts.h:180
hts_init_t::meas_interval
uint16_t meas_interval
Definition: hts.h:212
hts_init_t::min_meas_interval_sup
uint16_t min_meas_interval_sup
Definition: hts.h:213
HTS_TEMP_TYPE_RECTUM
@ HTS_TEMP_TYPE_RECTUM
Definition: hts.h:145
HTS_EVT_TEM_MEAS_INDICATION_DISABLE
@ HTS_EVT_TEM_MEAS_INDICATION_DISABLE
Definition: hts.h:105
HTS_TEMPERATURE_CELCIUS
@ HTS_TEMPERATURE_CELCIUS
Definition: hts.h:117
hts_meas_val_t::temp_convert_value
ieee_float32_t temp_convert_value
Definition: hts.h:199
hts_read_characteristic_t
hts_read_characteristic_t
The parameters for HTS_EVT_READ_CHARACTERISTIC.
Definition: hts.h:152
hts_meas_val_t::time_stamp
hts_date_time_t time_stamp
Definition: hts.h:200
HTS_EVT_MEAS_INTREVAL_INDICATION_ENABLE
@ HTS_EVT_MEAS_INTREVAL_INDICATION_ENABLE
Definition: hts.h:108
hts_init_t
Health Thermometer Service init stucture. This contains all option and data needed for initialization...
Definition: hts.h:206
hts_evt_handler_t
void(* hts_evt_handler_t)(hts_evt_t *p_evt)
Health Thermometer Service event handler type.
Definition: hts.h:177
hts_evt_t::conn_idx
uint8_t conn_idx
Definition: hts.h:166
HTS_EVT_INTM_TEM_NOTIFICATION_ENABLE
@ HTS_EVT_INTM_TEM_NOTIFICATION_ENABLE
Definition: hts.h:106
HTS_EVT_MEAS_INTERVAL_INDICATION_DISABLE
@ HTS_EVT_MEAS_INTERVAL_INDICATION_DISABLE
Definition: hts.h:109
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
ieee_float32_t
SFLOAT format (IEEE-11073 32-bit FLOAT, defined as a 32-bit vlue with 24-bit mantissa and 8-bit expon...
Definition: hts.h:189
hts_init_t::time_stamp_present
bool time_stamp_present
Definition: hts.h:210
hts_init_t::evt_handler
hts_evt_handler_t evt_handler
Definition: hts.h:207
prf_date_time_t
The date and time structure. The packed size is 7 bytes.
Definition: ble_prf_types.h:101
HTS_TEMPERATURE_INTERMEDIATE
@ HTS_TEMPERATURE_INTERMEDIATE
Definition: hts.h:125
HTS_TEMP_TYPE_ARMPIT
@ HTS_TEMP_TYPE_ARMPIT
Definition: hts.h:139
HTS_TEMP_TYPE_EAR
@ HTS_TEMP_TYPE_EAR
Definition: hts.h:141
HTS_EVT_MEAS_INTERVAL_UPDATE
@ HTS_EVT_MEAS_INTERVAL_UPDATE
Definition: hts.h:110
hts_evt_type_t
hts_evt_type_t
Health Thermometer Service event type.
Definition: hts.h:102
hts_flag_bit_t
hts_flag_bit_t
Health Thermometer Measurement flag bits.
Definition: hts.h:130
hts_init_t::max_meas_interval_sup
uint16_t max_meas_interval_sup
Definition: hts.h:214
hts_meas_val_t::temp_type
hts_temp_meas_loc_t temp_type
Definition: hts.h:201
HTS_TEMP_TYPE_TOE
@ HTS_TEMP_TYPE_TOE
Definition: hts.h:146
hts_meas_val_t
Health Theromometer Measurement Character value structure.
Definition: hts.h:196
ble_prf_utils.h
Profile/Service Utilities API.
hts_init_t::temperature_units
hts_temp_unit_t temperature_units
Definition: hts.h:209
hts_measurement_interval_send
sdk_err_t hts_measurement_interval_send(uint8_t conn_idx)
Send temperature measurement interval if indication has been enabled.
HTS_TEMP_TYPE_GI_TRACT
@ HTS_TEMP_TYPE_GI_TRACT
Definition: hts.h:143
HTS_TEMP_TYPE_EAR_DRUM
@ HTS_TEMP_TYPE_EAR_DRUM
Definition: hts.h:147
ieee_float32_t::mantissa
int32_t mantissa
Definition: hts.h:191
hts_temp_meas_type_t
hts_temp_meas_type_t
Health Thermometer temperature measurement type.
Definition: hts.h:123
HTS_TEMPERATURE_STABLE
@ HTS_TEMPERATURE_STABLE
Definition: hts.h:124
hts_meas_val_t::temp_meas_type
hts_temp_meas_type_t temp_meas_type
Definition: hts.h:197
hts_temp_meas_loc_t
hts_temp_meas_loc_t
Temperature Type measurement locations.
Definition: hts.h:138