rscs_c.h
Go to the documentation of this file.
1
59 #ifndef __RSCS_C_H__
60 #define __RSCS_C_H__
61
62 #include "ble_prf_types.h"
63 #include "gr55xx_sys.h"
64 #include "custom_config.h"
65 #include <stdint.h>
66 #include <stdbool.h>
67
72 #define RSCS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
73 10 : CFG_MAX_CONNECTIONS)
74 #define RSCS_C_PT_RSP_LEN_MAX (3 + RSCS_C_SENSOR_LOC_SUP_NB)
75 #define RSCS_C_ERROR_PROC_IN_PROGRESS 0x80
76 #define RSCS_C_ERROR_CCCD_INVALID 0x81
83 #define RSCS_C_MEAS_FLAG_INST_STRIDE_LEN_BIT (0x01 << 0)
84 #define RSCS_C_MEAS_FLAG_TOTAL_DISTANCE_BIT (0x01 << 1)
85 #define RSCS_C_MEAS_FLAG_RUNNING_OR_WALKING_BIT (0x01 << 2)
93 #define RSCS_C_FEAT_INSTANT_STRIDE_LEN_BIT (0x01 << 0)
94 #define RSCS_C_FEAT_TOTAL_DISTANCE_BIT (0x01 << 1)
95 #define RSCS_C_FEAT_RUNNING_OR_WALKING_STATUS_BIT (0x01 << 2)
96 #define RSCS_C_FEAT_CALIBRATION_PROCEDURE_BIT (0x01 << 3)
97 #define RSCS_C_FEAT_MULTIPLE_SENSORS_BIT (0x01 << 4)
106 typedef enum
107 {
108 RSCS_C_EVT_INVALID, /*<* RSCS Client invalid event. */
109 RSCS_C_EVT_DISCOVERY_COMPLETE,
110 RSCS_C_EVT_DISCOVERY_FAIL,
111 RSCS_C_EVT_RSC_MEAS_NTF_SET_SUCCESS,
112 RSCS_C_EVT_CTRL_PT_IND_SET_SUCCESS,
113 RSCS_C_EVT_RSC_MEAS_VAL_RECEIVE,
114 RSCS_C_EVT_RSC_FEATURE_RECEIVE,
115 RSCS_C_EVT_SENSOR_LOC_RECEIVE,
116 RSCS_C_EVT_CTRL_PT_SET_SUCCESS,
117 RSCS_C_EVT_CTRL_PT_RSP_RECEIVE,
118 RSCS_C_EVT_WRITE_OP_ERR,
119 } rscs_c_evt_type_t;
120
122 typedef enum
123 {
124 RSCS_C_SENSOR_LOC_OTHER,
125 RSCS_C_SENSOR_LOC_SHOE_TOP,
126 RSCS_C_SENSOR_LOC_SHOE_IN,
127 RSCS_C_SENSOR_LOC_HIP,
128 RSCS_C_SENSOR_LOC_FRONT_WHEEL,
129 RSCS_C_SENSOR_LOC_LEFT_PEDAL,
130 RSCS_C_SENSOR_LOC_RIGHT_PEDAL,
131 RSCS_C_SENSOR_LOC_FRONT_HUB,
132 RSCS_C_SENSOR_LOC_SUP_NB
133 } rscs_c_sensor_loc_t;
134
136 typedef enum
137 {
138 RSCS_C_CTRL_PT_OP_RESERVED,
139 RSCS_C_CTRL_PT_OP_SET_CUMUL_VAL,
140 RSCS_C_CTRL_PT_OP_START_CALIB,
141 RSCS_C_CTRL_PT_OP_UPD_LOC,
142 RSCS_C_CTRL_PT_OP_REQ_SUP_LOC,
143 RSCS_C_CTRL_PT_OP_RSP_CODE = 0x10,
144 } rscs_c_ctrl_pt_op_code_t;
145
147 typedef enum
148 {
149 RSCS_C_CTRL_PT_RSP_RESERVED,
150 RSCS_C_CTRL_PT_RSP_SUCCESS,
151 RSCS_C_CTRL_PT_RSP_NOT_SUP,
152 RSCS_C_CTRL_PT_RSP_INVALID_PARAM,
153 RSCS_C_CTRL_PT_RSP_FAILED
154 } rscs_c_ctrl_pt_rsp_t;
162 typedef struct
163 {
164 bool inst_stride_length_present;
165 bool total_distance_present;
166 bool is_run_or_walk;
167 uint16_t inst_speed;
168 uint8_t inst_cadence;
169 uint16_t inst_stride_length;
170 uint32_t total_distance;
171 } rscs_c_meas_val_t;
172
174 typedef struct
175 {
176 uint16_t rscs_srvc_start_handle;
177 uint16_t rscs_srvc_end_handle;
178 uint16_t rscs_rsc_meas_handle;
179 uint16_t rscs_rsc_meas_cccd_handle;
180 uint16_t rscs_sensor_loc_handle;
181 uint16_t rscs_rsc_feature_handle;
182 uint16_t rscs_ctrl_pt_handle;
183 uint16_t rscs_ctrl_pt_cccd_handle;
184 } rscs_c_handles_t;
185
187 typedef struct
188 {
189 uint8_t conn_idx;
190 rscs_c_evt_type_t evt_type;
191 uint16_t handle;
192 union
193 {
194 rscs_c_meas_val_t rsc_meas_buff;
195 uint16_t rsc_feature;
196 rscs_c_sensor_loc_t rsc_sensor_loc;
197 uint8_t ctrl_pt_rsp[RSCS_C_PT_RSP_LEN_MAX];
198 } value;
200 } rscs_c_evt_t;
208 typedef void (*rscs_c_evt_handler_t)(rscs_c_evt_t *p_evt);
224 sdk_err_t rscs_client_init(rscs_c_evt_handler_t evt_handler);
225
235 sdk_err_t rscs_c_disc_srvc_start(uint8_t conn_idx);
236
247 sdk_err_t rscs_c_rsc_meas_notify_set(uint8_t conn_idx, bool is_enable);
248
258 sdk_err_t rscs_c_rsc_feature_read(uint8_t conn_idx);
259
269 sdk_err_t rscs_c_sensor_loc_read(uint8_t conn_idx);
270
281 sdk_err_t rscs_c_ctrl_pt_indicate_set(uint8_t conn_idx, bool is_enable);
282
293 sdk_err_t rscs_c_ctrl_pt_set(uint8_t conn_idx, uint16_t ctrl_value);
295 #endif
296
RSCS_C_SENSOR_LOC_SHOE_TOP
@ RSCS_C_SENSOR_LOC_SHOE_TOP
Definition: rscs_c.h:125
RSCS_C_PT_RSP_LEN_MAX
#define RSCS_C_PT_RSP_LEN_MAX
Definition: rscs_c.h:74
RSCS_C_SENSOR_LOC_LEFT_PEDAL
@ RSCS_C_SENSOR_LOC_LEFT_PEDAL
Definition: rscs_c.h:129
RSCS_C_EVT_DISCOVERY_COMPLETE
@ RSCS_C_EVT_DISCOVERY_COMPLETE
Definition: rscs_c.h:109
rscs_c_ctrl_pt_set
sdk_err_t rscs_c_ctrl_pt_set(uint8_t conn_idx, uint16_t ctrl_value)
Set Control Point characteristic value.
RSCS_C_CTRL_PT_OP_RESERVED
@ RSCS_C_CTRL_PT_OP_RESERVED
Definition: rscs_c.h:138
RSCS_C_CTRL_PT_OP_START_CALIB
@ RSCS_C_CTRL_PT_OP_START_CALIB
Definition: rscs_c.h:140
RSCS_C_SENSOR_LOC_SUP_NB
@ RSCS_C_SENSOR_LOC_SUP_NB
Definition: rscs_c.h:132
rscs_c_handles_t::rscs_rsc_meas_handle
uint16_t rscs_rsc_meas_handle
Definition: rscs_c.h:178
RSCS_C_EVT_CTRL_PT_IND_SET_SUCCESS
@ RSCS_C_EVT_CTRL_PT_IND_SET_SUCCESS
Definition: rscs_c.h:112
RSCS_C_SENSOR_LOC_SHOE_IN
@ RSCS_C_SENSOR_LOC_SHOE_IN
Definition: rscs_c.h:126
rscs_c_handles_t::rscs_ctrl_pt_cccd_handle
uint16_t rscs_ctrl_pt_cccd_handle
Definition: rscs_c.h:183
rscs_c_handles_t::rscs_sensor_loc_handle
uint16_t rscs_sensor_loc_handle
Definition: rscs_c.h:180
rscs_c_rsc_meas_notify_set
sdk_err_t rscs_c_rsc_meas_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer RSC Measurement characteristic notify.
rscs_c_rsc_feature_read
sdk_err_t rscs_c_rsc_feature_read(uint8_t conn_idx)
Read RSC Feature characteristic value.
rscs_c_sensor_loc_t
rscs_c_sensor_loc_t
Running Speed and Cadence Service Sensor Location.
Definition: rscs_c.h:123
RSCS_C_CTRL_PT_RSP_RESERVED
@ RSCS_C_CTRL_PT_RSP_RESERVED
Definition: rscs_c.h:149
rscs_c_evt_t::rsc_feature
uint16_t rsc_feature
Definition: rscs_c.h:195
rscs_c_evt_t::rsc_meas_buff
rscs_c_meas_val_t rsc_meas_buff
Definition: rscs_c.h:194
rscs_client_init
sdk_err_t rscs_client_init(rscs_c_evt_handler_t evt_handler)
Register RSCS Client event handler.
rscs_c_handles_t::rscs_rsc_meas_cccd_handle
uint16_t rscs_rsc_meas_cccd_handle
Definition: rscs_c.h:179
rscs_c_evt_t::evt_type
rscs_c_evt_type_t evt_type
Definition: rscs_c.h:190
rscs_c_evt_t::rsc_sensor_loc
rscs_c_sensor_loc_t rsc_sensor_loc
Definition: rscs_c.h:196
rscs_c_meas_val_t::is_run_or_walk
bool is_run_or_walk
Definition: rscs_c.h:166
gr55xx_sys.h
GR55XX System API.
rscs_c_evt_type_t
rscs_c_evt_type_t
Running Speed and Cadence Service Client event type.
Definition: rscs_c.h:107
rscs_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: rscs_c.h:175
rscs_c_meas_val_t::total_distance
uint32_t total_distance
Definition: rscs_c.h:170
rscs_c_ctrl_pt_rsp_t
rscs_c_ctrl_pt_rsp_t
Running Speed and Cadence Service Control Point Response value.
Definition: rscs_c.h:148
RSCS_C_EVT_RSC_MEAS_NTF_SET_SUCCESS
@ RSCS_C_EVT_RSC_MEAS_NTF_SET_SUCCESS
Definition: rscs_c.h:111
RSCS_C_SENSOR_LOC_HIP
@ RSCS_C_SENSOR_LOC_HIP
Definition: rscs_c.h:127
RSCS_C_SENSOR_LOC_FRONT_WHEEL
@ RSCS_C_SENSOR_LOC_FRONT_WHEEL
Definition: rscs_c.h:128
rscs_c_meas_val_t
Running Speed and Cadence Measurement Character value structure.
Definition: rscs_c.h:163
RSCS_C_CTRL_PT_RSP_SUCCESS
@ RSCS_C_CTRL_PT_RSP_SUCCESS
Definition: rscs_c.h:150
RSCS_C_CTRL_PT_RSP_INVALID_PARAM
@ RSCS_C_CTRL_PT_RSP_INVALID_PARAM
Definition: rscs_c.h:152
rscs_c_meas_val_t::total_distance_present
bool total_distance_present
Definition: rscs_c.h:165
RSCS_C_EVT_WRITE_OP_ERR
@ RSCS_C_EVT_WRITE_OP_ERR
Definition: rscs_c.h:118
RSCS_C_EVT_CTRL_PT_SET_SUCCESS
@ RSCS_C_EVT_CTRL_PT_SET_SUCCESS
Definition: rscs_c.h:116
rscs_c_handles_t::rscs_srvc_start_handle
uint16_t rscs_srvc_start_handle
Definition: rscs_c.h:176
RSCS_C_EVT_RSC_FEATURE_RECEIVE
@ RSCS_C_EVT_RSC_FEATURE_RECEIVE
Definition: rscs_c.h:114
rscs_c_handles_t::rscs_srvc_end_handle
uint16_t rscs_srvc_end_handle
Definition: rscs_c.h:177
rscs_c_meas_val_t::inst_cadence
uint8_t inst_cadence
Definition: rscs_c.h:168
RSCS_C_CTRL_PT_OP_REQ_SUP_LOC
@ RSCS_C_CTRL_PT_OP_REQ_SUP_LOC
Definition: rscs_c.h:142
RSCS_C_EVT_SENSOR_LOC_RECEIVE
@ RSCS_C_EVT_SENSOR_LOC_RECEIVE
Definition: rscs_c.h:115
RSCS_C_EVT_RSC_MEAS_VAL_RECEIVE
@ RSCS_C_EVT_RSC_MEAS_VAL_RECEIVE
Definition: rscs_c.h:113
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
RSCS_C_CTRL_PT_OP_UPD_LOC
@ RSCS_C_CTRL_PT_OP_UPD_LOC
Definition: rscs_c.h:141
RSCS_C_EVT_CTRL_PT_RSP_RECEIVE
@ RSCS_C_EVT_CTRL_PT_RSP_RECEIVE
Definition: rscs_c.h:117
rscs_c_evt_t
Running Speed and Cadence Service Client event.
Definition: rscs_c.h:188
rscs_c_ctrl_pt_op_code_t
rscs_c_ctrl_pt_op_code_t
Running Speed and Cadence Service Control Point Operation Code.
Definition: rscs_c.h:137
rscs_c_meas_val_t::inst_speed
uint16_t inst_speed
Definition: rscs_c.h:167
RSCS_C_CTRL_PT_RSP_FAILED
@ RSCS_C_CTRL_PT_RSP_FAILED
Definition: rscs_c.h:153
rscs_c_meas_val_t::inst_stride_length
uint16_t inst_stride_length
Definition: rscs_c.h:169
RSCS_C_CTRL_PT_OP_RSP_CODE
@ RSCS_C_CTRL_PT_OP_RSP_CODE
Definition: rscs_c.h:143
RSCS_C_SENSOR_LOC_RIGHT_PEDAL
@ RSCS_C_SENSOR_LOC_RIGHT_PEDAL
Definition: rscs_c.h:130
rscs_c_meas_val_t::inst_stride_length_present
bool inst_stride_length_present
Definition: rscs_c.h:164
rscs_c_disc_srvc_start
sdk_err_t rscs_c_disc_srvc_start(uint8_t conn_idx)
Discovery Running Speed and Cadence Service on peer.
RSCS_C_EVT_DISCOVERY_FAIL
@ RSCS_C_EVT_DISCOVERY_FAIL
Definition: rscs_c.h:110
rscs_c_handles_t::rscs_ctrl_pt_handle
uint16_t rscs_ctrl_pt_handle
Definition: rscs_c.h:182
RSCS_C_CTRL_PT_OP_SET_CUMUL_VAL
@ RSCS_C_CTRL_PT_OP_SET_CUMUL_VAL
Definition: rscs_c.h:139
rscs_c_evt_handler_t
void(* rscs_c_evt_handler_t)(rscs_c_evt_t *p_evt)
Running Speed and Cadence Service Client event handler type.
Definition: rscs_c.h:208
RSCS_C_SENSOR_LOC_FRONT_HUB
@ RSCS_C_SENSOR_LOC_FRONT_HUB
Definition: rscs_c.h:131
rscs_c_ctrl_pt_indicate_set
sdk_err_t rscs_c_ctrl_pt_indicate_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer Control Point characteristic indicate.
RSCS_C_SENSOR_LOC_OTHER
@ RSCS_C_SENSOR_LOC_OTHER
Definition: rscs_c.h:124
rscs_c_evt_t::conn_idx
uint8_t conn_idx
Definition: rscs_c.h:189
rscs_c_handles_t::rscs_rsc_feature_handle
uint16_t rscs_rsc_feature_handle
Definition: rscs_c.h:181
rscs_c_sensor_loc_read
sdk_err_t rscs_c_sensor_loc_read(uint8_t conn_idx)
Read Sensor Location characteristic value.
RSCS_C_CTRL_PT_RSP_NOT_SUP
@ RSCS_C_CTRL_PT_RSP_NOT_SUP
Definition: rscs_c.h:151
rscs_c_evt_t::handle
uint16_t handle
Definition: rscs_c.h:191