-
Notifications
You must be signed in to change notification settings - Fork 42
/
messages.go
5656 lines (5208 loc) · 175 KB
/
messages.go
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated using the program found in 'cmd/fitgen/main.go'. DO NOT EDIT.
// SDK Version: 21.115
package fit
import (
"math"
"time"
)
// FileIdMsg represents the file_id FIT message type.
type FileIdMsg struct {
Type FileType
Manufacturer Manufacturer
Product uint16
SerialNumber uint32
TimeCreated time.Time // Only set for files that are can be created/erased.
Number uint16 // Only set for files that are not created/erased.
ProductName string // Optional free form string to indicate the devices name or model
}
// NewFileIdMsg returns a file_id FIT message
// initialized to all-invalid values.
func NewFileIdMsg() *FileIdMsg {
return &FileIdMsg{
Type: 0xFF,
Manufacturer: 0xFFFF,
Product: 0xFFFF,
SerialNumber: 0x00000000,
TimeCreated: timeBase,
Number: 0xFFFF,
ProductName: "",
}
}
// GetProduct returns the appropriate Product
// subfield if a matching reference field/value combination is found.
// If none of the reference field/value combinations are true
// then the main field is returned.
func (x *FileIdMsg) GetProduct() interface{} {
switch x.Manufacturer {
case ManufacturerGarmin, ManufacturerDynastream, ManufacturerDynastreamOem, ManufacturerTacx:
return GarminProduct(x.Product)
default:
return x.Product
}
}
// FileCreatorMsg represents the file_creator FIT message type.
type FileCreatorMsg struct {
SoftwareVersion uint16
HardwareVersion uint8
}
// NewFileCreatorMsg returns a file_creator FIT message
// initialized to all-invalid values.
func NewFileCreatorMsg() *FileCreatorMsg {
return &FileCreatorMsg{
SoftwareVersion: 0xFFFF,
HardwareVersion: 0xFF,
}
}
// TimestampCorrelationMsg represents the timestamp_correlation FIT message type.
type TimestampCorrelationMsg struct {
}
// NewTimestampCorrelationMsg returns a timestamp_correlation FIT message
// initialized to all-invalid values.
func NewTimestampCorrelationMsg() *TimestampCorrelationMsg {
return &TimestampCorrelationMsg{}
}
// SoftwareMsg represents the software FIT message type.
type SoftwareMsg struct {
MessageIndex MessageIndex
Version uint16
PartNumber string
}
// NewSoftwareMsg returns a software FIT message
// initialized to all-invalid values.
func NewSoftwareMsg() *SoftwareMsg {
return &SoftwareMsg{
MessageIndex: 0xFFFF,
Version: 0xFFFF,
PartNumber: "",
}
}
// GetVersionScaled returns Version
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
func (x *SoftwareMsg) GetVersionScaled() float64 {
if x.Version == 0xFFFF {
return math.NaN()
}
return float64(x.Version) / 100
}
// SlaveDeviceMsg represents the slave_device FIT message type.
type SlaveDeviceMsg struct {
Manufacturer Manufacturer
Product uint16
}
// NewSlaveDeviceMsg returns a slave_device FIT message
// initialized to all-invalid values.
func NewSlaveDeviceMsg() *SlaveDeviceMsg {
return &SlaveDeviceMsg{
Manufacturer: 0xFFFF,
Product: 0xFFFF,
}
}
// GetProduct returns the appropriate Product
// subfield if a matching reference field/value combination is found.
// If none of the reference field/value combinations are true
// then the main field is returned.
func (x *SlaveDeviceMsg) GetProduct() interface{} {
switch x.Manufacturer {
case ManufacturerGarmin, ManufacturerDynastream, ManufacturerDynastreamOem, ManufacturerTacx:
return GarminProduct(x.Product)
default:
return x.Product
}
}
// CapabilitiesMsg represents the capabilities FIT message type.
type CapabilitiesMsg struct {
Languages []uint8 // Use language_bits_x types where x is index of array.
Sports []SportBits0 // Use sport_bits_x types where x is index of array.
WorkoutsSupported WorkoutCapabilities
ConnectivitySupported ConnectivityCapabilities
}
// NewCapabilitiesMsg returns a capabilities FIT message
// initialized to all-invalid values.
func NewCapabilitiesMsg() *CapabilitiesMsg {
return &CapabilitiesMsg{
Languages: nil,
Sports: nil,
WorkoutsSupported: 0x00000000,
ConnectivitySupported: 0x00000000,
}
}
// FileCapabilitiesMsg represents the file_capabilities FIT message type.
type FileCapabilitiesMsg struct {
MessageIndex MessageIndex
Type FileType
Flags FileFlags
Directory string
MaxCount uint16
MaxSize uint32
}
// NewFileCapabilitiesMsg returns a file_capabilities FIT message
// initialized to all-invalid values.
func NewFileCapabilitiesMsg() *FileCapabilitiesMsg {
return &FileCapabilitiesMsg{
MessageIndex: 0xFFFF,
Type: 0xFF,
Flags: 0x00,
Directory: "",
MaxCount: 0xFFFF,
MaxSize: 0xFFFFFFFF,
}
}
// MesgCapabilitiesMsg represents the mesg_capabilities FIT message type.
type MesgCapabilitiesMsg struct {
MessageIndex MessageIndex
File FileType
MesgNum MesgNum
CountType MesgCount
Count uint16
}
// NewMesgCapabilitiesMsg returns a mesg_capabilities FIT message
// initialized to all-invalid values.
func NewMesgCapabilitiesMsg() *MesgCapabilitiesMsg {
return &MesgCapabilitiesMsg{
MessageIndex: 0xFFFF,
File: 0xFF,
MesgNum: 0xFFFF,
CountType: 0xFF,
Count: 0xFFFF,
}
}
// GetCount returns the appropriate Count
// subfield if a matching reference field/value combination is found.
// If none of the reference field/value combinations are true
// then the main field is returned.
func (x *MesgCapabilitiesMsg) GetCount() interface{} {
switch x.CountType {
case MesgCountNumPerFile:
return uint16(x.Count)
case MesgCountMaxPerFile:
return uint16(x.Count)
case MesgCountMaxPerFileType:
return uint16(x.Count)
default:
return x.Count
}
}
// FieldCapabilitiesMsg represents the field_capabilities FIT message type.
type FieldCapabilitiesMsg struct {
MessageIndex MessageIndex
File FileType
MesgNum MesgNum
FieldNum uint8
Count uint16
}
// NewFieldCapabilitiesMsg returns a field_capabilities FIT message
// initialized to all-invalid values.
func NewFieldCapabilitiesMsg() *FieldCapabilitiesMsg {
return &FieldCapabilitiesMsg{
MessageIndex: 0xFFFF,
File: 0xFF,
MesgNum: 0xFFFF,
FieldNum: 0xFF,
Count: 0xFFFF,
}
}
// DeviceSettingsMsg represents the device_settings FIT message type.
type DeviceSettingsMsg struct {
ActiveTimeZone uint8 // Index into time zone arrays.
UtcOffset uint32 // Offset from system time. Required to convert timestamp from system time to UTC.
TimeOffset []uint32 // Offset from system time.
TimeMode []TimeMode // Display mode for the time
TimeZoneOffset []int8 // timezone offset in 1/4 hour increments
BacklightMode BacklightMode // Mode for backlight
ActivityTrackerEnabled Bool // Enabled state of the activity tracker functionality
ClockTime time.Time // UTC timestamp used to set the devices clock and date
PagesEnabled []uint16 // Bitfield to configure enabled screens for each supported loop
MoveAlertEnabled Bool // Enabled state of the move alert
DateMode DateMode // Display mode for the date
DisplayOrientation DisplayOrientation
MountingSide Side
DefaultPage []uint16 // Bitfield to indicate one page as default for each supported loop
AutosyncMinSteps uint16 // Minimum steps before an autosync can occur
AutosyncMinTime uint16 // Minimum minutes before an autosync can occur
TapSensitivity TapSensitivity // Used to hold the tap threshold setting
}
// NewDeviceSettingsMsg returns a device_settings FIT message
// initialized to all-invalid values.
func NewDeviceSettingsMsg() *DeviceSettingsMsg {
return &DeviceSettingsMsg{
ActiveTimeZone: 0xFF,
UtcOffset: 0xFFFFFFFF,
TimeOffset: nil,
TimeMode: nil,
TimeZoneOffset: nil,
BacklightMode: 0xFF,
ActivityTrackerEnabled: 0xFF,
ClockTime: timeBase,
PagesEnabled: nil,
MoveAlertEnabled: 0xFF,
DateMode: 0xFF,
DisplayOrientation: 0xFF,
MountingSide: 0xFF,
DefaultPage: nil,
AutosyncMinSteps: 0xFFFF,
AutosyncMinTime: 0xFFFF,
TapSensitivity: 0xFF,
}
}
// GetTimeZoneOffsetScaled returns TimeZoneOffset
// as a slice with scale and any offset applied to every element.
// Units: hr
func (x *DeviceSettingsMsg) GetTimeZoneOffsetScaled() []float64 {
if len(x.TimeZoneOffset) == 0 {
return nil
}
s := make([]float64, len(x.TimeZoneOffset))
for i, v := range x.TimeZoneOffset {
s[i] = float64(v) / 4
}
return s
}
// UserProfileMsg represents the user_profile FIT message type.
type UserProfileMsg struct {
MessageIndex MessageIndex
FriendlyName string
Gender Gender
Age uint8
Height uint8
Weight uint16
Language Language
ElevSetting DisplayMeasure
WeightSetting DisplayMeasure
RestingHeartRate uint8
DefaultMaxRunningHeartRate uint8
DefaultMaxBikingHeartRate uint8
DefaultMaxHeartRate uint8
HrSetting DisplayHeart
SpeedSetting DisplayMeasure
DistSetting DisplayMeasure
PowerSetting DisplayPower
ActivityClass ActivityClass
PositionSetting DisplayPosition
TemperatureSetting DisplayMeasure
LocalId UserLocalId
GlobalId []byte
HeightSetting DisplayMeasure
UserRunningStepLength uint16 // User defined running step length set to 0 for auto length
UserWalkingStepLength uint16 // User defined walking step length set to 0 for auto length
}
// NewUserProfileMsg returns a user_profile FIT message
// initialized to all-invalid values.
func NewUserProfileMsg() *UserProfileMsg {
return &UserProfileMsg{
MessageIndex: 0xFFFF,
FriendlyName: "",
Gender: 0xFF,
Age: 0xFF,
Height: 0xFF,
Weight: 0xFFFF,
Language: 0xFF,
ElevSetting: 0xFF,
WeightSetting: 0xFF,
RestingHeartRate: 0xFF,
DefaultMaxRunningHeartRate: 0xFF,
DefaultMaxBikingHeartRate: 0xFF,
DefaultMaxHeartRate: 0xFF,
HrSetting: 0xFF,
SpeedSetting: 0xFF,
DistSetting: 0xFF,
PowerSetting: 0xFF,
ActivityClass: 0xFF,
PositionSetting: 0xFF,
TemperatureSetting: 0xFF,
LocalId: 0xFFFF,
GlobalId: nil,
HeightSetting: 0xFF,
UserRunningStepLength: 0xFFFF,
UserWalkingStepLength: 0xFFFF,
}
}
// GetHeightScaled returns Height
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *UserProfileMsg) GetHeightScaled() float64 {
if x.Height == 0xFF {
return math.NaN()
}
return float64(x.Height) / 100
}
// GetWeightScaled returns Weight
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: kg
func (x *UserProfileMsg) GetWeightScaled() float64 {
if x.Weight == 0xFFFF {
return math.NaN()
}
return float64(x.Weight) / 10
}
// GetUserRunningStepLengthScaled returns UserRunningStepLength
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *UserProfileMsg) GetUserRunningStepLengthScaled() float64 {
if x.UserRunningStepLength == 0xFFFF {
return math.NaN()
}
return float64(x.UserRunningStepLength) / 1000
}
// GetUserWalkingStepLengthScaled returns UserWalkingStepLength
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *UserProfileMsg) GetUserWalkingStepLengthScaled() float64 {
if x.UserWalkingStepLength == 0xFFFF {
return math.NaN()
}
return float64(x.UserWalkingStepLength) / 1000
}
// HrmProfileMsg represents the hrm_profile FIT message type.
type HrmProfileMsg struct {
MessageIndex MessageIndex
Enabled Bool
HrmAntId uint16
LogHrv Bool
HrmAntIdTransType uint8
}
// NewHrmProfileMsg returns a hrm_profile FIT message
// initialized to all-invalid values.
func NewHrmProfileMsg() *HrmProfileMsg {
return &HrmProfileMsg{
MessageIndex: 0xFFFF,
Enabled: 0xFF,
HrmAntId: 0x0000,
LogHrv: 0xFF,
HrmAntIdTransType: 0x00,
}
}
// SdmProfileMsg represents the sdm_profile FIT message type.
type SdmProfileMsg struct {
MessageIndex MessageIndex
Enabled Bool
SdmAntId uint16
SdmCalFactor uint16
Odometer uint32
SpeedSource Bool // Use footpod for speed source instead of GPS
SdmAntIdTransType uint8
OdometerRollover uint8 // Rollover counter that can be used to extend the odometer
}
// NewSdmProfileMsg returns a sdm_profile FIT message
// initialized to all-invalid values.
func NewSdmProfileMsg() *SdmProfileMsg {
return &SdmProfileMsg{
MessageIndex: 0xFFFF,
Enabled: 0xFF,
SdmAntId: 0x0000,
SdmCalFactor: 0xFFFF,
Odometer: 0xFFFFFFFF,
SpeedSource: 0xFF,
SdmAntIdTransType: 0x00,
OdometerRollover: 0xFF,
}
}
// GetSdmCalFactorScaled returns SdmCalFactor
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: %
func (x *SdmProfileMsg) GetSdmCalFactorScaled() float64 {
if x.SdmCalFactor == 0xFFFF {
return math.NaN()
}
return float64(x.SdmCalFactor) / 10
}
// GetOdometerScaled returns Odometer
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *SdmProfileMsg) GetOdometerScaled() float64 {
if x.Odometer == 0xFFFFFFFF {
return math.NaN()
}
return float64(x.Odometer) / 100
}
// BikeProfileMsg represents the bike_profile FIT message type.
type BikeProfileMsg struct {
MessageIndex MessageIndex
Name string
Sport Sport
SubSport SubSport
Odometer uint32
BikeSpdAntId uint16
BikeCadAntId uint16
BikeSpdcadAntId uint16
BikePowerAntId uint16
CustomWheelsize uint16
AutoWheelsize uint16
BikeWeight uint16
PowerCalFactor uint16
AutoWheelCal Bool
AutoPowerZero Bool
Id uint8
SpdEnabled Bool
CadEnabled Bool
SpdcadEnabled Bool
PowerEnabled Bool
CrankLength uint8
Enabled Bool
BikeSpdAntIdTransType uint8
BikeCadAntIdTransType uint8
BikeSpdcadAntIdTransType uint8
BikePowerAntIdTransType uint8
OdometerRollover uint8 // Rollover counter that can be used to extend the odometer
FrontGearNum uint8 // Number of front gears
FrontGear []uint8 // Number of teeth on each gear 0 is innermost
RearGearNum uint8 // Number of rear gears
RearGear []uint8 // Number of teeth on each gear 0 is innermost
ShimanoDi2Enabled Bool
}
// NewBikeProfileMsg returns a bike_profile FIT message
// initialized to all-invalid values.
func NewBikeProfileMsg() *BikeProfileMsg {
return &BikeProfileMsg{
MessageIndex: 0xFFFF,
Name: "",
Sport: 0xFF,
SubSport: 0xFF,
Odometer: 0xFFFFFFFF,
BikeSpdAntId: 0x0000,
BikeCadAntId: 0x0000,
BikeSpdcadAntId: 0x0000,
BikePowerAntId: 0x0000,
CustomWheelsize: 0xFFFF,
AutoWheelsize: 0xFFFF,
BikeWeight: 0xFFFF,
PowerCalFactor: 0xFFFF,
AutoWheelCal: 0xFF,
AutoPowerZero: 0xFF,
Id: 0xFF,
SpdEnabled: 0xFF,
CadEnabled: 0xFF,
SpdcadEnabled: 0xFF,
PowerEnabled: 0xFF,
CrankLength: 0xFF,
Enabled: 0xFF,
BikeSpdAntIdTransType: 0x00,
BikeCadAntIdTransType: 0x00,
BikeSpdcadAntIdTransType: 0x00,
BikePowerAntIdTransType: 0x00,
OdometerRollover: 0xFF,
FrontGearNum: 0x00,
FrontGear: nil,
RearGearNum: 0x00,
RearGear: nil,
ShimanoDi2Enabled: 0xFF,
}
}
// GetOdometerScaled returns Odometer
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *BikeProfileMsg) GetOdometerScaled() float64 {
if x.Odometer == 0xFFFFFFFF {
return math.NaN()
}
return float64(x.Odometer) / 100
}
// GetCustomWheelsizeScaled returns CustomWheelsize
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *BikeProfileMsg) GetCustomWheelsizeScaled() float64 {
if x.CustomWheelsize == 0xFFFF {
return math.NaN()
}
return float64(x.CustomWheelsize) / 1000
}
// GetAutoWheelsizeScaled returns AutoWheelsize
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m
func (x *BikeProfileMsg) GetAutoWheelsizeScaled() float64 {
if x.AutoWheelsize == 0xFFFF {
return math.NaN()
}
return float64(x.AutoWheelsize) / 1000
}
// GetBikeWeightScaled returns BikeWeight
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: kg
func (x *BikeProfileMsg) GetBikeWeightScaled() float64 {
if x.BikeWeight == 0xFFFF {
return math.NaN()
}
return float64(x.BikeWeight) / 10
}
// GetPowerCalFactorScaled returns PowerCalFactor
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: %
func (x *BikeProfileMsg) GetPowerCalFactorScaled() float64 {
if x.PowerCalFactor == 0xFFFF {
return math.NaN()
}
return float64(x.PowerCalFactor) / 10
}
// GetCrankLengthScaled returns CrankLength
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: mm
func (x *BikeProfileMsg) GetCrankLengthScaled() float64 {
if x.CrankLength == 0xFF {
return math.NaN()
}
return float64(x.CrankLength)/2 - -110
}
// ConnectivityMsg represents the connectivity FIT message type.
type ConnectivityMsg struct {
BluetoothEnabled Bool // Use Bluetooth for connectivity features
BluetoothLeEnabled Bool // Use Bluetooth Low Energy for connectivity features
AntEnabled Bool // Use ANT for connectivity features
Name string
LiveTrackingEnabled Bool
WeatherConditionsEnabled Bool
WeatherAlertsEnabled Bool
AutoActivityUploadEnabled Bool
CourseDownloadEnabled Bool
WorkoutDownloadEnabled Bool
GpsEphemerisDownloadEnabled Bool
IncidentDetectionEnabled Bool
GrouptrackEnabled Bool
}
// NewConnectivityMsg returns a connectivity FIT message
// initialized to all-invalid values.
func NewConnectivityMsg() *ConnectivityMsg {
return &ConnectivityMsg{
BluetoothEnabled: 0xFF,
BluetoothLeEnabled: 0xFF,
AntEnabled: 0xFF,
Name: "",
LiveTrackingEnabled: 0xFF,
WeatherConditionsEnabled: 0xFF,
WeatherAlertsEnabled: 0xFF,
AutoActivityUploadEnabled: 0xFF,
CourseDownloadEnabled: 0xFF,
WorkoutDownloadEnabled: 0xFF,
GpsEphemerisDownloadEnabled: 0xFF,
IncidentDetectionEnabled: 0xFF,
GrouptrackEnabled: 0xFF,
}
}
// WatchfaceSettingsMsg represents the watchface_settings FIT message type.
type WatchfaceSettingsMsg struct {
}
// NewWatchfaceSettingsMsg returns a watchface_settings FIT message
// initialized to all-invalid values.
func NewWatchfaceSettingsMsg() *WatchfaceSettingsMsg {
return &WatchfaceSettingsMsg{}
}
// OhrSettingsMsg represents the ohr_settings FIT message type.
type OhrSettingsMsg struct {
}
// NewOhrSettingsMsg returns a ohr_settings FIT message
// initialized to all-invalid values.
func NewOhrSettingsMsg() *OhrSettingsMsg {
return &OhrSettingsMsg{}
}
// TimeInZoneMsg represents the time_in_zone FIT message type.
type TimeInZoneMsg struct {
}
// NewTimeInZoneMsg returns a time_in_zone FIT message
// initialized to all-invalid values.
func NewTimeInZoneMsg() *TimeInZoneMsg {
return &TimeInZoneMsg{}
}
// ZonesTargetMsg represents the zones_target FIT message type.
type ZonesTargetMsg struct {
MaxHeartRate uint8
ThresholdHeartRate uint8
FunctionalThresholdPower uint16
HrCalcType HrZoneCalc
PwrCalcType PwrZoneCalc
}
// NewZonesTargetMsg returns a zones_target FIT message
// initialized to all-invalid values.
func NewZonesTargetMsg() *ZonesTargetMsg {
return &ZonesTargetMsg{
MaxHeartRate: 0xFF,
ThresholdHeartRate: 0xFF,
FunctionalThresholdPower: 0xFFFF,
HrCalcType: 0xFF,
PwrCalcType: 0xFF,
}
}
// SportMsg represents the sport FIT message type.
type SportMsg struct {
Sport Sport
SubSport SubSport
Name string
}
// NewSportMsg returns a sport FIT message
// initialized to all-invalid values.
func NewSportMsg() *SportMsg {
return &SportMsg{
Sport: 0xFF,
SubSport: 0xFF,
Name: "",
}
}
// HrZoneMsg represents the hr_zone FIT message type.
type HrZoneMsg struct {
MessageIndex MessageIndex
HighBpm uint8
Name string
}
// NewHrZoneMsg returns a hr_zone FIT message
// initialized to all-invalid values.
func NewHrZoneMsg() *HrZoneMsg {
return &HrZoneMsg{
MessageIndex: 0xFFFF,
HighBpm: 0xFF,
Name: "",
}
}
// SpeedZoneMsg represents the speed_zone FIT message type.
type SpeedZoneMsg struct {
MessageIndex MessageIndex
HighValue uint16
Name string
}
// NewSpeedZoneMsg returns a speed_zone FIT message
// initialized to all-invalid values.
func NewSpeedZoneMsg() *SpeedZoneMsg {
return &SpeedZoneMsg{
MessageIndex: 0xFFFF,
HighValue: 0xFFFF,
Name: "",
}
}
// GetHighValueScaled returns HighValue
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: m/s
func (x *SpeedZoneMsg) GetHighValueScaled() float64 {
if x.HighValue == 0xFFFF {
return math.NaN()
}
return float64(x.HighValue) / 1000
}
// CadenceZoneMsg represents the cadence_zone FIT message type.
type CadenceZoneMsg struct {
MessageIndex MessageIndex
HighValue uint8
Name string
}
// NewCadenceZoneMsg returns a cadence_zone FIT message
// initialized to all-invalid values.
func NewCadenceZoneMsg() *CadenceZoneMsg {
return &CadenceZoneMsg{
MessageIndex: 0xFFFF,
HighValue: 0xFF,
Name: "",
}
}
// PowerZoneMsg represents the power_zone FIT message type.
type PowerZoneMsg struct {
MessageIndex MessageIndex
HighValue uint16
Name string
}
// NewPowerZoneMsg returns a power_zone FIT message
// initialized to all-invalid values.
func NewPowerZoneMsg() *PowerZoneMsg {
return &PowerZoneMsg{
MessageIndex: 0xFFFF,
HighValue: 0xFFFF,
Name: "",
}
}
// MetZoneMsg represents the met_zone FIT message type.
type MetZoneMsg struct {
MessageIndex MessageIndex
HighBpm uint8
Calories uint16
FatCalories uint8
}
// NewMetZoneMsg returns a met_zone FIT message
// initialized to all-invalid values.
func NewMetZoneMsg() *MetZoneMsg {
return &MetZoneMsg{
MessageIndex: 0xFFFF,
HighBpm: 0xFF,
Calories: 0xFFFF,
FatCalories: 0xFF,
}
}
// GetCaloriesScaled returns Calories
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: kcal / min
func (x *MetZoneMsg) GetCaloriesScaled() float64 {
if x.Calories == 0xFFFF {
return math.NaN()
}
return float64(x.Calories) / 10
}
// GetFatCaloriesScaled returns FatCalories
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: kcal / min
func (x *MetZoneMsg) GetFatCaloriesScaled() float64 {
if x.FatCalories == 0xFF {
return math.NaN()
}
return float64(x.FatCalories) / 10
}
// DiveSettingsMsg represents the dive_settings FIT message type.
type DiveSettingsMsg struct {
Name string
HeartRateSourceType SourceType
HeartRateSource uint8
}
// NewDiveSettingsMsg returns a dive_settings FIT message
// initialized to all-invalid values.
func NewDiveSettingsMsg() *DiveSettingsMsg {
return &DiveSettingsMsg{
Name: "",
HeartRateSourceType: 0xFF,
HeartRateSource: 0xFF,
}
}
// GetHeartRateSource returns the appropriate HeartRateSource
// subfield if a matching reference field/value combination is found.
// If none of the reference field/value combinations are true
// then the main field is returned.
func (x *DiveSettingsMsg) GetHeartRateSource() interface{} {
switch x.HeartRateSourceType {
case SourceTypeAntplus:
return AntplusDeviceType(x.HeartRateSource)
case SourceTypeLocal:
return LocalDeviceType(x.HeartRateSource)
default:
return x.HeartRateSource
}
}
// DiveAlarmMsg represents the dive_alarm FIT message type.
type DiveAlarmMsg struct {
}
// NewDiveAlarmMsg returns a dive_alarm FIT message
// initialized to all-invalid values.
func NewDiveAlarmMsg() *DiveAlarmMsg {
return &DiveAlarmMsg{}
}
// DiveApneaAlarmMsg represents the dive_apnea_alarm FIT message type.
type DiveApneaAlarmMsg struct {
}
// NewDiveApneaAlarmMsg returns a dive_apnea_alarm FIT message
// initialized to all-invalid values.
func NewDiveApneaAlarmMsg() *DiveApneaAlarmMsg {
return &DiveApneaAlarmMsg{}
}
// DiveGasMsg represents the dive_gas FIT message type.
type DiveGasMsg struct {
}
// NewDiveGasMsg returns a dive_gas FIT message
// initialized to all-invalid values.
func NewDiveGasMsg() *DiveGasMsg {
return &DiveGasMsg{}
}
// GoalMsg represents the goal FIT message type.
type GoalMsg struct {
MessageIndex MessageIndex
Sport Sport
SubSport SubSport
StartDate time.Time
EndDate time.Time
Type Goal
Value uint32
Repeat Bool
TargetValue uint32
Recurrence GoalRecurrence
RecurrenceValue uint16
Enabled Bool
Source GoalSource
}
// NewGoalMsg returns a goal FIT message
// initialized to all-invalid values.
func NewGoalMsg() *GoalMsg {
return &GoalMsg{
MessageIndex: 0xFFFF,
Sport: 0xFF,
SubSport: 0xFF,
StartDate: timeBase,
EndDate: timeBase,
Type: 0xFF,
Value: 0xFFFFFFFF,
Repeat: 0xFF,
TargetValue: 0xFFFFFFFF,
Recurrence: 0xFF,
RecurrenceValue: 0xFFFF,
Enabled: 0xFF,
Source: 0xFF,
}
}
// ActivityMsg represents the activity FIT message type.
type ActivityMsg struct {
Timestamp time.Time
TotalTimerTime uint32 // Exclude pauses
NumSessions uint16
Type ActivityMode
Event Event
EventType EventType
LocalTimestamp time.Time // timestamp epoch expressed in local time, used to convert activity timestamps to local time
EventGroup uint8
}
// NewActivityMsg returns a activity FIT message
// initialized to all-invalid values.
func NewActivityMsg() *ActivityMsg {
return &ActivityMsg{
Timestamp: timeBase,
TotalTimerTime: 0xFFFFFFFF,
NumSessions: 0xFFFF,
Type: 0xFF,
Event: 0xFF,
EventType: 0xFF,
LocalTimestamp: timeBase,
EventGroup: 0xFF,
}
}
// GetTotalTimerTimeScaled returns TotalTimerTime
// with scale and any offset applied. NaN is returned if the
// field has an invalid value (i.e. has not been set).
// Units: s
func (x *ActivityMsg) GetTotalTimerTimeScaled() float64 {
if x.TotalTimerTime == 0xFFFFFFFF {
return math.NaN()
}
return float64(x.TotalTimerTime) / 1000
}
// SessionMsg represents the session FIT message type.
type SessionMsg struct {
MessageIndex MessageIndex // Selected bit is set for the current session.
Timestamp time.Time // Sesson end time.
Event Event // session
EventType EventType // stop
StartTime time.Time
StartPositionLat Latitude
StartPositionLong Longitude
Sport Sport
SubSport SubSport
TotalElapsedTime uint32 // Time (includes pauses)
TotalTimerTime uint32 // Timer Time (excludes pauses)
TotalDistance uint32
TotalCycles uint32
TotalCalories uint16
TotalFatCalories uint16
AvgSpeed uint16 // total_distance / total_timer_time
MaxSpeed uint16
AvgHeartRate uint8 // average heart rate (excludes pause time)
MaxHeartRate uint8
AvgCadence uint8 // total_cycles / total_timer_time if non_zero_avg_cadence otherwise total_cycles / total_elapsed_time
MaxCadence uint8
AvgPower uint16 // total_power / total_timer_time if non_zero_avg_power otherwise total_power / total_elapsed_time
MaxPower uint16
TotalAscent uint16
TotalDescent uint16
TotalTrainingEffect uint8
FirstLapIndex uint16
NumLaps uint16
EventGroup uint8
Trigger SessionTrigger
NecLat Latitude // North east corner latitude