@hangtime/grip-connect 0.5.10 → 0.5.11
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 +3 -2
- package/deno.json +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/device/kilterboard.model.js +1 -1
- package/dist/models/device/wh-c06.model.js +5 -2
- package/dist/models/device.model.d.ts +1 -1
- package/dist/models/device.model.js +6 -3
- package/dist/models/index.js +1 -0
- package/package.json +2 -1
- package/src/index.ts +1 -1
- package/src/models/device/entralpi.model.ts +1 -1
- package/src/models/device/forceboard.model.ts +1 -1
- package/src/models/device/kilterboard.model.ts +1 -1
- package/src/models/device/motherboard.model.ts +1 -1
- package/src/models/device/progressor.model.ts +1 -1
- package/src/models/device/wh-c06.model.ts +7 -4
- package/src/models/device.model.ts +7 -4
- package/src/models/index.ts +2 -0
package/README.md
CHANGED
|
@@ -35,7 +35,8 @@ Learn more: [Documentation](https://stevie-ray.github.io/hangtime-grip-connect/)
|
|
|
35
35
|
|
|
36
36
|
## Install
|
|
37
37
|
|
|
38
|
-
This project can be found in the [NPM
|
|
38
|
+
This project can be found in the [NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and
|
|
39
|
+
[JSR](https://jsr.io/@hangtime/grip-connect) package registries.
|
|
39
40
|
|
|
40
41
|
```sh [npm]
|
|
41
42
|
$ npm install @hangtime/grip-connect
|
|
@@ -113,7 +114,7 @@ document.querySelector("#motherboard").addEventListener("click", async () => {
|
|
|
113
114
|
- By default [watchAdvertisements](https://chromestatus.com/feature/5180688812736512) isn't supported . For Chrome,
|
|
114
115
|
enable it at `chrome://flags/#enable-experimental-web-platform-features`.
|
|
115
116
|
- ✅ [Kilter Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/kilterboard.html)
|
|
116
|
-
- ✅ [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) / Lefu Scale
|
|
117
|
+
- ✅ [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) / Lefu / Unique CW275 Scale
|
|
117
118
|
- ✅ [PitchSix Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html)
|
|
118
119
|
- ➡️ [Climbro](https://stevie-ray.github.io/hangtime-grip-connect/devices/climbro.html)
|
|
119
120
|
- ➡️ [Smartboard Climbing - mySmartBoard](https://stevie-ray.github.io/hangtime-grip-connect/devices/mysmartboard.html)
|
package/deno.json
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard,
|
|
1
|
+
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,
|
|
1
|
+
export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index";
|
|
@@ -154,7 +154,7 @@ export class KilterBoard extends Device {
|
|
|
154
154
|
- 0x2
|
|
155
155
|
- *packets
|
|
156
156
|
- 0x3
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
First byte is always 1, the second is a number of packets, then checksum, then 2, packets themselves, and finally 3.
|
|
159
159
|
*/
|
|
160
160
|
return [1, data.length, this.checksum(data), 2, ...data, 3];
|
|
@@ -154,10 +154,13 @@ export class WHC06 extends Device {
|
|
|
154
154
|
clearTimeout(this.advertisementTimeout);
|
|
155
155
|
}
|
|
156
156
|
// Set a new timeout to stop tracking if no advertisement is received
|
|
157
|
-
this.advertisementTimeout =
|
|
157
|
+
this.advertisementTimeout = globalThis.setTimeout(() => {
|
|
158
158
|
// Mimic a disconnect
|
|
159
159
|
const disconnectedEvent = new Event("gattserverdisconnected");
|
|
160
|
-
Object.defineProperty(disconnectedEvent, "target", {
|
|
160
|
+
Object.defineProperty(disconnectedEvent, "target", {
|
|
161
|
+
value: this.bluetooth,
|
|
162
|
+
writable: false,
|
|
163
|
+
});
|
|
161
164
|
// Print error to the console
|
|
162
165
|
console.error(`No advertisement received for ${this.advertisementTimeoutTime} seconds, stopping tracking..`);
|
|
163
166
|
this.onDisconnected(disconnectedEvent);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseModel } from "./../models/base.model";
|
|
2
2
|
import type { IDevice, Service } from "../interfaces/device.interface";
|
|
3
|
-
import type { NotifyCallback, WriteCallback
|
|
3
|
+
import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface";
|
|
4
4
|
import type { DownloadPacket } from "../interfaces/download.interface";
|
|
5
5
|
import type { Commands } from "../interfaces/command.interface";
|
|
6
6
|
export declare abstract class Device extends BaseModel implements IDevice {
|
|
@@ -51,7 +51,10 @@ export class Device extends BaseModel {
|
|
|
51
51
|
/**
|
|
52
52
|
* Configuration for threshold and duration.
|
|
53
53
|
*/
|
|
54
|
-
activeConfig = {
|
|
54
|
+
activeConfig = {
|
|
55
|
+
threshold: 2.5,
|
|
56
|
+
duration: 1000,
|
|
57
|
+
};
|
|
55
58
|
/**
|
|
56
59
|
* Maximum mass recorded from the device, initialized to "0".
|
|
57
60
|
* @type {string}
|
|
@@ -406,7 +409,7 @@ export class Device extends BaseModel {
|
|
|
406
409
|
// Create a Blob object containing the data
|
|
407
410
|
const blob = new Blob([content], { type: mimeType });
|
|
408
411
|
// Create a URL for the Blob
|
|
409
|
-
const url =
|
|
412
|
+
const url = globalThis.URL.createObjectURL(blob);
|
|
410
413
|
// Create a link element
|
|
411
414
|
const link = document.createElement("a");
|
|
412
415
|
// Set link attributes
|
|
@@ -418,7 +421,7 @@ export class Device extends BaseModel {
|
|
|
418
421
|
link.click();
|
|
419
422
|
// Clean up: remove the link and revoke the URL
|
|
420
423
|
document.body.removeChild(link);
|
|
421
|
-
|
|
424
|
+
globalThis.URL.revokeObjectURL(url);
|
|
422
425
|
};
|
|
423
426
|
/**
|
|
424
427
|
* Returns UUIDs of all services associated with the device.
|
package/dist/models/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hangtime/grip-connect",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"description": "Griptonite Motherboard, Tindeq Progressor, PitchSix Force Board, WHC-06, Entralpi, Climbro, mySmartBoard: Web Bluetooth API Force-Sensing strength analysis for climbers",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -155,7 +155,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
155
155
|
*
|
|
156
156
|
* @param {BluetoothRemoteGATTCharacteristic} characteristic - The notification event.
|
|
157
157
|
*/
|
|
158
|
-
handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
158
|
+
override handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
159
159
|
const value: DataView | undefined = characteristic.value
|
|
160
160
|
|
|
161
161
|
if (value) {
|
|
@@ -182,7 +182,7 @@ export class ForceBoard extends Device implements IForceBoard {
|
|
|
182
182
|
*
|
|
183
183
|
* @param {BluetoothRemoteGATTCharacteristic} characteristic - The notification event.
|
|
184
184
|
*/
|
|
185
|
-
handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
185
|
+
override handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
186
186
|
const value: DataView | undefined = characteristic.value
|
|
187
187
|
if (value) {
|
|
188
188
|
// Update timestamp
|
|
@@ -161,7 +161,7 @@ export class KilterBoard extends Device implements IKilterBoard {
|
|
|
161
161
|
- 0x2
|
|
162
162
|
- *packets
|
|
163
163
|
- 0x3
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
First byte is always 1, the second is a number of packets, then checksum, then 2, packets themselves, and finally 3.
|
|
166
166
|
*/
|
|
167
167
|
return [1, data.length, this.checksum(data), 2, ...data, 3]
|
|
@@ -203,7 +203,7 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
203
203
|
*
|
|
204
204
|
* @param {BluetoothRemoteGATTCharacteristic} characteristic - The notification event.
|
|
205
205
|
*/
|
|
206
|
-
handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
206
|
+
override handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
207
207
|
const value: DataView | undefined = characteristic.value
|
|
208
208
|
|
|
209
209
|
if (value) {
|
|
@@ -122,7 +122,7 @@ export class Progressor extends Device implements IProgressor {
|
|
|
122
122
|
*
|
|
123
123
|
* @param {BluetoothRemoteGATTCharacteristic} characteristic - The notification event.
|
|
124
124
|
*/
|
|
125
|
-
handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
125
|
+
override handleNotifications = (characteristic: BluetoothRemoteGATTCharacteristic): void => {
|
|
126
126
|
const value: DataView | undefined = characteristic.value
|
|
127
127
|
|
|
128
128
|
if (value) {
|
|
@@ -68,7 +68,7 @@ export class WHC06 extends Device implements IWHC06 {
|
|
|
68
68
|
* @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
|
|
69
69
|
* @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
|
|
70
70
|
*/
|
|
71
|
-
connect = async (
|
|
71
|
+
override connect = async (
|
|
72
72
|
onSuccess: () => void = () => console.log("Connected successfully"),
|
|
73
73
|
onError: (error: Error) => void = (error) => console.error(error),
|
|
74
74
|
): Promise<void> => {
|
|
@@ -168,7 +168,7 @@ export class WHC06 extends Device implements IWHC06 {
|
|
|
168
168
|
* For the WH-C06 device, the `gatt.connected` property remains `false` even after the device is connected.
|
|
169
169
|
* @returns {boolean} A boolean indicating whether the device is connected.
|
|
170
170
|
*/
|
|
171
|
-
isConnected = (): boolean => {
|
|
171
|
+
override isConnected = (): boolean => {
|
|
172
172
|
return !!this.bluetooth
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -182,10 +182,13 @@ export class WHC06 extends Device implements IWHC06 {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// Set a new timeout to stop tracking if no advertisement is received
|
|
185
|
-
this.advertisementTimeout =
|
|
185
|
+
this.advertisementTimeout = globalThis.setTimeout(() => {
|
|
186
186
|
// Mimic a disconnect
|
|
187
187
|
const disconnectedEvent = new Event("gattserverdisconnected")
|
|
188
|
-
Object.defineProperty(disconnectedEvent, "target", {
|
|
188
|
+
Object.defineProperty(disconnectedEvent, "target", {
|
|
189
|
+
value: this.bluetooth,
|
|
190
|
+
writable: false,
|
|
191
|
+
})
|
|
189
192
|
// Print error to the console
|
|
190
193
|
console.error(`No advertisement received for ${this.advertisementTimeoutTime} seconds, stopping tracking..`)
|
|
191
194
|
this.onDisconnected(disconnectedEvent)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseModel } from "./../models/base.model"
|
|
2
2
|
import type { IDevice, Service } from "../interfaces/device.interface"
|
|
3
|
-
import type {
|
|
3
|
+
import type { ActiveCallback, massObject, NotifyCallback, WriteCallback } from "../interfaces/callback.interface"
|
|
4
4
|
import type { DownloadPacket } from "../interfaces/download.interface"
|
|
5
5
|
import type { Commands } from "../interfaces/command.interface"
|
|
6
6
|
|
|
@@ -61,7 +61,10 @@ export abstract class Device extends BaseModel implements IDevice {
|
|
|
61
61
|
/**
|
|
62
62
|
* Configuration for threshold and duration.
|
|
63
63
|
*/
|
|
64
|
-
private activeConfig: { threshold: number; duration: number } = {
|
|
64
|
+
private activeConfig: { threshold: number; duration: number } = {
|
|
65
|
+
threshold: 2.5,
|
|
66
|
+
duration: 1000,
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* Maximum mass recorded from the device, initialized to "0".
|
|
@@ -456,7 +459,7 @@ export abstract class Device extends BaseModel implements IDevice {
|
|
|
456
459
|
const blob = new Blob([content], { type: mimeType })
|
|
457
460
|
|
|
458
461
|
// Create a URL for the Blob
|
|
459
|
-
const url =
|
|
462
|
+
const url = globalThis.URL.createObjectURL(blob)
|
|
460
463
|
|
|
461
464
|
// Create a link element
|
|
462
465
|
const link = document.createElement("a")
|
|
@@ -473,7 +476,7 @@ export abstract class Device extends BaseModel implements IDevice {
|
|
|
473
476
|
|
|
474
477
|
// Clean up: remove the link and revoke the URL
|
|
475
478
|
document.body.removeChild(link)
|
|
476
|
-
|
|
479
|
+
globalThis.URL.revokeObjectURL(url)
|
|
477
480
|
}
|
|
478
481
|
|
|
479
482
|
/**
|