hrs_c.h
Go to the documentation of this file.
1
58 #ifndef __HRS_C_H__
59 #define __HRS_C_H__
60
61 #include "gr55xx_sys.h"
62 #include "ble_prf_types.h"
63 #include "custom_config.h"
64 #include <stdint.h>
65 #include <stdbool.h>
66
71 #define HRS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
72 10 : CFG_MAX_CONNECTIONS)
73 #define HRS_C_RR_INTERVALS_NUM_MAX 9
74 #define HRS_C_CTRL_POINT_ENERGY_EXP 0x01
82 typedef enum
83 {
84 HRS_C_EVT_INVALID,
85 HRS_C_EVT_DISCOVERY_COMPLETE,
86 HRS_C_EVT_DISCOVERY_FAIL,
87 HRS_C_EVT_HR_MEAS_NTF_SET_SUCCESS,
88 HRS_C_EVT_HR_MEAS_VAL_RECEIVE,
89 HRS_C_EVT_SENSOR_LOC_READ_RSP,
90 HRS_C_EVT_CTRL_POINT_SET,
91 HRS_C_EVT_WRITE_OP_ERR,
92 } hrs_c_evt_type_t;
93
95 typedef enum
96 {
97
98 HRS_C_BIT_RATE_FORMAT = 0x01,
99 HRS_C_BIT_SENSOR_CONTACT_DETECTED = 0x02,
100 HRS_C_BIT_SENSOR_CONTACT_SUPPORTED = 0x04,
101 HRS_C_BIT_ENERGY_EXPENDED_STATUS = 0x08,
102 HRS_C_BIT_INTERVAL = 0x10,
103 } hrs_c_flag_bit_t;
104
106 typedef enum
107 {
108 HRS_C_SENS_LOC_OTHER,
109 HRS_C_SENS_LOC_CHEST,
110 HRS_C_SENS_LOC_WRIST,
111 HRS_C_SENS_LOC_FINGER,
112 HRS_C_SENS_LOC_HAND,
113 HRS_C_SENS_LOC_EARLOBE,
114 HRS_C_SENS_LOC_FOOT,
115 } hrs_c_sensor_loc_t;
123 typedef struct
124 {
125 bool is_sensor_contact_detected;
126 uint16_t hr_value;
127 uint8_t rr_intervals_num;
128 float rr_intervals[HRS_C_RR_INTERVALS_NUM_MAX];
129 uint16_t energy_expended;
130 } hrs_c_hr_meas_t;
131
133 typedef struct
134 {
135 uint16_t hrs_srvc_start_handle;
136 uint16_t hrs_srvc_end_handle;
137 uint16_t hrs_hr_meas_handle;
138 uint16_t hrs_hr_meas_cccd_handle;
139 uint16_t hrs_sensor_loc_handle;
140 uint16_t hrs_ctrl_point_handle;
141 } hrs_c_handles_t;
142
144 typedef struct
145 {
146 uint8_t conn_idx;
147 hrs_c_evt_type_t evt_type;
148 union
149 {
150 hrs_c_hr_meas_t hr_meas_buff;
151 hrs_c_sensor_loc_t sensor_loc;
152 } value;
153 } hrs_c_evt_t;
161 typedef void (*hrs_c_evt_handler_t)(hrs_c_evt_t *p_evt);
177 sdk_err_t hrs_client_init(hrs_c_evt_handler_t evt_handler);
178
188 sdk_err_t hrs_c_disc_srvc_start(uint8_t conn_idx);
189
200 sdk_err_t hrs_c_heart_rate_meas_notify_set(uint8_t conn_idx, bool is_enable);
201
211 sdk_err_t hrs_c_sensor_loc_read(uint8_t conn_idx);
212
223 sdk_err_t hrs_c_ctrl_point_set(uint8_t conn_idx, uint16_t ctrl_value);
226 #endif
227
hrs_c_disc_srvc_start
sdk_err_t hrs_c_disc_srvc_start(uint8_t conn_idx)
Discovery Heart Rate Service on peer.
hrs_c_flag_bit_t
hrs_c_flag_bit_t
Heart Rate Service Measurement flag bit.
Definition: hrs_c.h:96
hrs_c_handles_t::hrs_hr_meas_handle
uint16_t hrs_hr_meas_handle
Definition: hrs_c.h:137
HRS_C_EVT_INVALID
@ HRS_C_EVT_INVALID
Definition: hrs_c.h:84
hrs_c_handles_t::hrs_srvc_start_handle
uint16_t hrs_srvc_start_handle
Definition: hrs_c.h:135
HRS_C_BIT_INTERVAL
@ HRS_C_BIT_INTERVAL
Definition: hrs_c.h:102
hrs_c_evt_t::evt_type
hrs_c_evt_type_t evt_type
Definition: hrs_c.h:147
HRS_C_SENS_LOC_FOOT
@ HRS_C_SENS_LOC_FOOT
Definition: hrs_c.h:114
hrs_c_evt_type_t
hrs_c_evt_type_t
Heart Rate Service Client event type.
Definition: hrs_c.h:83
hrs_client_init
sdk_err_t hrs_client_init(hrs_c_evt_handler_t evt_handler)
Register HRS Client event handler.
HRS_C_EVT_HR_MEAS_NTF_SET_SUCCESS
@ HRS_C_EVT_HR_MEAS_NTF_SET_SUCCESS
Definition: hrs_c.h:87
hrs_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: hrs_c.h:134
HRS_C_SENS_LOC_HAND
@ HRS_C_SENS_LOC_HAND
Definition: hrs_c.h:112
hrs_c_heart_rate_meas_notify_set
sdk_err_t hrs_c_heart_rate_meas_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer Heart Rate Measurement characteristic notify.
HRS_C_SENS_LOC_CHEST
@ HRS_C_SENS_LOC_CHEST
Definition: hrs_c.h:109
gr55xx_sys.h
GR55XX System API.
hrs_c_evt_handler_t
void(* hrs_c_evt_handler_t)(hrs_c_evt_t *p_evt)
Heart Rate Service Client event handler type.
Definition: hrs_c.h:161
HRS_C_EVT_WRITE_OP_ERR
@ HRS_C_EVT_WRITE_OP_ERR
Definition: hrs_c.h:91
HRS_C_BIT_SENSOR_CONTACT_SUPPORTED
@ HRS_C_BIT_SENSOR_CONTACT_SUPPORTED
Definition: hrs_c.h:100
HRS_C_EVT_CTRL_POINT_SET
@ HRS_C_EVT_CTRL_POINT_SET
Definition: hrs_c.h:90
HRS_C_BIT_RATE_FORMAT
@ HRS_C_BIT_RATE_FORMAT
Definition: hrs_c.h:98
HRS_C_BIT_SENSOR_CONTACT_DETECTED
@ HRS_C_BIT_SENSOR_CONTACT_DETECTED
Definition: hrs_c.h:99
hrs_c_evt_t
Heart Rate Service Client event.
Definition: hrs_c.h:145
hrs_c_evt_t::conn_idx
uint8_t conn_idx
Definition: hrs_c.h:146
hrs_c_hr_meas_t::rr_intervals_num
uint8_t rr_intervals_num
Definition: hrs_c.h:127
hrs_c_handles_t::hrs_ctrl_point_handle
uint16_t hrs_ctrl_point_handle
Definition: hrs_c.h:140
ble_prf_types.h
Profile/Service Common Types.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
HRS_C_EVT_DISCOVERY_FAIL
@ HRS_C_EVT_DISCOVERY_FAIL
Definition: hrs_c.h:86
HRS_C_SENS_LOC_WRIST
@ HRS_C_SENS_LOC_WRIST
Definition: hrs_c.h:110
HRS_C_SENS_LOC_OTHER
@ HRS_C_SENS_LOC_OTHER
Definition: hrs_c.h:108
hrs_c_hr_meas_t::energy_expended
uint16_t energy_expended
Definition: hrs_c.h:129
hrs_c_sensor_loc_t
hrs_c_sensor_loc_t
Values for sensor location.
Definition: hrs_c.h:107
hrs_c_evt_t::sensor_loc
hrs_c_sensor_loc_t sensor_loc
Definition: hrs_c.h:151
hrs_c_hr_meas_t
Heart Rate Measurement characteristic value structure.
Definition: hrs_c.h:124
HRS_C_EVT_HR_MEAS_VAL_RECEIVE
@ HRS_C_EVT_HR_MEAS_VAL_RECEIVE
Definition: hrs_c.h:88
hrs_c_handles_t::hrs_hr_meas_cccd_handle
uint16_t hrs_hr_meas_cccd_handle
Definition: hrs_c.h:138
HRS_C_EVT_DISCOVERY_COMPLETE
@ HRS_C_EVT_DISCOVERY_COMPLETE
Definition: hrs_c.h:85
hrs_c_handles_t::hrs_sensor_loc_handle
uint16_t hrs_sensor_loc_handle
Definition: hrs_c.h:139
HRS_C_RR_INTERVALS_NUM_MAX
#define HRS_C_RR_INTERVALS_NUM_MAX
Definition: hrs_c.h:73
hrs_c_hr_meas_t::hr_value
uint16_t hr_value
Definition: hrs_c.h:126
HRS_C_SENS_LOC_EARLOBE
@ HRS_C_SENS_LOC_EARLOBE
Definition: hrs_c.h:113
hrs_c_ctrl_point_set
sdk_err_t hrs_c_ctrl_point_set(uint8_t conn_idx, uint16_t ctrl_value)
Set Control Point characteristic value.
hrs_c_handles_t::hrs_srvc_end_handle
uint16_t hrs_srvc_end_handle
Definition: hrs_c.h:136
HRS_C_BIT_ENERGY_EXPENDED_STATUS
@ HRS_C_BIT_ENERGY_EXPENDED_STATUS
Definition: hrs_c.h:101
hrs_c_hr_meas_t::is_sensor_contact_detected
bool is_sensor_contact_detected
Definition: hrs_c.h:125
HRS_C_SENS_LOC_FINGER
@ HRS_C_SENS_LOC_FINGER
Definition: hrs_c.h:111
HRS_C_EVT_SENSOR_LOC_READ_RSP
@ HRS_C_EVT_SENSOR_LOC_READ_RSP
Definition: hrs_c.h:89
hrs_c_evt_t::hr_meas_buff
hrs_c_hr_meas_t hr_meas_buff
Definition: hrs_c.h:150
hrs_c_sensor_loc_read
sdk_err_t hrs_c_sensor_loc_read(uint8_t conn_idx)
Read Sensor Location characteristic value.