@garmin/fitsdk 21.170.0 → 21.171.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/README.md CHANGED
@@ -9,7 +9,8 @@ The FIT JavaScript SDK uses ECMAScript module syntax and requires Node.js v14.0
9
9
  ```sh
10
10
  npm install @garmin/fitsdk
11
11
  ```
12
- ## Usage
12
+ ## Decoder
13
+ ### Usage
13
14
  ````js
14
15
  import { Decoder, Stream, Profile, Utils } from '@garmin/fitsdk';
15
16
 
@@ -27,8 +28,6 @@ const { messages, errors } = decoder.read();
27
28
  console.log(errors);
28
29
  console.log(messages);
29
30
  ````
30
- ## Decoder
31
-
32
31
  ### Constructor
33
32
 
34
33
  Decoder objects are created from Streams representing the binary FIT file data to be decoded. See [Creating Streams](#creatingstreams) for more information on constructing Stream objects.
@@ -37,16 +36,16 @@ Once a Decoder object is created it can be used to check that the Stream is a FI
37
36
 
38
37
  ### isFIT Method
39
38
 
40
- All valid FIT files should include a 12 or 14 byte file header. The 14 byte header is the preferred header size and the most common size used. Bytes 8–11 of the header contain the ASCII values ".FIT”. This string can easily be spotted when opening a binary FIT file in a text or hex editor.
39
+ All valid FIT files should include a 12 or 14 byte file header. The 14 byte header is the preferred header size and the most common size used. Bytes 8–11 of the header contain the ASCII values ".FIT". This string can easily be spotted when opening a binary FIT file in a text or hex editor.
41
40
 
42
- ```
41
+ ````bash
43
42
  Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
44
43
  00000000: 0E 10 43 08 78 06 09 00 2E 46 49 54 96 85 40 00 ..C.x....FIT..@.
45
44
  00000010: 00 00 00 07 03 04 8C 04 04 86 07 04 86 01 02 84 ................
46
45
  00000020: 02 02 84 05 02 84 00 01 00 00 19 28 7E C5 95 B0 ...........(~E.0
47
- ```
46
+ ````
48
47
 
49
- The isFIT method reads the file header and returns true if bytes 8–11 are equal to the ACSII values ".FIT”. isFIT provides a quick way to check that the file is a FIT file before attempting to decode the file.
48
+ The isFIT method reads the file header and returns true if bytes 8–11 are equal to the ACSII values ".FIT". isFIT provides a quick way to check that the file is a FIT file before attempting to decode the file.
50
49
 
51
50
  The Decoder class includes a static and instance version of the isFIT method.
52
51
 
@@ -54,7 +53,7 @@ The Decoder class includes a static and instance version of the isFIT method.
54
53
 
55
54
  The checkIntegrity method performs three checks on a FIT file:
56
55
 
57
- 1. Checks that bytes 8–11 of the header contain the ASCII values ".FIT”.
56
+ 1. Checks that bytes 8–11 of the header contain the ASCII values ".FIT".
58
57
  2. Checks that the total file size is equal to Header Size + Data Size + CRC Size.
59
58
  3. Reads the contents of the file, computes the CRC, and then checks that the computed CRC matches the file CRC.
60
59
 
@@ -83,7 +82,6 @@ const { messages, errors } = decoder.read({
83
82
  Optional callback function that can be used to inspect or manipulate messages after they are fully decoded and all the options have been applied. The message is mutable and we be returned from the Read method in the messages dictionary.
84
83
 
85
84
  Example mesgListener callback that tracks the field names across all Record messages.
86
-
87
85
  ````js
88
86
  const recordFields = new Set();
89
87
 
@@ -221,3 +219,65 @@ A convince method for converting FIT Epoch values to JavaScript Date objects.
221
219
  ````js
222
220
  const jsDate = Utils.convertDateTimeToDate(fitDateTime);
223
221
  ````
222
+ ## Encoder
223
+ ### Usage
224
+ ````js
225
+ // Import the SDK
226
+ import { Encoder, Profile} from "@garmin/fitsdk";
227
+
228
+ // Create an Encoder
229
+ const encoder = new Encoder();
230
+
231
+ //
232
+ // Write messages to the output-stream
233
+ //
234
+ // The message data should match the format returned by
235
+ // the Decoder. Field names should be camelCase. The fields
236
+ // definitions can be found in the Profile.
237
+ //
238
+
239
+ // Pass the MesgNum and message data as separate parameters to the onMesg() method
240
+ encoder.onMesg(Profile.MesgNum.FILE_ID, {
241
+ manufacturer: "development",
242
+ product: 1,
243
+ timeCreated: new Date(),
244
+ type: "activity",
245
+ });
246
+
247
+ // The writeMesg() method expects the mesgNum to be included in the message data
248
+ // Internally, writeMesg() calls onMesg()
249
+ encoder.writeMesg({
250
+ mesgNum: Profile.MesgNum.FILE_ID,
251
+ manufacturer: "development",
252
+ product: 1,
253
+ timeCreated: new Date(),
254
+ type: "activity",
255
+ });
256
+
257
+ // Unknown values in the message will be ignored by the Encoder
258
+ encoder.onMesg(Profile.MesgNum.FILE_ID, {
259
+ manufacturer: "development",
260
+ product: 1,
261
+ timeCreated: new Date(),
262
+ type: "activity",
263
+ customField: 12345, // This value will be ignored by the Encoder
264
+ });
265
+
266
+ // Subfield values in the message will be ignored by the Encoder
267
+ encoder.onMesg(Profile.MesgNum.FILE_ID, {
268
+ manufacturer: "development",
269
+ product: 4440, // This is the main product field, which is a uint16
270
+ garminProduct: "edge1050", // This value will be ignored by the Encoder, use the main field value instead
271
+ timeCreated: new Date(),
272
+ type: "activity",
273
+ });
274
+
275
+ // Closing the encoder returns the file as an UInt8 Array
276
+ const uint8Array = encoder.close();
277
+
278
+ // Write the file to disk,
279
+ import * as fs from "fs";
280
+ fs.writeFileSync("example.fit", uint8Array);
281
+
282
+ ````
283
+ See the [Encode Activity Recipe](https://github.com/garmin/fit-javascript-sdk/blob/main/test/encode-activity-recipe.test.js) for a complete example of encoding a FIT Activity file usine the FIT JavaScript SDK.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garmin/fitsdk",
3
- "version": "21.170.0",
3
+ "version": "21.171.0",
4
4
  "description": "FIT JavaScript SDK",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/bit-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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/decoder.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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/encoder.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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/fit.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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/index.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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/profile.js CHANGED
@@ -5,15 +5,15 @@
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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
13
13
  const Profile = {
14
14
  version: {
15
15
  major: 21,
16
- minor: 170,
16
+ minor: 171,
17
17
  patch: 0,
18
18
  type: "Release"
19
19
  },
@@ -24716,6 +24716,8 @@ types: {
24716
24716
  4586: "instinct3Amoled45mm",
24717
24717
  4587: "instinct3Amoled50mm",
24718
24718
  4588: "descentG2",
24719
+ 4606: "hrm200",
24720
+ 4625: "vivoactive6",
24719
24721
  4647: "approachS44",
24720
24722
  4656: "approachS50",
24721
24723
  4666: "fenixE",
@@ -24843,6 +24845,8 @@ types: {
24843
24845
  4: "drill",
24844
24846
  5: "mixed",
24845
24847
  6: "im", // IM is a mixed interval containing the same number of lengths for each of: Butterfly, Backstroke, Breaststroke, Freestyle, swam in that order.
24848
+ 7: "imByRound", // For repeated workout steps, a new individual medly stroke is used for each round.
24849
+ 8: "rimo", // Reverse IM Order
24846
24850
  },
24847
24851
  activityType: {
24848
24852
  0: "generic",
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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
  import Profile from "./profile.js";
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.170.0Release
9
- // Tag = production/release/21.170.0-0-g5991e72
8
+ // Profile Version = 21.171.0Release
9
+ // Tag = production/release/21.171.0-0-g57fed75
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12