rscs.h
Go to the documentation of this file.
1
60 #ifndef __RSCS_H__
61 #define __RSCS_H__
62
63 #include "gr55xx_sys.h"
64 #include "custom_config.h"
65 #include <stdint.h>
66 #include <stdbool.h>
67
72 #define RSCS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
73 10 : CFG_MAX_CONNECTIONS)
74 #define RSCS_MEAS_VAL_LEN_MAX 20
75 #define RSCS_FEAT_VAL_LEN_MAX 2
76 #define RSCS_SENSOR_LOC_VAL_LEN_MAX 1
77 #define RSCS_CTRL_PT_RSP_LEN_MIN 3
78 #define RSCS_CTRL_PT_VAL_LEN_MAX (RSCS_CTRL_PT_RSP_LEN_MIN + RSCS_SENSOR_LOC_SUP_NB)
80 #define RSCS_ERROR_PROC_IN_PROGRESS 0x80
81 #define RSCS_ERROR_CCCD_INVALID 0x81
88 #define RSCS_CHAR_MANDATORY 0x003f
89 #define RSCS_CHAR_SENSOR_LOC_SUP 0x00c0
90 #define RSCS_CHAR_SC_CTRL_POINT 0x0700
91 #define RSCS_CHAR_FULL 0x07ff
99 #define RSCS_MEAS_FLAG_INST_STRIDE_LEN_BIT (0x01 << 0)
100 #define RSCS_MEAS_FLAG_TOTAL_DISTANCE_BIT (0x01 << 1)
101 #define RSCS_MEAS_FLAG_RUNNING_OR_WALKING_BIT (0x01 << 2)
109 #define RSCS_FEAT_INSTANT_STRIDE_LEN_BIT (0x01 << 0)
110 #define RSCS_FEAT_TOTAL_DISTANCE_BIT (0x01 << 1)
111 #define RSCS_FEAT_RUNNING_OR_WALKING_STATUS_BIT (0x01 << 2)
112 #define RSCS_FEAT_CALIBRATION_PROCEDURE_BIT (0x01 << 3)
113 #define RSCS_FEAT_MULTIPLE_SENSORS_BIT (0x01 << 4)
114 #define RSCS_FEAR_FULL_BIT (0x1f)
123 typedef enum
124 {
125 RSCS_SENSOR_LOC_OTHER,
126 RSCS_SENSOR_LOC_SHOE_TOP,
127 RSCS_SENSOR_LOC_SHOE_IN,
128 RSCS_SENSOR_LOC_HIP,
129 RSCS_SENSOR_LOC_FRONT_WHEEL,
130 RSCS_SENSOR_LOC_LEFT_PEDAL,
131 RSCS_SENSOR_LOC_RIGHT_PEDAL,
132 RSCS_SENSOR_LOC_FRONT_HUB,
133 RSCS_SENSOR_LOC_SUP_NB
134 } rscs_sensor_loc_t;
135
137 typedef enum
138 {
139 RSCS_CTRL_PT_OP_RESERVED,
140 RSCS_CTRL_PT_OP_SET_CUMUL_VAL,
141 RSCS_CTRL_PT_OP_START_CALIB,
142 RSCS_CTRL_PT_OP_UPD_LOC,
143 RSCS_CTRL_PT_OP_REQ_SUP_LOC,
144 RSCS_CTRL_PT_OP_RSP_CODE = 0x10,
145 } rscs_ctrl_pt_op_code_t;
146
148 typedef enum
149 {
150 RSCS_CTRL_PT_RSP_RESERVED,
151 RSCS_CTRL_PT_RSP_SUCCESS,
152 RSCS_CTRL_PT_RSP_NOT_SUP,
153 RSCS_CTRL_PT_RSP_INVALID_PARAM,
154 RSCS_CTRL_PT_RSP_FAILED
155 } rscs_ctrl_pt_rsp_t;
156
158 typedef enum
159 {
160 RSCS_EVT_INVALID,
161 RSCS_EVT_RSC_MEAS_NOTIFICATION_ENABLE,
162 RSCS_EVT_RSC_MEAS_NOTIFICATION_DISABLE,
163 RSCS_EVT_CTRL_POINT_INDICATION_ENABLE,
164 RSCS_EVT_CTRL_POINT_INDICATION_DISABLE,
165 RSCS_EVT_RSC_MEAS_SEND_CPLT,
166 RSCS_EVT_CUMUL_VAL_SET,
167 RSCS_EVT_SEBSOR_CALIBRATION,
168 RSCS_EVT_SEBSOR_LOC_UPD,
169 RSCS_EVT_SUP_SEBSOR_LOC_REQ,
170 RSCS_EVT_CTRL_POINT_RSP_CPLT
171 } rscs_evt_type_t;
179 typedef struct
180 {
181 rscs_evt_type_t evt_type;
182 uint8_t conn_idx;
183 const uint8_t *p_data;
184 uint16_t length;
185 } rscs_evt_t;
186
188 typedef struct
189 {
190 bool inst_stride_length_present;
191 bool total_distance_present;
192 bool is_run_or_walk;
193 uint16_t inst_speed;
194 uint8_t inst_cadence;
195 uint16_t inst_stride_length;
196 uint32_t total_distance;
197 } rscs_meas_val_t;
205 typedef void (*rscs_evt_handler_t)(rscs_evt_t *p_evt);
213 typedef struct
214 {
215 rscs_evt_handler_t evt_handler;
216 uint16_t char_mask;
217 rscs_sensor_loc_t sensor_location;
218 uint16_t feature;
219 } rscs_init_t;
236 sdk_err_t rscs_service_init(rscs_init_t *p_rscs_init);
237
248 sdk_err_t rscs_measurement_send(uint8_t conn_idx, rscs_meas_val_t *p_meas);
249
261 sdk_err_t rscs_ctrl_pt_rsp_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
262
272 sdk_err_t rscs_sensor_loc_update(rscs_sensor_loc_t sensor_loc);
273
276 #endif
277
rscs_ctrl_pt_rsp_t
rscs_ctrl_pt_rsp_t
Running Speed and Cadence Service Control Point Response value.
Definition: rscs.h:149
RSCS_CTRL_PT_OP_RESERVED
@ RSCS_CTRL_PT_OP_RESERVED
Definition: rscs.h:139
RSCS_CTRL_PT_OP_START_CALIB
@ RSCS_CTRL_PT_OP_START_CALIB
Definition: rscs.h:141
RSCS_EVT_CTRL_POINT_INDICATION_DISABLE
@ RSCS_EVT_CTRL_POINT_INDICATION_DISABLE
Definition: rscs.h:164
rscs_init_t
Running Speed and Cadence Service init stucture. This contains all option and data needed for initial...
Definition: rscs.h:214
rscs_meas_val_t::inst_stride_length_present
bool inst_stride_length_present
Definition: rscs.h:190
RSCS_CTRL_PT_RSP_FAILED
@ RSCS_CTRL_PT_RSP_FAILED
Definition: rscs.h:154
rscs_init_t::sensor_location
rscs_sensor_loc_t sensor_location
Definition: rscs.h:217
rscs_evt_t::conn_idx
uint8_t conn_idx
Definition: rscs.h:182
rscs_evt_t::evt_type
rscs_evt_type_t evt_type
Definition: rscs.h:181
RSCS_SENSOR_LOC_HIP
@ RSCS_SENSOR_LOC_HIP
Definition: rscs.h:128
rscs_measurement_send
sdk_err_t rscs_measurement_send(uint8_t conn_idx, rscs_meas_val_t *p_meas)
Send RSC measurement if notification has been enabled.
rscs_sensor_loc_t
rscs_sensor_loc_t
Running Speed and Cadence Service Sensor Location.
Definition: rscs.h:124
RSCS_CTRL_PT_RSP_NOT_SUP
@ RSCS_CTRL_PT_RSP_NOT_SUP
Definition: rscs.h:152
RSCS_SENSOR_LOC_OTHER
@ RSCS_SENSOR_LOC_OTHER
Definition: rscs.h:125
rscs_ctrl_pt_op_code_t
rscs_ctrl_pt_op_code_t
Running Speed and Cadence Service Control Point Operation Code.
Definition: rscs.h:138
RSCS_SENSOR_LOC_LEFT_PEDAL
@ RSCS_SENSOR_LOC_LEFT_PEDAL
Definition: rscs.h:130
gr55xx_sys.h
GR55XX System API.
RSCS_EVT_CUMUL_VAL_SET
@ RSCS_EVT_CUMUL_VAL_SET
Definition: rscs.h:166
rscs_meas_val_t::inst_speed
uint16_t inst_speed
Definition: rscs.h:193
rscs_meas_val_t::is_run_or_walk
bool is_run_or_walk
Definition: rscs.h:192
RSCS_CTRL_PT_OP_UPD_LOC
@ RSCS_CTRL_PT_OP_UPD_LOC
Definition: rscs.h:142
RSCS_EVT_CTRL_POINT_RSP_CPLT
@ RSCS_EVT_CTRL_POINT_RSP_CPLT
Definition: rscs.h:170
rscs_ctrl_pt_rsp_send
sdk_err_t rscs_ctrl_pt_rsp_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send SC Control Point responce if indication has been enabled.
RSCS_EVT_SEBSOR_CALIBRATION
@ RSCS_EVT_SEBSOR_CALIBRATION
Definition: rscs.h:167
rscs_init_t::evt_handler
rscs_evt_handler_t evt_handler
Definition: rscs.h:215
RSCS_CTRL_PT_OP_SET_CUMUL_VAL
@ RSCS_CTRL_PT_OP_SET_CUMUL_VAL
Definition: rscs.h:140
rscs_meas_val_t
Running Speed and Cadence Measurement Character value structure.
Definition: rscs.h:189
RSCS_SENSOR_LOC_SHOE_IN
@ RSCS_SENSOR_LOC_SHOE_IN
Definition: rscs.h:127
RSCS_SENSOR_LOC_FRONT_HUB
@ RSCS_SENSOR_LOC_FRONT_HUB
Definition: rscs.h:132
rscs_meas_val_t::inst_cadence
uint8_t inst_cadence
Definition: rscs.h:194
RSCS_CTRL_PT_OP_REQ_SUP_LOC
@ RSCS_CTRL_PT_OP_REQ_SUP_LOC
Definition: rscs.h:143
RSCS_EVT_SEBSOR_LOC_UPD
@ RSCS_EVT_SEBSOR_LOC_UPD
Definition: rscs.h:168
RSCS_EVT_CTRL_POINT_INDICATION_ENABLE
@ RSCS_EVT_CTRL_POINT_INDICATION_ENABLE
Definition: rscs.h:163
rscs_evt_t
Running Speed and Cadence Service event.
Definition: rscs.h:180
RSCS_SENSOR_LOC_SHOE_TOP
@ RSCS_SENSOR_LOC_SHOE_TOP
Definition: rscs.h:126
RSCS_CTRL_PT_RSP_INVALID_PARAM
@ RSCS_CTRL_PT_RSP_INVALID_PARAM
Definition: rscs.h:153
RSCS_EVT_RSC_MEAS_SEND_CPLT
@ RSCS_EVT_RSC_MEAS_SEND_CPLT
Definition: rscs.h:165
rscs_meas_val_t::inst_stride_length
uint16_t inst_stride_length
Definition: rscs.h:195
RSCS_EVT_INVALID
@ RSCS_EVT_INVALID
Definition: rscs.h:160
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
RSCS_SENSOR_LOC_FRONT_WHEEL
@ RSCS_SENSOR_LOC_FRONT_WHEEL
Definition: rscs.h:129
rscs_service_init
sdk_err_t rscs_service_init(rscs_init_t *p_rscs_init)
Initialize a Running Speed and Cadence Service instance and add in the DB.
rscs_meas_val_t::total_distance
uint32_t total_distance
Definition: rscs.h:196
RSCS_SENSOR_LOC_RIGHT_PEDAL
@ RSCS_SENSOR_LOC_RIGHT_PEDAL
Definition: rscs.h:131
RSCS_SENSOR_LOC_SUP_NB
@ RSCS_SENSOR_LOC_SUP_NB
Definition: rscs.h:133
RSCS_CTRL_PT_RSP_RESERVED
@ RSCS_CTRL_PT_RSP_RESERVED
Definition: rscs.h:150
rscs_init_t::char_mask
uint16_t char_mask
Definition: rscs.h:216
RSCS_CTRL_PT_RSP_SUCCESS
@ RSCS_CTRL_PT_RSP_SUCCESS
Definition: rscs.h:151
RSCS_EVT_SUP_SEBSOR_LOC_REQ
@ RSCS_EVT_SUP_SEBSOR_LOC_REQ
Definition: rscs.h:169
RSCS_CTRL_PT_OP_RSP_CODE
@ RSCS_CTRL_PT_OP_RSP_CODE
Definition: rscs.h:144
rscs_evt_t::length
uint16_t length
Definition: rscs.h:184
rscs_meas_val_t::total_distance_present
bool total_distance_present
Definition: rscs.h:191
RSCS_EVT_RSC_MEAS_NOTIFICATION_ENABLE
@ RSCS_EVT_RSC_MEAS_NOTIFICATION_ENABLE
Definition: rscs.h:161
rscs_evt_type_t
rscs_evt_type_t
Running Speed and Cadence Service event type.
Definition: rscs.h:159
RSCS_EVT_RSC_MEAS_NOTIFICATION_DISABLE
@ RSCS_EVT_RSC_MEAS_NOTIFICATION_DISABLE
Definition: rscs.h:162
rscs_evt_t::p_data
const uint8_t * p_data
Definition: rscs.h:183
rscs_evt_handler_t
void(* rscs_evt_handler_t)(rscs_evt_t *p_evt)
Running Speed and Cadence Service event handler type.
Definition: rscs.h:205
rscs_init_t::feature
uint16_t feature
Definition: rscs.h:218
rscs_sensor_loc_update
sdk_err_t rscs_sensor_loc_update(rscs_sensor_loc_t sensor_loc)
Update Sensor Location if Multiple Sensor Locations Supported rscs_init_t::feature.