Select one of the symbols to view example projects that use it.
 
Outline
#define CYCLING_POWER_SERVICE_SERVER_H
#include <stdint.h>
#define CYCLING_POWER_MANUFACTURER_SPECIFIC_DATA_MAX_SIZE
cycling_power_pedal_power_balance_reference_t
cycling_power_torque_source_t
cycling_power_sensor_measurement_context_t
cycling_power_distributed_system_t
cycling_power_measurement_flag_t
cycling_power_instantaneous_measurement_direction_t
cycling_power_vector_flag_t
cycling_power_sensor_location_t
cycling_power_feature_flag_t
cycling_power_calibration_status_t
cycling_power_service_server_init(uint32_t, cycling_power_pedal_power_balance_reference_t, cycling_power_torque_source_t, cycling_power_sensor_location_t *, uint16_t, cycling_power_sensor_location_t);
cycling_power_get_measurement_adv(uint16_t, uint8_t *, uint16_t);
cycling_power_service_server_packet_handler(btstack_packet_handler_t);
cycling_power_server_calibration_done(cycling_power_sensor_measurement_context_t, uint16_t);
cycling_power_server_enhanced_calibration_done(cycling_power_sensor_measurement_context_t, uint16_t, uint16_t, uint8_t, uint8_t *);
cycling_power_service_server_set_factory_calibration_date(gatt_date_time_t);
cycling_power_service_server_set_sampling_rate(uint8_t);
cycling_power_service_server_add_torque(int16_t);
cycling_power_service_server_add_wheel_revolution(int32_t, uint16_t);
cycling_power_service_server_add_crank_revolution(uint16_t, uint16_t);
cycling_power_service_add_energy(uint16_t);
cycling_power_service_server_set_instantaneous_power(int16_t);
cycling_power_service_server_set_pedal_power_balance(uint8_t);
cycling_power_service_server_set_force_magnitude(int16_t, int16_t);
cycling_power_service_server_set_torque_magnitude(int16_t, int16_t);
cycling_power_service_server_set_angle(uint16_t, uint16_t);
cycling_power_service_server_set_top_dead_spot_angle(uint16_t);
cycling_power_service_server_set_bottom_dead_spot_angle(uint16_t);
cycling_power_service_server_set_force_magnitude_values(int, int16_t *);
cycling_power_service_server_set_torque_magnitude_values(int, int16_t *);
cycling_power_service_server_set_instantaneous_measurement_direction(cycling_power_instantaneous_measurement_direction_t);
cycling_power_service_server_set_first_crank_measurement_angle(uint16_t);
cycling_power_service_measurement_flags();
cycling_power_service_vector_flags();
cycling_power_service_server_update_values();
Files
loading...
SourceVuRaspberry Pi Pico SDK and ExamplesBluetooth LE Stacksrc/ble/gatt-service/cycling_power_service_server.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * Copyright (C) 2018 BlueKitchen GmbH * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * 4. Any redistribution, use, or modification is done solely for * personal benefit and not for any commercial purpose or for * monetary gain. * * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Please inquire about commercial licensing options at * contact@bluekitchen-gmbh.com * *//* ... */ /** * @title Cycling Power Service Server * *//* ... */ #ifndef CYCLING_POWER_SERVICE_SERVER_H #define CYCLING_POWER_SERVICE_SERVER_H #include <stdint.h> #if defined __cplusplus extern "C" { #endif /** * @text The Cycling Power Service allows to query device's power- and * force-related data and optionally speed- and cadence-related data for * use in sports and fitness applications. * * To use with your application, add `#import <cycling_power_service.gatt>` * to your .gatt file. *//* ... */ /* API_START */ #define CYCLING_POWER_MANUFACTURER_SPECIFIC_DATA_MAX_SIZE 16 typedef enum { CP_PEDAL_POWER_BALANCE_REFERENCE_UNKNOWN = 0, CP_PEDAL_POWER_BALANCE_REFERENCE_LEFT, CP_PEDAL_POWER_BALANCE_REFERENCE_NOT_SUPPORTED ...} cycling_power_pedal_power_balance_reference_t; typedef enum { CP_TORQUE_SOURCE_WHEEL = 0, CP_TORQUE_SOURCE_CRANK, CP_TORQUE_SOURCE_NOT_SUPPORTED ...} cycling_power_torque_source_t; typedef enum { CP_SENSOR_MEASUREMENT_CONTEXT_FORCE = 0, CP_SENSOR_MEASUREMENT_CONTEXT_TORQUE ...} cycling_power_sensor_measurement_context_t; typedef enum { CP_DISTRIBUTED_SYSTEM_UNSPECIFIED = 0, CP_DISTRIBUTED_SYSTEM_NOT_SUPPORTED, CP_DISTRIBUTED_SYSTEM_SUPPORTED ...} cycling_power_distributed_system_t; typedef enum { CP_MEASUREMENT_FLAG_PEDAL_POWER_BALANCE_PRESENT = 0, CP_MEASUREMENT_FLAG_PEDAL_POWER_BALANCE_REFERENCE, // 0 - unknown, 1 - left CP_MEASUREMENT_FLAG_ACCUMULATED_TORQUE_PRESENT, CP_MEASUREMENT_FLAG_ACCUMULATED_TORQUE_SOURCE, // 0 - wheel based, 1 - crank based CP_MEASUREMENT_FLAG_WHEEL_REVOLUTION_DATA_PRESENT, CP_MEASUREMENT_FLAG_CRANK_REVOLUTION_DATA_PRESENT, CP_MEASUREMENT_FLAG_EXTREME_FORCE_MAGNITUDES_PRESENT, CP_MEASUREMENT_FLAG_EXTREME_TORQUE_MAGNITUDES_PRESENT, CP_MEASUREMENT_FLAG_EXTREME_ANGLES_PRESENT, CP_MEASUREMENT_FLAG_TOP_DEAD_SPOT_ANGLE_PRESENT, CP_MEASUREMENT_FLAG_BOTTOM_DEAD_SPOT_ANGLE_PRESENT, CP_MEASUREMENT_FLAG_ACCUMULATED_ENERGY_PRESENT, CP_MEASUREMENT_FLAG_OFFSET_COMPENSATION_INDICATOR, CP_MEASUREMENT_FLAG_RESERVED ...} cycling_power_measurement_flag_t; typedef enum { CP_INSTANTANEOUS_MEASUREMENT_DIRECTION_UNKNOWN = 0, CP_INSTANTANEOUS_MEASUREMENT_DIRECTION_TANGENTIAL_COMPONENT, CP_INSTANTANEOUS_MEASUREMENT_DIRECTION_RADIAL_COMPONENT, CP_INSTANTANEOUS_MEASUREMENT_DIRECTION_LATERAL_COMPONENT ...} cycling_power_instantaneous_measurement_direction_t; typedef enum { CP_VECTOR_FLAG_CRANK_REVOLUTION_DATA_PRESENT = 0, CP_VECTOR_FLAG_FIRST_CRANK_MEASUREMENT_ANGLE_PRESENT, CP_VECTOR_FLAG_INSTANTANEOUS_FORCE_MAGNITUDE_ARRAY_PRESENT, CP_VECTOR_FLAG_INSTANTANEOUS_TORQUE_MAGNITUDE_ARRAY_PRESENT, CP_VECTOR_FLAG_INSTANTANEOUS_MEASUREMENT_DIRECTION = 4, // 2 bit CP_VECTOR_FLAG_RESERVED = 6 ...} cycling_power_vector_flag_t; typedef enum { CP_SENSOR_LOCATION_OTHER, CP_SENSOR_LOCATION_TOP_OF_SHOE, CP_SENSOR_LOCATION_IN_SHOE, CP_SENSOR_LOCATION_HIP, CP_SENSOR_LOCATION_FRONT_WHEEL, CP_SENSOR_LOCATION_LEFT_CRANK, CP_SENSOR_LOCATION_RIGHT_CRANK, CP_SENSOR_LOCATION_LEFT_PEDAL, CP_SENSOR_LOCATION_RIGHT_PEDAL, CP_SENSOR_LOCATION_FRONT_HUB, CP_SENSOR_LOCATION_REAR_DROPOUT, CP_SENSOR_LOCATION_CHAINSTAY, CP_SENSOR_LOCATION_REAR_WHEEL, CP_SENSOR_LOCATION_REAR_HUB, CP_SENSOR_LOCATION_CHEST, CP_SENSOR_LOCATION_SPIDER, CP_SENSOR_LOCATION_CHAIN_RING, CP_SENSOR_LOCATION_RESERVED ...} cycling_power_sensor_location_t; typedef enum { CP_FEATURE_FLAG_PEDAL_POWER_BALANCE_SUPPORTED = 0, CP_FEATURE_FLAG_ACCUMULATED_TORQUE_SUPPORTED, CP_FEATURE_FLAG_WHEEL_REVOLUTION_DATA_SUPPORTED, CP_FEATURE_FLAG_CRANK_REVOLUTION_DATA_SUPPORTED, CP_FEATURE_FLAG_EXTREME_MAGNITUDES_SUPPORTED, CP_FEATURE_FLAG_EXTREME_ANGLES_SUPPORTED, CP_FEATURE_FLAG_TOP_AND_BOTTOM_DEAD_SPOT_ANGLE_SUPPORTED, CP_FEATURE_FLAG_ACCUMULATED_ENERGY_SUPPORTED, CP_FEATURE_FLAG_OFFSET_COMPENSATION_INDICATOR_SUPPORTED, CP_FEATURE_FLAG_OFFSET_COMPENSATION_SUPPORTED, CP_FEATURE_FLAG_CYCLING_POWER_MEASUREMENT_CHARACTERISTIC_CONTENT_MASKING_SUPPORTED, CP_FEATURE_FLAG_MULTIPLE_SENSOR_LOCATIONS_SUPPORTED, CP_FEATURE_FLAG_CRANK_LENGTH_ADJUSTMENT_SUPPORTED, CP_FEATURE_FLAG_CHAIN_LENGTH_ADJUSTMENT_SUPPORTED, CP_FEATURE_FLAG_CHAIN_WEIGHT_ADJUSTMENT_SUPPORTED, CP_FEATURE_FLAG_SPAN_LENGTH_ADJUSTMENT_SUPPORTED, CP_FEATURE_FLAG_SENSOR_MEASUREMENT_CONTEXT, // 0-force based, 1-torque based CP_FEATURE_FLAG_INSTANTANEOUS_MEASUREMENT_DIRECTION_SUPPORTED, CP_FEATURE_FLAG_FACTORY_CALIBRATION_DATE_SUPPORTED, CP_FEATURE_FLAG_ENHANCED_OFFSET_COMPENSATION_SUPPORTED, CP_FEATURE_FLAG_DISTRIBUTED_SYSTEM_SUPPORT = 20, // 0-unspecified, 1-not for use in distr. system, 2-used in distr. system, 3-reserved CP_FEATURE_FLAG_RESERVED = 22 ...} cycling_power_feature_flag_t; typedef enum { CP_CALIBRATION_STATUS_INCORRECT_CALIBRATION_POSITION = 0x01, CP_CALIBRATION_STATUS_MANUFACTURER_SPECIFIC_ERROR_FOLLOWS = 0xFF ...} cycling_power_calibration_status_t; /** * @brief Init Server with ATT DB * * @param feature_flags * @param pedal_power_balance_reference * @param torque_source * @param supported_sensor_locations * @param num_supported_sensor_locations * @param current_sensor_location *//* ... */ void cycling_power_service_server_init(uint32_t feature_flags, cycling_power_pedal_power_balance_reference_t pedal_power_balance_reference, cycling_power_torque_source_t torque_source, cycling_power_sensor_location_t * supported_sensor_locations, uint16_t num_supported_sensor_locations, cycling_power_sensor_location_t current_sensor_location); /** * @brief Setup measurement as advertisement data * @param adv_interval * @param adv_buffer * @param adv_size * @return *//* ... */ int cycling_power_get_measurement_adv(uint16_t adv_interval, uint8_t * adv_buffer, uint16_t adv_size); /** * @brief Register callback for the calibration and broadcast updates. * * @param callback *//* ... */ void cycling_power_service_server_packet_handler(btstack_packet_handler_t callback); /** * @brief Report calibration done. * @param measurement_type * @param calibrated_value *//* ... */ void cycling_power_server_calibration_done(cycling_power_sensor_measurement_context_t measurement_type, uint16_t calibrated_value); /** * @brief Report enhanced calibration done. * * @param measurement_type * @param calibrated_value * @param manufacturer_company_id * @param num_manufacturer_specific_data * @param manufacturer_specific_data *//* ... */ void cycling_power_server_enhanced_calibration_done(cycling_power_sensor_measurement_context_t measurement_type, uint16_t calibrated_value, uint16_t manufacturer_company_id, uint8_t num_manufacturer_specific_data, uint8_t * manufacturer_specific_data); /** * @brief Set factory calibration date. * @param date * @return 1 if successful *//* ... */ int cycling_power_service_server_set_factory_calibration_date(gatt_date_time_t date); /** * @brief Set sampling rate. * @param sampling_rate_Hz *//* ... */ void cycling_power_service_server_set_sampling_rate(uint8_t sampling_rate_Hz); /** * @brief Accumulate torque value. * @param torque_Nm *//* ... */ void cycling_power_service_server_add_torque(int16_t torque_Nm); /** * @brief Accumulate wheel revolution value and set the time of the last measurement. * @param wheel_revolution * @param wheel_event_time_s unit: seconds *//* ... */ void cycling_power_service_server_add_wheel_revolution(int32_t wheel_revolution, uint16_t wheel_event_time_s); /** * @brief Accumulate crank revolution value and set the time of the last measurement. * @param crank_revolution * @param crank_event_time_s unit: seconds *//* ... */ void cycling_power_service_server_add_crank_revolution(uint16_t crank_revolution, uint16_t crank_event_time_s); /** * @brief Accumulate energy. * @param energy_kJ unit: kilo Joule *//* ... */ void cycling_power_service_add_energy(uint16_t energy_kJ); /** * @brief Set the value of the power. The Instantaneous Power field represents either * the total power the user is producing or a part of the total power depending on the * type of sensor (e.g., single sensor or distributed power sensor system). * * @param instantaneous_power_W unit: watt *//* ... */ void cycling_power_service_server_set_instantaneous_power(int16_t instantaneous_power_W); /** * @brief Set the pedal power balance value. The Pedal Power Balance field represents the ratio between * the total amount of power measured by the sensor and a reference (either unknown or left). * * @param pedal_power_balance_percentage *//* ... */ void cycling_power_service_server_set_pedal_power_balance(uint8_t pedal_power_balance_percentage); /** * @brief Set the minimum and maximum force value measured in a single crank revolution. * * This, so called, Extreme Force Magnitude field pair will be included in the Cycling Power Measurement * characteristic only if the device supports the Extreme Magnitudes feature and * the Sensor Measurement Context of the Cycling Power Feature characteristic is set to 0 (Force-based). * * @param min_force_magnitude_N unit: newton * @param max_force_magnitude_N unit: newton *//* ... */ void cycling_power_service_server_set_force_magnitude(int16_t min_force_magnitude_N, int16_t max_force_magnitude_N); /** * @brief Set the minimum and maximum torque value measured in a single crank revolution. * * This, so called, Extreme Torque Magnitude field pair will be included in the Cycling Power Measurement * characteristic only if the device supports the Extreme Magnitudes feature and * the Sensor Measurement Context of the Cycling Power Feature characteristic is set to 1 (Torque-based). * * @param min_torque_magnitude_Nm unit: newton meter * @param max_torque_magnitude_Nm unit: newton meter *//* ... */ void cycling_power_service_server_set_torque_magnitude(int16_t min_torque_magnitude_Nm, int16_t max_torque_magnitude_Nm); /** * @brief Set the minimum and maximum angle of the crank measured in a single crank revolution (unit: degree). * * This, so called, Extreme Angles Magnitude field pair will be included in the Cycling Power Measurement * characteristic only if the device supports the Extreme Angles feature. * * @param min_angle_degree * @param max_angle_degree *//* ... */ void cycling_power_service_server_set_angle(uint16_t min_angle_degree, uint16_t max_angle_degree); /** * @brief Set the value of the crank angle measured when the value of the Instantaneous Power value becomes positive. * * This field will be included in the Cycling Power Measurement characteristic * only if the device supports the Top and Bottom Dead Spot Angles feature. * * @param top_dead_spot_angle_degree *//* ... */ void cycling_power_service_server_set_top_dead_spot_angle(uint16_t top_dead_spot_angle_degree); /** * @brief Set the value of the crank angle measured when the value of the Instantaneous Power value becomes negative. * * This field will be included in the Cycling Power Measurement characteristic * only if the device supports the Top and Bottom Dead Spot Angles feature. * * @param bottom_dead_spot_angle_degree *//* ... */ void cycling_power_service_server_set_bottom_dead_spot_angle(uint16_t bottom_dead_spot_angle_degree); /** * @brief Set the raw sensor force magnitude measurements. * * @param force_magnitude_count * @param force_magnitude_N_array unit: newton *//* ... */ void cycling_power_service_server_set_force_magnitude_values(int force_magnitude_count, int16_t * force_magnitude_N_array); /** * @brief Set the raw sensor torque magnitude measurements. * * @param force_magnitude_count * @param force_magnitude_N_array unit: newton meter *//* ... */ void cycling_power_service_server_set_torque_magnitude_values(int torque_magnitude_count, int16_t * torque_magnitude_Nm_array); /** * @brief Set the instantaneous measurement direction. The field describes * the direction of the Instantaneous Magnitude values the Server measures * (e.g., Unknown, Tangential Component, Radial Component, or Lateral Component). * * @param direction *//* ... */ void cycling_power_service_server_set_instantaneous_measurement_direction(cycling_power_instantaneous_measurement_direction_t direction); /** * Set first crank measurement angle. The value will be present only in the first packet of * the Cycling Power Vector notification. * * @param first_crank_measurement_angle_degree *//* ... */ void cycling_power_service_server_set_first_crank_measurement_angle(uint16_t first_crank_measurement_angle_degree); /** * Get measurement flags bitmask. * @return measurement_flags_bitmask, see cycling_power_measurement_flag_t *//* ... */ uint16_t cycling_power_service_measurement_flags(void); /** * Get vector flags bitmask. * @return vector_flags_bitmask, see cycling_power_vector_flag_t *//* ... */ uint8_t cycling_power_service_vector_flags(void); /** * @brief Trigger notification if subscribed *//* ... */ void cycling_power_service_server_update_values(void); /* API_END */ #if defined __cplusplus }extern "C" { ... } #endif /* ... */ #endif
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.