@hangtime/grip-connect 0.6.1 → 0.7.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.
Files changed (60) hide show
  1. package/README.md +3 -3
  2. package/deno.json +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +1 -1
  5. package/dist/interfaces/command.interface.d.ts +6 -0
  6. package/dist/interfaces/device/climbro.interface.d.ts +1 -1
  7. package/dist/interfaces/device/entralpi.interface.d.ts +1 -1
  8. package/dist/interfaces/device/forceboard.interface.d.ts +30 -4
  9. package/dist/interfaces/device/kilterboard.interface.d.ts +1 -1
  10. package/dist/interfaces/device/motherboard.interface.d.ts +1 -1
  11. package/dist/interfaces/device/mysmartboard.interface.d.ts +1 -1
  12. package/dist/interfaces/device/progressor.interface.d.ts +1 -1
  13. package/dist/interfaces/device/wh-c06.interface.d.ts +1 -1
  14. package/dist/interfaces/device.interface.d.ts +3 -3
  15. package/dist/interfaces/index.d.ts +8 -8
  16. package/dist/models/base.model.d.ts +1 -1
  17. package/dist/models/device/climbro.model.d.ts +2 -2
  18. package/dist/models/device/climbro.model.js +1 -1
  19. package/dist/models/device/entralpi.model.d.ts +2 -2
  20. package/dist/models/device/entralpi.model.js +1 -1
  21. package/dist/models/device/forceboard.model.d.ts +29 -5
  22. package/dist/models/device/forceboard.model.js +95 -52
  23. package/dist/models/device/kilterboard.model.d.ts +3 -3
  24. package/dist/models/device/kilterboard.model.js +2 -2
  25. package/dist/models/device/motherboard.model.d.ts +2 -2
  26. package/dist/models/device/motherboard.model.js +1 -1
  27. package/dist/models/device/mysmartboard.model.d.ts +2 -2
  28. package/dist/models/device/mysmartboard.model.js +1 -1
  29. package/dist/models/device/progressor.model.d.ts +2 -2
  30. package/dist/models/device/progressor.model.js +1 -1
  31. package/dist/models/device/wh-c06.model.d.ts +2 -2
  32. package/dist/models/device/wh-c06.model.js +1 -1
  33. package/dist/models/device.model.d.ts +13 -23
  34. package/dist/models/device.model.js +51 -64
  35. package/dist/models/index.d.ts +8 -8
  36. package/dist/models/index.js +8 -8
  37. package/package.json +3 -3
  38. package/src/index.ts +2 -2
  39. package/src/interfaces/command.interface.ts +9 -0
  40. package/src/interfaces/device/climbro.interface.ts +1 -1
  41. package/src/interfaces/device/entralpi.interface.ts +1 -1
  42. package/src/interfaces/device/forceboard.interface.ts +34 -4
  43. package/src/interfaces/device/kilterboard.interface.ts +1 -1
  44. package/src/interfaces/device/motherboard.interface.ts +1 -1
  45. package/src/interfaces/device/mysmartboard.interface.ts +1 -1
  46. package/src/interfaces/device/progressor.interface.ts +1 -1
  47. package/src/interfaces/device/wh-c06.interface.ts +1 -1
  48. package/src/interfaces/device.interface.ts +3 -3
  49. package/src/interfaces/index.ts +8 -8
  50. package/src/models/base.model.ts +1 -1
  51. package/src/models/device/climbro.model.ts +2 -2
  52. package/src/models/device/entralpi.model.ts +2 -2
  53. package/src/models/device/forceboard.model.ts +104 -53
  54. package/src/models/device/kilterboard.model.ts +3 -3
  55. package/src/models/device/motherboard.model.ts +3 -3
  56. package/src/models/device/mysmartboard.model.ts +2 -2
  57. package/src/models/device/progressor.model.ts +2 -2
  58. package/src/models/device/wh-c06.model.ts +2 -2
  59. package/src/models/device.model.ts +60 -77
  60. package/src/models/index.ts +8 -8
