@hangtime/grip-connect 0.6.0 → 0.6.2
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 +4 -5
- package/deno.json +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -2
- package/dist/interfaces/device/climbro.interface.d.ts +1 -1
- package/dist/interfaces/device/entralpi.interface.d.ts +1 -1
- package/dist/interfaces/device/forceboard.interface.d.ts +1 -1
- package/dist/interfaces/device/kilterboard.interface.d.ts +1 -1
- package/dist/interfaces/device/motherboard.interface.d.ts +1 -1
- package/dist/interfaces/device/mysmartboard.interface.d.ts +1 -1
- package/dist/interfaces/device/progressor.interface.d.ts +1 -1
- package/dist/interfaces/device/wh-c06.interface.d.ts +1 -1
- package/dist/interfaces/device.interface.d.ts +3 -3
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/models/base.model.d.ts +1 -1
- package/dist/models/device/climbro.model.d.ts +2 -2
- package/dist/models/device/climbro.model.js +1 -1
- package/dist/models/device/entralpi.model.d.ts +2 -2
- package/dist/models/device/entralpi.model.js +1 -1
- package/dist/models/device/forceboard.model.d.ts +2 -2
- package/dist/models/device/forceboard.model.js +1 -1
- package/dist/models/device/kilterboard.model.d.ts +7 -7
- package/dist/models/device/kilterboard.model.js +6 -6
- package/dist/models/device/motherboard.model.d.ts +2 -2
- package/dist/models/device/motherboard.model.js +1 -1
- package/dist/models/device/mysmartboard.model.d.ts +2 -2
- package/dist/models/device/mysmartboard.model.js +1 -1
- package/dist/models/device/progressor.model.d.ts +3 -2
- package/dist/models/device/progressor.model.js +3 -3
- package/dist/models/device/wh-c06.model.d.ts +2 -2
- package/dist/models/device/wh-c06.model.js +1 -1
- package/dist/models/device.model.d.ts +17 -27
- package/dist/models/device.model.js +84 -94
- package/dist/models/index.d.ts +8 -8
- package/dist/models/index.js +8 -8
- package/package.json +3 -3
- package/src/index.ts +11 -2
- package/src/interfaces/device/climbro.interface.ts +1 -1
- package/src/interfaces/device/entralpi.interface.ts +1 -1
- package/src/interfaces/device/forceboard.interface.ts +1 -1
- package/src/interfaces/device/kilterboard.interface.ts +1 -1
- package/src/interfaces/device/motherboard.interface.ts +1 -1
- package/src/interfaces/device/mysmartboard.interface.ts +1 -1
- package/src/interfaces/device/progressor.interface.ts +1 -1
- package/src/interfaces/device/wh-c06.interface.ts +1 -1
- package/src/interfaces/device.interface.ts +3 -3
- package/src/interfaces/index.ts +15 -0
- package/src/models/base.model.ts +1 -1
- package/src/models/device/climbro.model.ts +2 -2
- package/src/models/device/entralpi.model.ts +2 -2
- package/src/models/device/forceboard.model.ts +2 -2
- package/src/models/device/kilterboard.model.ts +14 -14
- package/src/models/device/motherboard.model.ts +3 -3
- package/src/models/device/mysmartboard.model.ts +2 -2
- package/src/models/device/progressor.model.ts +4 -4
- package/src/models/device/wh-c06.model.ts +2 -2
- package/src/models/device.model.ts +92 -107
- 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
|
|
39
|
-
[NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and [JSR](https://jsr.io/@hangtime/grip-connect)
|
|
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
|
|
@@ -102,10 +101,10 @@ document.querySelector("#motherboard").addEventListener("click", async () => {
|
|
|
102
101
|
// await motherboard.stop()
|
|
103
102
|
|
|
104
103
|
// Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
|
|
105
|
-
// motherboard.download('json')
|
|
104
|
+
// await motherboard.download('json')
|
|
106
105
|
|
|
107
106
|
// Optionally disconnect from device after we are done
|
|
108
|
-
motherboard.disconnect(
|
|
107
|
+
motherboard.disconnect()
|
|
109
108
|
},
|
|
110
109
|
(error) => {
|
|
111
110
|
// Optinal custom error handeling
|
package/deno.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
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,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IBase } from "./base.interface
|
|
2
|
-
import type { massObject } from "./callback.interface
|
|
3
|
-
import type { Commands } from "./command.interface
|
|
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
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
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";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IClimbro } from "../../interfaces/device/climbro.interface
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IEntralpi } from "../../interfaces/device/entralpi.interface
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IForceBoard } from "../../interfaces/device/forceboard.interface
|
|
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}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface
|
|
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.
|
|
@@ -74,13 +74,13 @@ export declare class KilterBoard extends Device implements IKilterBoard {
|
|
|
74
74
|
/**
|
|
75
75
|
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|
|
76
76
|
* @param data - The array of bytes to calculate the checksum for.
|
|
77
|
-
* @returns The calculated checksum value.
|
|
77
|
+
* @returns {number} The calculated checksum value.
|
|
78
78
|
*/
|
|
79
79
|
private checksum;
|
|
80
80
|
/**
|
|
81
81
|
* Wraps a byte array with header and footer bytes for transmission.
|
|
82
82
|
* @param data - The array of bytes to wrap.
|
|
83
|
-
* @returns The wrapped byte array.
|
|
83
|
+
* @returns {number[]} The wrapped byte array.
|
|
84
84
|
*/
|
|
85
85
|
private wrapBytes;
|
|
86
86
|
/**
|
|
@@ -88,7 +88,7 @@ export declare class KilterBoard extends Device implements IKilterBoard {
|
|
|
88
88
|
* The lowest 8 bits of the position get put in the first byte of the group.
|
|
89
89
|
* The highest 8 bits of the position get put in the second byte of the group.
|
|
90
90
|
* @param position - The position to encode.
|
|
91
|
-
* @returns The encoded byte array representing the position.
|
|
91
|
+
* @returns {number[]} The encoded byte array representing the position.
|
|
92
92
|
*/
|
|
93
93
|
private encodePosition;
|
|
94
94
|
/**
|
|
@@ -113,10 +113,10 @@ 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
|
|
116
|
+
* https://github.com/ramda/ramda/blob/master/source/splitEvery
|
|
117
117
|
* @param {Number} n
|
|
118
118
|
* @param {Array} list
|
|
119
|
-
* @return {Array}
|
|
119
|
+
* @return {Array<number[]>}
|
|
120
120
|
*/
|
|
121
121
|
private splitEvery;
|
|
122
122
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
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.
|
|
@@ -130,7 +130,7 @@ export class KilterBoard extends Device {
|
|
|
130
130
|
/**
|
|
131
131
|
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|
|
132
132
|
* @param data - The array of bytes to calculate the checksum for.
|
|
133
|
-
* @returns The calculated checksum value.
|
|
133
|
+
* @returns {number} The calculated checksum value.
|
|
134
134
|
*/
|
|
135
135
|
checksum(data) {
|
|
136
136
|
let i = 0;
|
|
@@ -142,7 +142,7 @@ export class KilterBoard extends Device {
|
|
|
142
142
|
/**
|
|
143
143
|
* Wraps a byte array with header and footer bytes for transmission.
|
|
144
144
|
* @param data - The array of bytes to wrap.
|
|
145
|
-
* @returns The wrapped byte array.
|
|
145
|
+
* @returns {number[]} The wrapped byte array.
|
|
146
146
|
*/
|
|
147
147
|
wrapBytes(data) {
|
|
148
148
|
if (data.length > KilterBoard.messageBodyMaxLength) {
|
|
@@ -165,7 +165,7 @@ export class KilterBoard extends Device {
|
|
|
165
165
|
* The lowest 8 bits of the position get put in the first byte of the group.
|
|
166
166
|
* The highest 8 bits of the position get put in the second byte of the group.
|
|
167
167
|
* @param position - The position to encode.
|
|
168
|
-
* @returns The encoded byte array representing the position.
|
|
168
|
+
* @returns {number[]} The encoded byte array representing the position.
|
|
169
169
|
*/
|
|
170
170
|
encodePosition(position) {
|
|
171
171
|
const position1 = position & 255;
|
|
@@ -234,10 +234,10 @@ 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
|
|
237
|
+
* https://github.com/ramda/ramda/blob/master/source/splitEvery
|
|
238
238
|
* @param {Number} n
|
|
239
239
|
* @param {Array} list
|
|
240
|
-
* @return {Array}
|
|
240
|
+
* @return {Array<number[]>}
|
|
241
241
|
*/
|
|
242
242
|
splitEvery(n, list) {
|
|
243
243
|
if (n <= 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IMotherboard } from "../../interfaces/device/motherboard.interface
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { ImySmartBoard } from "../../interfaces/device/mysmartboard.interface
|
|
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,7 +1,8 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IProgressor } from "../../interfaces/device/progressor.interface
|
|
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
|
+
* {@link https://tindeq.com}
|
|
5
6
|
*/
|
|
6
7
|
export declare class Progressor extends Device implements IProgressor {
|
|
7
8
|
constructor();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
1
|
+
import { Device } from "../device.model";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* {@link https://tindeq.com}
|
|
3
|
+
* Progressor responses
|
|
5
4
|
*/
|
|
6
5
|
var ProgressorResponses;
|
|
7
6
|
(function (ProgressorResponses) {
|
|
@@ -33,6 +32,7 @@ var ProgressorResponses;
|
|
|
33
32
|
})(ProgressorResponses || (ProgressorResponses = {}));
|
|
34
33
|
/**
|
|
35
34
|
* Represents a Tindeq Progressor device.
|
|
35
|
+
* {@link https://tindeq.com}
|
|
36
36
|
*/
|
|
37
37
|
export class Progressor extends Device {
|
|
38
38
|
constructor() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Device } from "../device.model
|
|
2
|
-
import type { IWHC06 } from "../../interfaces/device/wh-c06.interface
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import { BaseModel } from "./../models/base.model
|
|
2
|
-
import type { IDevice, Service } from "../interfaces/device.interface
|
|
3
|
-
import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface
|
|
4
|
-
import type { DownloadPacket } from "../interfaces/download.interface
|
|
5
|
-
import type { Commands } from "../interfaces/command.interface
|
|
1
|
+
import { BaseModel } from "./../models/base.model";
|
|
2
|
+
import type { IDevice, Service } from "../interfaces/device.interface";
|
|
3
|
+
import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface";
|
|
4
|
+
import type { DownloadPacket } from "../interfaces/download.interface";
|
|
5
|
+
import type { Commands } from "../interfaces/command.interface";
|
|
6
6
|
export declare abstract class Device extends BaseModel implements IDevice {
|
|
7
7
|
/**
|
|
8
8
|
* Filters to identify the device during Bluetooth scanning.
|
|
@@ -26,7 +26,7 @@ export declare abstract class Device extends BaseModel implements IDevice {
|
|
|
26
26
|
* @type {BluetoothDevice | undefined}
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
|
-
bluetooth?: BluetoothDevice
|
|
29
|
+
bluetooth?: BluetoothDevice;
|
|
30
30
|
/**
|
|
31
31
|
* Object representing the set of commands available for this device.
|
|
32
32
|
* These commands allow communication with the device to perform various operations such as starting measurements, retrieving data, or calibrating the device.
|
|
@@ -257,13 +257,13 @@ export declare abstract class Device extends BaseModel implements IDevice {
|
|
|
257
257
|
* @param {('csv' | 'json' | 'xml')} [format='csv'] - The format in which to download the data.
|
|
258
258
|
* Defaults to 'csv'. Accepted values are 'csv', 'json', and 'xml'.
|
|
259
259
|
*
|
|
260
|
-
* @returns {void}
|
|
261
|
-
* @
|
|
260
|
+
* @returns {Promise<void>} Resolves when the data has been downloaded/written
|
|
261
|
+
* @public
|
|
262
262
|
*
|
|
263
263
|
* @example
|
|
264
|
-
* device.download('json');
|
|
264
|
+
* await device.download('json');
|
|
265
265
|
*/
|
|
266
|
-
download: (format?: "csv" | "json" | "xml") => void
|
|
266
|
+
download: (format?: "csv" | "json" | "xml") => Promise<void>;
|
|
267
267
|
/**
|
|
268
268
|
* Returns UUIDs of all services associated with the device.
|
|
269
269
|
* @returns {string[]} Array of service UUIDs.
|
|
@@ -275,25 +275,15 @@ export declare abstract class Device extends BaseModel implements IDevice {
|
|
|
275
275
|
*/
|
|
276
276
|
protected getAllServiceUUIDs: () => string[];
|
|
277
277
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
|
|
282
|
-
protected getBluetooth(): Promise<Bluetooth | import("webbluetooth").Bluetooth>;
|
|
283
|
-
/**
|
|
284
|
-
* Retrieves the characteristic from the device's service.
|
|
285
|
-
* @param {string} serviceId - The UUID of the service.
|
|
286
|
-
* @param {string} characteristicId - The UUID of the characteristic.
|
|
287
|
-
* @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
|
|
288
|
-
* @protected
|
|
278
|
+
* Returns the Bluetooth instance available for the current environment.
|
|
279
|
+
* In browsers, it returns the native Web Bluetooth API (i.e. `navigator.bluetooth`).
|
|
280
|
+
* In a Node, Bun, or Deno environment, it dynamically imports the `webbluetooth` package.
|
|
281
|
+
* {@link https://github.com/thegecko/webbluetooth}
|
|
289
282
|
*
|
|
290
|
-
* @
|
|
291
|
-
*
|
|
292
|
-
* if (characteristic) {
|
|
293
|
-
* console.log('Characteristic found');
|
|
294
|
-
* }
|
|
283
|
+
* @returns {Promise<Bluetooth>} A promise that resolves to the Bluetooth instance.
|
|
284
|
+
* @throws {Error} If Web Bluetooth is not available in the current environment.
|
|
295
285
|
*/
|
|
296
|
-
protected
|
|
286
|
+
protected getBluetooth(): Promise<Bluetooth>;
|
|
297
287
|
/**
|
|
298
288
|
* Handles notifications received from a characteristic.
|
|
299
289
|
* @param {BluetoothRemoteGATTCharacteristic} characteristic - The notification event.
|