@hangtime/grip-connect 0.4.2 → 0.5.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 +49 -40
- package/dist/characteristic.d.ts +1 -1
- package/dist/commands/forceboard.d.ts +6 -0
- package/dist/commands/forceboard.js +5 -0
- package/dist/commands/index.d.ts +3 -2
- package/dist/commands/index.js +3 -2
- package/dist/index.d.ts +1 -13
- package/dist/index.js +3 -23
- package/dist/interfaces/base.interface.d.ts +5 -0
- package/dist/interfaces/device/climbro.interface.d.ts +3 -0
- package/dist/interfaces/device/climbro.interface.js +1 -0
- package/dist/interfaces/device/entralpi.interface.d.ts +3 -0
- package/dist/interfaces/device/entralpi.interface.js +1 -0
- package/dist/interfaces/device/forceboard.interface.d.ts +3 -0
- package/dist/interfaces/device/forceboard.interface.js +1 -0
- package/dist/interfaces/device/kilterboard.interface.d.ts +3 -0
- package/dist/interfaces/device/kilterboard.interface.js +1 -0
- package/dist/interfaces/device/motherboard.interface.d.ts +10 -0
- package/dist/interfaces/device/motherboard.interface.js +1 -0
- package/dist/interfaces/device/mysmartboard.interface.d.ts +3 -0
- package/dist/interfaces/device/mysmartboard.interface.js +1 -0
- package/dist/interfaces/device/progressor.interface.d.ts +3 -0
- package/dist/interfaces/device/progressor.interface.js +1 -0
- package/dist/interfaces/device/wh-c06.interface.d.ts +3 -0
- package/dist/interfaces/device/wh-c06.interface.js +1 -0
- package/dist/interfaces/device.interface.d.ts +76 -0
- package/dist/interfaces/device.interface.js +1 -0
- package/dist/is-device.d.ts +19 -13
- package/dist/is-device.js +19 -13
- package/dist/models/base.model.d.ts +7 -0
- package/dist/models/base.model.js +10 -0
- package/dist/models/device/climbro.model.d.ts +9 -0
- package/dist/models/device/climbro.model.js +13 -0
- package/dist/models/device/entralpi.model.d.ts +43 -0
- package/dist/models/device/entralpi.model.js +246 -0
- package/dist/models/device/forceboard.model.d.ts +23 -0
- package/dist/models/device/forceboard.model.js +201 -0
- package/dist/models/device/kilterboard.model.d.ts +85 -0
- package/dist/models/device/kilterboard.model.js +213 -0
- package/dist/models/device/motherboard.model.d.ts +76 -0
- package/dist/models/device/motherboard.model.js +391 -0
- package/dist/models/device/mysmartboard.model.d.ts +9 -0
- package/dist/models/device/mysmartboard.model.js +13 -0
- package/dist/models/device/progressor.model.d.ts +32 -0
- package/dist/models/device/progressor.model.js +177 -0
- package/dist/models/device/wh-c06.model.d.ts +15 -0
- package/dist/models/device/wh-c06.model.js +97 -0
- package/dist/models/device.model.d.ts +45 -0
- package/dist/models/device.model.js +140 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +8 -0
- package/dist/notify.js +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/read.js +1 -2
- package/dist/stop.d.ts +1 -1
- package/dist/stop.js +1 -2
- package/dist/write.d.ts +1 -1
- package/dist/write.js +1 -2
- package/package.json +4 -2
- package/src/characteristic.ts +1 -1
- package/src/commands/forceboard.ts +6 -0
- package/src/commands/index.ts +4 -2
- package/src/index.ts +14 -27
- package/src/interfaces/base.interface.ts +5 -0
- package/src/interfaces/device/climbro.interface.ts +4 -0
- package/src/interfaces/device/entralpi.interface.ts +4 -0
- package/src/interfaces/device/forceboard.interface.ts +4 -0
- package/src/interfaces/device/kilterboard.interface.ts +4 -0
- package/src/interfaces/device/motherboard.interface.ts +11 -0
- package/src/interfaces/device/mysmartboard.interface.ts +4 -0
- package/src/interfaces/device/progressor.interface.ts +4 -0
- package/src/interfaces/device/wh-c06.interface.ts +4 -0
- package/src/interfaces/device.interface.ts +85 -0
- package/src/is-device.ts +23 -16
- package/src/models/base.model.ts +16 -0
- package/src/models/device/climbro.model.ts +15 -0
- package/src/models/device/entralpi.model.ts +264 -0
- package/src/models/device/forceboard.model.ts +206 -0
- package/src/models/device/kilterboard.model.ts +229 -0
- package/src/models/device/motherboard.model.ts +430 -0
- package/src/models/device/mysmartboard.model.ts +15 -0
- package/src/models/device/progressor.model.ts +184 -0
- package/src/models/device/wh-c06.model.ts +118 -0
- package/src/models/device.model.ts +159 -0
- package/src/models/index.ts +15 -0
- package/src/notify.ts +1 -1
- package/src/read.ts +2 -3
- package/src/stop.ts +2 -3
- package/src/write.ts +2 -3
- package/dist/battery.d.ts +0 -10
- package/dist/battery.js +0 -34
- package/dist/calibration.d.ts +0 -7
- package/dist/calibration.js +0 -21
- package/dist/connect.d.ts +0 -8
- package/dist/connect.js +0 -163
- package/dist/data/entralpi.d.ts +0 -5
- package/dist/data/entralpi.js +0 -33
- package/dist/data/index.d.ts +0 -4
- package/dist/data/index.js +0 -4
- package/dist/data/motherboard.d.ts +0 -10
- package/dist/data/motherboard.js +0 -141
- package/dist/data/progressor.d.ts +0 -9
- package/dist/data/progressor.js +0 -78
- package/dist/data/wh-c06.d.ts +0 -5
- package/dist/data/wh-c06.js +0 -38
- package/dist/devices/climbro.d.ts +0 -6
- package/dist/devices/climbro.js +0 -8
- package/dist/devices/entralpi.d.ts +0 -5
- package/dist/devices/entralpi.js +0 -59
- package/dist/devices/index.d.ts +0 -7
- package/dist/devices/index.js +0 -7
- package/dist/devices/kilterboard.d.ts +0 -10
- package/dist/devices/kilterboard.js +0 -34
- package/dist/devices/motherboard.d.ts +0 -5
- package/dist/devices/motherboard.js +0 -81
- package/dist/devices/mysmartboard.d.ts +0 -6
- package/dist/devices/mysmartboard.js +0 -8
- package/dist/devices/progressor.d.ts +0 -5
- package/dist/devices/progressor.js +0 -37
- package/dist/devices/wh-c06.d.ts +0 -6
- package/dist/devices/wh-c06.js +0 -17
- package/dist/disconnect.d.ts +0 -8
- package/dist/disconnect.js +0 -14
- package/dist/firmware.d.ts +0 -10
- package/dist/firmware.js +0 -34
- package/dist/hardware.d.ts +0 -9
- package/dist/hardware.js +0 -22
- package/dist/is-connected.d.ts +0 -7
- package/dist/is-connected.js +0 -13
- package/dist/led.d.ts +0 -24
- package/dist/led.js +0 -195
- package/dist/manufacturer.d.ts +0 -9
- package/dist/manufacturer.js +0 -22
- package/dist/serial.d.ts +0 -9
- package/dist/serial.js +0 -27
- package/dist/stream.d.ts +0 -8
- package/dist/stream.js +0 -41
- package/dist/text.d.ts +0 -12
- package/dist/text.js +0 -30
- package/dist/types/devices.d.ts +0 -38
- package/src/battery.ts +0 -36
- package/src/calibration.ts +0 -23
- package/src/connect.ts +0 -187
- package/src/data/entralpi.ts +0 -41
- package/src/data/index.ts +0 -7
- package/src/data/motherboard.ts +0 -163
- package/src/data/progressor.ts +0 -79
- package/src/data/wh-c06.ts +0 -47
- package/src/devices/climbro.ts +0 -10
- package/src/devices/entralpi.ts +0 -61
- package/src/devices/index.ts +0 -13
- package/src/devices/kilterboard.ts +0 -37
- package/src/devices/motherboard.ts +0 -83
- package/src/devices/mysmartboard.ts +0 -10
- package/src/devices/progressor.ts +0 -38
- package/src/devices/wh-c06.ts +0 -19
- package/src/disconnect.ts +0 -16
- package/src/firmware.ts +0 -36
- package/src/hardware.ts +0 -24
- package/src/is-connected.ts +0 -15
- package/src/led.ts +0 -210
- package/src/manufacturer.ts +0 -24
- package/src/serial.ts +0 -29
- package/src/stream.ts +0 -43
- package/src/text.ts +0 -32
- package/src/types/devices.ts +0 -39
- /package/dist/{types/devices.js → interfaces/base.interface.js} +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Device } from "../device.model";
|
|
2
|
+
import { notifyCallback } from "../../notify";
|
|
3
|
+
import { applyTare } from "../../tare";
|
|
4
|
+
import { checkActivity } from "../../is-active";
|
|
5
|
+
import { read } from "../../read";
|
|
6
|
+
// Constants
|
|
7
|
+
let MASS_MAX = "0";
|
|
8
|
+
let MASS_AVERAGE = "0";
|
|
9
|
+
let MASS_TOTAL_SUM = 0;
|
|
10
|
+
let DATAPOINT_COUNT = 0;
|
|
11
|
+
export class Entralpi extends Device {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
filters: [
|
|
15
|
+
{
|
|
16
|
+
name: "ENTRALPI",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
services: [
|
|
20
|
+
{
|
|
21
|
+
name: "Device Information",
|
|
22
|
+
id: "device",
|
|
23
|
+
uuid: "0000180a-0000-1000-8000-00805f9b34fb",
|
|
24
|
+
characteristics: [
|
|
25
|
+
{
|
|
26
|
+
name: "System ID",
|
|
27
|
+
id: "id",
|
|
28
|
+
uuid: "00002a23-0000-1000-8000-00805f9b34fb",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "Model Number String",
|
|
32
|
+
id: "model",
|
|
33
|
+
uuid: "00002a24-0000-1000-8000-00805f9b34fb",
|
|
34
|
+
},
|
|
35
|
+
// {
|
|
36
|
+
// name: "Serial Number String (Blocked)",
|
|
37
|
+
// id: "serial",
|
|
38
|
+
// uuid: "00002a25-0000-1000-8000-00805f9b34fb",
|
|
39
|
+
// },
|
|
40
|
+
{
|
|
41
|
+
name: "Firmware Revision String",
|
|
42
|
+
id: "firmware",
|
|
43
|
+
uuid: "00002a26-0000-1000-8000-00805f9b34fb",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Hardware Revision String",
|
|
47
|
+
id: "hardware",
|
|
48
|
+
uuid: "00002a27-0000-1000-8000-00805f9b34fb",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "Software Revision String",
|
|
52
|
+
id: "software",
|
|
53
|
+
uuid: "00002a28-0000-1000-8000-00805f9b34fb",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Manufacturer Name String",
|
|
57
|
+
id: "manufacturer",
|
|
58
|
+
uuid: "00002a29-0000-1000-8000-00805f9b34fb",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "IEEE 11073-20601 Regulatory Certification Data List",
|
|
62
|
+
id: "certification",
|
|
63
|
+
uuid: "00002a2a-0000-1000-8000-00805f9b34fb",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "PnP ID",
|
|
67
|
+
id: "pnp",
|
|
68
|
+
uuid: "00002a50-0000-1000-8000-00805f9b34fb",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "Battery Service",
|
|
74
|
+
id: "battery",
|
|
75
|
+
uuid: "0000180f-0000-1000-8000-00805f9b34fb",
|
|
76
|
+
characteristics: [
|
|
77
|
+
{
|
|
78
|
+
name: "Battery Level",
|
|
79
|
+
id: "level",
|
|
80
|
+
uuid: "00002a19-0000-1000-8000-00805f9b34fb",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "Generic Attribute",
|
|
86
|
+
id: "attribute",
|
|
87
|
+
uuid: "f000ffc0-0451-4000-b000-000000000000",
|
|
88
|
+
characteristics: [
|
|
89
|
+
{
|
|
90
|
+
name: "",
|
|
91
|
+
id: "",
|
|
92
|
+
uuid: "f000ffc1-0451-4000-b000-000000000000",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "",
|
|
96
|
+
id: "",
|
|
97
|
+
uuid: "f000ffc2-0451-4000-b000-000000000000",
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "UART ISSC Transparent Service",
|
|
103
|
+
id: "uart",
|
|
104
|
+
uuid: "0000fff0-0000-1000-8000-00805f9b34fb",
|
|
105
|
+
characteristics: [
|
|
106
|
+
{
|
|
107
|
+
name: "TX",
|
|
108
|
+
id: "tx",
|
|
109
|
+
uuid: "0000fff1-0000-1000-8000-00805f9b34fb",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "RX",
|
|
113
|
+
id: "rx",
|
|
114
|
+
uuid: "0000fff4-0000-1000-8000-00805f9b34fb",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "Weight Scale",
|
|
120
|
+
id: "weight",
|
|
121
|
+
uuid: "0000181d-0000-1000-8000-00805f9b34fb",
|
|
122
|
+
characteristics: [
|
|
123
|
+
{
|
|
124
|
+
name: "notify",
|
|
125
|
+
id: "rx",
|
|
126
|
+
uuid: "0000fff1-0000-1000-8000-00805f9b34fb",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Retrieves battery or voltage information from the device.
|
|
135
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
|
|
136
|
+
*/
|
|
137
|
+
battery = async () => {
|
|
138
|
+
if (this.isConnected()) {
|
|
139
|
+
return await read(this, "battery", "level", 250);
|
|
140
|
+
}
|
|
141
|
+
// If device is not found, return undefined
|
|
142
|
+
return undefined;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves firmware version from the device.
|
|
146
|
+
* @returns {Promise<string>} A Promise that resolves with the firmware version,
|
|
147
|
+
*/
|
|
148
|
+
firmware = async () => {
|
|
149
|
+
// Check if the device is connected
|
|
150
|
+
if (this.isConnected()) {
|
|
151
|
+
// Read firmware version from the Motherboard
|
|
152
|
+
return await read(this, "device", "firmware", 250);
|
|
153
|
+
}
|
|
154
|
+
// If device is not found, return undefined
|
|
155
|
+
return undefined;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Handles data received from the Progressor device, processes weight measurements,
|
|
159
|
+
* and updates mass data including maximum and average values.
|
|
160
|
+
* It also handles command responses for retrieving device information.
|
|
161
|
+
*
|
|
162
|
+
* @param {Event} event - The notification event.
|
|
163
|
+
*/
|
|
164
|
+
handleNotifications = (event) => {
|
|
165
|
+
const characteristic = event.target;
|
|
166
|
+
const value = characteristic.value;
|
|
167
|
+
if (value) {
|
|
168
|
+
if (value.buffer) {
|
|
169
|
+
const buffer = value.buffer;
|
|
170
|
+
const rawData = new DataView(buffer);
|
|
171
|
+
const receivedData = (rawData.getUint16(0) / 100).toFixed(1);
|
|
172
|
+
let numericData = Number(receivedData);
|
|
173
|
+
// Tare correction
|
|
174
|
+
numericData -= applyTare(numericData);
|
|
175
|
+
// Update MASS_MAX
|
|
176
|
+
MASS_MAX = Math.max(Number(MASS_MAX), numericData).toFixed(1);
|
|
177
|
+
// Update running sum and count
|
|
178
|
+
const currentMassTotal = Math.max(-1000, numericData);
|
|
179
|
+
MASS_TOTAL_SUM += currentMassTotal;
|
|
180
|
+
DATAPOINT_COUNT++;
|
|
181
|
+
// Calculate the average dynamically
|
|
182
|
+
MASS_AVERAGE = (MASS_TOTAL_SUM / DATAPOINT_COUNT).toFixed(1);
|
|
183
|
+
// Check if device is being used
|
|
184
|
+
checkActivity(numericData);
|
|
185
|
+
// Notify with weight data
|
|
186
|
+
notifyCallback({
|
|
187
|
+
massMax: MASS_MAX,
|
|
188
|
+
massAverage: MASS_AVERAGE,
|
|
189
|
+
massTotal: Math.max(-1000, numericData).toFixed(1),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves hardware version from the device.
|
|
196
|
+
* @returns {Promise<string>} A Promise that resolves with the hardware version,
|
|
197
|
+
*/
|
|
198
|
+
hardware = async () => {
|
|
199
|
+
// Check if the device is connected
|
|
200
|
+
if (this.isConnected()) {
|
|
201
|
+
// Read hardware version from the device
|
|
202
|
+
return await read(this, "device", "hardware", 250);
|
|
203
|
+
}
|
|
204
|
+
// If device is not found, return undefined
|
|
205
|
+
return undefined;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Retrieves manufacturer information from the device.
|
|
209
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
210
|
+
*/
|
|
211
|
+
manufacturer = async () => {
|
|
212
|
+
// Check if the device is connected
|
|
213
|
+
if (this.isConnected()) {
|
|
214
|
+
// Read manufacturer information from the device
|
|
215
|
+
return await read(this, "device", "manufacturer", 250);
|
|
216
|
+
}
|
|
217
|
+
// If device is not found, return undefined
|
|
218
|
+
return undefined;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves model number from the device.
|
|
222
|
+
* @returns {Promise<string>} A Promise that resolves with the model number,
|
|
223
|
+
*/
|
|
224
|
+
model = async () => {
|
|
225
|
+
// Check if the device is connected
|
|
226
|
+
if (this.isConnected()) {
|
|
227
|
+
// Read model number from the Entralpi
|
|
228
|
+
return await read(this, "device", "model", 250);
|
|
229
|
+
}
|
|
230
|
+
// If device is not found, return undefined
|
|
231
|
+
return undefined;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves software version from the device.
|
|
235
|
+
* @returns {Promise<string>} A Promise that resolves with the software version,
|
|
236
|
+
*/
|
|
237
|
+
software = async () => {
|
|
238
|
+
// Check if the device is connected
|
|
239
|
+
if (this.isConnected()) {
|
|
240
|
+
// Read software version from the Entralpi
|
|
241
|
+
return await read(this, "device", "software", 250);
|
|
242
|
+
}
|
|
243
|
+
// If device is not found, return undefined
|
|
244
|
+
return undefined;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Device } from "../device.model";
|
|
2
|
+
import type { IForceBoard } from "../../interfaces/device/forceboard.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a PitchSix Force Board device
|
|
5
|
+
*/
|
|
6
|
+
export declare class ForceBoard extends Device implements IForceBoard {
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves battery or voltage information from the device.
|
|
10
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
|
|
11
|
+
*/
|
|
12
|
+
battery: () => Promise<string | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves humidity level from the device.
|
|
15
|
+
* @returns {Promise<string>} A Promise that resolves with the humidity level,
|
|
16
|
+
*/
|
|
17
|
+
humidity: () => Promise<string | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves manufacturer information from the device.
|
|
20
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
21
|
+
*/
|
|
22
|
+
manufacturer: () => Promise<string | undefined>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Device } from "../device.model";
|
|
2
|
+
import { read } from "../../read";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a PitchSix Force Board device
|
|
5
|
+
*/
|
|
6
|
+
export class ForceBoard extends Device {
|
|
7
|
+
constructor() {
|
|
8
|
+
super({
|
|
9
|
+
filters: [{ name: "Force Board" }],
|
|
10
|
+
services: [
|
|
11
|
+
{
|
|
12
|
+
name: "Device Information",
|
|
13
|
+
id: "device",
|
|
14
|
+
uuid: "0000180a-0000-1000-8000-00805f9b34fb",
|
|
15
|
+
characteristics: [
|
|
16
|
+
// {
|
|
17
|
+
// name: "Serial Number String (Blocked)",
|
|
18
|
+
// id: "serial",
|
|
19
|
+
// uuid: "00002a25-0000-1000-8000-00805f9b34fb",
|
|
20
|
+
// },
|
|
21
|
+
// {
|
|
22
|
+
// name: "Firmware Revision String (Blocked)",
|
|
23
|
+
// id: "firmware",
|
|
24
|
+
// uuid: "00002a26-0000-1000-8000-00805f9b34f",
|
|
25
|
+
// },
|
|
26
|
+
{
|
|
27
|
+
name: "Manufacturer Name String",
|
|
28
|
+
id: "manufacturer",
|
|
29
|
+
uuid: "00002a29-0000-1000-8000-00805f9b34fb",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "Battery Service",
|
|
35
|
+
id: "battery",
|
|
36
|
+
uuid: "0000180f-0000-1000-8000-00805f9b34fb",
|
|
37
|
+
characteristics: [
|
|
38
|
+
{
|
|
39
|
+
name: "Battery Level",
|
|
40
|
+
id: "level",
|
|
41
|
+
uuid: "00002a19-0000-1000-8000-00805f9b34fb",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Nordic Device Firmware Update (DFU) Service",
|
|
47
|
+
id: "dfu",
|
|
48
|
+
uuid: "0000fe59-0000-1000-8000-00805f9b34fb",
|
|
49
|
+
characteristics: [
|
|
50
|
+
{
|
|
51
|
+
name: "Buttonless DFU",
|
|
52
|
+
id: "dfu",
|
|
53
|
+
uuid: "8ec90003-f315-4f60-9fb8-838830daea50",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "",
|
|
59
|
+
id: "",
|
|
60
|
+
uuid: "f3641400-00b0-4240-ba50-05ca45bf8abc",
|
|
61
|
+
characteristics: [
|
|
62
|
+
{
|
|
63
|
+
name: "Read + Indicate",
|
|
64
|
+
id: "",
|
|
65
|
+
uuid: "f3641401-00b0-4240-ba50-05ca45bf8abc",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "Humidity Service",
|
|
71
|
+
id: "humidity",
|
|
72
|
+
uuid: "cf194c6f-d0c1-47b2-aeff-dc610f09bd18",
|
|
73
|
+
characteristics: [
|
|
74
|
+
{
|
|
75
|
+
name: "Humidity Level",
|
|
76
|
+
id: "level",
|
|
77
|
+
uuid: "cf194c70-d0c1-47b2-aeff-dc610f09bd18",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "",
|
|
83
|
+
id: "",
|
|
84
|
+
uuid: "3a90328c-c266-4c76-b05a-6af6104a0b13",
|
|
85
|
+
characteristics: [
|
|
86
|
+
{
|
|
87
|
+
name: "Read",
|
|
88
|
+
id: "",
|
|
89
|
+
uuid: "3a90328d-c266-4c76-b05a-6af6104a0b13",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "",
|
|
95
|
+
id: "forceboard",
|
|
96
|
+
uuid: "9a88d67f-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
97
|
+
characteristics: [
|
|
98
|
+
{
|
|
99
|
+
name: "Write",
|
|
100
|
+
id: "",
|
|
101
|
+
uuid: "9a88d680-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "Read + Indicate",
|
|
105
|
+
id: "",
|
|
106
|
+
uuid: "9a88d681-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "Read + Notify",
|
|
110
|
+
id: "rx",
|
|
111
|
+
uuid: "9a88d682-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "Write",
|
|
115
|
+
id: "",
|
|
116
|
+
uuid: "9a88d683-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "Read",
|
|
120
|
+
id: "",
|
|
121
|
+
uuid: "9a88d685-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "Write",
|
|
125
|
+
id: "",
|
|
126
|
+
uuid: "9a88d686-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "Read + Write",
|
|
130
|
+
id: "",
|
|
131
|
+
uuid: "9a88d687-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "Serial / Read + Write",
|
|
135
|
+
id: "",
|
|
136
|
+
uuid: "9a88d688-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "Read + Write",
|
|
140
|
+
id: "",
|
|
141
|
+
uuid: "9a88d689-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "",
|
|
147
|
+
id: "",
|
|
148
|
+
uuid: "467a8516-6e39-11eb-9439-0242ac130002",
|
|
149
|
+
characteristics: [
|
|
150
|
+
{
|
|
151
|
+
name: "Read + Write",
|
|
152
|
+
id: "",
|
|
153
|
+
uuid: "467a8517-6e39-11eb-9439-0242ac130002",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "Read + Write",
|
|
157
|
+
id: "",
|
|
158
|
+
uuid: "467a8518-6e39-11eb-9439-0242ac130002",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Retrieves battery or voltage information from the device.
|
|
167
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
|
|
168
|
+
*/
|
|
169
|
+
battery = async () => {
|
|
170
|
+
if (this.isConnected()) {
|
|
171
|
+
return await read(this, "battery", "level", 250);
|
|
172
|
+
}
|
|
173
|
+
// If device is not found, return undefined
|
|
174
|
+
return undefined;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Retrieves humidity level from the device.
|
|
178
|
+
* @returns {Promise<string>} A Promise that resolves with the humidity level,
|
|
179
|
+
*/
|
|
180
|
+
humidity = async () => {
|
|
181
|
+
// Check if the device is connected
|
|
182
|
+
if (this.isConnected()) {
|
|
183
|
+
return await read(this, "humidity", "level", 250);
|
|
184
|
+
}
|
|
185
|
+
// If device is not found, return undefined
|
|
186
|
+
return undefined;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves manufacturer information from the device.
|
|
190
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
191
|
+
*/
|
|
192
|
+
manufacturer = async () => {
|
|
193
|
+
// Check if the device is connected
|
|
194
|
+
if (this.isConnected()) {
|
|
195
|
+
// Read manufacturer information from the device
|
|
196
|
+
return await read(this, "device", "manufacturer", 250);
|
|
197
|
+
}
|
|
198
|
+
// If device is not found, return undefined
|
|
199
|
+
return undefined;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Device } from "../device.model";
|
|
2
|
+
import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Aurora Climbing Advertising service
|
|
5
|
+
*/
|
|
6
|
+
export declare const AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
|
|
7
|
+
declare class ClimbPlacement {
|
|
8
|
+
position: number;
|
|
9
|
+
role_id: number;
|
|
10
|
+
constructor(position: number, role_id: number);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a Aurora Climbing device
|
|
14
|
+
* Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
|
|
15
|
+
*/
|
|
16
|
+
export declare class KilterBoard extends Device implements IKilterBoard {
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|
|
20
|
+
* @param data - The array of bytes to calculate the checksum for.
|
|
21
|
+
* @returns The calculated checksum value.
|
|
22
|
+
*/
|
|
23
|
+
checksum(data: number[]): number;
|
|
24
|
+
/**
|
|
25
|
+
* Wraps a byte array with header and footer bytes for transmission.
|
|
26
|
+
* @param data - The array of bytes to wrap.
|
|
27
|
+
* @returns The wrapped byte array.
|
|
28
|
+
*/
|
|
29
|
+
wrapBytes(data: number[]): number[];
|
|
30
|
+
/**
|
|
31
|
+
* Encodes a position into a byte array.
|
|
32
|
+
* The lowest 8 bits of the position get put in the first byte of the group.
|
|
33
|
+
* The highest 8 bits of the position get put in the second byte of the group.
|
|
34
|
+
* @param position - The position to encode.
|
|
35
|
+
* @returns The encoded byte array representing the position.
|
|
36
|
+
*/
|
|
37
|
+
encodePosition(position: number): number[];
|
|
38
|
+
/**
|
|
39
|
+
* Encodes a color string into a numeric representation.
|
|
40
|
+
* The rgb color, 3 bits for the R and G components, 2 bits for the B component, with the 3 R bits occupying the high end of the byte and the 2 B bits in the low end (hence 3 G bits in the middle).
|
|
41
|
+
* @param color - The color string in hexadecimal format (e.g., 'FFFFFF').
|
|
42
|
+
* @returns The encoded /compressed color value.
|
|
43
|
+
*/
|
|
44
|
+
encodeColor(color: string): number;
|
|
45
|
+
/**
|
|
46
|
+
* Encodes a placement (requires a 16-bit position and a 24-bit rgb color. ) into a byte array.
|
|
47
|
+
* @param position - The position to encode.
|
|
48
|
+
* @param ledColor - The color of the LED in hexadecimal format (e.g., 'FFFFFF').
|
|
49
|
+
* @returns The encoded byte array representing the placement.
|
|
50
|
+
*/
|
|
51
|
+
encodePlacement(position: number, ledColor: string): number[];
|
|
52
|
+
/**
|
|
53
|
+
* Prepares byte arrays for transmission based on a list of climb placements.
|
|
54
|
+
* @param climbPlacementList - The list of climb placements containing position and role ID.
|
|
55
|
+
* @returns The final byte array ready for transmission.
|
|
56
|
+
*/
|
|
57
|
+
prepBytesV3(climbPlacementList: ClimbPlacement[]): number[];
|
|
58
|
+
/**
|
|
59
|
+
* Splits a collection into slices of the specified length.
|
|
60
|
+
* https://github.com/ramda/ramda/blob/master/source/splitEvery.js
|
|
61
|
+
* @param {Number} n
|
|
62
|
+
* @param {Array} list
|
|
63
|
+
* @return {Array}
|
|
64
|
+
*/
|
|
65
|
+
splitEvery(n: number, list: number[]): number[][];
|
|
66
|
+
/**
|
|
67
|
+
* The kilter board only supports messages of 20 bytes
|
|
68
|
+
* at a time. This method splits a full message into parts
|
|
69
|
+
* of 20 bytes
|
|
70
|
+
*
|
|
71
|
+
* @param buffer
|
|
72
|
+
*/
|
|
73
|
+
splitMessages: (buffer: number[]) => Uint8Array[];
|
|
74
|
+
/**
|
|
75
|
+
* Sends a series of messages to a device.
|
|
76
|
+
*/
|
|
77
|
+
writeMessageSeries(messages: Uint8Array[]): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Configures the LEDs based on an array of climb placements. If a configuration is provided, it prepares and sends a payload to the device.
|
|
80
|
+
* @param {ClimbPlacement[]} [config] - Optional color or array of climb placements for the LEDs. Ignored if placements are provided.
|
|
81
|
+
* @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.
|
|
82
|
+
*/
|
|
83
|
+
led: (config?: "green" | "red" | "orange" | ClimbPlacement[]) => Promise<number[] | undefined>;
|
|
84
|
+
}
|
|
85
|
+
export {};
|