@hangtime/grip-connect 0.8.6 → 0.9.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 +7 -5
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/base.interface.d.ts +18 -0
- package/dist/cjs/interfaces/base.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/base.interface.js +3 -0
- package/dist/cjs/interfaces/base.interface.js.map +1 -0
- package/dist/cjs/interfaces/callback.interface.d.ts +56 -0
- package/dist/cjs/interfaces/callback.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/callback.interface.js +3 -0
- package/dist/cjs/interfaces/callback.interface.js.map +1 -0
- package/dist/cjs/interfaces/command.interface.d.ts +92 -0
- package/dist/cjs/interfaces/command.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/command.interface.js +3 -0
- package/dist/cjs/interfaces/command.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/climbro.interface.d.ts +12 -0
- package/dist/cjs/interfaces/device/climbro.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/climbro.interface.js +3 -0
- package/dist/cjs/interfaces/device/climbro.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/entralpi.interface.d.ts +53 -0
- package/dist/cjs/interfaces/device/entralpi.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/entralpi.interface.js +3 -0
- package/dist/cjs/interfaces/device/entralpi.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/forceboard.interface.d.ts +64 -0
- package/dist/cjs/interfaces/device/forceboard.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/forceboard.interface.js +3 -0
- package/dist/cjs/interfaces/device/forceboard.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/kilterboard.interface.d.ts +16 -0
- package/dist/cjs/interfaces/device/kilterboard.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/kilterboard.interface.js +3 -0
- package/dist/cjs/interfaces/device/kilterboard.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/motherboard.interface.d.ts +54 -0
- package/dist/cjs/interfaces/device/motherboard.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/motherboard.interface.js +3 -0
- package/dist/cjs/interfaces/device/motherboard.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/mysmartboard.interface.d.ts +7 -0
- package/dist/cjs/interfaces/device/mysmartboard.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/mysmartboard.interface.js +3 -0
- package/dist/cjs/interfaces/device/mysmartboard.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/progressor.interface.d.ts +28 -0
- package/dist/cjs/interfaces/device/progressor.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/progressor.interface.js +3 -0
- package/dist/cjs/interfaces/device/progressor.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/smartboard-pro.interface.d.ts +7 -0
- package/dist/cjs/interfaces/device/smartboard-pro.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/smartboard-pro.interface.js +3 -0
- package/dist/cjs/interfaces/device/smartboard-pro.interface.js.map +1 -0
- package/dist/cjs/interfaces/device/wh-c06.interface.d.ts +7 -0
- package/dist/cjs/interfaces/device/wh-c06.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device/wh-c06.interface.js +3 -0
- package/dist/cjs/interfaces/device/wh-c06.interface.js.map +1 -0
- package/dist/cjs/interfaces/device.interface.d.ts +203 -0
- package/dist/cjs/interfaces/device.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/device.interface.js +3 -0
- package/dist/cjs/interfaces/device.interface.js.map +1 -0
- package/dist/cjs/interfaces/download.interface.d.ts +16 -0
- package/dist/cjs/interfaces/download.interface.d.ts.map +1 -0
- package/dist/cjs/interfaces/download.interface.js +3 -0
- package/dist/cjs/interfaces/download.interface.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +10 -0
- package/dist/cjs/interfaces/index.d.ts.map +1 -0
- package/dist/cjs/interfaces/index.js +3 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/models/base.model.d.ts +13 -0
- package/dist/cjs/models/base.model.d.ts.map +1 -0
- package/dist/cjs/models/base.model.js +24 -0
- package/dist/cjs/models/base.model.js.map +1 -0
- package/dist/cjs/models/device/climbro.model.d.ts +42 -0
- package/dist/cjs/models/device/climbro.model.d.ts.map +1 -0
- package/dist/cjs/models/device/climbro.model.js +149 -0
- package/dist/cjs/models/device/climbro.model.js.map +1 -0
- package/dist/cjs/models/device/entralpi.model.d.ts +64 -0
- package/dist/cjs/models/device/entralpi.model.d.ts.map +1 -0
- package/dist/cjs/models/device/entralpi.model.js +244 -0
- package/dist/cjs/models/device/entralpi.model.js.map +1 -0
- package/dist/cjs/models/device/forceboard.model.d.ts +73 -0
- package/dist/cjs/models/device/forceboard.model.d.ts.map +1 -0
- package/dist/cjs/models/device/forceboard.model.js +316 -0
- package/dist/cjs/models/device/forceboard.model.js.map +1 -0
- package/dist/cjs/models/device/kilterboard.model.d.ts +144 -0
- package/dist/cjs/models/device/kilterboard.model.d.ts.map +1 -0
- package/dist/cjs/models/device/kilterboard.model.js +291 -0
- package/dist/cjs/models/device/kilterboard.model.js.map +1 -0
- package/dist/cjs/models/device/motherboard.model.d.ts +110 -0
- package/dist/cjs/models/device/motherboard.model.d.ts.map +1 -0
- package/dist/cjs/models/device/motherboard.model.js +382 -0
- package/dist/cjs/models/device/motherboard.model.js.map +1 -0
- package/dist/cjs/models/device/mysmartboard.model.d.ts +11 -0
- package/dist/cjs/models/device/mysmartboard.model.d.ts.map +1 -0
- package/dist/cjs/models/device/mysmartboard.model.js +19 -0
- package/dist/cjs/models/device/mysmartboard.model.js.map +1 -0
- package/dist/cjs/models/device/progressor.model.d.ts +39 -0
- package/dist/cjs/models/device/progressor.model.d.ts.map +1 -0
- package/dist/cjs/models/device/progressor.model.js +220 -0
- package/dist/cjs/models/device/progressor.model.js.map +1 -0
- package/dist/cjs/models/device/smartboard-pro.model.d.ts +11 -0
- package/dist/cjs/models/device/smartboard-pro.model.d.ts.map +1 -0
- package/dist/cjs/models/device/smartboard-pro.model.js +56 -0
- package/dist/cjs/models/device/smartboard-pro.model.js.map +1 -0
- package/dist/cjs/models/device/wh-c06.model.d.ts +57 -0
- package/dist/cjs/models/device/wh-c06.model.d.ts.map +1 -0
- package/dist/cjs/models/device/wh-c06.model.js +171 -0
- package/dist/cjs/models/device/wh-c06.model.js.map +1 -0
- package/dist/cjs/models/device.model.d.ts +408 -0
- package/dist/cjs/models/device.model.d.ts.map +1 -0
- package/dist/cjs/models/device.model.js +665 -0
- package/dist/cjs/models/device.model.js.map +1 -0
- package/dist/cjs/models/index.d.ts +10 -0
- package/dist/cjs/models/index.d.ts.map +1 -0
- package/dist/cjs/models/index.js +22 -0
- package/dist/cjs/models/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/base.interface.d.ts +18 -0
- package/dist/interfaces/base.interface.d.ts.map +1 -0
- package/dist/interfaces/base.interface.js +2 -0
- package/dist/interfaces/base.interface.js.map +1 -0
- package/dist/interfaces/callback.interface.d.ts +56 -0
- package/dist/interfaces/callback.interface.d.ts.map +1 -0
- package/dist/interfaces/callback.interface.js +2 -0
- package/dist/interfaces/callback.interface.js.map +1 -0
- package/dist/interfaces/command.interface.d.ts +92 -0
- package/dist/interfaces/command.interface.d.ts.map +1 -0
- package/dist/interfaces/command.interface.js +2 -0
- package/dist/interfaces/command.interface.js.map +1 -0
- package/dist/interfaces/device/climbro.interface.d.ts +12 -0
- package/dist/interfaces/device/climbro.interface.d.ts.map +1 -0
- package/dist/interfaces/device/climbro.interface.js +2 -0
- package/dist/interfaces/device/climbro.interface.js.map +1 -0
- package/dist/interfaces/device/entralpi.interface.d.ts +53 -0
- package/dist/interfaces/device/entralpi.interface.d.ts.map +1 -0
- package/dist/interfaces/device/entralpi.interface.js +2 -0
- package/dist/interfaces/device/entralpi.interface.js.map +1 -0
- package/dist/interfaces/device/forceboard.interface.d.ts +64 -0
- package/dist/interfaces/device/forceboard.interface.d.ts.map +1 -0
- package/dist/interfaces/device/forceboard.interface.js +2 -0
- package/dist/interfaces/device/forceboard.interface.js.map +1 -0
- package/dist/interfaces/device/kilterboard.interface.d.ts +16 -0
- package/dist/interfaces/device/kilterboard.interface.d.ts.map +1 -0
- package/dist/interfaces/device/kilterboard.interface.js +2 -0
- package/dist/interfaces/device/kilterboard.interface.js.map +1 -0
- package/dist/interfaces/device/motherboard.interface.d.ts +54 -0
- package/dist/interfaces/device/motherboard.interface.d.ts.map +1 -0
- package/dist/interfaces/device/motherboard.interface.js +2 -0
- package/dist/interfaces/device/motherboard.interface.js.map +1 -0
- package/dist/interfaces/device/mysmartboard.interface.d.ts +7 -0
- package/dist/interfaces/device/mysmartboard.interface.d.ts.map +1 -0
- package/dist/interfaces/device/mysmartboard.interface.js +2 -0
- package/dist/interfaces/device/mysmartboard.interface.js.map +1 -0
- package/dist/interfaces/device/progressor.interface.d.ts +28 -0
- package/dist/interfaces/device/progressor.interface.d.ts.map +1 -0
- package/dist/interfaces/device/progressor.interface.js +2 -0
- package/dist/interfaces/device/progressor.interface.js.map +1 -0
- package/dist/interfaces/device/smartboard-pro.interface.d.ts +7 -0
- package/dist/interfaces/device/smartboard-pro.interface.d.ts.map +1 -0
- package/dist/interfaces/device/smartboard-pro.interface.js +2 -0
- package/dist/interfaces/device/smartboard-pro.interface.js.map +1 -0
- package/dist/interfaces/device/wh-c06.interface.d.ts +7 -0
- package/dist/interfaces/device/wh-c06.interface.d.ts.map +1 -0
- package/dist/interfaces/device/wh-c06.interface.js +2 -0
- package/dist/interfaces/device/wh-c06.interface.js.map +1 -0
- package/dist/interfaces/device.interface.d.ts +203 -0
- package/dist/interfaces/device.interface.d.ts.map +1 -0
- package/dist/interfaces/device.interface.js +2 -0
- package/dist/interfaces/device.interface.js.map +1 -0
- package/dist/interfaces/download.interface.d.ts +16 -0
- package/dist/interfaces/download.interface.d.ts.map +1 -0
- package/dist/interfaces/download.interface.js +2 -0
- package/dist/interfaces/download.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/models/base.model.d.ts +13 -0
- package/dist/models/base.model.d.ts.map +1 -0
- package/dist/models/base.model.js +22 -0
- package/dist/models/base.model.js.map +1 -0
- package/dist/models/device/climbro.model.d.ts +42 -0
- package/dist/models/device/climbro.model.d.ts.map +1 -0
- package/dist/models/device/climbro.model.js +143 -0
- package/dist/models/device/climbro.model.js.map +1 -0
- package/dist/models/device/entralpi.model.d.ts +64 -0
- package/dist/models/device/entralpi.model.d.ts.map +1 -0
- package/dist/models/device/entralpi.model.js +240 -0
- package/dist/models/device/entralpi.model.js.map +1 -0
- package/dist/models/device/forceboard.model.d.ts +73 -0
- package/dist/models/device/forceboard.model.d.ts.map +1 -0
- package/dist/models/device/forceboard.model.js +312 -0
- package/dist/models/device/forceboard.model.js.map +1 -0
- package/dist/models/device/kilterboard.model.d.ts +144 -0
- package/dist/models/device/kilterboard.model.d.ts.map +1 -0
- package/dist/models/device/kilterboard.model.js +287 -0
- package/dist/models/device/kilterboard.model.js.map +1 -0
- package/dist/models/device/motherboard.model.d.ts +110 -0
- package/dist/models/device/motherboard.model.d.ts.map +1 -0
- package/dist/models/device/motherboard.model.js +378 -0
- package/dist/models/device/motherboard.model.js.map +1 -0
- package/dist/models/device/mysmartboard.model.d.ts +11 -0
- package/dist/models/device/mysmartboard.model.d.ts.map +1 -0
- package/dist/models/device/mysmartboard.model.js +15 -0
- package/dist/models/device/mysmartboard.model.js.map +1 -0
- package/dist/models/device/progressor.model.d.ts +39 -0
- package/dist/models/device/progressor.model.d.ts.map +1 -0
- package/dist/models/device/progressor.model.js +216 -0
- package/dist/models/device/progressor.model.js.map +1 -0
- package/dist/models/device/smartboard-pro.model.d.ts +11 -0
- package/dist/models/device/smartboard-pro.model.d.ts.map +1 -0
- package/dist/models/device/smartboard-pro.model.js +52 -0
- package/dist/models/device/smartboard-pro.model.js.map +1 -0
- package/dist/models/device/wh-c06.model.d.ts +57 -0
- package/dist/models/device/wh-c06.model.d.ts.map +1 -0
- package/dist/models/device/wh-c06.model.js +167 -0
- package/dist/models/device/wh-c06.model.js.map +1 -0
- package/dist/models/device.model.d.ts +408 -0
- package/dist/models/device.model.d.ts.map +1 -0
- package/dist/models/device.model.js +720 -0
- package/dist/models/device.model.js.map +1 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +10 -0
- package/dist/models/index.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/package.json +5 -1
- package/src/interfaces/device/climbro.interface.ts +8 -2
- package/src/models/device/climbro.model.ts +150 -3
- package/deno.json +0 -8
- package/tsconfig.cjs.json +0 -15
- package/tsconfig.json +0 -13
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Device } from "../device.model.js";
|
|
2
|
+
import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* For API level 2 and API level 3.
|
|
5
|
+
* The first byte in the data is dependent on where the packet is in the message as a whole.
|
|
6
|
+
* More details: https://github.com/1-max-1/fake_kilter_board
|
|
7
|
+
*/
|
|
8
|
+
export declare enum KilterBoardPacket {
|
|
9
|
+
/** If this packet is in the middle, the byte gets set to 77 (M). */
|
|
10
|
+
V2_MIDDLE = 77,
|
|
11
|
+
/** If this packet is the first packet in the message, then this byte gets set to 78 (N). */
|
|
12
|
+
V2_FIRST = 78,
|
|
13
|
+
/** If this is the last packet in the message, this byte gets set to 79 (0). */
|
|
14
|
+
V2_LAST = 79,
|
|
15
|
+
/** If this packet is the only packet in the message, the byte gets set to 80 (P). Note that this takes priority over the other conditions. */
|
|
16
|
+
V2_ONLY = 80,
|
|
17
|
+
/** If this packet is in the middle, the byte gets set to 81 (Q). */
|
|
18
|
+
V3_MIDDLE = 81,
|
|
19
|
+
/** If this packet is the first packet in the message, then this byte gets set to 82 (R). */
|
|
20
|
+
V3_FIRST = 82,
|
|
21
|
+
/** If this is the last packet in the message, this byte gets set to 83 (S). */
|
|
22
|
+
V3_LAST = 83,
|
|
23
|
+
/** If this packet is the only packet in the message, the byte gets set to 84 (T). Note that this takes priority over the other conditions. */
|
|
24
|
+
V3_ONLY = 84
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extracted from placement_roles database table.
|
|
28
|
+
*/
|
|
29
|
+
export declare const KilterBoardPlacementRoles: {
|
|
30
|
+
id: number;
|
|
31
|
+
product_id: number;
|
|
32
|
+
position: number;
|
|
33
|
+
name: string;
|
|
34
|
+
full_name: string;
|
|
35
|
+
led_color: string;
|
|
36
|
+
screen_color: string;
|
|
37
|
+
}[];
|
|
38
|
+
/**
|
|
39
|
+
* Represents a Aurora Climbing device.
|
|
40
|
+
* Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
|
|
41
|
+
* {@link https://auroraclimbing.com}
|
|
42
|
+
*/
|
|
43
|
+
export declare class KilterBoard extends Device implements IKilterBoard {
|
|
44
|
+
/**
|
|
45
|
+
* UUID for the Aurora Climbing Advertising service.
|
|
46
|
+
* This constant is used to identify the specific Bluetooth service for Kilter Boards.
|
|
47
|
+
* @type {string}
|
|
48
|
+
* @static
|
|
49
|
+
* @readonly
|
|
50
|
+
* @constant
|
|
51
|
+
*/
|
|
52
|
+
static readonly AuroraUUID: string;
|
|
53
|
+
/**
|
|
54
|
+
* Maximum length of the message body for byte wrapping.
|
|
55
|
+
* This value defines the limit for the size of messages that can be sent or received
|
|
56
|
+
* to ensure proper byte wrapping in communication.
|
|
57
|
+
* @type {number}
|
|
58
|
+
* @private
|
|
59
|
+
* @readonly
|
|
60
|
+
* @constant
|
|
61
|
+
*/
|
|
62
|
+
private static readonly messageBodyMaxLength;
|
|
63
|
+
/**
|
|
64
|
+
* Maximum length of the Bluetooth message chunk.
|
|
65
|
+
* This value sets the upper limit for the size of individual Bluetooth messages
|
|
66
|
+
* sent to and from the device to comply with Bluetooth protocol constraints.
|
|
67
|
+
* @type {number}
|
|
68
|
+
* @private
|
|
69
|
+
* @readonly
|
|
70
|
+
* @constant
|
|
71
|
+
*/
|
|
72
|
+
private static readonly maxBluetoothMessageSize;
|
|
73
|
+
constructor();
|
|
74
|
+
/**
|
|
75
|
+
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|
|
76
|
+
* @param data - The array of bytes to calculate the checksum for.
|
|
77
|
+
* @returns {number} The calculated checksum value.
|
|
78
|
+
*/
|
|
79
|
+
private checksum;
|
|
80
|
+
/**
|
|
81
|
+
* Wraps a byte array with header and footer bytes for transmission.
|
|
82
|
+
* @param data - The array of bytes to wrap.
|
|
83
|
+
* @returns {number[]} The wrapped byte array.
|
|
84
|
+
*/
|
|
85
|
+
private wrapBytes;
|
|
86
|
+
/**
|
|
87
|
+
* Encodes a position into a byte array.
|
|
88
|
+
* The lowest 8 bits of the position get put in the first byte of the group.
|
|
89
|
+
* The highest 8 bits of the position get put in the second byte of the group.
|
|
90
|
+
* @param position - The position to encode.
|
|
91
|
+
* @returns {number[]} The encoded byte array representing the position.
|
|
92
|
+
*/
|
|
93
|
+
private encodePosition;
|
|
94
|
+
/**
|
|
95
|
+
* Encodes a color string into a numeric representation.
|
|
96
|
+
* 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).
|
|
97
|
+
* @param color - The color string in hexadecimal format (e.g., 'FFFFFF').
|
|
98
|
+
* @returns The encoded /compressed color value.
|
|
99
|
+
*/
|
|
100
|
+
private encodeColor;
|
|
101
|
+
/**
|
|
102
|
+
* Encodes a placement (requires a 16-bit position and a 24-bit rgb color. ) into a byte array.
|
|
103
|
+
* @param position - The position to encode.
|
|
104
|
+
* @param ledColor - The color of the LED in hexadecimal format (e.g., 'FFFFFF').
|
|
105
|
+
* @returns The encoded byte array representing the placement.
|
|
106
|
+
*/
|
|
107
|
+
private encodePlacement;
|
|
108
|
+
/**
|
|
109
|
+
* Prepares byte arrays for transmission based on a list of climb placements.
|
|
110
|
+
* @param {{ position: number; role_id: number }[]} climbPlacementList - The list of climb placements containing position and role ID.
|
|
111
|
+
* @returns {number[]} The final byte array ready for transmission.
|
|
112
|
+
*/
|
|
113
|
+
private prepBytesV3;
|
|
114
|
+
/**
|
|
115
|
+
* Splits a collection into slices of the specified length.
|
|
116
|
+
* https://github.com/ramda/ramda/blob/master/source/splitEvery
|
|
117
|
+
* @param {Number} n
|
|
118
|
+
* @param {Array} list
|
|
119
|
+
* @return {Array<number[]>}
|
|
120
|
+
*/
|
|
121
|
+
private splitEvery;
|
|
122
|
+
/**
|
|
123
|
+
* The kilter board only supports messages of 20 bytes
|
|
124
|
+
* at a time. This method splits a full message into parts
|
|
125
|
+
* of 20 bytes
|
|
126
|
+
*
|
|
127
|
+
* @param buffer
|
|
128
|
+
*/
|
|
129
|
+
private splitMessages;
|
|
130
|
+
/**
|
|
131
|
+
* Sends a series of messages to a device.
|
|
132
|
+
*/
|
|
133
|
+
private writeMessageSeries;
|
|
134
|
+
/**
|
|
135
|
+
* Configures the LEDs based on an array of climb placements.
|
|
136
|
+
* @param {{ position: number; role_id: number }[]} config - Array of climb placements for the LEDs.
|
|
137
|
+
* @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.
|
|
138
|
+
*/
|
|
139
|
+
led: (config: {
|
|
140
|
+
position: number;
|
|
141
|
+
role_id: number;
|
|
142
|
+
}[]) => Promise<number[] | undefined>;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=kilterboard.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kilterboard.model.d.ts","sourceRoot":"","sources":["../../../../src/models/device/kilterboard.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAA;AAEpF;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,oEAAoE;IACpE,SAAS,KAAK;IACd,4FAA4F;IAC5F,QAAQ,KAAA;IACR,+EAA+E;IAC/E,OAAO,KAAA;IACP,8IAA8I;IAC9I,OAAO,KAAA;IACP,oEAAoE;IACpE,SAAS,KAAA;IACT,4FAA4F;IAC5F,QAAQ,KAAA;IACR,+EAA+E;IAC/E,OAAO,KAAA;IACP,8IAA8I;IAC9I,OAAO,KAAA;CACR;AACD;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;GAqCrC,CAAA;AAED;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,MAAO,YAAW,YAAY;IAC7D;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAyC;IAE3E;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAc;IAE1D;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAa;;IA+B5D;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAQhB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAiBjB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAOtB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAenB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAIvB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAkCnB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAYlB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa,CAC2E;IAEhG;;OAEG;YACW,kBAAkB;IAMhC;;;;OAIG;IACH,GAAG,GAAU,QAAQ;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAW3F;CACF"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KilterBoard = exports.KilterBoardPlacementRoles = exports.KilterBoardPacket = void 0;
|
|
4
|
+
const device_model_js_1 = require("../device.model.js");
|
|
5
|
+
/**
|
|
6
|
+
* For API level 2 and API level 3.
|
|
7
|
+
* The first byte in the data is dependent on where the packet is in the message as a whole.
|
|
8
|
+
* More details: https://github.com/1-max-1/fake_kilter_board
|
|
9
|
+
*/
|
|
10
|
+
var KilterBoardPacket;
|
|
11
|
+
(function (KilterBoardPacket) {
|
|
12
|
+
/** If this packet is in the middle, the byte gets set to 77 (M). */
|
|
13
|
+
KilterBoardPacket[KilterBoardPacket["V2_MIDDLE"] = 77] = "V2_MIDDLE";
|
|
14
|
+
/** If this packet is the first packet in the message, then this byte gets set to 78 (N). */
|
|
15
|
+
KilterBoardPacket[KilterBoardPacket["V2_FIRST"] = 78] = "V2_FIRST";
|
|
16
|
+
/** If this is the last packet in the message, this byte gets set to 79 (0). */
|
|
17
|
+
KilterBoardPacket[KilterBoardPacket["V2_LAST"] = 79] = "V2_LAST";
|
|
18
|
+
/** If this packet is the only packet in the message, the byte gets set to 80 (P). Note that this takes priority over the other conditions. */
|
|
19
|
+
KilterBoardPacket[KilterBoardPacket["V2_ONLY"] = 80] = "V2_ONLY";
|
|
20
|
+
/** If this packet is in the middle, the byte gets set to 81 (Q). */
|
|
21
|
+
KilterBoardPacket[KilterBoardPacket["V3_MIDDLE"] = 81] = "V3_MIDDLE";
|
|
22
|
+
/** If this packet is the first packet in the message, then this byte gets set to 82 (R). */
|
|
23
|
+
KilterBoardPacket[KilterBoardPacket["V3_FIRST"] = 82] = "V3_FIRST";
|
|
24
|
+
/** If this is the last packet in the message, this byte gets set to 83 (S). */
|
|
25
|
+
KilterBoardPacket[KilterBoardPacket["V3_LAST"] = 83] = "V3_LAST";
|
|
26
|
+
/** If this packet is the only packet in the message, the byte gets set to 84 (T). Note that this takes priority over the other conditions. */
|
|
27
|
+
KilterBoardPacket[KilterBoardPacket["V3_ONLY"] = 84] = "V3_ONLY";
|
|
28
|
+
})(KilterBoardPacket || (exports.KilterBoardPacket = KilterBoardPacket = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Extracted from placement_roles database table.
|
|
31
|
+
*/
|
|
32
|
+
exports.KilterBoardPlacementRoles = [
|
|
33
|
+
{
|
|
34
|
+
id: 12,
|
|
35
|
+
product_id: 1,
|
|
36
|
+
position: 1,
|
|
37
|
+
name: "start",
|
|
38
|
+
full_name: "Start",
|
|
39
|
+
led_color: "00FF00",
|
|
40
|
+
screen_color: "00DD00",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 13,
|
|
44
|
+
product_id: 1,
|
|
45
|
+
position: 2,
|
|
46
|
+
name: "middle",
|
|
47
|
+
full_name: "Middle",
|
|
48
|
+
led_color: "00FFFF",
|
|
49
|
+
screen_color: "00FFFF",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 14,
|
|
53
|
+
product_id: 1,
|
|
54
|
+
position: 3,
|
|
55
|
+
name: "finish",
|
|
56
|
+
full_name: "Finish",
|
|
57
|
+
led_color: "FF00FF",
|
|
58
|
+
screen_color: "FF00FF",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 15,
|
|
62
|
+
product_id: 1,
|
|
63
|
+
position: 4,
|
|
64
|
+
name: "foot",
|
|
65
|
+
full_name: "Foot Only",
|
|
66
|
+
led_color: "FFB600",
|
|
67
|
+
screen_color: "FFA500",
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* Represents a Aurora Climbing device.
|
|
72
|
+
* Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
|
|
73
|
+
* {@link https://auroraclimbing.com}
|
|
74
|
+
*/
|
|
75
|
+
class KilterBoard extends device_model_js_1.Device {
|
|
76
|
+
constructor() {
|
|
77
|
+
super({
|
|
78
|
+
filters: [
|
|
79
|
+
{
|
|
80
|
+
services: [KilterBoard.AuroraUUID],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
services: [
|
|
84
|
+
{
|
|
85
|
+
name: "UART Nordic Service",
|
|
86
|
+
id: "uart",
|
|
87
|
+
uuid: "6e400001-b5a3-f393-e0a9-e50e24dcca9e",
|
|
88
|
+
characteristics: [
|
|
89
|
+
{
|
|
90
|
+
name: "TX",
|
|
91
|
+
id: "tx",
|
|
92
|
+
uuid: "6e400002-b5a3-f393-e0a9-e50e24dcca9e",
|
|
93
|
+
},
|
|
94
|
+
// {
|
|
95
|
+
// name: "RX",
|
|
96
|
+
// id: "rx",
|
|
97
|
+
// uuid: "6e400003-b5a3-f393-e0a9-e50e24dcca9e",
|
|
98
|
+
// },
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* The kilter board only supports messages of 20 bytes
|
|
105
|
+
* at a time. This method splits a full message into parts
|
|
106
|
+
* of 20 bytes
|
|
107
|
+
*
|
|
108
|
+
* @param buffer
|
|
109
|
+
*/
|
|
110
|
+
this.splitMessages = (buffer) => this.splitEvery(KilterBoard.maxBluetoothMessageSize, buffer).map((arr) => new Uint8Array(arr));
|
|
111
|
+
/**
|
|
112
|
+
* Configures the LEDs based on an array of climb placements.
|
|
113
|
+
* @param {{ position: number; role_id: number }[]} config - Array of climb placements for the LEDs.
|
|
114
|
+
* @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.
|
|
115
|
+
*/
|
|
116
|
+
this.led = async (config) => {
|
|
117
|
+
// Handle Kilterboard logic: process placements and send payload if connected
|
|
118
|
+
if (Array.isArray(config)) {
|
|
119
|
+
// Prepares byte arrays for transmission based on a list of climb placements.
|
|
120
|
+
const payload = this.prepBytesV3(config);
|
|
121
|
+
if (this.isConnected()) {
|
|
122
|
+
await this.writeMessageSeries(this.splitMessages(payload));
|
|
123
|
+
}
|
|
124
|
+
return payload;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|
|
131
|
+
* @param data - The array of bytes to calculate the checksum for.
|
|
132
|
+
* @returns {number} The calculated checksum value.
|
|
133
|
+
*/
|
|
134
|
+
checksum(data) {
|
|
135
|
+
let i = 0;
|
|
136
|
+
for (const value of data) {
|
|
137
|
+
i = (i + value) & 255;
|
|
138
|
+
}
|
|
139
|
+
return ~i & 255;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Wraps a byte array with header and footer bytes for transmission.
|
|
143
|
+
* @param data - The array of bytes to wrap.
|
|
144
|
+
* @returns {number[]} The wrapped byte array.
|
|
145
|
+
*/
|
|
146
|
+
wrapBytes(data) {
|
|
147
|
+
if (data.length > KilterBoard.messageBodyMaxLength) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
- 0x1
|
|
152
|
+
- len(packets)
|
|
153
|
+
- checksum(packets)
|
|
154
|
+
- 0x2
|
|
155
|
+
- *packets
|
|
156
|
+
- 0x3
|
|
157
|
+
|
|
158
|
+
First byte is always 1, the second is a number of packets, then checksum, then 2, packets themselves, and finally 3.
|
|
159
|
+
*/
|
|
160
|
+
return [1, data.length, this.checksum(data), 2, ...data, 3];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Encodes a position into a byte array.
|
|
164
|
+
* The lowest 8 bits of the position get put in the first byte of the group.
|
|
165
|
+
* The highest 8 bits of the position get put in the second byte of the group.
|
|
166
|
+
* @param position - The position to encode.
|
|
167
|
+
* @returns {number[]} The encoded byte array representing the position.
|
|
168
|
+
*/
|
|
169
|
+
encodePosition(position) {
|
|
170
|
+
const position1 = position & 255;
|
|
171
|
+
const position2 = (position & 65280) >> 8;
|
|
172
|
+
return [position1, position2];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Encodes a color string into a numeric representation.
|
|
176
|
+
* 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).
|
|
177
|
+
* @param color - The color string in hexadecimal format (e.g., 'FFFFFF').
|
|
178
|
+
* @returns The encoded /compressed color value.
|
|
179
|
+
*/
|
|
180
|
+
encodeColor(color) {
|
|
181
|
+
const substring = color.substring(0, 2);
|
|
182
|
+
const substring2 = color.substring(2, 4);
|
|
183
|
+
const parsedSubstring = parseInt(substring, 16) / 32;
|
|
184
|
+
const parsedSubstring2 = parseInt(substring2, 16) / 32;
|
|
185
|
+
const parsedResult = (parsedSubstring << 5) | (parsedSubstring2 << 2);
|
|
186
|
+
const substring3 = color.substring(4, 6);
|
|
187
|
+
const parsedSubstring3 = parseInt(substring3, 16) / 64;
|
|
188
|
+
const finalParsedResult = parsedResult | parsedSubstring3;
|
|
189
|
+
return finalParsedResult;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Encodes a placement (requires a 16-bit position and a 24-bit rgb color. ) into a byte array.
|
|
193
|
+
* @param position - The position to encode.
|
|
194
|
+
* @param ledColor - The color of the LED in hexadecimal format (e.g., 'FFFFFF').
|
|
195
|
+
* @returns The encoded byte array representing the placement.
|
|
196
|
+
*/
|
|
197
|
+
encodePlacement(position, ledColor) {
|
|
198
|
+
return [...this.encodePosition(position), this.encodeColor(ledColor)];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Prepares byte arrays for transmission based on a list of climb placements.
|
|
202
|
+
* @param {{ position: number; role_id: number }[]} climbPlacementList - The list of climb placements containing position and role ID.
|
|
203
|
+
* @returns {number[]} The final byte array ready for transmission.
|
|
204
|
+
*/
|
|
205
|
+
prepBytesV3(climbPlacementList) {
|
|
206
|
+
const resultArray = [];
|
|
207
|
+
let tempArray = [KilterBoardPacket.V3_MIDDLE];
|
|
208
|
+
for (const climbPlacement of climbPlacementList) {
|
|
209
|
+
if (tempArray.length + 3 > KilterBoard.messageBodyMaxLength) {
|
|
210
|
+
resultArray.push(tempArray);
|
|
211
|
+
tempArray = [KilterBoardPacket.V3_MIDDLE];
|
|
212
|
+
}
|
|
213
|
+
const role = exports.KilterBoardPlacementRoles.find((placement) => placement.id === climbPlacement.role_id);
|
|
214
|
+
if (!role) {
|
|
215
|
+
throw new Error(`Role with id ${climbPlacement.role_id} not found in placement_roles`);
|
|
216
|
+
}
|
|
217
|
+
const encodedPlacement = this.encodePlacement(climbPlacement.position, role.led_color);
|
|
218
|
+
tempArray.push(...encodedPlacement);
|
|
219
|
+
}
|
|
220
|
+
resultArray.push(tempArray);
|
|
221
|
+
if (resultArray.length === 1) {
|
|
222
|
+
resultArray[0][0] = KilterBoardPacket.V3_ONLY;
|
|
223
|
+
}
|
|
224
|
+
else if (resultArray.length > 1) {
|
|
225
|
+
resultArray[0][0] = KilterBoardPacket.V3_FIRST;
|
|
226
|
+
resultArray[resultArray.length - 1][0] = KilterBoardPacket.V3_LAST;
|
|
227
|
+
}
|
|
228
|
+
const finalResultArray = [];
|
|
229
|
+
for (const currentArray of resultArray) {
|
|
230
|
+
finalResultArray.push(...this.wrapBytes(currentArray));
|
|
231
|
+
}
|
|
232
|
+
return finalResultArray;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Splits a collection into slices of the specified length.
|
|
236
|
+
* https://github.com/ramda/ramda/blob/master/source/splitEvery
|
|
237
|
+
* @param {Number} n
|
|
238
|
+
* @param {Array} list
|
|
239
|
+
* @return {Array<number[]>}
|
|
240
|
+
*/
|
|
241
|
+
splitEvery(n, list) {
|
|
242
|
+
if (n <= 0) {
|
|
243
|
+
throw new Error("First argument to splitEvery must be a positive integer");
|
|
244
|
+
}
|
|
245
|
+
const result = [];
|
|
246
|
+
let idx = 0;
|
|
247
|
+
while (idx < list.length) {
|
|
248
|
+
result.push(list.slice(idx, (idx += n)));
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Sends a series of messages to a device.
|
|
254
|
+
*/
|
|
255
|
+
async writeMessageSeries(messages) {
|
|
256
|
+
for (const message of messages) {
|
|
257
|
+
await this.write("uart", "tx", message);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.KilterBoard = KilterBoard;
|
|
262
|
+
/**
|
|
263
|
+
* UUID for the Aurora Climbing Advertising service.
|
|
264
|
+
* This constant is used to identify the specific Bluetooth service for Kilter Boards.
|
|
265
|
+
* @type {string}
|
|
266
|
+
* @static
|
|
267
|
+
* @readonly
|
|
268
|
+
* @constant
|
|
269
|
+
*/
|
|
270
|
+
KilterBoard.AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
|
|
271
|
+
/**
|
|
272
|
+
* Maximum length of the message body for byte wrapping.
|
|
273
|
+
* This value defines the limit for the size of messages that can be sent or received
|
|
274
|
+
* to ensure proper byte wrapping in communication.
|
|
275
|
+
* @type {number}
|
|
276
|
+
* @private
|
|
277
|
+
* @readonly
|
|
278
|
+
* @constant
|
|
279
|
+
*/
|
|
280
|
+
KilterBoard.messageBodyMaxLength = 255;
|
|
281
|
+
/**
|
|
282
|
+
* Maximum length of the Bluetooth message chunk.
|
|
283
|
+
* This value sets the upper limit for the size of individual Bluetooth messages
|
|
284
|
+
* sent to and from the device to comply with Bluetooth protocol constraints.
|
|
285
|
+
* @type {number}
|
|
286
|
+
* @private
|
|
287
|
+
* @readonly
|
|
288
|
+
* @constant
|
|
289
|
+
*/
|
|
290
|
+
KilterBoard.maxBluetoothMessageSize = 20;
|
|
291
|
+
//# sourceMappingURL=kilterboard.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kilterboard.model.js","sourceRoot":"","sources":["../../../../src/models/device/kilterboard.model.ts"],"names":[],"mappings":";;;AAAA,wDAA2C;AAG3C;;;;GAIG;AACH,IAAY,iBAiBX;AAjBD,WAAY,iBAAiB;IAC3B,oEAAoE;IACpE,oEAAc,CAAA;IACd,4FAA4F;IAC5F,kEAAQ,CAAA;IACR,+EAA+E;IAC/E,gEAAO,CAAA;IACP,8IAA8I;IAC9I,gEAAO,CAAA;IACP,oEAAoE;IACpE,oEAAS,CAAA;IACT,4FAA4F;IAC5F,kEAAQ,CAAA;IACR,+EAA+E;IAC/E,gEAAO,CAAA;IACP,8IAA8I;IAC9I,gEAAO,CAAA;AACT,CAAC,EAjBW,iBAAiB,iCAAjB,iBAAiB,QAiB5B;AACD;;GAEG;AACU,QAAA,yBAAyB,GAAG;IACvC;QACE,EAAE,EAAE,EAAE;QACN,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD;QACE,EAAE,EAAE,EAAE;QACN,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD;QACE,EAAE,EAAE,EAAE;QACN,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD;QACE,EAAE,EAAE,EAAE;QACN,UAAU,EAAE,CAAC;Q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,CAAC;IAYD;;OAEG;IACK,KAAK,CAAC,kBAAkB,CAAC,QAAsB;QACrD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;;AAzNH,kCA4OC;AA3OC;;;;;;;GAOG;AACa,sBAAU,GAAW,sCAAsC,AAAjD,CAAiD;AAE3E;;;;;;;;GAQG;AACqB,gCAAoB,GAAW,GAAG,AAAd,CAAc;AAE1D;;;;;;;;GAQG;AACqB,mCAAuB,GAAW,EAAE,AAAb,CAAa"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Device } from "../device.model.js";
|
|
2
|
+
import type { IMotherboard } from "../../interfaces/device/motherboard.interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Griptonite Motherboard device.
|
|
5
|
+
* {@link https://griptonite.io}
|
|
6
|
+
*/
|
|
7
|
+
export declare class Motherboard extends Device implements IMotherboard {
|
|
8
|
+
/**
|
|
9
|
+
* Length of the packet received from the device.
|
|
10
|
+
* @type {number}
|
|
11
|
+
* @static
|
|
12
|
+
* @readonly
|
|
13
|
+
* @constant
|
|
14
|
+
*/
|
|
15
|
+
private static readonly packetLength;
|
|
16
|
+
/**
|
|
17
|
+
* Number of samples contained in the data packet.
|
|
18
|
+
* @type {number}
|
|
19
|
+
* @static
|
|
20
|
+
* @readonly
|
|
21
|
+
* @constant
|
|
22
|
+
*/
|
|
23
|
+
private static readonly samplesNumber;
|
|
24
|
+
/**
|
|
25
|
+
* Buffer to store received data from the device.
|
|
26
|
+
* @type {number[]}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
private receiveBuffer;
|
|
30
|
+
/**
|
|
31
|
+
* Calibration data for each sensor of the device.
|
|
32
|
+
* @type {number[][][]}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
private calibrationData;
|
|
36
|
+
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Applies calibration to a sample value.
|
|
39
|
+
* @param {number} sample - The sample value to calibrate.
|
|
40
|
+
* @param {number[][]} calibration - The calibration data.
|
|
41
|
+
* @returns {number} The calibrated sample value.
|
|
42
|
+
*/
|
|
43
|
+
private applyCalibration;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves battery or voltage information from the device.
|
|
46
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
|
|
47
|
+
*/
|
|
48
|
+
battery: () => Promise<string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Writes a command to get calibration data from the device.
|
|
51
|
+
* @returns {Promise<void>} A Promise that resolves when the command is successfully sent.
|
|
52
|
+
*/
|
|
53
|
+
calibration: () => Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves firmware version from the device.
|
|
56
|
+
* @returns {Promise<string>} A Promise that resolves with the firmware version,
|
|
57
|
+
*/
|
|
58
|
+
firmware: () => Promise<string | undefined>;
|
|
59
|
+
/**
|
|
60
|
+
* Handles data received from the Motherboard device. Processes hex-encoded streaming packets
|
|
61
|
+
* to extract samples, calibrate masses, and update running averages of mass data.
|
|
62
|
+
* If the received data is not a valid hex packet, it returns the unprocessed data.
|
|
63
|
+
*
|
|
64
|
+
* @param {DataView} value - The notification event.
|
|
65
|
+
*/
|
|
66
|
+
handleNotifications: (value: DataView) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves hardware version from the device.
|
|
69
|
+
* @returns {Promise<string>} A Promise that resolves with the hardware version,
|
|
70
|
+
*/
|
|
71
|
+
hardware: () => Promise<string | undefined>;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the LED color based on a single color option. Defaults to turning the LEDs off if no configuration is provided.
|
|
74
|
+
* @param {"green" | "red" | "orange"} [config] - Optional color or array of climb placements for the LEDs. Ignored if placements are provided.
|
|
75
|
+
* @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.
|
|
76
|
+
*/
|
|
77
|
+
led: (config?: "green" | "red" | "orange") => Promise<number[] | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves manufacturer information from the device.
|
|
80
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
81
|
+
*/
|
|
82
|
+
manufacturer: () => Promise<string | undefined>;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves serial number from the device.
|
|
85
|
+
* @returns {Promise<string>} A Promise that resolves with the serial number,
|
|
86
|
+
*/
|
|
87
|
+
serial: () => Promise<string | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Stops the data stream on the specified device.
|
|
90
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
91
|
+
*/
|
|
92
|
+
stop: () => Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Starts streaming data from the specified device.
|
|
95
|
+
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
96
|
+
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
97
|
+
*/
|
|
98
|
+
stream: (duration?: number) => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves the entire 320 bytes of non-volatile memory from the device.
|
|
101
|
+
*
|
|
102
|
+
* The memory consists of 10 segments, each 32 bytes long. If any segment was previously written,
|
|
103
|
+
* the corresponding data will appear in the response. Unused portions of the memory are
|
|
104
|
+
* padded with whitespace.
|
|
105
|
+
*
|
|
106
|
+
* @returns {Promise<string>} A Promise that resolves with the 320-byte memory content as a string,
|
|
107
|
+
*/
|
|
108
|
+
text: () => Promise<string | undefined>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=motherboard.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motherboard.model.d.ts","sourceRoot":"","sources":["../../../../src/models/device/motherboard.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAA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