cscs.h
Go to the documentation of this file.
1
58 #ifndef __CSCS_H__
59 #define __CSCS_H__
60
61 #include "gr55xx_sys.h"
62 #include "custom_config.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
70 #define CSCS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS)
72 #define CSCS_MEAS_VAL_LEN_MAX 20
73 #define CSCS_FEAT_VAL_LEN_MAX 2
74 #define CSCS_SENSOR_LOC_VAL_LEN_MAX 1
75 #define CSCS_CTRL_PT_RSP_LEN_MIN 3
76 #define CSCS_CTRL_PT_VAL_LEN_MAX (CSCS_CTRL_PT_RSP_LEN_MIN + CSCS_SENSOR_LOC_SUP_NB)
78 #define CSCS_ERROR_PROC_IN_PROGRESS 0x80
79 #define CSCS_ERROR_CCCD_INVALID 0x81
86 #define CSCS_CHAR_MANDATORY 0x003f
87 #define CSCS_CHAR_SENSOR_LOC_SUP 0x00c0
88 #define CSCS_CHAR_SC_CTRL_POINT 0x0700
89 #define CSCS_CHAR_FULL 0x07ff
97 #define CSCS_MEAS_FLAG_WHEEL_REVOLUTION_BIT (0x01 << 0)
98 #define CSCS_MEAS_FLAG_CRANK_REVOLUTION_BIT (0x01 << 1)
106 #define CSCS_FEAT_WHEEL_REVOLUTION_SUP_BIT (0x01 << 0)
107 #define CSCS_FEAT_CRANK_REVOLUTION_SUP_BIT (0x01 << 1)
108 #define CSCS_FEAT_MULTIPLE_SENSORS_BIT (0x01 << 2)
109 #define CSCS_FEAR_FULL_BIT (0x07)
118 typedef enum
119 {
120 CSCS_SENSOR_LOC_OTHER,
121 CSCS_SENSOR_LOC_SHOE_TOP,
122 CSCS_SENSOR_LOC_SHOE_IN,
123 CSCS_SENSOR_LOC_HIP,
124 CSCS_SENSOR_LOC_FRONT_WHEEL,
125 CSCS_SENSOR_LOC_LEFT_PEDAL,
126 CSCS_SENSOR_LOC_RIGHT_PEDAL,
127 CSCS_SENSOR_LOC_FRONT_HUB,
128 CSCS_SENSOR_LOC_SUP_NB
129 } cscs_sensor_loc_t;
130
132 typedef enum
133 {
134 CSCS_CTRL_PT_OP_RESERVED,
135 CSCS_CTRL_PT_OP_SET_CUMUL_VAL,
136 CSCS_CTRL_PT_OP_START_CALIB,
137 CSCS_CTRL_PT_OP_UPD_LOC,
138 CSCS_CTRL_PT_OP_REQ_SUP_LOC,
139 CSCS_CTRL_PT_OP_RSP_CODE = 0x10,
140 } cscs_ctrl_pt_op_code_t;
141
143 typedef enum
144 {
145 CSCS_CTRL_PT_RSP_RESERVED,
146 CSCS_CTRL_PT_RSP_SUCCESS,
147 CSCS_CTRL_PT_RSP_NOT_SUP,
148 CSCS_CTRL_PT_RSP_INVALID_PARAM,
149 CSCS_CTRL_PT_RSP_FAILED
150 } cscs_ctrl_pt_rsp_t;
151
153 typedef enum
154 {
155 CSCS_EVT_INVALID,
156 CSCS_EVT_CSC_MEAS_NOTIFICATION_ENABLE,
157 CSCS_EVT_CSC_MEAS_NOTIFICATION_DISABLE,
158 CSCS_EVT_CTRL_POINT_INDICATION_ENABLE,
159 CSCS_EVT_CTRL_POINT_INDICATION_DISABLE,
160 CSCS_EVT_CSC_MEAS_SEND_CPLT,
161 CSCS_EVT_CUMUL_VAL_SET,
162 CSCS_EVT_SEBSOR_CALIBRATION,
163 CSCS_EVT_SEBSOR_LOC_UPD,
164 CSCS_EVT_SUP_SEBSOR_LOC_REQ,
165 CSCS_EVT_CTRL_POINT_RSP_CPLT
166 } cscs_evt_type_t;
174 typedef struct
175 {
176 cscs_evt_type_t evt_type;
177 uint8_t conn_idx;
178 const uint8_t *p_data;
179 uint16_t length;
180 } cscs_evt_t;
188 typedef void (*cscs_evt_handler_t)(cscs_evt_t *p_evt);
196 typedef struct
197 {
198 bool wheel_rev_data_present;
199 bool crank_rev_data_present;
200 uint32_t cumulative_wheel_revs;
201 uint16_t last_wheel_event_time;
202 uint16_t cumulative_crank_revs;
203 uint16_t last_crank_event_time;
204 } cscs_meas_val_t;
205
207 typedef struct
208 {
209 cscs_evt_handler_t evt_handler;
210 uint16_t char_mask;
211 cscs_sensor_loc_t sensor_location;
212 uint16_t feature;
213 } cscs_init_t;
229 sdk_err_t cscs_service_init(cscs_init_t *p_cscs_init);
230
241 sdk_err_t cscs_measurement_send(uint8_t conn_idx, cscs_meas_val_t *p_meas);
242
254 sdk_err_t cscs_ctrl_pt_rsp_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
255
265 sdk_err_t cscs_sensor_loc_update(cscs_sensor_loc_t sensor_loc);
268 #endif
269
CSCS_SENSOR_LOC_SHOE_TOP
@ CSCS_SENSOR_LOC_SHOE_TOP
Definition: cscs.h:121
CSCS_CTRL_PT_RSP_RESERVED
@ CSCS_CTRL_PT_RSP_RESERVED
Definition: cscs.h:145
cscs_evt_t::p_data
const uint8_t * p_data
Definition: cscs.h:178
CSCS_EVT_CSC_MEAS_NOTIFICATION_ENABLE
@ CSCS_EVT_CSC_MEAS_NOTIFICATION_ENABLE
Definition: cscs.h:156
cscs_meas_val_t::cumulative_wheel_revs
uint32_t cumulative_wheel_revs
Definition: cscs.h:200
cscs_init_t::char_mask
uint16_t char_mask
Definition: cscs.h:210
CSCS_CTRL_PT_RSP_SUCCESS
@ CSCS_CTRL_PT_RSP_SUCCESS
Definition: cscs.h:146
cscs_evt_t::conn_idx
uint8_t conn_idx
Definition: cscs.h:177
CSCS_SENSOR_LOC_RIGHT_PEDAL
@ CSCS_SENSOR_LOC_RIGHT_PEDAL
Definition: cscs.h:126
CSCS_CTRL_PT_RSP_NOT_SUP
@ CSCS_CTRL_PT_RSP_NOT_SUP
Definition: cscs.h:147
cscs_ctrl_pt_op_code_t
cscs_ctrl_pt_op_code_t
Cycling Speed and Cadence Service Control Point Operation Code.
Definition: cscs.h:133
cscs_ctrl_pt_rsp_send
sdk_err_t cscs_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.
cscs_measurement_send
sdk_err_t cscs_measurement_send(uint8_t conn_idx, cscs_meas_val_t *p_meas)
Send CSC measurement if notification has been enabled.
cscs_meas_val_t::crank_rev_data_present
bool crank_rev_data_present
Definition: cscs.h:199
cscs_meas_val_t
Cycling Speed and Cadence Measurement Character value structure.
Definition: cscs.h:197
gr55xx_sys.h
GR55XX System API.
cscs_evt_type_t
cscs_evt_type_t
Cycling Speed and Cadence Service event type.
Definition: cscs.h:154
CSCS_CTRL_PT_OP_REQ_SUP_LOC
@ CSCS_CTRL_PT_OP_REQ_SUP_LOC
Definition: cscs.h:138
CSCS_CTRL_PT_RSP_INVALID_PARAM
@ CSCS_CTRL_PT_RSP_INVALID_PARAM
Definition: cscs.h:148
CSCS_SENSOR_LOC_HIP
@ CSCS_SENSOR_LOC_HIP
Definition: cscs.h:123
cscs_meas_val_t::cumulative_crank_revs
uint16_t cumulative_crank_revs
Definition: cscs.h:202
cscs_init_t::sensor_location
cscs_sensor_loc_t sensor_location
Definition: cscs.h:211
CSCS_SENSOR_LOC_FRONT_HUB
@ CSCS_SENSOR_LOC_FRONT_HUB
Definition: cscs.h:127
CSCS_CTRL_PT_RSP_FAILED
@ CSCS_CTRL_PT_RSP_FAILED
Definition: cscs.h:149
CSCS_SENSOR_LOC_FRONT_WHEEL
@ CSCS_SENSOR_LOC_FRONT_WHEEL
Definition: cscs.h:124
cscs_ctrl_pt_rsp_t
cscs_ctrl_pt_rsp_t
Cycling Speed and Cadence Service Control Point Response value.
Definition: cscs.h:144
cscs_sensor_loc_update
sdk_err_t cscs_sensor_loc_update(cscs_sensor_loc_t sensor_loc)
Update Sensor Location if Multiple Sensor Locations Supported cscs_init_t::feature.
cscs_evt_handler_t
void(* cscs_evt_handler_t)(cscs_evt_t *p_evt)
Cycling Speed and Cadence Service event handler type.
Definition: cscs.h:188
cscs_init_t::feature
uint16_t feature
Definition: cscs.h:212
CSCS_CTRL_PT_OP_RESERVED
@ CSCS_CTRL_PT_OP_RESERVED
Definition: cscs.h:134
CSCS_SENSOR_LOC_LEFT_PEDAL
@ CSCS_SENSOR_LOC_LEFT_PEDAL
Definition: cscs.h:125
CSCS_EVT_CTRL_POINT_INDICATION_DISABLE
@ CSCS_EVT_CTRL_POINT_INDICATION_DISABLE
Definition: cscs.h:159
cscs_init_t::evt_handler
cscs_evt_handler_t evt_handler
Definition: cscs.h:209
cscs_sensor_loc_t
cscs_sensor_loc_t
Cycling Speed and Cadence Service Sensor Location.
Definition: cscs.h:119
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
CSCS_EVT_CTRL_POINT_INDICATION_ENABLE
@ CSCS_EVT_CTRL_POINT_INDICATION_ENABLE
Definition: cscs.h:158
CSCS_CTRL_PT_OP_RSP_CODE
@ CSCS_CTRL_PT_OP_RSP_CODE
Definition: cscs.h:139
CSCS_EVT_INVALID
@ CSCS_EVT_INVALID
Definition: cscs.h:155
cscs_init_t
Cycling Speed and Cadence Service init stucture. This contains all option and data needed for initial...
Definition: cscs.h:208
CSCS_EVT_CTRL_POINT_RSP_CPLT
@ CSCS_EVT_CTRL_POINT_RSP_CPLT
Definition: cscs.h:165
CSCS_EVT_CSC_MEAS_SEND_CPLT
@ CSCS_EVT_CSC_MEAS_SEND_CPLT
Definition: cscs.h:160
cscs_meas_val_t::last_wheel_event_time
uint16_t last_wheel_event_time
Definition: cscs.h:201
cscs_evt_t::evt_type
cscs_evt_type_t evt_type
Definition: cscs.h:176
cscs_meas_val_t::last_crank_event_time
uint16_t last_crank_event_time
Definition: cscs.h:203
CSCS_SENSOR_LOC_SUP_NB
@ CSCS_SENSOR_LOC_SUP_NB
Definition: cscs.h:128
cscs_service_init
sdk_err_t cscs_service_init(cscs_init_t *p_cscs_init)
Initialize a Cycling Speed and Cadence Service instance and add in the DB.
cscs_evt_t::length
uint16_t length
Definition: cscs.h:179
CSCS_EVT_CSC_MEAS_NOTIFICATION_DISABLE
@ CSCS_EVT_CSC_MEAS_NOTIFICATION_DISABLE
Definition: cscs.h:157
CSCS_SENSOR_LOC_SHOE_IN
@ CSCS_SENSOR_LOC_SHOE_IN
Definition: cscs.h:122
CSCS_EVT_SEBSOR_CALIBRATION
@ CSCS_EVT_SEBSOR_CALIBRATION
Definition: cscs.h:162
cscs_meas_val_t::wheel_rev_data_present
bool wheel_rev_data_present
Definition: cscs.h:198
CSCS_CTRL_PT_OP_START_CALIB
@ CSCS_CTRL_PT_OP_START_CALIB
Definition: cscs.h:136
CSCS_EVT_CUMUL_VAL_SET
@ CSCS_EVT_CUMUL_VAL_SET
Definition: cscs.h:161
CSCS_SENSOR_LOC_OTHER
@ CSCS_SENSOR_LOC_OTHER
Definition: cscs.h:120
CSCS_EVT_SEBSOR_LOC_UPD
@ CSCS_EVT_SEBSOR_LOC_UPD
Definition: cscs.h:163
CSCS_CTRL_PT_OP_UPD_LOC
@ CSCS_CTRL_PT_OP_UPD_LOC
Definition: cscs.h:137
CSCS_EVT_SUP_SEBSOR_LOC_REQ
@ CSCS_EVT_SUP_SEBSOR_LOC_REQ
Definition: cscs.h:164
CSCS_CTRL_PT_OP_SET_CUMUL_VAL
@ CSCS_CTRL_PT_OP_SET_CUMUL_VAL
Definition: cscs.h:135
cscs_evt_t
Cycling Speed and Cadence Service event.
Definition: cscs.h:175