@hangtime/grip-connect 0.5.0 → 0.5.1
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 +17 -29
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/interfaces/base.interface.d.ts +12 -0
- package/dist/interfaces/device/climbro.interface.d.ts +3 -0
- package/dist/interfaces/device/entralpi.interface.d.ts +49 -0
- package/dist/interfaces/device/forceboard.interface.d.ts +18 -0
- package/dist/interfaces/device/kilterboard.interface.d.ts +73 -0
- package/dist/interfaces/device/motherboard.interface.d.ts +53 -3
- package/dist/interfaces/device/mysmartboard.interface.d.ts +3 -0
- package/dist/interfaces/device/progressor.interface.d.ts +24 -0
- package/dist/interfaces/device/wh-c06.interface.d.ts +3 -0
- package/dist/interfaces/device.interface.d.ts +33 -19
- package/dist/models/device/entralpi.model.d.ts +22 -6
- package/dist/models/device/entralpi.model.js +48 -9
- package/dist/models/device/kilterboard.model.d.ts +1 -1
- package/dist/models/device/motherboard.model.d.ts +5 -0
- package/dist/models/device/motherboard.model.js +12 -4
- package/dist/models/device/progressor.model.d.ts +5 -0
- package/dist/models/device/progressor.model.js +12 -4
- package/dist/models/device/wh-c06.model.js +3 -4
- package/dist/models/device.model.d.ts +35 -19
- package/dist/models/device.model.js +76 -62
- package/package.json +1 -1
- package/src/index.ts +0 -4
- package/src/interfaces/base.interface.ts +14 -0
- package/src/interfaces/device/climbro.interface.ts +3 -1
- package/src/interfaces/device/entralpi.interface.ts +59 -2
- package/src/interfaces/device/forceboard.interface.ts +22 -2
- package/src/interfaces/device/kilterboard.interface.ts +83 -2
- package/src/interfaces/device/motherboard.interface.ts +62 -3
- package/src/interfaces/device/mysmartboard.interface.ts +3 -1
- package/src/interfaces/device/progressor.interface.ts +29 -2
- package/src/interfaces/device/wh-c06.interface.ts +3 -1
- package/src/interfaces/device.interface.ts +36 -20
- package/src/models/device/entralpi.model.ts +51 -9
- package/src/models/device/kilterboard.model.ts +1 -1
- package/src/models/device/motherboard.model.ts +13 -4
- package/src/models/device/progressor.model.ts +13 -4
- package/src/models/device/wh-c06.model.ts +4 -4
- package/src/models/device.model.ts +87 -69
- package/dist/notify.d.ts +0 -16
- package/dist/notify.js +0 -14
- package/dist/stop.d.ts +0 -7
- package/dist/stop.js +0 -20
- package/src/notify.ts +0 -18
- package/src/stop.ts +0 -22
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type { IDevice } from "../device.interface"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the PitchSix ForceBoard device, extending the base Device interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface IForceBoard extends IDevice {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves battery or voltage information from the device.
|
|
9
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
|
|
10
|
+
*/
|
|
11
|
+
battery(): Promise<string | undefined>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves humidity level from the device.
|
|
15
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the humidity level.
|
|
16
|
+
*/
|
|
17
|
+
humidity(): Promise<string | undefined>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves manufacturer information from the device.
|
|
21
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
|
|
22
|
+
*/
|
|
23
|
+
manufacturer(): Promise<string | undefined>
|
|
24
|
+
}
|
|
@@ -1,4 +1,85 @@
|
|
|
1
1
|
import type { IDevice } from "../device.interface"
|
|
2
|
+
/**
|
|
3
|
+
* Represents a climbing placement with a position and role identifier.
|
|
4
|
+
*/
|
|
5
|
+
export interface ClimbPlacement {
|
|
6
|
+
/** The position of the hold placement. */
|
|
7
|
+
position: number
|
|
8
|
+
/** The role ID associated with the climb placement. */
|
|
9
|
+
role_id: number
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Interface representing the KilterBoard device, extending the base Device interface.
|
|
13
|
+
*/
|
|
14
|
+
export interface IKilterBoard extends IDevice {
|
|
15
|
+
/**
|
|
16
|
+
* Calculates the checksum for a byte array.
|
|
17
|
+
* @param data - The array of bytes to calculate the checksum for.
|
|
18
|
+
* @returns The calculated checksum value.
|
|
19
|
+
*/
|
|
20
|
+
checksum(data: number[]): number
|
|
2
21
|
|
|
3
|
-
|
|
4
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a byte array with header and footer bytes for transmission.
|
|
24
|
+
* @param data - The array of bytes to wrap.
|
|
25
|
+
* @returns The wrapped byte array.
|
|
26
|
+
*/
|
|
27
|
+
wrapBytes(data: number[]): number[]
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Encodes a position into a byte array.
|
|
31
|
+
* @param position - The position to encode.
|
|
32
|
+
* @returns The encoded byte array representing the position.
|
|
33
|
+
*/
|
|
34
|
+
encodePosition(position: number): number[]
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Encodes a color string into a numeric representation.
|
|
38
|
+
* @param color - The color string in hexadecimal format.
|
|
39
|
+
* @returns The encoded/compressed color value.
|
|
40
|
+
*/
|
|
41
|
+
encodeColor(color: string): number
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Encodes a placement into a byte array.
|
|
45
|
+
* @param position - The position to encode.
|
|
46
|
+
* @param ledColor - The color of the LED in hexadecimal format.
|
|
47
|
+
* @returns The encoded byte array representing the placement.
|
|
48
|
+
*/
|
|
49
|
+
encodePlacement(position: number, ledColor: string): number[]
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Prepares byte arrays for transmission based on a list of climb placements.
|
|
53
|
+
* @param climbPlacementList - The list of climb placements.
|
|
54
|
+
* @returns The final byte array ready for transmission.
|
|
55
|
+
*/
|
|
56
|
+
prepBytesV3(climbPlacementList: ClimbPlacement[]): number[]
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Splits a collection into slices of the specified length.
|
|
60
|
+
* @param n - Number of elements per slice.
|
|
61
|
+
* @param list - Array to be sliced.
|
|
62
|
+
* @returns The sliced array.
|
|
63
|
+
*/
|
|
64
|
+
splitEvery(n: number, list: number[]): number[][]
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Splits a message into 20-byte chunks for Bluetooth transmission.
|
|
68
|
+
* @param buffer - The message to split.
|
|
69
|
+
* @returns The array of Uint8Arrays.
|
|
70
|
+
*/
|
|
71
|
+
splitMessages(buffer: number[]): Uint8Array[]
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sends a series of messages to the device.
|
|
75
|
+
* @param messages - Array of Uint8Arrays to send.
|
|
76
|
+
*/
|
|
77
|
+
writeMessageSeries(messages: Uint8Array[]): Promise<void>
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Configures the LEDs based on an array of climb placements.
|
|
81
|
+
* @param config - Optional color or array of climb placements.
|
|
82
|
+
* @returns The prepared payload or undefined.
|
|
83
|
+
*/
|
|
84
|
+
led(config?: ClimbPlacement[]): Promise<number[] | undefined>
|
|
85
|
+
}
|
|
@@ -1,11 +1,70 @@
|
|
|
1
1
|
import type { IDevice } from "../device.interface"
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the Griptonite Motherboard device.
|
|
5
|
+
*/
|
|
3
6
|
export interface IMotherboard extends IDevice {
|
|
4
7
|
/**
|
|
5
8
|
* Applies calibration to a sample value.
|
|
6
|
-
* @param sample - The sample value to calibrate.
|
|
7
|
-
* @param calibration - The calibration data.
|
|
8
|
-
* @returns The calibrated sample value.
|
|
9
|
+
* @param {number} sample - The sample value to calibrate.
|
|
10
|
+
* @param {number[][]} calibration - The calibration data.
|
|
11
|
+
* @returns {number} The calibrated sample value.
|
|
9
12
|
*/
|
|
10
13
|
applyCalibration(sample: number, calibration: number[][]): number
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves battery or voltage information from the device.
|
|
17
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
|
|
18
|
+
*/
|
|
19
|
+
battery(): Promise<string | undefined>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Writes a command to get calibration data from the device.
|
|
23
|
+
* @returns {Promise<void>} A Promise that resolves when the command is successfully sent.
|
|
24
|
+
*/
|
|
25
|
+
calibration(): Promise<void>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves firmware version from the device.
|
|
29
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the firmware version.
|
|
30
|
+
*/
|
|
31
|
+
firmware(): Promise<string | undefined>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves hardware version from the device.
|
|
35
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the hardware version.
|
|
36
|
+
*/
|
|
37
|
+
hardware(): Promise<string | undefined>
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sets the LED color based on a single color option.
|
|
41
|
+
* @param {"green" | "red" | "orange"} [config] - Optional color for the LEDs.
|
|
42
|
+
* @returns {Promise<number[] | undefined>} A promise that resolves with the payload array for the Kilter Board if LED settings were applied.
|
|
43
|
+
*/
|
|
44
|
+
led(config?: "green" | "red" | "orange"): Promise<number[] | undefined>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves manufacturer information from the device.
|
|
48
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
|
|
49
|
+
*/
|
|
50
|
+
manufacturer(): Promise<string | undefined>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves serial number from the device.
|
|
54
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the serial number.
|
|
55
|
+
*/
|
|
56
|
+
serial(): Promise<string | undefined>
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Stops the data stream on the specified device.
|
|
60
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
61
|
+
*/
|
|
62
|
+
stop(): Promise<void>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Starts streaming data from the specified device.
|
|
66
|
+
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
67
|
+
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
68
|
+
*/
|
|
69
|
+
stream(duration?: number): Promise<void>
|
|
11
70
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IDevice } from "../device.interface"
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing the mySmartBoard device, extending the base Device interface.
|
|
4
|
+
*/
|
|
3
5
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
4
6
|
export interface ImySmartBoard extends IDevice {}
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import type { IDevice } from "../device.interface"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the Tindeq Progressor device.
|
|
5
|
+
*/
|
|
6
|
+
export interface IProgressor extends IDevice {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves battery or voltage information from the device.
|
|
9
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
|
|
10
|
+
*/
|
|
11
|
+
battery(): Promise<string | undefined>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves firmware version from the device.
|
|
15
|
+
* @returns {Promise<string>} A Promise that resolves with the firmware version.
|
|
16
|
+
*/
|
|
17
|
+
firmware(): Promise<string | undefined>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Stops the data stream on the specified device.
|
|
21
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
22
|
+
*/
|
|
23
|
+
stop(): Promise<void>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Starts streaming data from the specified device.
|
|
27
|
+
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
28
|
+
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
29
|
+
*/
|
|
30
|
+
stream(duration?: number): Promise<void>
|
|
31
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { IBase } from "./base.interface"
|
|
2
|
+
import type { massObject } from "../types/notify"
|
|
2
3
|
|
|
4
|
+
type NotifyCallback = (data: massObject) => void
|
|
3
5
|
/**
|
|
4
6
|
* Represents a characteristic of a Bluetooth service.
|
|
5
7
|
*/
|
|
@@ -40,22 +42,18 @@ export interface IDevice extends IBase {
|
|
|
40
42
|
bluetooth?: BluetoothDevice
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {
|
|
45
|
-
|
|
46
|
-
onDisconnected(event: Event): void
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Handles notifications received from a characteristic.
|
|
50
|
-
* @param {Event} event - The notification event.
|
|
45
|
+
* Connects to a Bluetooth device.
|
|
46
|
+
* @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
|
|
47
|
+
* @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
|
|
51
48
|
*/
|
|
52
|
-
|
|
49
|
+
connect(onSuccess?: () => void, onError?: (error: Error) => void): Promise<void>
|
|
53
50
|
|
|
54
51
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* Disconnects the device if it is currently connected.
|
|
53
|
+
* - Checks if the device is connected via it's GATT server.
|
|
54
|
+
* - If the device is connected, it attempts to gracefully disconnect.
|
|
57
55
|
*/
|
|
58
|
-
|
|
56
|
+
disconnect(): void
|
|
59
57
|
|
|
60
58
|
/**
|
|
61
59
|
* Returns UUIDs of all services associated with the device.
|
|
@@ -64,11 +62,10 @@ export interface IDevice extends IBase {
|
|
|
64
62
|
getAllServiceUUIDs(): string[]
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
|
|
65
|
+
* Handles notifications received from a characteristic.
|
|
66
|
+
* @param {Event} event - The notification event.
|
|
70
67
|
*/
|
|
71
|
-
|
|
68
|
+
handleNotifications(event: Event): void
|
|
72
69
|
|
|
73
70
|
/**
|
|
74
71
|
* Checks if a Bluetooth device is connected.
|
|
@@ -77,9 +74,28 @@ export interface IDevice extends IBase {
|
|
|
77
74
|
isConnected(): boolean
|
|
78
75
|
|
|
79
76
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
77
|
+
* Sets the callback function to be called when notifications are received.
|
|
78
|
+
* @param {NotifyCallback} callback - The callback function to be set.
|
|
79
|
+
* @returns {void}
|
|
83
80
|
*/
|
|
84
|
-
|
|
81
|
+
notify(callback: NotifyCallback): void
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Defines the type for the callback function.
|
|
85
|
+
* @callback NotifyCallback
|
|
86
|
+
* @param {massObject} data - The data passed to the callback.
|
|
87
|
+
*/
|
|
88
|
+
notifyCallback: NotifyCallback
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Handles the 'connected' event.
|
|
92
|
+
* @param {Function} onSuccess - Callback function to execute on successful connection.
|
|
93
|
+
*/
|
|
94
|
+
onConnected(onSuccess: () => void): Promise<void>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Handles the 'disconnected' event.
|
|
98
|
+
* @param {Event} event - The 'disconnected' event.
|
|
99
|
+
*/
|
|
100
|
+
onDisconnected(event: Event): void
|
|
85
101
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Device } from "../device.model"
|
|
2
2
|
import type { IEntralpi } from "../../interfaces/device/entralpi.interface"
|
|
3
|
-
import { notifyCallback } from "../../notify"
|
|
4
3
|
import { applyTare } from "../../tare"
|
|
5
4
|
import { checkActivity } from "../../is-active"
|
|
6
5
|
import { read } from "../../read"
|
|
@@ -27,7 +26,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
27
26
|
characteristics: [
|
|
28
27
|
{
|
|
29
28
|
name: "System ID",
|
|
30
|
-
id: "
|
|
29
|
+
id: "system",
|
|
31
30
|
uuid: "00002a23-0000-1000-8000-00805f9b34fb",
|
|
32
31
|
},
|
|
33
32
|
{
|
|
@@ -136,7 +135,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
136
135
|
|
|
137
136
|
/**
|
|
138
137
|
* Retrieves battery or voltage information from the device.
|
|
139
|
-
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information
|
|
138
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
|
|
140
139
|
*/
|
|
141
140
|
battery = async (): Promise<string | undefined> => {
|
|
142
141
|
if (this.isConnected()) {
|
|
@@ -146,9 +145,23 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
146
145
|
return undefined
|
|
147
146
|
}
|
|
148
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves IEEE 11073-20601 Regulatory Certification from the device.
|
|
150
|
+
* @returns {Promise<string>} A Promise that resolves with the certification.
|
|
151
|
+
*/
|
|
152
|
+
certification = async (): Promise<string | undefined> => {
|
|
153
|
+
// Check if the device is connected
|
|
154
|
+
if (this.isConnected()) {
|
|
155
|
+
// Read certification from the device
|
|
156
|
+
return await read(this, "device", "certification", 250)
|
|
157
|
+
}
|
|
158
|
+
// If device is not found, return undefined
|
|
159
|
+
return undefined
|
|
160
|
+
}
|
|
161
|
+
|
|
149
162
|
/**
|
|
150
163
|
* Retrieves firmware version from the device.
|
|
151
|
-
* @returns {Promise<string>} A Promise that resolves with the firmware version
|
|
164
|
+
* @returns {Promise<string>} A Promise that resolves with the firmware version.
|
|
152
165
|
*/
|
|
153
166
|
firmware = async (): Promise<string | undefined> => {
|
|
154
167
|
// Check if the device is connected
|
|
@@ -197,7 +210,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
197
210
|
checkActivity(numericData)
|
|
198
211
|
|
|
199
212
|
// Notify with weight data
|
|
200
|
-
notifyCallback({
|
|
213
|
+
this.notifyCallback({
|
|
201
214
|
massMax: MASS_MAX,
|
|
202
215
|
massAverage: MASS_AVERAGE,
|
|
203
216
|
massTotal: Math.max(-1000, numericData).toFixed(1),
|
|
@@ -208,7 +221,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
208
221
|
|
|
209
222
|
/**
|
|
210
223
|
* Retrieves hardware version from the device.
|
|
211
|
-
* @returns {Promise<string>} A Promise that resolves with the hardware version
|
|
224
|
+
* @returns {Promise<string>} A Promise that resolves with the hardware version.
|
|
212
225
|
*/
|
|
213
226
|
hardware = async (): Promise<string | undefined> => {
|
|
214
227
|
// Check if the device is connected
|
|
@@ -222,7 +235,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
222
235
|
|
|
223
236
|
/**
|
|
224
237
|
* Retrieves manufacturer information from the device.
|
|
225
|
-
* @returns {Promise<string>} A Promise that resolves with the manufacturer information
|
|
238
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information.
|
|
226
239
|
*/
|
|
227
240
|
manufacturer = async (): Promise<string | undefined> => {
|
|
228
241
|
// Check if the device is connected
|
|
@@ -236,7 +249,7 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
236
249
|
|
|
237
250
|
/**
|
|
238
251
|
* Retrieves model number from the device.
|
|
239
|
-
* @returns {Promise<string>} A Promise that resolves with the model number
|
|
252
|
+
* @returns {Promise<string>} A Promise that resolves with the model number.
|
|
240
253
|
*/
|
|
241
254
|
model = async (): Promise<string | undefined> => {
|
|
242
255
|
// Check if the device is connected
|
|
@@ -248,9 +261,24 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
248
261
|
return undefined
|
|
249
262
|
}
|
|
250
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Retrieves PnP ID from the device, a set of values that used to create a device ID value that is unique for this device.
|
|
266
|
+
* Included in the characteristic is a Vendor ID Source field, a Vendor ID field, a Product ID field and a Product Version field
|
|
267
|
+
* @returns {Promise<string>} A Promise that resolves with the PnP ID.
|
|
268
|
+
*/
|
|
269
|
+
pnp = async (): Promise<string | undefined> => {
|
|
270
|
+
// Check if the device is connected
|
|
271
|
+
if (this.isConnected()) {
|
|
272
|
+
// Read software version from the Entralpi
|
|
273
|
+
return await read(this, "device", "pnp", 250)
|
|
274
|
+
}
|
|
275
|
+
// If device is not found, return undefined
|
|
276
|
+
return undefined
|
|
277
|
+
}
|
|
278
|
+
|
|
251
279
|
/**
|
|
252
280
|
* Retrieves software version from the device.
|
|
253
|
-
* @returns {Promise<string>} A Promise that resolves with the software version
|
|
281
|
+
* @returns {Promise<string>} A Promise that resolves with the software version.
|
|
254
282
|
*/
|
|
255
283
|
software = async (): Promise<string | undefined> => {
|
|
256
284
|
// Check if the device is connected
|
|
@@ -261,4 +289,18 @@ export class Entralpi extends Device implements IEntralpi {
|
|
|
261
289
|
// If device is not found, return undefined
|
|
262
290
|
return undefined
|
|
263
291
|
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Retrieves system id from the device.
|
|
295
|
+
* @returns {Promise<string>} A Promise that resolves with the system id.
|
|
296
|
+
*/
|
|
297
|
+
system = async (): Promise<string | undefined> => {
|
|
298
|
+
// Check if the device is connected
|
|
299
|
+
if (this.isConnected()) {
|
|
300
|
+
// Read system id from the device
|
|
301
|
+
return await read(this, "device", "system", 250)
|
|
302
|
+
}
|
|
303
|
+
// If device is not found, return undefined
|
|
304
|
+
return undefined
|
|
305
|
+
}
|
|
264
306
|
}
|
|
@@ -214,7 +214,7 @@ export class KilterBoard extends Device implements IKilterBoard {
|
|
|
214
214
|
* @param {ClimbPlacement[]} [config] - Optional color or array of climb placements for the LEDs. Ignored if placements are provided.
|
|
215
215
|
* @returns {Promise<number[] | undefined>} A promise that resolves with the payload array for the Kilter Board if LED settings were applied, or `undefined` if no action was taken or for the Motherboard.
|
|
216
216
|
*/
|
|
217
|
-
led = async (config?:
|
|
217
|
+
led = async (config?: ClimbPlacement[]): Promise<number[] | undefined> => {
|
|
218
218
|
// Handle Kilterboard logic: process placements and send payload if connected
|
|
219
219
|
if (Array.isArray(config)) {
|
|
220
220
|
// Prepares byte arrays for transmission based on a list of climb placements.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Device } from "../device.model"
|
|
2
2
|
import type { IMotherboard } from "../../interfaces/device/motherboard.interface"
|
|
3
|
-
import { notifyCallback } from "../../notify"
|
|
4
3
|
import { write, writeCallback } from "../../write"
|
|
5
4
|
import { applyTare } from "../../tare"
|
|
6
5
|
import { MotherboardCommands } from "../../commands"
|
|
@@ -9,7 +8,6 @@ import { lastWrite } from "../../write"
|
|
|
9
8
|
import { DownloadPackets, emptyDownloadPackets } from "../../download"
|
|
10
9
|
import type { DownloadPacket } from "../../types/download"
|
|
11
10
|
import { read } from "../../read"
|
|
12
|
-
import { stop } from "../../stop"
|
|
13
11
|
|
|
14
12
|
// Constants
|
|
15
13
|
const PACKET_LENGTH = 32
|
|
@@ -289,7 +287,7 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
289
287
|
checkActivity(center)
|
|
290
288
|
|
|
291
289
|
// Notify with weight data
|
|
292
|
-
notifyCallback({
|
|
290
|
+
this.notifyCallback({
|
|
293
291
|
massTotal: Math.max(-1000, left + center + right).toFixed(1),
|
|
294
292
|
massMax: MASS_MAX,
|
|
295
293
|
massAverage: MASS_AVERAGE,
|
|
@@ -381,6 +379,17 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
381
379
|
return undefined
|
|
382
380
|
}
|
|
383
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Stops the data stream on the specified device.
|
|
384
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
385
|
+
*/
|
|
386
|
+
stop = async (): Promise<void> => {
|
|
387
|
+
if (this.isConnected()) {
|
|
388
|
+
// Stop stream of device
|
|
389
|
+
await write(this, "uart", "tx", MotherboardCommands.STOP_WEIGHT_MEAS, 0)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
384
393
|
/**
|
|
385
394
|
* Starts streaming data from the specified device.
|
|
386
395
|
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
@@ -400,7 +409,7 @@ export class Motherboard extends Device implements IMotherboard {
|
|
|
400
409
|
await write(this, "uart", "tx", MotherboardCommands.START_WEIGHT_MEAS, duration)
|
|
401
410
|
// Stop streaming if duration is set
|
|
402
411
|
if (duration !== 0) {
|
|
403
|
-
await stop(
|
|
412
|
+
await this.stop()
|
|
404
413
|
}
|
|
405
414
|
}
|
|
406
415
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Device } from "../device.model"
|
|
2
2
|
import type { IProgressor } from "../../interfaces/device/progressor.interface"
|
|
3
|
-
import { notifyCallback } from "../../notify"
|
|
4
3
|
import { applyTare } from "../../tare"
|
|
5
4
|
import { checkActivity } from "../../is-active"
|
|
6
5
|
import { ProgressorCommands, ProgressorResponses } from "../../commands/progressor"
|
|
7
6
|
import struct from "../../struct"
|
|
8
7
|
import { DownloadPackets, emptyDownloadPackets } from "../../download"
|
|
9
8
|
import { lastWrite, write, writeCallback } from "../../write"
|
|
10
|
-
import { stop } from "../../stop"
|
|
11
9
|
|
|
12
10
|
// Constants
|
|
13
11
|
let MASS_MAX = "0"
|
|
@@ -135,7 +133,7 @@ export class Progressor extends Device implements IProgressor {
|
|
|
135
133
|
// Check if device is being used
|
|
136
134
|
checkActivity(weight)
|
|
137
135
|
|
|
138
|
-
notifyCallback({
|
|
136
|
+
this.notifyCallback({
|
|
139
137
|
massMax: MASS_MAX,
|
|
140
138
|
massAverage: MASS_AVERAGE,
|
|
141
139
|
massTotal: Math.max(-1000, weight).toFixed(1),
|
|
@@ -164,6 +162,17 @@ export class Progressor extends Device implements IProgressor {
|
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Stops the data stream on the specified device.
|
|
167
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
168
|
+
*/
|
|
169
|
+
stop = async (): Promise<void> => {
|
|
170
|
+
if (this.isConnected()) {
|
|
171
|
+
// Stop stream of device
|
|
172
|
+
await write(this, "progressor", "tx", ProgressorCommands.STOP_WEIGHT_MEAS, 0)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
167
176
|
/**
|
|
168
177
|
* Starts streaming data from the specified device.
|
|
169
178
|
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
@@ -177,7 +186,7 @@ export class Progressor extends Device implements IProgressor {
|
|
|
177
186
|
await write(this, "progressor", "tx", ProgressorCommands.START_WEIGHT_MEAS, duration)
|
|
178
187
|
// Stop streaming if duration is set
|
|
179
188
|
if (duration !== 0) {
|
|
180
|
-
await stop(
|
|
189
|
+
await this.stop()
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Device } from "../device.model"
|
|
2
2
|
import { applyTare } from "../../tare"
|
|
3
3
|
import { checkActivity } from "../../is-active"
|
|
4
|
-
import { notifyCallback } from "../../notify"
|
|
5
4
|
import type { IWHC06 } from "../../interfaces/device/wh-c06.interface"
|
|
6
5
|
|
|
7
6
|
// Constants
|
|
@@ -57,14 +56,15 @@ export class WHC06 extends Device implements IWHC06 {
|
|
|
57
56
|
throw new Error("GATT is not available on this device")
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
// Device has no services / characteristics
|
|
60
|
+
onSuccess()
|
|
61
|
+
|
|
60
62
|
// WH-C06
|
|
61
63
|
const MANUFACTURER_ID = 256 // 0x0100
|
|
62
64
|
|
|
63
65
|
this.bluetooth.addEventListener("advertisementreceived", (event) => {
|
|
64
66
|
const data = event.manufacturerData.get(MANUFACTURER_ID)
|
|
65
67
|
if (data) {
|
|
66
|
-
// Device has no services / characteristics
|
|
67
|
-
onSuccess()
|
|
68
68
|
// Handle recieved data
|
|
69
69
|
const weight = (data.getUint8(WEIGHT_OFFSET) << 8) | data.getUint8(WEIGHT_OFFSET + 1)
|
|
70
70
|
// const stable = (data.getUint8(STABLE_OFFSET) & 0xf0) >> 4
|
|
@@ -90,7 +90,7 @@ export class WHC06 extends Device implements IWHC06 {
|
|
|
90
90
|
checkActivity(numericData)
|
|
91
91
|
|
|
92
92
|
// Notify with weight data
|
|
93
|
-
notifyCallback({
|
|
93
|
+
this.notifyCallback({
|
|
94
94
|
massMax: MASS_MAX,
|
|
95
95
|
massAverage: MASS_AVERAGE,
|
|
96
96
|
massTotal: Math.max(-1000, numericData).toFixed(1),
|