package/README.md CHANGED
@@ -35,9 +35,8 @@ Learn more: [Documentation](https://stevie-ray.github.io/hangtime-grip-connect/)
35
35
 
36
36
  ## Install
37
37
 
38
- This package is compatible with both Node.js and browser environments. It can be found in the
39
- [NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and [JSR](https://jsr.io/@hangtime/grip-connect) package
40
- registries.
38
+ This package works with Node.js, Bun, Deno, and the web, and is available on both
39
+ [NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and [JSR](https://jsr.io/@hangtime/grip-connect).
41
40
 
42
41
  ```sh [npm]
43
42
  $ npm install @hangtime/grip-connect
@@ -156,6 +155,7 @@ A special thank you to:
156
155
  - [@ecstrema](https://github.com/ecstrema) for providing [examples](https://github.com/ecstrema/entralpi-games) on how
157
156
  to play games with the Entralpi.
158
157
  - [Tindeq](https://tindeq.com/) for providing an open [Progressor API](https://tindeq.com/progressor_api/).
158
+ - [PitchSix](https://pitchsix.com/) for the [Force Board Portable Public API](https://pitchsix.com/pages/downloads).
159
159
  - [@StuartLittlefair](https://github.com/StuartLittlefair) for his
160
160
  [PyTindeq](https://github.com/StuartLittlefair/PyTindeq) implementation.
161
161
  - [@Phil9l](https://github.com/phil9l) for his research and providing a [blog](https://bazun.me/blog/kiterboard/) on how
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hangtime/grip-connect",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { IClimbro, IEntralpi, IForceBoard, IKilterBoard, IMotherboard, ImySmartBoard, IProgressor, IWHC06, } from "./interfaces/index.js";
2
- export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index.js";
1
+ export type { IClimbro, IEntralpi, IForceBoard, IKilterBoard, IMotherboard, ImySmartBoard, IProgressor, IWHC06, } from "./interfaces/index";
2
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index.js";
1
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index";
@@ -37,6 +37,12 @@ export interface Commands {
37
37
  * Used to ensure accurate measurements by applying calibration points.
38
38
  */
39
39
  GET_CALIBRATION?: string;
40
+ /**
41
+ * Sets the Force Board into Quick Start mode.
42
+ * In this mode, data transmission starts when force exceeds the threshold
43
+ * and stops when force drops below the threshold.
44
+ */
45
+ START_QUICK_MEAS?: string;
40
46
  /**
41
47
  * Tares the scale, zeroing the current weight measurement.
42
48
  * Used to reset the baseline for weight data.
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Climbro device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Entralpi device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the PitchSix ForceBoard device, extending the base Device interface.
4
4
  */
@@ -19,19 +19,45 @@ export interface IForceBoard extends IDevice {
19
19
  */
20
20
  manufacturer(): Promise<string | undefined>;
21
21
  /**
22
- * Stops the data stream on the specified device.
22
+ * Stops the data stream on the specified device by setting it to Idle mode.
23
+ * Writes 0x07 to the Device Mode characteristic.
23
24
  * @returns {Promise<void>} A promise that resolves when the stream is stopped.
24
25
  */
25
26
  stop(): Promise<void>;
26
27
  /**
27
- * Starts streaming data from the specified device.
28
+ * Starts streaming data from the specified device in Streaming Data Mode.
29
+ * Writes 0x04 to the Device Mode characteristic.
28
30
  * @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
29
31
  * @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
30
32
  */
31
33
  stream(duration?: number): Promise<void>;
34
+ /**
35
+ * Tares the Force Board device using a characteristic to zero out the current load value.
36
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
37
+ */
38
+ tareByCharacteristic(): Promise<void>;
39
+ /**
40
+ * Tares the Force Board device using the Device Mode characteristic.
41
+ * Writes 0x05 to the Device Mode characteristic to zero out the current load value.
42
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
43
+ */
44
+ tareByMode(): Promise<void>;
45
+ /**
46
+ * Sets the threshold for the Quick Start mode.
47
+ * @param {number} thresholdLbs - The threshold value in pounds.
48
+ * @returns {Promise<void>} A promise that resolves when the threshold is set.
49
+ */
50
+ threshold(thresholdLbs: number): Promise<void>;
32
51
  /**
33
52
  * Retrieves temperature information from the device.
34
- * @returns {Promise<string | undefined>} A Promise that resolves with the humidity level.
53
+ * @returns {Promise<string | undefined>} A Promise that resolves with the temperature information.
35
54
  */
36
55
  temperature(): Promise<string | undefined>;
56
+ /**
57
+ * Starts the Force Board in Quick Start mode.
58
+ * Writes 0x06 to the Device Mode characteristic.
59
+ * @param {number} [duration=0] - The duration in milliseconds. If set to 0, mode will continue indefinitely.
60
+ * @returns {Promise<void>} A promise that resolves when the operation is completed.
61
+ */
62
+ quick(duration?: number): Promise<void>;
37
63
  }
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the KilterBoard device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Griptonite Motherboard device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Smartboard Climbing mySmartBoard device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Tindeq Progressor device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface.js";
1
+ import type { IDevice } from "../device.interface";
2
2
  /**
3
3
  * Interface representing the Weiheng WH-C06 device, extending the base Device interface.
4
4
  */
@@ -1,6 +1,6 @@
1
- import type { IBase } from "./base.interface.js";
2
- import type { massObject } from "./callback.interface.js";
3
- import type { Commands } from "./command.interface.js";
1
+ import type { IBase } from "./base.interface";
2
+ import type { massObject } from "./callback.interface";
3
+ import type { Commands } from "./command.interface";
4
4
  /**
5
5
  * Represents a characteristic of a Bluetooth service.
6
6
  */
@@ -1,8 +1,8 @@
1
- export type { IClimbro } from "./device/climbro.interface.js";
2
- export type { IEntralpi } from "./device/entralpi.interface.js";
3
- export type { IForceBoard } from "./device/forceboard.interface.js";
4
- export type { IKilterBoard } from "./device/kilterboard.interface.js";
5
- export type { IMotherboard } from "./device/motherboard.interface.js";
6
- export type { ImySmartBoard } from "./device/mysmartboard.interface.js";
7
- export type { IProgressor } from "./device/progressor.interface.js";
8
- export type { IWHC06 } from "./device/wh-c06.interface.js";
1
+ export type { IClimbro } from "./device/climbro.interface";
2
+ export type { IEntralpi } from "./device/entralpi.interface";
3
+ export type { IForceBoard } from "./device/forceboard.interface";
4
+ export type { IKilterBoard } from "./device/kilterboard.interface";
5
+ export type { IMotherboard } from "./device/motherboard.interface";
6
+ export type { ImySmartBoard } from "./device/mysmartboard.interface";
7
+ export type { IProgressor } from "./device/progressor.interface";
8
+ export type { IWHC06 } from "./device/wh-c06.interface";
@@ -1,4 +1,4 @@
1
- import type { IBase } from "../interfaces/base.interface.js";
1
+ import type { IBase } from "../interfaces/base.interface";
2
2
  export declare abstract class BaseModel {
3
3
  id?: string;
4
4
  createdAt?: Date;
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IClimbro } from "../../interfaces/device/climbro.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IClimbro } from "../../interfaces/device/climbro.interface";
3
3
  /**
4
4
  * Represents a Climbro device.
5
5
  * TODO: Add services, do you own a Climbro? Help us!
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a Climbro device.
4
4
  * TODO: Add services, do you own a Climbro? Help us!
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IEntralpi } from "../../interfaces/device/entralpi.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IEntralpi } from "../../interfaces/device/entralpi.interface";
3
3
  /**
4
4
  * Represents a Entralpi device.
5
5
  * {@link https://entralpi.com}
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a Entralpi device.
4
4
  * {@link https://entralpi.com}
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IForceBoard } from "../../interfaces/device/forceboard.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IForceBoard } from "../../interfaces/device/forceboard.interface";
3
3
  /**
4
4
  * Represents a PitchSix Force Board device.
5
5
  * {@link https://pitchsix.com}
@@ -30,19 +30,43 @@ export declare class ForceBoard extends Device implements IForceBoard {
30
30
  */
31
31
  manufacturer: () => Promise<string | undefined>;
32
32
  /**
33
- * Stops the data stream on the specified device.
33
+ * Stops the data stream on the specified device by setting it to Idle mode.
34
34
  * @returns {Promise<void>} A promise that resolves when the stream is stopped.
35
35
  */
36
36
  stop: () => Promise<void>;
37
37
  /**
38
- * Starts streaming data from the specified device.
38
+ * Starts streaming data from the specified device in Streaming Data Mode.
39
39
  * @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
40
40
  * @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
41
41
  */
42
42
  stream: (duration?: number) => Promise<void>;
43
+ /**
44
+ * Sets the threshold in Lbs for the Quick Start mode.
45
+ * @param {number} thresholdLbs - The threshold value in pounds.
46
+ * @returns {Promise<void>} A promise that resolves when the threshold is set.
47
+ */
48
+ threshold: (thresholdLbs: number) => Promise<void>;
49
+ /**
50
+ * Tares the Force Board device using a characteristic to zero out the current load value.
51
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
52
+ */
53
+ tareByCharacteristic: () => Promise<void>;
54
+ /**
55
+ * Initiates a tare routine via the Device Mode characteristic.
56
+ * Writes 0x05 to the Device Mode characteristic to zero out the current load value.
57
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
58
+ */
59
+ tareByMode: () => Promise<void>;
43
60
  /**
44
61
  * Retrieves temperature information from the device.
45
- * @returns {Promise<string>} A Promise that resolves with the manufacturer information,
62
+ * @returns {Promise<string>} A Promise that resolves with the temperature information,
46
63
  */
47
64
  temperature: () => Promise<string | undefined>;
65
+ /**
66
+ * Starts the Force Board in Quick Start mode.
67
+ * Writes 0x06 to the Device Mode characteristic.
68
+ * @param {number} [duration=0] - The duration in milliseconds. If set to 0, mode will continue indefinitely.
69
+ * @returns {Promise<void>} A promise that resolves when the operation is completed.
70
+ */
71
+ quick: (duration?: number) => Promise<void>;
48
72
  }
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a PitchSix Force Board device.
4
4
  * {@link https://pitchsix.com}
@@ -106,13 +106,13 @@ export class ForceBoard extends Device {
106
106
  uuid: "9a88d681-8df2-4afe-9e0d-c2bbbe773dd0",
107
107
  },
108
108
  {
109
- name: "Read + Notify",
109
+ name: "Force Data",
110
110
  id: "rx",
111
111
  uuid: "9a88d682-8df2-4afe-9e0d-c2bbbe773dd0",
112
112
  },
113
113
  {
114
- name: "Write",
115
- id: "",
114
+ name: "Tare",
115
+ id: "tare",
116
116
  uuid: "9a88d683-8df2-4afe-9e0d-c2bbbe773dd0",
117
117
  },
118
118
  {
@@ -121,8 +121,8 @@ export class ForceBoard extends Device {
121
121
  uuid: "9a88d685-8df2-4afe-9e0d-c2bbbe773dd0",
122
122
  },
123
123
  {
124
- name: "Write",
125
- id: "",
124
+ name: "Threshold",
125
+ id: "threshold",
126
126
  uuid: "9a88d686-8df2-4afe-9e0d-c2bbbe773dd0",
127
127
  },
128
128
  {
@@ -143,12 +143,12 @@ export class ForceBoard extends Device {
143
143
  ],
144
144
  },
145
145
  {
146
- name: "Weight Serivce",
146
+ name: "Weight Service",
147
147
  id: "weight",
148
148
  uuid: "467a8516-6e39-11eb-9439-0242ac130002",
149
149
  characteristics: [
150
150
  {
151
- name: "Read + Write",
151
+ name: "Device Mode",
152
152
  id: "tx",
153
153
  uuid: "467a8517-6e39-11eb-9439-0242ac130002",
154
154
  },
@@ -161,7 +161,10 @@ export class ForceBoard extends Device {
161
161
  },
162
162
  ],
163
163
  commands: {
164
- STOP_WEIGHT_MEAS: "",
164
+ START_WEIGHT_MEAS: String.fromCharCode(0x04), // Streaming Data Mode: continuously streams force data.
165
+ TARE_SCALE: String.fromCharCode(0x05), // Tare function: zeroes out the current load value
166
+ START_QUICK_MEAS: String.fromCharCode(0x06), // Quick Start Mode: Starts data transmission when a force value exceeds the Threshold and stops data transmission when the force data drops below the Threshold.
167
+ STOP_WEIGHT_MEAS: String.fromCharCode(0x07), // Idle Mode: Force Board is idle.
165
168
  },
166
169
  });
167
170
  }
@@ -187,38 +190,43 @@ export class ForceBoard extends Device {
187
190
  if (value.buffer) {
188
191
  const receivedTime = Date.now();
189
192
  const dataArray = new Uint8Array(value.buffer);
190
- // Skip the first 2 bytes, which are the command and length
191
- // The data is sent in groups of 3 bytes
192
- for (let i = 2; i < dataArray.length; i += 3) {
193
- const receivedData = (dataArray[i] << 16) | (dataArray[i + 1] << 8) | dataArray[i + 2];
194
- // Convert from LBS to KG
195
- const convertedReceivedData = receivedData * 0.453592;
196
- // Tare correction
197
- const numericData = convertedReceivedData - this.applyTare(convertedReceivedData);
198
- // Add data to downloadable Array
199
- this.downloadPackets.push({
200
- received: receivedTime,
201
- sampleNum: this.dataPointCount,
202
- battRaw: 0,
203
- samples: [convertedReceivedData],
204
- masses: [numericData],
205
- });
206
- // Update massMax
207
- this.massMax = Math.max(Number(this.massMax), numericData).toFixed(1);
208
- // Update running sum and count
209
- const currentMassTotal = Math.max(-1000, numericData);
210
- this.massTotalSum += currentMassTotal;
211
- this.dataPointCount++;
212
- // Calculate the average dynamically
213
- this.massAverage = (this.massTotalSum / this.dataPointCount).toFixed(1);
214
- // Check if device is being used
215
- this.activityCheck(numericData);
216
- // Notify with weight data
217
- this.notifyCallback({
218
- massMax: this.massMax,
219
- massAverage: this.massAverage,
220
- massTotal: Math.max(-1000, numericData).toFixed(1),
221
- });
193
+ // First two bytes contain the number of samples in the packet
194
+ const numSamples = (dataArray[0] << 8) | dataArray[1];
195
+ // Process each sample (3 bytes per sample)
196
+ for (let i = 0; i < numSamples; i++) {
197
+ const offset = 2 + i * 3; // Skip the first 2 bytes which indicate number of samples
198
+ if (offset + 2 < dataArray.length) {
199
+ // Sample = byte1*32768 + byte2*256 + byte3
200
+ const receivedData = dataArray[offset] * 32768 + dataArray[offset + 1] * 256 + dataArray[offset + 2];
201
+ // Convert from LBS to KG
202
+ const convertedReceivedData = receivedData * 0.453592;
203
+ // Tare correction
204
+ const numericData = convertedReceivedData - this.applyTare(convertedReceivedData);
205
+ // Add data to downloadable Array
206
+ this.downloadPackets.push({
207
+ received: receivedTime,
208
+ sampleNum: this.dataPointCount,
209
+ battRaw: 0,
210
+ samples: [convertedReceivedData],
211
+ masses: [numericData],
212
+ });
213
+ // Update massMax
214
+ this.massMax = Math.max(Number(this.massMax), numericData).toFixed(1);
215
+ // Update running sum and count
216
+ const currentMassTotal = Math.max(-1000, numericData);
217
+ this.massTotalSum += currentMassTotal;
218
+ this.dataPointCount++;
219
+ // Calculate the average dynamically
220
+ this.massAverage = (this.massTotalSum / this.dataPointCount).toFixed(1);
221
+ // Check if device is being used
222
+ this.activityCheck(numericData);
223
+ // Notify with weight data
224
+ this.notifyCallback({
225
+ massMax: this.massMax,
226
+ massAverage: this.massAverage,
227
+ massTotal: Math.max(-1000, numericData).toFixed(1),
228
+ });
229
+ }
222
230
  }
223
231
  }
224
232
  }
@@ -238,32 +246,67 @@ export class ForceBoard extends Device {
238
246
  return await this.read("device", "manufacturer", 250);
239
247
  };
240
248
  /**
241
- * Stops the data stream on the specified device.
249
+ * Stops the data stream on the specified device by setting it to Idle mode.
242
250
  * @returns {Promise<void>} A promise that resolves when the stream is stopped.
243
251
  */
244
252
  stop = async () => {
245
253
  await this.write("weight", "tx", this.commands.STOP_WEIGHT_MEAS, 0);
246
254
  };
247
255
  /**
248
- * Starts streaming data from the specified device.
256
+ * Starts streaming data from the specified device in Streaming Data Mode.
249
257
  * @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
250
258
  * @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
251
259
  */
252
260
  stream = async (duration = 0) => {
253
- // Reset download packets
254
- this.downloadPackets.length = 0;
255
- // Start streaming data
256
- await this.write("weight", "tx", new Uint8Array([0x04]), duration); // ASCII control character EOT (End of Transmission)
257
- // Stop streaming if duration is set
258
- if (duration !== 0) {
259
- await this.stop();
260
- }
261
+ // Start streaming data - Streaming Data Mode
262
+ await this.write("weight", "tx", this.commands.START_WEIGHT_MEAS, duration);
263
+ };
264
+ /**
265
+ * Sets the threshold in Lbs for the Quick Start mode.
266
+ * @param {number} thresholdLbs - The threshold value in pounds.
267
+ * @returns {Promise<void>} A promise that resolves when the threshold is set.
268
+ */
269
+ threshold = async (thresholdLbs) => {
270
+ const thresholdHex = thresholdLbs.toString(16).padStart(6, "0");
271
+ // 3-byte array from the hex string
272
+ const bytes = new Uint8Array(3);
273
+ bytes[0] = parseInt(thresholdHex.substring(0, 2), 16);
274
+ bytes[1] = parseInt(thresholdHex.substring(2, 4), 16);
275
+ bytes[2] = parseInt(thresholdHex.substring(4, 6), 16);
276
+ await this.write("forceboard", "threshold", String.fromCharCode(...bytes), 0);
277
+ };
278
+ /**
279
+ * Tares the Force Board device using a characteristic to zero out the current load value.
280
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
281
+ */
282
+ tareByCharacteristic = async () => {
283
+ // Send tare command (0x01) to the tare characteristic
284
+ const tareValue = String.fromCharCode(0x01);
285
+ await this.write("forceboard", "tare", tareValue, 0);
286
+ };
287
+ /**
288
+ * Initiates a tare routine via the Device Mode characteristic.
289
+ * Writes 0x05 to the Device Mode characteristic to zero out the current load value.
290
+ * @returns {Promise<void>} A promise that resolves when the tare operation is completed.
291
+ */
292
+ tareByMode = async () => {
293
+ await this.write("weight", "tx", this.commands.TARE_SCALE, 0);
261
294
  };
262
295
  /**
263
296
  * Retrieves temperature information from the device.
264
- * @returns {Promise<string>} A Promise that resolves with the manufacturer information,
297
+ * @returns {Promise<string>} A Promise that resolves with the temperature information,
265
298
  */
266
299
  temperature = async () => {
267
300
  return await this.read("temperature", "level", 250);
268
301
  };
302
+ /**
303
+ * Starts the Force Board in Quick Start mode.
304
+ * Writes 0x06 to the Device Mode characteristic.
305
+ * @param {number} [duration=0] - The duration in milliseconds. If set to 0, mode will continue indefinitely.
306
+ * @returns {Promise<void>} A promise that resolves when the operation is completed.
307
+ */
308
+ quick = async (duration = 0) => {
309
+ // Start in Quick Start mode
310
+ await this.write("weight", "tx", this.commands.START_QUICK_MEAS, duration);
311
+ };
269
312
  }
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface";
3
3
  /**
4
4
  * For API level 2 and API level 3.
5
5
  * The first byte in the data is dependent on where the packet is in the message as a whole.
@@ -113,7 +113,7 @@ export declare class KilterBoard extends Device implements IKilterBoard {
113
113
  private prepBytesV3;
114
114
  /**
115
115
  * Splits a collection into slices of the specified length.
116
- * https://github.com/ramda/ramda/blob/master/source/splitEvery.js
116
+ * https://github.com/ramda/ramda/blob/master/source/splitEvery
117
117
  * @param {Number} n
118
118
  * @param {Array} list
119
119
  * @return {Array<number[]>}
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * For API level 2 and API level 3.
4
4
  * The first byte in the data is dependent on where the packet is in the message as a whole.
@@ -234,7 +234,7 @@ export class KilterBoard extends Device {
234
234
  }
235
235
  /**
236
236
  * Splits a collection into slices of the specified length.
237
- * https://github.com/ramda/ramda/blob/master/source/splitEvery.js
237
+ * https://github.com/ramda/ramda/blob/master/source/splitEvery
238
238
  * @param {Number} n
239
239
  * @param {Array} list
240
240
  * @return {Array<number[]>}
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IMotherboard } from "../../interfaces/device/motherboard.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IMotherboard } from "../../interfaces/device/motherboard.interface";
3
3
  /**
4
4
  * Represents a Griptonite Motherboard device.
5
5
  * {@link https://griptonite.io}
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a Griptonite Motherboard device.
4
4
  * {@link https://griptonite.io}
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { ImySmartBoard } from "../../interfaces/device/mysmartboard.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { ImySmartBoard } from "../../interfaces/device/mysmartboard.interface";
3
3
  /**
4
4
  * Represents a Smartboard Climbing mySmartBoard device.
5
5
  * TODO: Add services, do you own a mySmartBoard? Help us!
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a Smartboard Climbing mySmartBoard device.
4
4
  * TODO: Add services, do you own a mySmartBoard? Help us!
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IProgressor } from "../../interfaces/device/progressor.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IProgressor } from "../../interfaces/device/progressor.interface";
3
3
  /**
4
4
  * Represents a Tindeq Progressor device.
5
5
  * {@link https://tindeq.com}
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Progressor responses
4
4
  */
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model.js";
2
- import type { IWHC06 } from "../../interfaces/device/wh-c06.interface.js";
1
+ import { Device } from "../device.model";
2
+ import type { IWHC06 } from "../../interfaces/device/wh-c06.interface";
3
3
  /**
4
4
  * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device.
5
5
  * To use this device enable: `chrome://flags/#enable-experimental-web-platform-features`.
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model.js";
1
+ import { Device } from "../device.model";
2
2
  /**
3
3
  * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device.
4
4
  * To use this device enable: `chrome://flags/#enable-experimental-web-platform-features`.