Skip to content

Commit 1f7d035

Browse files
authored
Garmin FIT SDK 21.178.0
Garmin FIT SDK 21.178.0
1 parent dc76a02 commit 1f7d035

20 files changed

+181
-45
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const { messages, errors } = decoder.read({
7676
convertDateTimesToDates: true,
7777
includeUnknownData: false,
7878
mergeHeartRates: true
79+
decodeMemoGlobs: false,
7980
});
8081
````
8182
#### mesgListener = (messageNumber, message) => {}
@@ -178,6 +179,10 @@ When true unknown field values are stored in the message using the field id as t
178179
````
179180
#### mergeHeartRates: true | false
180181
When true automatically merge heart rate values from HR messages into the Record messages. This option requires the applyScaleAndOffset and expandComponents options to be enabled. This option has no effect on the Record messages when no HR messages are present in the decoded messages.
182+
183+
#### decodeMemoGlobs: true | false
184+
When true, the decoder will reconstruct strings from memoGlob messages. Each reconstructed string will overwrite the targeted message field.
185+
181186
## Creating Streams
182187
Stream objects contain the binary FIT data to be decoded. Streams objects can be created from byte-arrays, ArrayBuffers, and Node.js Buffers. Internally the Stream class uses an ArrayBuffer to manage the byte stream.
183188
#### From a Byte Array

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@garmin/fitsdk",
3-
"version": "21.171.0",
3+
"version": "21.178.0",
44
"description": "FIT JavaScript SDK",
55
"main": "src/index.js",
66
"type": "module",

src/accumulator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/bit-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/crc-calculator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/decoder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -729,8 +729,8 @@ class Decoder {
729729
return rawFieldValue;
730730
}
731731

732-
const scale = Array.isArray(field?.scale ?? 1) ? field?.scale[0] : field?.scale ?? 1;
733-
const offset = Array.isArray(field?.offset ?? 1) ? field?.offset[0] : field?.offset ?? 0;
732+
const scale = Array.isArray(field?.scale ?? FIT.FIELD_DEFAULT_SCALE) ? field?.scale[0] : field?.scale ?? FIT.FIELD_DEFAULT_SCALE;
733+
const offset = Array.isArray(field?.offset ?? FIT.FIELD_DEFAULT_OFFSET) ? field?.offset[0] : field?.offset ?? FIT.FIELD_DEFAULT_OFFSET;
734734

735735
try {
736736
if (Array.isArray(rawFieldValue)) {

src/encoder.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -20,9 +20,6 @@ import Utils from "./utils.js";
2020
const HEADER_WITH_CRC_SIZE = 14;
2121
const HEADER_WITHOUT_CRC_SIZE = 12;
2222

23-
const FIELD_DEFAULT_SCALE = 1;
24-
const FIELD_DEFAULT_OFFSET = 0;
25-
2623
/**
2724
* A class for encoding FIT files.
2825
* @class
@@ -131,7 +128,7 @@ class Encoder {
131128
throw new Error("addDeveloperField() - one or more developerDataIndex values are null.", {
132129
cause: {
133130
key,
134-
developerDataIdMesg,
131+
developerDataIdMesg,
135132
fieldDescriptionMesg
136133
}
137134
});
@@ -141,7 +138,7 @@ class Encoder {
141138
throw new Error("addDeveloperField() - developerDataIndex values do not match.", {
142139
cause: {
143140
key,
144-
developerDataIdMesg,
141+
developerDataIdMesg,
145142
fieldDescriptionMesg
146143
}
147144
});
@@ -215,12 +212,10 @@ class Encoder {
215212
throw new Error();
216213
}
217214

218-
const scale = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_SCALE : fieldDefinition.scale;
219-
const offset = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_OFFSET : fieldDefinition.offset;
220-
const hasScaleOrOffset = (scale != FIELD_DEFAULT_SCALE || offset != FIELD_DEFAULT_OFFSET);
215+
const hasScaleOrOffset = (fieldDefinition.scale != FIT.FIELD_DEFAULT_SCALE || fieldDefinition.offset != FIT.FIELD_DEFAULT_OFFSET);
221216

222217
if (hasScaleOrOffset) {
223-
const scaledValue = (value + offset) * scale;
218+
const scaledValue = (value + fieldDefinition.offset) * fieldDefinition.scale;
224219

225220
return FIT.FloatingPointFieldTypes.includes(fieldDefinition.type) ? scaledValue : Math.round(scaledValue);
226221
}

src/fit.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -172,6 +172,8 @@ export default {
172172
isNumberStringDateOrBoolean,
173173
isNotNumberStringDateOrBoolean,
174174
MAX_FIELD_SIZE: 255,
175+
FIELD_DEFAULT_SCALE: 1,
176+
FIELD_DEFAULT_OFFSET: 0,
175177
MESG_DEFINITION_MASK: 0x40,
176178
LOCAL_MESG_NUM_MASK: 0x0F,
177179
ARCH_LITTLE_ENDIAN: 0x00,

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/mesg-definition.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.171.0Release
9-
// Tag = production/release/21.171.0-0-g57fed75
8+
// Profile Version = 21.178.0Release
9+
// Tag = production/release/21.178.0-0-g3bea629
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -56,14 +56,20 @@ class MesgDefinition {
5656
const baseType = FIT.FieldTypeToBaseType[fieldProfile[1].baseType];
5757
const baseTypeDef = FIT.BaseTypeDefinitions[baseType];
5858

59+
let scale = fieldProfile[1].components.length > 1 ? FIT.FIELD_DEFAULT_SCALE : fieldProfile[1].scale;
60+
let offset = fieldProfile[1].components.length > 1 ? FIT.FIELD_DEFAULT_OFFSET : fieldProfile[1].offset;
61+
62+
scale = Array.isArray(scale) ? scale[0] : scale ?? FIT.FIELD_DEFAULT_SCALE;
63+
offset = Array.isArray(offset) ? offset[0] : offset ?? FIT.FIELD_DEFAULT_OFFSET;
64+
5965
this.fieldDefinitions.push({
6066
name: fieldName,
6167
num: fieldProfile[1].num,
6268
size: this.#fieldSize(mesg[fieldName], baseTypeDef),
6369
baseType: baseType,
6470
type: fieldProfile[1].type,
65-
scale: fieldProfile[1].scale,
66-
offset: fieldProfile[1].offset,
71+
scale,
72+
offset,
6773
components: fieldProfile[1].components,
6874
});
6975
});

0 commit comments

Comments
 (0)