Wahoo Fitness API  3.6.1
Documentation for the iPhone version of the Wahoo Fitness API.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
fit.h
Go to the documentation of this file.
1 // The following FIT Protocol software provided may be used with FIT protocol
3 // devices only and remains the copyrighted property of Dynastream Innovations Inc.
4 // The software is being provided on an "as-is" basis and as an accommodation,
5 // and therefore all warranties, representations, or guarantees of any kind
6 // (whether express, implied or statutory) including, without limitation,
7 // warranties of merchantability, non-infringement, or fitness for a particular
8 // purpose, are specifically disclaimed.
9 //
10 // Copyright 2008 Dynastream Innovations Inc.
12 // ****WARNING**** This file is auto-generated! Do NOT edit this file.
13 // Profile Version = 2.0Release
14 // Tag = $Name: AKW2_000 $
15 // Product = SDK
16 // Alignment = 4 bytes, padding disabled.
18 
19 
20 #if !defined(FIT_H)
21 #define FIT_H
22 
23 #include "fit_config.h"
24 
25 #if defined(FIT_USE_STDINT_H)
26  #include <stdint.h>
27 #else
28  typedef unsigned char uint8_t;
29  typedef signed char int8_t;
30  typedef unsigned short uint16_t;
31  typedef signed short int16_t;
32  typedef unsigned long uint32_t;
33  typedef signed long int32_t;
34 #endif
35 
36 #if defined(__cplusplus)
37  extern "C" {
38 #endif
39 
40 
42 // Version
44 
45 #define FIT_PROTOCOL_VERSION_MAJOR 1 // Non-backwards compatible changes. Decode compatible with this version and earlier.
46 #define FIT_PROTOCOL_VERSION_MINOR 0 // Backwards compatible changes.
47 #define FIT_PROTOCOL_VERSION_MAJOR_SHIFT 4
48 #define FIT_PROTOCOL_VERSION_MAJOR_MASK ((FIT_UINT8) (0x0F << FIT_PROTOCOL_VERSION_MAJOR_SHIFT))
49 #define FIT_PROTOCOL_VERSION_MINOR_MASK ((FIT_UINT8) 0x0F)
50 #define FIT_PROTOCOL_VERSION ((FIT_UINT8) (FIT_PROTOCOL_VERSION_MAJOR << FIT_PROTOCOL_VERSION_MAJOR_SHIFT) | FIT_PROTOCOL_VERSION_MINOR)
51 
52 #define FIT_PROFILE_VERSION_MAJOR 2
53 #define FIT_PROFILE_VERSION_MINOR 0
54 #define FIT_PROFILE_VERSION_SCALE 100
55 #define FIT_PROFILE_VERSION ((FIT_UINT16) (FIT_PROFILE_VERSION_MAJOR * 100 + FIT_PROFILE_VERSION_MINOR))
56 
57 
59 // Type Definitions
61 
62 #define FIT_ANTFS_FILE_DATA_TYPE 128
63 
64 #define FIT_BASE_TYPE_ENDIAN_FLAG ((FIT_UINT8)0x80)
65 #define FIT_BASE_TYPE_RESERVED ((FIT_UINT8)0x60)
66 #define FIT_BASE_TYPE_NUM_MASK ((FIT_UINT8)0x1F)
67 
68 typedef uint8_t FIT_ENUM;
69 typedef const FIT_ENUM * FIT_CONST_ENUM_PTR;
70 #define FIT_ENUM_INVALID ((FIT_ENUM)0xFF)
71 #define FIT_BASE_TYPE_ENUM ((FIT_UINT8)0x00)
72 
73 typedef int8_t FIT_SINT8;
74 typedef const FIT_SINT8 * FIT_CONST_SINT8_PTR;
75 #define FIT_SINT8_INVALID ((FIT_SINT8)0x7F)
76 #define FIT_BASE_TYPE_SINT8 ((FIT_UINT8)0x01)
77 
78 typedef uint8_t FIT_UINT8;
79 typedef const FIT_UINT8 * FIT_CONST_UINT8_PTR;
80 #define FIT_UINT8_INVALID ((FIT_UINT8)0xFF)
81 #define FIT_BASE_TYPE_UINT8 ((FIT_UINT8)0x02)
82 
83 typedef int16_t FIT_SINT16;
84 typedef const FIT_SINT16 * FIT_CONST_SINT16_PTR;
85 #define FIT_SINT16_INVALID ((FIT_SINT16)0x7FFF)
86 #define FIT_BASE_TYPE_SINT16 ((FIT_UINT8)0x83)
87 
88 typedef uint16_t FIT_UINT16;
89 typedef const FIT_UINT16 * FIT_CONST_UINT16_PTR;
90 #define FIT_UINT16_INVALID ((FIT_UINT16)0xFFFF)
91 #define FIT_BASE_TYPE_UINT16 ((FIT_UINT8)0x84)
92 
93 typedef int32_t FIT_SINT32;
94 typedef const FIT_SINT32 * FIT_CONST_SINT32_PTR;
95 #define FIT_SINT32_INVALID ((FIT_SINT32)0x7FFFFFFF)
96 #define FIT_BASE_TYPE_SINT32 ((FIT_UINT8)0x85)
97 
98 typedef uint32_t FIT_UINT32;
99 typedef const FIT_UINT32 * FIT_CONST_UINT32_PTR;
100 #define FIT_UINT32_INVALID ((FIT_UINT32)0xFFFFFFFF)
101 #define FIT_BASE_TYPE_UINT32 ((FIT_UINT8)0x86)
102 
103 typedef char FIT_STRING; // UTF-8 null terminated string
104 typedef const FIT_STRING * FIT_CONST_STRING_PTR;
105 #define FIT_STRING_INVALID ((FIT_STRING)0x00)
106 #define FIT_BASE_TYPE_STRING ((FIT_UINT8)0x07)
107 
108 typedef float FIT_FLOAT32;
109 typedef const FIT_FLOAT32 * FIT_CONST_FLOAT32_PTR;
110 #define FIT_FLOAT32_INVALID ((FIT_FLOAT32)0xFFFFFFFF)
111 #define FIT_BASE_TYPE_FLOAT32 ((FIT_UINT8)0x88)
112 
113 typedef double FIT_FLOAT64;
114 typedef const FIT_FLOAT64 * FIT_CONST_FLOAT64_PTR;
115 #define FIT_FLOAT64_INVALID ((FIT_FLOAT64)0xFFFFFFFFFFFFFFFFull)
116 #define FIT_BASE_TYPE_FLOAT64 ((FIT_UINT8)0x89)
117 
118 typedef uint8_t FIT_UINT8Z;
119 typedef const FIT_UINT8Z * FIT_CONST_UINT8Z_PTR;
120 #define FIT_UINT8Z_INVALID ((FIT_UINT8Z)0x00)
121 #define FIT_BASE_TYPE_UINT8Z ((FIT_UINT8)0x0A)
122 
123 typedef uint16_t FIT_UINT16Z;
124 typedef const FIT_UINT16Z * FIT_CONST_UINT16Z_PTR;
125 #define FIT_UINT16Z_INVALID ((FIT_UINT16Z)0x0000)
126 #define FIT_BASE_TYPE_UINT16Z ((FIT_UINT8)0x8B)
127 
128 typedef uint32_t FIT_UINT32Z;
129 typedef const FIT_UINT32Z * FIT_CONST_UINT32Z_PTR;
130 #define FIT_UINT32Z_INVALID ((FIT_UINT32Z)0x00000000)
131 #define FIT_BASE_TYPE_UINT32Z ((FIT_UINT8)0x8C)
132 
133 typedef uint8_t FIT_BYTE;
134 typedef const FIT_BYTE * FIT_CONST_BYTE_PTR;
135 #define FIT_BYTE_INVALID ((FIT_BYTE)0xFF) // Field is invalid if all bytes are invalid.
136 #define FIT_BASE_TYPE_BYTE ((FIT_UINT8)0x0D)
137 
138 #define FIT_BASE_TYPES 14
139 
140 typedef FIT_ENUM FIT_BOOL;
141 #define FIT_BOOL_INVALID FIT_ENUM_INVALID
142 #define FIT_BOOL_FALSE ((FIT_BOOL)0)
143 #define FIT_BOOL_TRUE ((FIT_BOOL)1)
144 #define FIT_FALSE FIT_BOOL_FALSE
145 #define FIT_TRUE FIT_BOOL_TRUE
146 #define FIT_NULL 0
147 
149 #define FIT_MESG_DEF_HEADER_SIZE FIT_STRUCT_OFFSET(fields, FIT_MESG_DEF)
150 
151 
153 // File Header
155 
156 typedef struct
157 {
158  FIT_UINT8 header_size; // FIT_FILE_HDR_SIZE (size of this structure)
159  FIT_UINT8 protocol_version; // FIT_PROTOCOL_VERSION
160  FIT_UINT16 profile_version; // FIT_PROFILE_VERSION
161  FIT_UINT32 data_size; // Does not include file header or crc. Little endian format.
162  FIT_UINT8 data_type[4]; // ".FIT"
163  FIT_UINT16 crc; // CRC of this file header in little endian format.
164 } FIT_FILE_HDR;
165 
166 #define FIT_FILE_HDR_SIZE 14
167 
168 
170 // Record Definitions
172 
173 #define FIT_HDR_SIZE 1
174 #define FIT_HDR_TIME_REC_BIT ((FIT_UINT8) 0x80)
175 #define FIT_HDR_TIME_TYPE_MASK ((FIT_UINT8) 0x60)
176 #define FIT_HDR_TIME_TYPE_SHIFT 5
177 #define FIT_HDR_TIME_OFFSET_MASK ((FIT_UINT8) 0x1F)
178 #define FIT_HDR_TYPE_DEF_BIT ((FIT_UINT8) 0x40)
179 #define FIT_HDR_TYPE_MASK ((FIT_UINT8) 0x0F)
180 #define FIT_MAX_LOCAL_MESGS (FIT_HDR_TYPE_MASK + 1)
181 
182 
184 // Message Definitions
186 
187 typedef struct
188 {
189  FIT_UINT8 field_def_num;
190  FIT_UINT8 size;
191  FIT_UINT8 base_type;
192 } FIT_FIELD_DEF;
193 
194 #define FIT_FIELD_DEF_SIZE 3
195 
196 typedef struct
197 {
198  FIT_UINT8 reserved_1;
199  FIT_UINT8 arch;
200  FIT_UINT16 global_mesg_num;
201  FIT_UINT8 num_fields;
202  FIT_UINT8 fields[1];
203 } FIT_MESG_DEF;
204 
205 #define FIT_MAX_MESG_SIZE ((FIT_UINT8)255)
206 
207 #define FIT_ARCH_ENDIAN_MASK ((FIT_UINT8)0x01)
208 #define FIT_ARCH_ENDIAN_LITTLE ((FIT_UINT8)0)
209 #define FIT_ARCH_ENDIAN_BIG ((FIT_UINT8)1)
210 
211 
213 // Field Definitions
215 
216 #define FIT_MAX_FIELD_SIZE ((FIT_UINT8)255)
217 #define FIT_FIELD_NUM_INVALID ((FIT_UINT8)0xFF)
218 #define FIT_FIELD_NUM_MESSAGE_INDEX ((FIT_UINT8)254)
219 #define FIT_FIELD_NUM_TIMESTAMP ((FIT_UINT8)253)
220 #define FIT_FIELD_NUM_CHECKSUM ((FIT_UINT8)252)
221 #define FIT_FIELD_NUM_PAD ((FIT_UINT8)251)
222 
223 #define FIT_MESSAGE_INDEX_FIELD_NUM FIT_FIELD_NUM_MESSAGE_INDEX // For reverse compatibility only. Use FIT_FIELD_NUM_MESSAGE_INDEX instead.
224 #define FIT_TIMESTAMP_FIELD_NUM FIT_FIELD_NUM_TIMESTAMP // For reverse compatibility only. Use FIT_FIELD_NUM_TIMESTAMP instead.
225 #define FIT_CHECKSUM_FIELD_NUM FIT_FIELD_NUM_CHECKSUM // For reverse compatibility only. Use FIT_FIELD_NUM_CHECKSUM instead.
226 
227 
229 // Macros
231 
232 #define FIT_STRUCT_OFFSET(MEMBER, STRUCT_TYPE) ( ((FIT_UINT8 *) &(((STRUCT_TYPE *) FIT_NULL)->MEMBER)) - ((FIT_UINT8 *) (FIT_NULL)) ) // Computes the byte offset of a member in a file. Compiles to a constant.
233 
234 #define FIT_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX) (FIT_STRUCT_OFFSET(FIELD_MEMBER, FIT_FIELD_DEF) + FIT_FIELD_DEF_SIZE * FIELD_INDEX) // Computes the byte offset of a field definition member. Compiles to a constant.
235 
236 // Offset of message in file including file header.
237 #define FIT_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE) (FIT_STRUCT_OFFSET(MESG_MEMBER, FILE) + MESG_INDEX * (FIT_HDR_SIZE + MESG_SIZE) + FIT_HDR_SIZE) // Computes the byte offset of a message in a file structure. Compiles to a constant.
238 #define FIT_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE) (FIT_STRUCT_OFFSET(MESG_DEF_MEMBER, FILE) + FIT_HDR_SIZE) // Computes the byte offset of a message definition in a file structure. Compiles to a constant.
239 
240 // Below macros are obsolete because C file structures now include file header. For reverse compatibility only.
241 #define FIT_FILE_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE) FIT_MESG_OFFSET(MESG_MEMBER, MESG_INDEX, MESG_SIZE, FILE)
242 #define FIT_FILE_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE) FIT_MESG_DEF_OFFSET(MESG_DEF_MEMBER, FILE)
243 #define FIT_FILE_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX) FIT_MESG_DEF_FIELD_OFFSET(FIELD_MEMBER, FIELD_INDEX)
244 
245 
247 // Public Constants
249 
250 const extern FIT_UINT8 fit_base_type_sizes[FIT_BASE_TYPES];
251 const extern FIT_CONST_UINT8_PTR fit_base_type_invalids[FIT_BASE_TYPES];
252 
253 
255 // Public Functions
257 
258 FIT_UINT8 Fit_GetArch(void);
260 // Returns architecture type.
261 // Includes runtime check for little or big endian.
262 // See FIT_MESG_DEF->arch and FIT_ARCH_*.
264 
265 const FIT_MESG_DEF *Fit_GetMesgDef(FIT_UINT16 global_mesg_num);
267 // Returns message definition corresponding to global message number.
269 
270 FIT_UINT16 Fit_GetMesgDefSize(const FIT_MESG_DEF *mesg_def);
272 // Returns the size of message definition.
274 
275 FIT_UINT8 Fit_GetMesgSize(FIT_UINT16 global_mesg_num);
277 // Returns the size of message corresponding to global message number.
279 
280 FIT_BOOL Fit_InitMesg(const FIT_MESG_DEF *mesg_def, void *mesg);
282 // Initializes message with invalids.
283 // Returns 1 if successful, otherwise 0.
285 
286 FIT_UINT8 Fit_GetFieldOffset(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num);
288 // Returns the byte offset of a field in a message.
290 
291 FIT_FIELD_DEF Fit_GetFieldDef(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num);
293 // Returns the definition for a field in a message.
294 // field_def_num is set to FIT_FIELD_NUM_INVALID if field is not found in message.
296 
297 FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index, FIT_UINT32 *offset, FIT_READ_BYTES_FUNC read_bytes_func, FIT_BOOL read_header);
299 // Finds the byte offset of a message with the given message index in a FIT file
300 // Requires a pointer to a function which can read a given number of bytes from a provided offset in a FIT file.
301 // Returns the local message number if successful, or FIT_UINT8_INVALID if unsuccessful.
303 
304 #if defined(__cplusplus)
305  }
306 #endif
307 
308 #endif // !defined(FIT_H)
FIT_UINT32(* FIT_READ_BYTES_FUNC)(void *, FIT_UINT32, FIT_UINT32)
Definition: fit.h:148
const FIT_BYTE * FIT_CONST_BYTE_PTR
Definition: fit.h:134
const FIT_SINT8 * FIT_CONST_SINT8_PTR
Definition: fit.h:74
FIT_UINT8 base_type
Definition: fit.h:191
double FIT_FLOAT64
Definition: fit.h:113
uint8_t FIT_UINT8
Definition: fit.h:78
const FIT_FLOAT32 * FIT_CONST_FLOAT32_PTR
Definition: fit.h:109
const FIT_SINT32 * FIT_CONST_SINT32_PTR
Definition: fit.h:94
int16_t FIT_SINT16
Definition: fit.h:83
FIT_UINT8 reserved_1
Definition: fit.h:198
FIT_UINT16 crc
Definition: fit.h:163
FIT_UINT8 field_def_num
Definition: fit.h:189
FIT_UINT8 num_fields
Definition: fit.h:201
uint8_t FIT_BYTE
Definition: fit.h:133
FIT_UINT8 Fit_GetFieldOffset(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num)
const FIT_FLOAT64 * FIT_CONST_FLOAT64_PTR
Definition: fit.h:114
FIT_UINT16 profile_version
Definition: fit.h:160
uint32_t FIT_UINT32Z
Definition: fit.h:128
const FIT_UINT32 * FIT_CONST_UINT32_PTR
Definition: fit.h:99
#define FIT_BASE_TYPES
Definition: fit.h:138
uint16_t FIT_UINT16Z
Definition: fit.h:123
uint8_t FIT_UINT8Z
Definition: fit.h:118
const FIT_MESG_DEF * Fit_GetMesgDef(FIT_UINT16 global_mesg_num)
FIT_UINT8 arch
Definition: fit.h:199
const FIT_UINT8 fit_base_type_sizes[FIT_BASE_TYPES]
FIT_FIELD_DEF Fit_GetFieldDef(const FIT_MESG_DEF *mesg_def, FIT_UINT8 field_def_num)
const FIT_UINT32Z * FIT_CONST_UINT32Z_PTR
Definition: fit.h:129
uint32_t FIT_UINT32
Definition: fit.h:98
FIT_UINT16 global_mesg_num
Definition: fit.h:200
FIT_UINT8 header_size
Definition: fit.h:158
Definition: fit.h:187
FIT_ENUM FIT_BOOL
Definition: fit.h:140
const FIT_UINT16Z * FIT_CONST_UINT16Z_PTR
Definition: fit.h:124
char FIT_STRING
Definition: fit.h:103
FIT_UINT8 size
Definition: fit.h:190
const FIT_CONST_UINT8_PTR fit_base_type_invalids[FIT_BASE_TYPES]
FIT_UINT8 Fit_GetArch(void)
const FIT_STRING * FIT_CONST_STRING_PTR
Definition: fit.h:104
FIT_BOOL Fit_InitMesg(const FIT_MESG_DEF *mesg_def, void *mesg)
const FIT_UINT8 * FIT_CONST_UINT8_PTR
Definition: fit.h:79
uint16_t FIT_UINT16
Definition: fit.h:88
Definition: fit.h:196
const FIT_UINT8Z * FIT_CONST_UINT8Z_PTR
Definition: fit.h:119
int32_t FIT_SINT32
Definition: fit.h:93
int8_t FIT_SINT8
Definition: fit.h:73
Definition: fit.h:156
const FIT_UINT16 * FIT_CONST_UINT16_PTR
Definition: fit.h:89
float FIT_FLOAT32
Definition: fit.h:108
FIT_UINT8 protocol_version
Definition: fit.h:159
FIT_UINT16 Fit_GetMesgDefSize(const FIT_MESG_DEF *mesg_def)
const FIT_SINT16 * FIT_CONST_SINT16_PTR
Definition: fit.h:84
FIT_UINT8 Fit_GetMesgSize(FIT_UINT16 global_mesg_num)
const FIT_ENUM * FIT_CONST_ENUM_PTR
Definition: fit.h:69
FIT_UINT8 Fit_LookupMessage(FIT_UINT16 global_mesg_num, FIT_UINT16 message_index, FIT_UINT32 *offset, FIT_READ_BYTES_FUNC read_bytes_func, FIT_BOOL read_header)
uint8_t FIT_ENUM
Definition: fit.h:68
FIT_UINT32 data_size
Definition: fit.h:161