@garmin/fitsdk 21.161.0 → 21.169.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/accumulator.js +2 -2
- package/src/bit-stream.js +2 -2
- package/src/crc-calculator.js +2 -2
- package/src/decoder.js +12 -3
- package/src/encoder.js +4 -4
- package/src/fit.js +2 -2
- package/src/index.js +2 -2
- package/src/mesg-definition.js +7 -6
- package/src/output-stream.js +2 -2
- package/src/profile.js +749 -4
- package/src/stream.js +2 -2
- package/src/utils-hr-mesg.js +2 -2
- package/src/utils-internal.js +20 -2
- package/src/utils-memo-glob.js +65 -0
- package/src/utils.js +2 -2
package/src/stream.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Transfer (FIT) Protocol License.
|
|
6
6
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
-
// Profile Version = 21.
|
|
9
|
-
// Tag = production/release/21.
|
|
8
|
+
// Profile Version = 21.169.0Release
|
|
9
|
+
// Tag = production/release/21.169.0-0-g7105132
|
|
10
10
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
|
|
12
12
|
|
package/src/utils-hr-mesg.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Transfer (FIT) Protocol License.
|
|
6
6
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
-
// Profile Version = 21.
|
|
9
|
-
// Tag = production/release/21.
|
|
8
|
+
// Profile Version = 21.169.0Release
|
|
9
|
+
// Tag = production/release/21.169.0-0-g7105132
|
|
10
10
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
|
|
12
12
|
|
package/src/utils-internal.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Transfer (FIT) Protocol License.
|
|
6
6
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
-
// Profile Version = 21.
|
|
9
|
-
// Tag = production/release/21.
|
|
8
|
+
// Profile Version = 21.169.0Release
|
|
9
|
+
// Tag = production/release/21.169.0-0-g7105132
|
|
10
10
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
|
|
12
12
|
|
|
@@ -18,6 +18,23 @@ const sanitizeValues = (values) => {
|
|
|
18
18
|
return values.length === 1 ? values[0] : values;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const trimStringTrailingNulls = (string) => {
|
|
22
|
+
if (string == null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let strings = string.split("\u0000")
|
|
27
|
+
|
|
28
|
+
while (strings[strings.length - 1] === "") {
|
|
29
|
+
strings.pop();
|
|
30
|
+
if (strings.length === 0) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return strings.length === 1 ? strings[0] : strings;
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
const onlyNullValues = (values) => values.reduce((state, value) => value != null ? false : state, true);
|
|
22
39
|
|
|
23
40
|
const onlyInvalidValues = (rawFieldValue, invalidValue) => {
|
|
@@ -30,6 +47,7 @@ const onlyInvalidValues = (rawFieldValue, invalidValue) => {
|
|
|
30
47
|
|
|
31
48
|
export default {
|
|
32
49
|
sanitizeValues,
|
|
50
|
+
trimStringTrailingNulls,
|
|
33
51
|
onlyNullValues,
|
|
34
52
|
onlyInvalidValues
|
|
35
53
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright 2025 Garmin International, Inc.
|
|
3
|
+
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
|
|
4
|
+
// may not use this file except in compliance with the Flexible and Interoperable Data
|
|
5
|
+
// Transfer (FIT) Protocol License.
|
|
6
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
+
// Profile Version = 21.169.0Release
|
|
9
|
+
// Tag = production/release/21.169.0-0-g7105132
|
|
10
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
import Profile from "./profile.js";
|
|
13
|
+
|
|
14
|
+
const decodeMemoGlobs = (messages) => {
|
|
15
|
+
if ((messages?.memoGlobMesgs?.length ?? 0) == 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const memoGlobMesgs = messages.memoGlobMesgs;
|
|
20
|
+
|
|
21
|
+
// Group memoGlob mesgs by mesgNum, parentIndex, and fieldNum
|
|
22
|
+
const groupedMemoGlobs = Object.groupBy(memoGlobMesgs, ({ mesgNum, parentIndex, fieldNum }) => {
|
|
23
|
+
return JSON.stringify({
|
|
24
|
+
mesgNum,
|
|
25
|
+
parentIndex,
|
|
26
|
+
fieldNum
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Object.entries(groupedMemoGlobs).forEach(([key, memoGlobMesgs]) => {
|
|
31
|
+
const { mesgNum, parentIndex, fieldNum } = JSON.parse(key);
|
|
32
|
+
|
|
33
|
+
// Sort grouped memoGlob messages by part index
|
|
34
|
+
memoGlobMesgs.sort((a, b) => a.partIndex - b.partIndex);
|
|
35
|
+
|
|
36
|
+
const mesgProfile = Object.values(Profile.messages).find((mesgDefinition) => {
|
|
37
|
+
return mesgDefinition.name == mesgNum || mesgDefinition.num == mesgNum
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const targetMesg = messages[mesgProfile?.messagesKey ?? mesgNum]?.[parentIndex];
|
|
41
|
+
if (targetMesg == null) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const targetFieldKey = mesgProfile?.fields?.[fieldNum]?.name ?? fieldNum;
|
|
46
|
+
|
|
47
|
+
const memoGlobBytes = memoGlobMesgs.reduce((accumluatedBytes, mesg) => {
|
|
48
|
+
return accumluatedBytes.concat(mesg.data);
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
targetMesg[targetFieldKey] = decodeMemoGlobBytesToUtf8(memoGlobBytes);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const decodeMemoGlobBytesToUtf8 = (memoGlobBytes) => {
|
|
56
|
+
let decoder = new TextDecoder('utf-8');
|
|
57
|
+
let bytes = new Uint8Array(memoGlobBytes);
|
|
58
|
+
|
|
59
|
+
return decoder.decode(bytes);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
decodeMemoGlobs,
|
|
64
|
+
decodeMemoGlobBytesToUtf8
|
|
65
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Transfer (FIT) Protocol License.
|
|
6
6
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
-
// Profile Version = 21.
|
|
9
|
-
// Tag = production/release/21.
|
|
8
|
+
// Profile Version = 21.169.0Release
|
|
9
|
+
// Tag = production/release/21.169.0-0-g7105132
|
|
10
10
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
11
|
|
|
12
12
|
|