xref: /btstack/src/ble/gatt-service/cycling_speed_and_cadence_service_server.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
1 /*
2  * Copyright (C) 2018 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 /**
39  * @title Cycling Speed and Cadence Service Server
40  *
41  */
42 
43 #ifndef CYCLING_SPEED_AND_CADENCE_SERVICE_SERVER_H
44 #define CYCLING_SPEED_AND_CADENCE_SERVICE_SERVER_H
45 
46 #include <stdint.h>
47 
48 #if defined __cplusplus
49 extern "C" {
50 #endif
51 
52 /**
53  * @text The Cycling Speed and Cadence Service allows to query
54  * device's speed- and cadence-related data for use in sports and
55  * fitness applications.
56  *
57  * To use with your application, add `#import <cycling_speed_and_cadence_service.gatt>`
58  * to your .gatt file.
59  */
60 
61 /* API_START */
62 
63 typedef enum {
64 	CSC_SERVICE_SENSOR_LOCATION_OTHER = 0,
65 	CSC_SERVICE_SENSOR_LOCATION_TOP_OF_SHOE,
66 	CSC_SERVICE_SENSOR_LOCATION_IN_SHOE,
67 	CSC_SERVICE_SENSOR_LOCATION_HIP,
68 	CSC_SERVICE_SENSOR_LOCATION_FRONT_WHEEL,
69 	CSC_SERVICE_SENSOR_LOCATION_LEFT_CRANK,
70 	CSC_SERVICE_SENSOR_LOCATION_RIGHT_CRANK,
71 	CSC_SERVICE_SENSOR_LOCATION_LEFT_PEDAL,
72 	CSC_SERVICE_SENSOR_LOCATION_RIGHT_PEDAL,
73 	CSC_SERVICE_SENSOR_LOCATION_FRONT_HUB,
74 	CSC_SERVICE_SENSOR_LOCATION_REAR_DROPOUT,
75 	CSC_SERVICE_SENSOR_LOCATION_CHAINSTAY,
76 	CSC_SERVICE_SENSOR_LOCATION_REAR_WHEEL,
77 	CSC_SERVICE_SENSOR_LOCATION_REAR_HUB,
78 	CSC_SERVICE_SENSOR_LOCATION_CHEST,
79 	CSC_SERVICE_SENSOR_LOCATION_SPIDER,
80 	CSC_SERVICE_SENSOR_LOCATION_CHAIN_RING,
81 	CSC_SERVICE_SENSOR_LOCATION_RESERVED
82 } cycling_speed_and_cadence_sensor_location_t;
83 
84 typedef enum {
85 	CSC_FLAG_WHEEL_REVOLUTION_DATA_SUPPORTED = 0,
86 	CSC_FLAG_CRANK_REVOLUTION_DATA_SUPPORTED,
87 	CSC_FLAG_MULTIPLE_SENSOR_LOCATIONS_SUPPORTED
88 } csc_feature_flag_bit_t;
89 
90 typedef enum {
91 	CSC_OPCODE_IDLE = 0,
92 	CSC_OPCODE_SET_CUMULATIVE_VALUE = 1,
93 	CSC_OPCODE_START_SENSOR_CALIBRATION,
94 	CSC_OPCODE_UPDATE_SENSOR_LOCATION,
95 	CSC_OPCODE_REQUEST_SUPPORTED_SENSOR_LOCATIONS,
96 	CSC_OPCODE_RESPONSE_CODE = 16
97 } csc_opcode_t;
98 
99 /**
100  * @brief Init Server with ATT DB
101  */
102 void cycling_speed_and_cadence_service_server_init(uint32_t supported_sensor_locations,
103 	uint8_t multiple_sensor_locations_supported, uint8_t wheel_revolution_data_supported, uint8_t crank_revolution_data_supported);
104 
105 /**
106  * @brief Update heart rate (unit: beats per minute)
107  * @note triggers notifications if subscribed
108  */
109 void cycling_speed_and_cadence_service_server_update_values(int32_t wheel_revolutions, uint16_t last_wheel_event_time, uint16_t crank_revolutions, uint16_t last_crank_event_time);
110 
111 /* API_END */
112 
113 #if defined __cplusplus
114 }
115 #endif
116 
117 #endif
118 
119