@hangtime/grip-connect 0.5.1 → 0.5.3
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 +8 -17
- package/dist/{download.d.ts → helpers/download.d.ts} +1 -1
- package/dist/helpers/is-device.d.ts +37 -0
- package/dist/helpers/is-device.js +39 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -5
- package/dist/interfaces/callback.interface.d.ts +49 -0
- package/dist/interfaces/command.interface.d.ts +85 -0
- package/dist/interfaces/device.interface.d.ts +54 -12
- package/dist/models/device/entralpi.model.js +18 -24
- package/dist/models/device/forceboard.model.js +7 -8
- package/dist/models/device/kilterboard.model.d.ts +61 -2
- package/dist/models/device/kilterboard.model.js +92 -13
- package/dist/models/device/motherboard.model.d.ts +24 -1
- package/dist/models/device/motherboard.model.js +63 -43
- package/dist/models/device/progressor.model.js +64 -26
- package/dist/models/device/wh-c06.model.d.ts +7 -0
- package/dist/models/device/wh-c06.model.js +18 -17
- package/dist/models/device.model.d.ts +105 -11
- package/dist/models/device.model.js +181 -10
- package/package.json +1 -1
- package/src/{download.ts → helpers/download.ts} +1 -1
- package/src/helpers/is-device.ts +50 -0
- package/src/index.ts +4 -5
- package/src/interfaces/callback.interface.ts +56 -0
- package/src/interfaces/command.interface.ts +106 -0
- package/src/interfaces/device.interface.ts +66 -13
- package/src/models/device/entralpi.model.ts +18 -25
- package/src/models/device/forceboard.model.ts +7 -8
- package/src/models/device/kilterboard.model.ts +94 -15
- package/src/models/device/motherboard.model.ts +68 -47
- package/src/models/device/progressor.model.ts +68 -27
- package/src/models/device/wh-c06.model.ts +20 -18
- package/src/models/device.model.ts +207 -17
- package/dist/characteristic.d.ts +0 -9
- package/dist/characteristic.js +0 -21
- package/dist/commands/climbro.d.ts +0 -6
- package/dist/commands/climbro.js +0 -5
- package/dist/commands/entralpi.d.ts +0 -6
- package/dist/commands/entralpi.js +0 -5
- package/dist/commands/forceboard.d.ts +0 -6
- package/dist/commands/forceboard.js +0 -5
- package/dist/commands/index.d.ts +0 -7
- package/dist/commands/index.js +0 -7
- package/dist/commands/kilterboard.d.ts +0 -35
- package/dist/commands/kilterboard.js +0 -65
- package/dist/commands/motherboard.d.ts +0 -6
- package/dist/commands/motherboard.js +0 -13
- package/dist/commands/mysmartboard.d.ts +0 -6
- package/dist/commands/mysmartboard.js +0 -5
- package/dist/commands/progressor.d.ts +0 -17
- package/dist/commands/progressor.js +0 -30
- package/dist/commands/wh-c06.d.ts +0 -6
- package/dist/commands/wh-c06.js +0 -5
- package/dist/is-device.d.ts +0 -37
- package/dist/is-device.js +0 -39
- package/dist/read.d.ts +0 -10
- package/dist/read.js +0 -43
- package/dist/types/commands.d.ts +0 -18
- package/dist/types/notify.d.ts +0 -14
- package/dist/write.d.ts +0 -34
- package/dist/write.js +0 -58
- package/src/characteristic.ts +0 -29
- package/src/commands/climbro.ts +0 -6
- package/src/commands/entralpi.ts +0 -6
- package/src/commands/forceboard.ts +0 -6
- package/src/commands/index.ts +0 -13
- package/src/commands/kilterboard.ts +0 -64
- package/src/commands/motherboard.ts +0 -14
- package/src/commands/mysmartboard.ts +0 -6
- package/src/commands/progressor.ts +0 -31
- package/src/commands/wh-c06.ts +0 -6
- package/src/is-device.ts +0 -50
- package/src/read.ts +0 -45
- package/src/types/commands.ts +0 -21
- package/src/types/notify.ts +0 -14
- package/src/write.ts +0 -74
- /package/dist/{download.js → helpers/download.js} +0 -0
- /package/dist/{is-active.d.ts → helpers/is-active.d.ts} +0 -0
- /package/dist/{is-active.js → helpers/is-active.js} +0 -0
- /package/dist/{struct/index.d.ts → helpers/struct.d.ts} +0 -0
- /package/dist/{struct/index.js → helpers/struct.js} +0 -0
- /package/dist/{tare.d.ts → helpers/tare.d.ts} +0 -0
- /package/dist/{tare.js → helpers/tare.js} +0 -0
- /package/dist/{types/commands.js → interfaces/callback.interface.js} +0 -0
- /package/dist/{types/download.js → interfaces/command.interface.js} +0 -0
- /package/dist/{types/download.d.ts → interfaces/download.interface.d.ts} +0 -0
- /package/dist/{types/notify.js → interfaces/download.interface.js} +0 -0
- /package/src/{is-active.ts → helpers/is-active.ts} +0 -0
- /package/src/{struct/index.ts → helpers/struct.ts} +0 -0
- /package/src/{tare.ts → helpers/tare.ts} +0 -0
- /package/src/{types/download.ts → interfaces/download.interface.ts} +0 -0
package/README.md
CHANGED
|
@@ -110,16 +110,16 @@ motherboardButton.addEventListener("click", () => {
|
|
|
110
110
|
|
|
111
111
|
## Device support
|
|
112
112
|
|
|
113
|
-
- ✅ Griptonite - Motherboard
|
|
114
|
-
- ✅ Tindeq - Progressor
|
|
115
|
-
- ✅ Weiheng - WH-C06
|
|
113
|
+
- ✅ [Griptonite - Motherboard](https://stevie-ray.github.io/hangtime-grip-connect/devices/motherboard.html)
|
|
114
|
+
- ✅ [Tindeq - Progressor](https://stevie-ray.github.io/hangtime-grip-connect/devices/progressor.html)
|
|
115
|
+
- ✅ [Weiheng - WH-C06](https://stevie-ray.github.io/hangtime-grip-connect/devices/wh-c06.html)
|
|
116
116
|
- By default [watchAdvertisements](https://chromestatus.com/feature/5180688812736512) isn't supported . For Chrome,
|
|
117
117
|
enable it at `chrome://flags/#enable-experimental-web-platform-features`.
|
|
118
|
-
- ✅ Kilter Board
|
|
119
|
-
- ✅ Entralpi / Lefu Scale
|
|
120
|
-
- ⏳ PitchSix Force Board
|
|
121
|
-
- ➡️ Climbro
|
|
122
|
-
- ➡️ Smartboard Climbing - mySmartBoard
|
|
118
|
+
- ✅ [Kilter Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/kilterboard.html)
|
|
119
|
+
- ✅ [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) / Lefu Scale
|
|
120
|
+
- ⏳ [PitchSix Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html)
|
|
121
|
+
- ➡️ [Climbro](https://stevie-ray.github.io/hangtime-grip-connect/devices/climbro.html)
|
|
122
|
+
- ➡️ [Smartboard Climbing - mySmartBoard](https://stevie-ray.github.io/hangtime-grip-connect/devices/mysmartboard.html)
|
|
123
123
|
|
|
124
124
|
## Features
|
|
125
125
|
|
|
@@ -132,15 +132,6 @@ reactive `isActive` check and a `download` feature.
|
|
|
132
132
|
`chrome://bluetooth-internals/#devices` and press `Start Scan` to look for your device, click on `Inspect` and share all
|
|
133
133
|
available services with us.
|
|
134
134
|
|
|
135
|
-
| | [Motherboard](https://stevie-ray.github.io/hangtime-grip-connect/devices/motherboard.html) | [Progressor](https://stevie-ray.github.io/hangtime-grip-connect/devices/progressor.html) | [WH-C06](https://stevie-ray.github.io/hangtime-grip-connect/devices/wh-c06.html) | [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) | [Kilter Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/kilterboard.html) | [Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html) | [Climbro](https://stevie-ray.github.io/hangtime-grip-connect/devices/climbro.html) | [mySmartBoard](https://stevie-ray.github.io/hangtime-grip-connect/devices/mysmartboard.html) |
|
|
136
|
-
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
137
|
-
| [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | | |
|
|
138
|
-
| [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | ✅ | ✅ | ✅ | ✅ | | | | |
|
|
139
|
-
| [isDevice](https://stevie-ray.github.io/hangtime-grip-connect/api/is-device.html) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | |
|
|
140
|
-
| [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) | ✅ | | | ✅ | | ✅ | | |
|
|
141
|
-
| [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) | ✅ | ✅ | ✅ | ✅ | | | | |
|
|
142
|
-
| [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ | ✅ | | | ✅ | | | |
|
|
143
|
-
|
|
144
135
|
## Development
|
|
145
136
|
|
|
146
137
|
```bash
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Device } from "./../models/device.model";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given device is an Entralpi.
|
|
4
|
+
* @param {Device} [device] - The device to check.
|
|
5
|
+
* @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEntralpi: (device?: Device) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the given device is a Force Board.
|
|
10
|
+
* @param {Device} [device] - The device to check.
|
|
11
|
+
* @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isForceBoard: (device?: Device) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the given device is a Kilter Board.
|
|
16
|
+
* @param {Device} [device] - The device to check.
|
|
17
|
+
* @returns {boolean} `true` if the device has a service UUID matching the Kilter Board Aurora UUID, otherwise `false`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isKilterBoard: (device?: Device) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the given device is a Motherboard.
|
|
22
|
+
* @param {Device} [device] - The device to check.
|
|
23
|
+
* @returns {boolean} `true` if the device has a filter with the name "Motherdevice", otherwise `false`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const isMotherboard: (device?: Device) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the given device is a Progressor.
|
|
28
|
+
* @param {Device} [device] - The device to check.
|
|
29
|
+
* @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const isProgressor: (device?: Device) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the given device is a WH-C06.
|
|
34
|
+
* @param {Device} [device] - The device to check.
|
|
35
|
+
* @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const isWHC06: (device?: Device) => boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { KilterBoard } from "../models";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given device is an Entralpi.
|
|
4
|
+
* @param {Device} [device] - The device to check.
|
|
5
|
+
* @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export const isEntralpi = (device) => device?.filters.some((filter) => filter.name === "ENTRALPI") ?? false;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the given device is a Force Board.
|
|
10
|
+
* @param {Device} [device] - The device to check.
|
|
11
|
+
* @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
|
|
12
|
+
*/
|
|
13
|
+
export const isForceBoard = (device) => device?.filters.some((filter) => filter.name === "Force Board") ?? false;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the given device is a Kilter Board.
|
|
16
|
+
* @param {Device} [device] - The device to check.
|
|
17
|
+
* @returns {boolean} `true` if the device has a service UUID matching the Kilter Board Aurora UUID, otherwise `false`.
|
|
18
|
+
*/
|
|
19
|
+
export const isKilterBoard = (device) => {
|
|
20
|
+
return device?.filters.some((filter) => filter.services?.includes(KilterBoard.AuroraUUID)) ?? false;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the given device is a Motherboard.
|
|
24
|
+
* @param {Device} [device] - The device to check.
|
|
25
|
+
* @returns {boolean} `true` if the device has a filter with the name "Motherdevice", otherwise `false`.
|
|
26
|
+
*/
|
|
27
|
+
export const isMotherboard = (device) => device?.filters.some((filter) => filter.name === "Motherdevice") ?? false;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the given device is a Progressor.
|
|
30
|
+
* @param {Device} [device] - The device to check.
|
|
31
|
+
* @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
|
|
32
|
+
*/
|
|
33
|
+
export const isProgressor = (device) => device?.filters.some((filter) => filter.namePrefix === "Progressor") ?? false;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the given device is a WH-C06.
|
|
36
|
+
* @param {Device} [device] - The device to check.
|
|
37
|
+
* @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
export const isWHC06 = (device) => device?.filters.some((filter) => filter.manufacturerData?.some((data) => data.companyIdentifier === 0x0100)) ?? false;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
|
|
2
|
-
export { isEntralpi,
|
|
3
|
-
export { download } from "./download";
|
|
4
|
-
export { active, isActive } from "./is-active";
|
|
5
|
-
export { tare } from "./tare";
|
|
2
|
+
export { isEntralpi, isKilterBoard, isMotherboard, isWHC06, isProgressor } from "./helpers/is-device";
|
|
3
|
+
export { download } from "./helpers/download";
|
|
4
|
+
export { active, isActive } from "./helpers/is-active";
|
|
5
|
+
export { tare } from "./helpers/tare";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
|
|
2
2
|
// helpers
|
|
3
|
-
export { isEntralpi,
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { tare } from "./tare";
|
|
3
|
+
export { isEntralpi, isKilterBoard, isMotherboard, isWHC06, isProgressor } from "./helpers/is-device";
|
|
4
|
+
export { download } from "./helpers/download";
|
|
5
|
+
export { active, isActive } from "./helpers/is-active";
|
|
6
|
+
export { tare } from "./helpers/tare";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the mass data collected from a device.
|
|
3
|
+
*/
|
|
4
|
+
export interface massObject {
|
|
5
|
+
/**
|
|
6
|
+
* The total mass measured from the device.
|
|
7
|
+
* This is the overall weight or force reading.
|
|
8
|
+
*/
|
|
9
|
+
massTotal: string;
|
|
10
|
+
/**
|
|
11
|
+
* The maximum mass recorded during the session.
|
|
12
|
+
* This is the highest weight or force value detected.
|
|
13
|
+
*/
|
|
14
|
+
massMax: string;
|
|
15
|
+
/**
|
|
16
|
+
* The average mass calculated from all the recorded data points.
|
|
17
|
+
* This represents the mean value of the mass measurements.
|
|
18
|
+
*/
|
|
19
|
+
massAverage: string;
|
|
20
|
+
/**
|
|
21
|
+
* The mass recorded on the left side of the device (optional for Motherboard devices).
|
|
22
|
+
* Used for devices that measure force across multiple zones.
|
|
23
|
+
*/
|
|
24
|
+
massLeft?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The mass recorded at the center of the device (optional for Motherboard devices).
|
|
27
|
+
* Used for devices that measure force distribution across a center zone.
|
|
28
|
+
*/
|
|
29
|
+
massCenter?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The mass recorded on the right side of the device (optional for Motherboard devices).
|
|
32
|
+
* Used for devices that measure force across multiple zones.
|
|
33
|
+
*/
|
|
34
|
+
massRight?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Defines the type for a callback function that handles mass data notifications.
|
|
38
|
+
* The callback receives a `massObject` as the parameter.
|
|
39
|
+
* @callback NotifyCallback
|
|
40
|
+
* @param {massObject} data - The mass data passed to the callback.
|
|
41
|
+
*/
|
|
42
|
+
export type NotifyCallback = (data: massObject) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Defines the type for a callback function that handles write operations to the device.
|
|
45
|
+
* The callback receives the data string written to the device.
|
|
46
|
+
* @callback WriteCallback
|
|
47
|
+
* @param {string} data - The string data passed to the callback.
|
|
48
|
+
*/
|
|
49
|
+
export type WriteCallback = (data: string) => void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the available commands for various devices such as the Motherboard and Tindeq Progressor.
|
|
3
|
+
*/
|
|
4
|
+
export interface Commands {
|
|
5
|
+
/**
|
|
6
|
+
* Starts a weight measurement on the device.
|
|
7
|
+
* Used to begin collecting weight or force data.
|
|
8
|
+
*/
|
|
9
|
+
START_WEIGHT_MEAS?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Stops the current weight measurement on the device.
|
|
12
|
+
* Used to end the data collection.
|
|
13
|
+
*/
|
|
14
|
+
STOP_WEIGHT_MEAS?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Puts the device to sleep or in a low-power mode.
|
|
17
|
+
* The format can be a string or a number depending on the device.
|
|
18
|
+
*/
|
|
19
|
+
SLEEP?: number | string;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the serial number of the device.
|
|
22
|
+
* This command fetches the unique identifier assigned by the manufacturer.
|
|
23
|
+
*/
|
|
24
|
+
GET_SERIAL?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves textual information from the device.
|
|
27
|
+
* May include readable data.
|
|
28
|
+
*/
|
|
29
|
+
GET_TEXT?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Starts or stops a debug data stream from the device.
|
|
32
|
+
* Used for diagnostic purposes or to monitor real-time data.
|
|
33
|
+
*/
|
|
34
|
+
DEBUG_STREAM?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves calibration data from the device.
|
|
37
|
+
* Used to ensure accurate measurements by applying calibration points.
|
|
38
|
+
*/
|
|
39
|
+
GET_CALIBRATION?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Tares the scale, zeroing the current weight measurement.
|
|
42
|
+
* Used to reset the baseline for weight data.
|
|
43
|
+
*/
|
|
44
|
+
TARE_SCALE?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Starts measuring the peak rate of force development (RFD).
|
|
47
|
+
* Captures how quickly force is applied over time.
|
|
48
|
+
*/
|
|
49
|
+
START_PEAK_RFD_MEAS?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Starts measuring a series of peak RFD measurements.
|
|
52
|
+
* This captures multiple RFD data points over a period of time.
|
|
53
|
+
*/
|
|
54
|
+
START_PEAK_RFD_MEAS_SERIES?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Adds a calibration point to the device.
|
|
57
|
+
* Used to improve the accuracy of future measurements.
|
|
58
|
+
*/
|
|
59
|
+
ADD_CALIB_POINT?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Saves the current calibration settings to the device.
|
|
62
|
+
* Ensures the device remembers the calibration for future sessions.
|
|
63
|
+
*/
|
|
64
|
+
SAVE_CALIB?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the firmware version of the device.
|
|
67
|
+
* Useful for ensuring compatibility and tracking updates.
|
|
68
|
+
*/
|
|
69
|
+
GET_FW_VERSION?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves error information from the device.
|
|
72
|
+
* Provides details on any faults or issues that occurred during operation.
|
|
73
|
+
*/
|
|
74
|
+
GET_ERR_INFO?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Clears the error information on the device.
|
|
77
|
+
* Used to reset error logs after troubleshooting or repair.
|
|
78
|
+
*/
|
|
79
|
+
CLR_ERR_INFO?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves the battery voltage level of the device.
|
|
82
|
+
* Provides insight into the device's remaining battery power.
|
|
83
|
+
*/
|
|
84
|
+
GET_BATT_VLTG?: string;
|
|
85
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IBase } from "./base.interface";
|
|
2
|
-
import type { massObject } from "
|
|
3
|
-
type
|
|
2
|
+
import type { massObject } from "./callback.interface";
|
|
3
|
+
import type { Commands } from "./command.interface";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a characteristic of a Bluetooth service.
|
|
6
6
|
*/
|
|
@@ -31,12 +31,26 @@ export interface Service {
|
|
|
31
31
|
* Represents a Bluetooth device.
|
|
32
32
|
*/
|
|
33
33
|
export interface IDevice extends IBase {
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Filters to identify the device during Bluetooth scanning.
|
|
36
|
+
* Used to match devices that meet specific criteria such as name, service UUIDs, etc.
|
|
37
|
+
*/
|
|
35
38
|
filters: BluetoothLEScanFilter[];
|
|
36
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Array of services provided by the device.
|
|
41
|
+
* Services represent functionalities that the device supports, such as weight measurement, battery information, or custom services.
|
|
42
|
+
*/
|
|
37
43
|
services: Service[];
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Reference to the `BluetoothDevice` object representing this device.
|
|
46
|
+
* This is the actual device object obtained from the Web Bluetooth API after a successful connection.
|
|
47
|
+
*/
|
|
39
48
|
bluetooth?: BluetoothDevice;
|
|
49
|
+
/**
|
|
50
|
+
* Object representing the set of commands available for this device.
|
|
51
|
+
* These commands allow communication with the device to perform various operations such as starting measurements, retrieving data, or calibrating the device.
|
|
52
|
+
*/
|
|
53
|
+
commands: Commands;
|
|
40
54
|
/**
|
|
41
55
|
* Connects to a Bluetooth device.
|
|
42
56
|
* @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
|
|
@@ -54,6 +68,13 @@ export interface IDevice extends IBase {
|
|
|
54
68
|
* @returns {string[]} Array of service UUIDs.
|
|
55
69
|
*/
|
|
56
70
|
getAllServiceUUIDs(): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the characteristic from the device's service.
|
|
73
|
+
* @param {string} serviceId - The UUID of the service.
|
|
74
|
+
* @param {string} characteristicId - The UUID of the characteristic.
|
|
75
|
+
* @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
|
|
76
|
+
*/
|
|
77
|
+
getCharacteristic(serviceId: string, characteristicId: string): BluetoothRemoteGATTCharacteristic | undefined;
|
|
57
78
|
/**
|
|
58
79
|
* Handles notifications received from a characteristic.
|
|
59
80
|
* @param {Event} event - The notification event.
|
|
@@ -69,13 +90,7 @@ export interface IDevice extends IBase {
|
|
|
69
90
|
* @param {NotifyCallback} callback - The callback function to be set.
|
|
70
91
|
* @returns {void}
|
|
71
92
|
*/
|
|
72
|
-
notify(callback:
|
|
73
|
-
/**
|
|
74
|
-
* Defines the type for the callback function.
|
|
75
|
-
* @callback NotifyCallback
|
|
76
|
-
* @param {massObject} data - The data passed to the callback.
|
|
77
|
-
*/
|
|
78
|
-
notifyCallback: NotifyCallback;
|
|
93
|
+
notify(callback: (data: massObject) => void): void;
|
|
79
94
|
/**
|
|
80
95
|
* Handles the 'connected' event.
|
|
81
96
|
* @param {Function} onSuccess - Callback function to execute on successful connection.
|
|
@@ -86,5 +101,32 @@ export interface IDevice extends IBase {
|
|
|
86
101
|
* @param {Event} event - The 'disconnected' event.
|
|
87
102
|
*/
|
|
88
103
|
onDisconnected(event: Event): void;
|
|
104
|
+
/**
|
|
105
|
+
* Reads the value of the specified characteristic from the device.
|
|
106
|
+
* @param {string} serviceId - The service ID where the characteristic belongs.
|
|
107
|
+
* @param {string} characteristicId - The characteristic ID to read from.
|
|
108
|
+
* @param {number} [duration=0] - The duration to wait before resolving the promise, in milliseconds.
|
|
109
|
+
* @returns {Promise<string>} A promise that resolves when the read operation is completed.
|
|
110
|
+
*/
|
|
111
|
+
read(serviceId: string, characteristicId: string, duration?: number): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Writes a message to the specified characteristic of a Bluetooth device and optionally provides a callback to handle responses.
|
|
114
|
+
* @param {string} serviceId - The service UUID of the Bluetooth device containing the target characteristic.
|
|
115
|
+
* @param {string} characteristicId - The characteristic UUID where the message will be written.
|
|
116
|
+
* @param {string | Uint8Array | undefined} message - The message to be written to the characteristic. It can be a string or a Uint8Array.
|
|
117
|
+
* @param {number} [duration=0] - Optional. The time in milliseconds to wait before resolving the promise. Defaults to 0 for immediate resolution.
|
|
118
|
+
* @param {WriteCallback} [callback=writeCallback] - Optional. A custom callback to handle the response after the write operation is successful.
|
|
119
|
+
*
|
|
120
|
+
* @returns {Promise<void>} A promise that resolves once the write operation is complete.
|
|
121
|
+
*
|
|
122
|
+
* @throws {Error} Throws an error if the characteristic is undefined.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* // Example usage of the write function with a custom callback
|
|
126
|
+
* await Progressor.write("progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250, (data) => {
|
|
127
|
+
* console.log(`Battery voltage: ${data}`);
|
|
128
|
+
* });
|
|
129
|
+
*/
|
|
130
|
+
write(serviceId: string, characteristicId: string, message: string | Uint8Array | undefined, duration?: number, callback?: (data: string) => void): Promise<void>;
|
|
89
131
|
}
|
|
90
132
|
export {};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Device } from "../device.model";
|
|
2
|
-
import { applyTare } from "../../tare";
|
|
3
|
-
import { checkActivity } from "../../is-active";
|
|
4
|
-
import { read } from "../../read";
|
|
5
|
-
// Constants
|
|
6
|
-
let MASS_MAX = "0";
|
|
7
|
-
let MASS_AVERAGE = "0";
|
|
8
|
-
let MASS_TOTAL_SUM = 0;
|
|
9
|
-
let DATAPOINT_COUNT = 0;
|
|
2
|
+
import { applyTare } from "../../helpers/tare";
|
|
3
|
+
import { checkActivity } from "../../helpers/is-active";
|
|
10
4
|
export class Entralpi extends Device {
|
|
11
5
|
constructor() {
|
|
12
6
|
super({
|
|
@@ -135,7 +129,7 @@ export class Entralpi extends Device {
|
|
|
135
129
|
*/
|
|
136
130
|
battery = async () => {
|
|
137
131
|
if (this.isConnected()) {
|
|
138
|
-
return await read(
|
|
132
|
+
return await this.read("battery", "level", 250);
|
|
139
133
|
}
|
|
140
134
|
// If device is not found, return undefined
|
|
141
135
|
return undefined;
|
|
@@ -148,7 +142,7 @@ export class Entralpi extends Device {
|
|
|
148
142
|
// Check if the device is connected
|
|
149
143
|
if (this.isConnected()) {
|
|
150
144
|
// Read certification from the device
|
|
151
|
-
return await read(
|
|
145
|
+
return await this.read("device", "certification", 250);
|
|
152
146
|
}
|
|
153
147
|
// If device is not found, return undefined
|
|
154
148
|
return undefined;
|
|
@@ -161,7 +155,7 @@ export class Entralpi extends Device {
|
|
|
161
155
|
// Check if the device is connected
|
|
162
156
|
if (this.isConnected()) {
|
|
163
157
|
// Read firmware version from the Motherboard
|
|
164
|
-
return await read(
|
|
158
|
+
return await this.read("device", "firmware", 250);
|
|
165
159
|
}
|
|
166
160
|
// If device is not found, return undefined
|
|
167
161
|
return undefined;
|
|
@@ -184,20 +178,20 @@ export class Entralpi extends Device {
|
|
|
184
178
|
let numericData = Number(receivedData);
|
|
185
179
|
// Tare correction
|
|
186
180
|
numericData -= applyTare(numericData);
|
|
187
|
-
// Update
|
|
188
|
-
|
|
181
|
+
// Update massMax
|
|
182
|
+
this.massMax = Math.max(Number(this.massMax), numericData).toFixed(1);
|
|
189
183
|
// Update running sum and count
|
|
190
184
|
const currentMassTotal = Math.max(-1000, numericData);
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
this.massTotalSum += currentMassTotal;
|
|
186
|
+
this.dataPointCount++;
|
|
193
187
|
// Calculate the average dynamically
|
|
194
|
-
|
|
188
|
+
this.massAverage = (this.massTotalSum / this.dataPointCount).toFixed(1);
|
|
195
189
|
// Check if device is being used
|
|
196
190
|
checkActivity(numericData);
|
|
197
191
|
// Notify with weight data
|
|
198
192
|
this.notifyCallback({
|
|
199
|
-
massMax:
|
|
200
|
-
massAverage:
|
|
193
|
+
massMax: this.massMax,
|
|
194
|
+
massAverage: this.massAverage,
|
|
201
195
|
massTotal: Math.max(-1000, numericData).toFixed(1),
|
|
202
196
|
});
|
|
203
197
|
}
|
|
@@ -211,7 +205,7 @@ export class Entralpi extends Device {
|
|
|
211
205
|
// Check if the device is connected
|
|
212
206
|
if (this.isConnected()) {
|
|
213
207
|
// Read hardware version from the device
|
|
214
|
-
return await read(
|
|
208
|
+
return await this.read("device", "hardware", 250);
|
|
215
209
|
}
|
|
216
210
|
// If device is not found, return undefined
|
|
217
211
|
return undefined;
|
|
@@ -224,7 +218,7 @@ export class Entralpi extends Device {
|
|
|
224
218
|
// Check if the device is connected
|
|
225
219
|
if (this.isConnected()) {
|
|
226
220
|
// Read manufacturer information from the device
|
|
227
|
-
return await read(
|
|
221
|
+
return await this.read("device", "manufacturer", 250);
|
|
228
222
|
}
|
|
229
223
|
// If device is not found, return undefined
|
|
230
224
|
return undefined;
|
|
@@ -237,7 +231,7 @@ export class Entralpi extends Device {
|
|
|
237
231
|
// Check if the device is connected
|
|
238
232
|
if (this.isConnected()) {
|
|
239
233
|
// Read model number from the Entralpi
|
|
240
|
-
return await read(
|
|
234
|
+
return await this.read("device", "model", 250);
|
|
241
235
|
}
|
|
242
236
|
// If device is not found, return undefined
|
|
243
237
|
return undefined;
|
|
@@ -251,7 +245,7 @@ export class Entralpi extends Device {
|
|
|
251
245
|
// Check if the device is connected
|
|
252
246
|
if (this.isConnected()) {
|
|
253
247
|
// Read software version from the Entralpi
|
|
254
|
-
return await read(
|
|
248
|
+
return await this.read("device", "pnp", 250);
|
|
255
249
|
}
|
|
256
250
|
// If device is not found, return undefined
|
|
257
251
|
return undefined;
|
|
@@ -264,7 +258,7 @@ export class Entralpi extends Device {
|
|
|
264
258
|
// Check if the device is connected
|
|
265
259
|
if (this.isConnected()) {
|
|
266
260
|
// Read software version from the Entralpi
|
|
267
|
-
return await read(
|
|
261
|
+
return await this.read("device", "software", 250);
|
|
268
262
|
}
|
|
269
263
|
// If device is not found, return undefined
|
|
270
264
|
return undefined;
|
|
@@ -277,7 +271,7 @@ export class Entralpi extends Device {
|
|
|
277
271
|
// Check if the device is connected
|
|
278
272
|
if (this.isConnected()) {
|
|
279
273
|
// Read system id from the device
|
|
280
|
-
return await read(
|
|
274
|
+
return await this.read("device", "system", 250);
|
|
281
275
|
}
|
|
282
276
|
// If device is not found, return undefined
|
|
283
277
|
return undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Device } from "../device.model";
|
|
2
|
-
import { read } from "../../read";
|
|
3
2
|
/**
|
|
4
3
|
* Represents a PitchSix Force Board device
|
|
5
4
|
*/
|
|
@@ -79,19 +78,19 @@ export class ForceBoard extends Device {
|
|
|
79
78
|
],
|
|
80
79
|
},
|
|
81
80
|
{
|
|
82
|
-
name: "",
|
|
83
|
-
id: "",
|
|
81
|
+
name: "Temperature Serivce",
|
|
82
|
+
id: "temperature",
|
|
84
83
|
uuid: "3a90328c-c266-4c76-b05a-6af6104a0b13",
|
|
85
84
|
characteristics: [
|
|
86
85
|
{
|
|
87
86
|
name: "Read",
|
|
88
|
-
id: "",
|
|
87
|
+
id: "level",
|
|
89
88
|
uuid: "3a90328d-c266-4c76-b05a-6af6104a0b13",
|
|
90
89
|
},
|
|
91
90
|
],
|
|
92
91
|
},
|
|
93
92
|
{
|
|
94
|
-
name: "",
|
|
93
|
+
name: "Forceboard Service",
|
|
95
94
|
id: "forceboard",
|
|
96
95
|
uuid: "9a88d67f-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
97
96
|
characteristics: [
|
|
@@ -168,7 +167,7 @@ export class ForceBoard extends Device {
|
|
|
168
167
|
*/
|
|
169
168
|
battery = async () => {
|
|
170
169
|
if (this.isConnected()) {
|
|
171
|
-
return await read(
|
|
170
|
+
return await this.read("battery", "level", 250);
|
|
172
171
|
}
|
|
173
172
|
// If device is not found, return undefined
|
|
174
173
|
return undefined;
|
|
@@ -180,7 +179,7 @@ export class ForceBoard extends Device {
|
|
|
180
179
|
humidity = async () => {
|
|
181
180
|
// Check if the device is connected
|
|
182
181
|
if (this.isConnected()) {
|
|
183
|
-
return await read(
|
|
182
|
+
return await this.read("humidity", "level", 250);
|
|
184
183
|
}
|
|
185
184
|
// If device is not found, return undefined
|
|
186
185
|
return undefined;
|
|
@@ -193,7 +192,7 @@ export class ForceBoard extends Device {
|
|
|
193
192
|
// Check if the device is connected
|
|
194
193
|
if (this.isConnected()) {
|
|
195
194
|
// Read manufacturer information from the device
|
|
196
|
-
return await read(
|
|
195
|
+
return await this.read("device", "manufacturer", 250);
|
|
197
196
|
}
|
|
198
197
|
// If device is not found, return undefined
|
|
199
198
|
return undefined;
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import { Device } from "../device.model";
|
|
2
2
|
import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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 climbs_placements from the Kilter Board application
|
|
5
40
|
*/
|
|
6
|
-
export declare const AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
|
|
7
41
|
declare class ClimbPlacement {
|
|
8
42
|
position: number;
|
|
9
43
|
role_id: number;
|
|
@@ -14,6 +48,31 @@ declare class ClimbPlacement {
|
|
|
14
48
|
* Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
|
|
15
49
|
*/
|
|
16
50
|
export declare class KilterBoard extends Device implements IKilterBoard {
|
|
51
|
+
/**
|
|
52
|
+
* UUID for the Aurora Climbing Advertising service.
|
|
53
|
+
* This constant is used to identify the specific Bluetooth service for Kilter Boards.
|
|
54
|
+
*
|
|
55
|
+
* @type {string}
|
|
56
|
+
*/
|
|
57
|
+
static AuroraUUID: string;
|
|
58
|
+
/**
|
|
59
|
+
* Maximum length of the message body for byte wrapping.
|
|
60
|
+
* This value defines the limit for the size of messages that can be sent or received
|
|
61
|
+
* to ensure proper byte wrapping in communication.
|
|
62
|
+
*
|
|
63
|
+
* @type {number}
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private MESSAGE_BODY_MAX_LENGTH;
|
|
67
|
+
/**
|
|
68
|
+
* Maximum length of the Bluetooth message chunk.
|
|
69
|
+
* This value sets the upper limit for the size of individual Bluetooth messages
|
|
70
|
+
* sent to and from the device to comply with Bluetooth protocol constraints.
|
|
71
|
+
*
|
|
72
|
+
* @type {number}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private MAX_BLUETOOTH_MESSAGE_SIZE;
|
|
17
76
|
constructor();
|
|
18
77
|
/**
|
|
19
78
|
* Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
|