@hangtime/grip-connect 0.5.2 → 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/dist/{download.d.ts → helpers/download.d.ts} +1 -1
- package/dist/helpers/is-device.d.ts +16 -16
- package/dist/helpers/is-device.js +18 -18
- 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 +19 -19
- package/dist/models/device/entralpi.model.js +9 -14
- package/dist/models/device/forceboard.model.js +4 -4
- package/dist/models/device/kilterboard.model.d.ts +61 -2
- package/dist/models/device/kilterboard.model.js +91 -11
- package/dist/models/device/motherboard.model.d.ts +24 -1
- package/dist/models/device/motherboard.model.js +56 -33
- package/dist/models/device/progressor.model.js +61 -22
- 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 +71 -22
- package/dist/models/device.model.js +76 -21
- package/package.json +1 -1
- package/src/{download.ts → helpers/download.ts} +1 -1
- package/src/helpers/is-device.ts +23 -23
- 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 +22 -21
- package/src/models/device/entralpi.model.ts +9 -15
- package/src/models/device/forceboard.model.ts +4 -4
- package/src/models/device/kilterboard.model.ts +93 -13
- package/src/models/device/motherboard.model.ts +61 -37
- package/src/models/device/progressor.model.ts +64 -22
- package/src/models/device/wh-c06.model.ts +20 -18
- package/src/models/device.model.ts +92 -30
- 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/types/commands.d.ts +0 -18
- package/dist/types/notify.d.ts +0 -14
- 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/types/commands.ts +0 -21
- package/src/types/notify.ts +0 -14
- /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/{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/{tare.ts → helpers/tare.ts} +0 -0
- /package/src/{types/download.ts → interfaces/download.interface.ts} +0 -0
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import type { Device } from "./../models/device.model";
|
|
2
2
|
/**
|
|
3
|
-
* Checks if the given device is an Entralpi
|
|
4
|
-
* @param {Device} [
|
|
3
|
+
* Checks if the given device is an Entralpi.
|
|
4
|
+
* @param {Device} [device] - The device to check.
|
|
5
5
|
* @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
|
|
6
6
|
*/
|
|
7
|
-
export declare const isEntralpi: (
|
|
7
|
+
export declare const isEntralpi: (device?: Device) => boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if the given device is a Force Board.
|
|
10
|
-
* @param {Device} [
|
|
10
|
+
* @param {Device} [device] - The device to check.
|
|
11
11
|
* @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
|
|
12
12
|
*/
|
|
13
|
-
export declare const isForceBoard: (
|
|
13
|
+
export declare const isForceBoard: (device?: Device) => boolean;
|
|
14
14
|
/**
|
|
15
|
-
* Checks if the given device is a
|
|
16
|
-
* @param {Device} [
|
|
17
|
-
* @returns {boolean} `true` if the device has a service UUID matching the
|
|
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
18
|
*/
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const isKilterBoard: (device?: Device) => boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Checks if the given device is a Motherboard.
|
|
22
|
-
* @param {Device} [
|
|
23
|
-
* @returns {boolean} `true` if the device has a filter with the name "
|
|
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
24
|
*/
|
|
25
|
-
export declare const isMotherboard: (
|
|
25
|
+
export declare const isMotherboard: (device?: Device) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Checks if the given device is a Progressor.
|
|
28
|
-
* @param {Device} [
|
|
28
|
+
* @param {Device} [device] - The device to check.
|
|
29
29
|
* @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
|
|
30
30
|
*/
|
|
31
|
-
export declare const isProgressor: (
|
|
31
|
+
export declare const isProgressor: (device?: Device) => boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Checks if the given device is a WH-C06.
|
|
34
|
-
* @param {Device} [
|
|
34
|
+
* @param {Device} [device] - The device to check.
|
|
35
35
|
* @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
|
|
36
36
|
*/
|
|
37
|
-
export declare const isWHC06: (
|
|
37
|
+
export declare const isWHC06: (device?: Device) => boolean;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KilterBoard } from "../models";
|
|
2
2
|
/**
|
|
3
|
-
* Checks if the given device is an Entralpi
|
|
4
|
-
* @param {Device} [
|
|
3
|
+
* Checks if the given device is an Entralpi.
|
|
4
|
+
* @param {Device} [device] - The device to check.
|
|
5
5
|
* @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
|
|
6
6
|
*/
|
|
7
|
-
export const isEntralpi = (
|
|
7
|
+
export const isEntralpi = (device) => device?.filters.some((filter) => filter.name === "ENTRALPI") ?? false;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if the given device is a Force Board.
|
|
10
|
-
* @param {Device} [
|
|
10
|
+
* @param {Device} [device] - The device to check.
|
|
11
11
|
* @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
|
|
12
12
|
*/
|
|
13
|
-
export const isForceBoard = (
|
|
13
|
+
export const isForceBoard = (device) => device?.filters.some((filter) => filter.name === "Force Board") ?? false;
|
|
14
14
|
/**
|
|
15
|
-
* Checks if the given device is a
|
|
16
|
-
* @param {Device} [
|
|
17
|
-
* @returns {boolean} `true` if the device has a service UUID matching the
|
|
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
18
|
*/
|
|
19
|
-
export const
|
|
20
|
-
return
|
|
19
|
+
export const isKilterBoard = (device) => {
|
|
20
|
+
return device?.filters.some((filter) => filter.services?.includes(KilterBoard.AuroraUUID)) ?? false;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Checks if the given device is a Motherboard.
|
|
24
|
-
* @param {Device} [
|
|
25
|
-
* @returns {boolean} `true` if the device has a filter with the name "
|
|
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
26
|
*/
|
|
27
|
-
export const isMotherboard = (
|
|
27
|
+
export const isMotherboard = (device) => device?.filters.some((filter) => filter.name === "Motherdevice") ?? false;
|
|
28
28
|
/**
|
|
29
29
|
* Checks if the given device is a Progressor.
|
|
30
|
-
* @param {Device} [
|
|
30
|
+
* @param {Device} [device] - The device to check.
|
|
31
31
|
* @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
|
|
32
32
|
*/
|
|
33
|
-
export const isProgressor = (
|
|
33
|
+
export const isProgressor = (device) => device?.filters.some((filter) => filter.namePrefix === "Progressor") ?? false;
|
|
34
34
|
/**
|
|
35
35
|
* Checks if the given device is a WH-C06.
|
|
36
|
-
* @param {Device} [
|
|
36
|
+
* @param {Device} [device] - The device to check.
|
|
37
37
|
* @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
|
|
38
38
|
*/
|
|
39
|
-
export const isWHC06 = (
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import type { IBase } from "./base.interface";
|
|
2
|
-
import type { massObject } from "
|
|
2
|
+
import type { massObject } from "./callback.interface";
|
|
3
|
+
import type { Commands } from "./command.interface";
|
|
3
4
|
/**
|
|
4
5
|
* Represents a characteristic of a Bluetooth service.
|
|
5
6
|
*/
|
|
@@ -30,12 +31,26 @@ export interface Service {
|
|
|
30
31
|
* Represents a Bluetooth device.
|
|
31
32
|
*/
|
|
32
33
|
export interface IDevice extends IBase {
|
|
33
|
-
/**
|
|
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
|
+
*/
|
|
34
38
|
filters: BluetoothLEScanFilter[];
|
|
35
|
-
/**
|
|
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
|
+
*/
|
|
36
43
|
services: Service[];
|
|
37
|
-
/**
|
|
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
|
+
*/
|
|
38
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;
|
|
39
54
|
/**
|
|
40
55
|
* Connects to a Bluetooth device.
|
|
41
56
|
* @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
|
|
@@ -76,12 +91,6 @@ export interface IDevice extends IBase {
|
|
|
76
91
|
* @returns {void}
|
|
77
92
|
*/
|
|
78
93
|
notify(callback: (data: massObject) => void): void;
|
|
79
|
-
/**
|
|
80
|
-
* Defines the type for the callback function.
|
|
81
|
-
* @callback NotifyCallback
|
|
82
|
-
* @param {massObject} data - The data passed to the callback.
|
|
83
|
-
*/
|
|
84
|
-
notifyCallback: (data: massObject) => void;
|
|
85
94
|
/**
|
|
86
95
|
* Handles the 'connected' event.
|
|
87
96
|
* @param {Function} onSuccess - Callback function to execute on successful connection.
|
|
@@ -119,14 +128,5 @@ export interface IDevice extends IBase {
|
|
|
119
128
|
* });
|
|
120
129
|
*/
|
|
121
130
|
write(serviceId: string, characteristicId: string, message: string | Uint8Array | undefined, duration?: number, callback?: (data: string) => void): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* A default write callback that logs the response
|
|
124
|
-
*/
|
|
125
|
-
writeCallback: (data: string) => void;
|
|
126
|
-
/**
|
|
127
|
-
* The last message written to the device.
|
|
128
|
-
* @type {string | Uint8Array | null}
|
|
129
|
-
*/
|
|
130
|
-
writeLast: string | Uint8Array | null;
|
|
131
131
|
}
|
|
132
132
|
export {};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Device } from "../device.model";
|
|
2
|
-
import { applyTare } from "../../tare";
|
|
3
|
-
import { checkActivity } from "../../is-active";
|
|
4
|
-
// Constants
|
|
5
|
-
let MASS_MAX = "0";
|
|
6
|
-
let MASS_AVERAGE = "0";
|
|
7
|
-
let MASS_TOTAL_SUM = 0;
|
|
8
|
-
let DATAPOINT_COUNT = 0;
|
|
2
|
+
import { applyTare } from "../../helpers/tare";
|
|
3
|
+
import { checkActivity } from "../../helpers/is-active";
|
|
9
4
|
export class Entralpi extends Device {
|
|
10
5
|
constructor() {
|
|
11
6
|
super({
|
|
@@ -183,20 +178,20 @@ export class Entralpi extends Device {
|
|
|
183
178
|
let numericData = Number(receivedData);
|
|
184
179
|
// Tare correction
|
|
185
180
|
numericData -= applyTare(numericData);
|
|
186
|
-
// Update
|
|
187
|
-
|
|
181
|
+
// Update massMax
|
|
182
|
+
this.massMax = Math.max(Number(this.massMax), numericData).toFixed(1);
|
|
188
183
|
// Update running sum and count
|
|
189
184
|
const currentMassTotal = Math.max(-1000, numericData);
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
this.massTotalSum += currentMassTotal;
|
|
186
|
+
this.dataPointCount++;
|
|
192
187
|
// Calculate the average dynamically
|
|
193
|
-
|
|
188
|
+
this.massAverage = (this.massTotalSum / this.dataPointCount).toFixed(1);
|
|
194
189
|
// Check if device is being used
|
|
195
190
|
checkActivity(numericData);
|
|
196
191
|
// Notify with weight data
|
|
197
192
|
this.notifyCallback({
|
|
198
|
-
massMax:
|
|
199
|
-
massAverage:
|
|
193
|
+
massMax: this.massMax,
|
|
194
|
+
massAverage: this.massAverage,
|
|
200
195
|
massTotal: Math.max(-1000, numericData).toFixed(1),
|
|
201
196
|
});
|
|
202
197
|
}
|
|
@@ -78,19 +78,19 @@ export class ForceBoard extends Device {
|
|
|
78
78
|
],
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
name: "",
|
|
82
|
-
id: "",
|
|
81
|
+
name: "Temperature Serivce",
|
|
82
|
+
id: "temperature",
|
|
83
83
|
uuid: "3a90328c-c266-4c76-b05a-6af6104a0b13",
|
|
84
84
|
characteristics: [
|
|
85
85
|
{
|
|
86
86
|
name: "Read",
|
|
87
|
-
id: "",
|
|
87
|
+
id: "level",
|
|
88
88
|
uuid: "3a90328d-c266-4c76-b05a-6af6104a0b13",
|
|
89
89
|
},
|
|
90
90
|
],
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
|
-
name: "",
|
|
93
|
+
name: "Forceboard Service",
|
|
94
94
|
id: "forceboard",
|
|
95
95
|
uuid: "9a88d67f-8df2-4afe-9e0d-c2bbbe773dd0",
|
|
96
96
|
characteristics: [
|
|
@@ -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.
|
|
@@ -1,17 +1,72 @@
|
|
|
1
1
|
import { Device } from "../device.model";
|
|
2
|
-
import { KilterBoardPacket, KilterBoardPlacementRoles } from "../../commands/kilterboard";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* For API level 2 and API level 3.
|
|
4
|
+
* The first byte in the data is dependent on where the packet is in the message as a whole.
|
|
5
|
+
* More details: https://github.com/1-max-1/fake_kilter_board
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export var KilterBoardPacket;
|
|
8
|
+
(function (KilterBoardPacket) {
|
|
9
|
+
/** If this packet is in the middle, the byte gets set to 77 (M). */
|
|
10
|
+
KilterBoardPacket[KilterBoardPacket["V2_MIDDLE"] = 77] = "V2_MIDDLE";
|
|
11
|
+
/** If this packet is the first packet in the message, then this byte gets set to 78 (N). */
|
|
12
|
+
KilterBoardPacket[KilterBoardPacket["V2_FIRST"] = 78] = "V2_FIRST";
|
|
13
|
+
/** If this is the last packet in the message, this byte gets set to 79 (0). */
|
|
14
|
+
KilterBoardPacket[KilterBoardPacket["V2_LAST"] = 79] = "V2_LAST";
|
|
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
|
+
KilterBoardPacket[KilterBoardPacket["V2_ONLY"] = 80] = "V2_ONLY";
|
|
17
|
+
/** If this packet is in the middle, the byte gets set to 81 (Q). */
|
|
18
|
+
KilterBoardPacket[KilterBoardPacket["V3_MIDDLE"] = 81] = "V3_MIDDLE";
|
|
19
|
+
/** If this packet is the first packet in the message, then this byte gets set to 82 (R). */
|
|
20
|
+
KilterBoardPacket[KilterBoardPacket["V3_FIRST"] = 82] = "V3_FIRST";
|
|
21
|
+
/** If this is the last packet in the message, this byte gets set to 83 (S). */
|
|
22
|
+
KilterBoardPacket[KilterBoardPacket["V3_LAST"] = 83] = "V3_LAST";
|
|
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
|
+
KilterBoardPacket[KilterBoardPacket["V3_ONLY"] = 84] = "V3_ONLY";
|
|
25
|
+
})(KilterBoardPacket || (KilterBoardPacket = {}));
|
|
7
26
|
/**
|
|
8
|
-
*
|
|
27
|
+
* Extracted from placement_roles database table.
|
|
9
28
|
*/
|
|
10
|
-
const
|
|
29
|
+
export const KilterBoardPlacementRoles = [
|
|
30
|
+
{
|
|
31
|
+
id: 12,
|
|
32
|
+
product_id: 1,
|
|
33
|
+
position: 1,
|
|
34
|
+
name: "start",
|
|
35
|
+
full_name: "Start",
|
|
36
|
+
led_color: "00FF00",
|
|
37
|
+
screen_color: "00DD00",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 13,
|
|
41
|
+
product_id: 1,
|
|
42
|
+
position: 2,
|
|
43
|
+
name: "middle",
|
|
44
|
+
full_name: "Middle",
|
|
45
|
+
led_color: "00FFFF",
|
|
46
|
+
screen_color: "00FFFF",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 14,
|
|
50
|
+
product_id: 1,
|
|
51
|
+
position: 3,
|
|
52
|
+
name: "finish",
|
|
53
|
+
full_name: "Finish",
|
|
54
|
+
led_color: "FF00FF",
|
|
55
|
+
screen_color: "FF00FF",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 15,
|
|
59
|
+
product_id: 1,
|
|
60
|
+
position: 4,
|
|
61
|
+
name: "foot",
|
|
62
|
+
full_name: "Foot Only",
|
|
63
|
+
led_color: "FFB600",
|
|
64
|
+
screen_color: "FFA500",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
11
67
|
/**
|
|
12
|
-
*
|
|
68
|
+
* Represents climbs_placements from the Kilter Board application
|
|
13
69
|
*/
|
|
14
|
-
const MAX_BLUETOOTH_MESSAGE_SIZE = 20;
|
|
15
70
|
class ClimbPlacement {
|
|
16
71
|
position;
|
|
17
72
|
role_id;
|
|
@@ -25,11 +80,36 @@ class ClimbPlacement {
|
|
|
25
80
|
* Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
|
|
26
81
|
*/
|
|
27
82
|
export class KilterBoard extends Device {
|
|
83
|
+
/**
|
|
84
|
+
* UUID for the Aurora Climbing Advertising service.
|
|
85
|
+
* This constant is used to identify the specific Bluetooth service for Kilter Boards.
|
|
86
|
+
*
|
|
87
|
+
* @type {string}
|
|
88
|
+
*/
|
|
89
|
+
static AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
|
|
90
|
+
/**
|
|
91
|
+
* Maximum length of the message body for byte wrapping.
|
|
92
|
+
* This value defines the limit for the size of messages that can be sent or received
|
|
93
|
+
* to ensure proper byte wrapping in communication.
|
|
94
|
+
*
|
|
95
|
+
* @type {number}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
MESSAGE_BODY_MAX_LENGTH = 255;
|
|
99
|
+
/**
|
|
100
|
+
* Maximum length of the Bluetooth message chunk.
|
|
101
|
+
* This value sets the upper limit for the size of individual Bluetooth messages
|
|
102
|
+
* sent to and from the device to comply with Bluetooth protocol constraints.
|
|
103
|
+
*
|
|
104
|
+
* @type {number}
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
MAX_BLUETOOTH_MESSAGE_SIZE = 20;
|
|
28
108
|
constructor() {
|
|
29
109
|
super({
|
|
30
110
|
filters: [
|
|
31
111
|
{
|
|
32
|
-
services: [AuroraUUID],
|
|
112
|
+
services: [KilterBoard.AuroraUUID],
|
|
33
113
|
},
|
|
34
114
|
],
|
|
35
115
|
services: [
|
|
@@ -71,7 +151,7 @@ export class KilterBoard extends Device {
|
|
|
71
151
|
* @returns The wrapped byte array.
|
|
72
152
|
*/
|
|
73
153
|
wrapBytes(data) {
|
|
74
|
-
if (data.length > MESSAGE_BODY_MAX_LENGTH) {
|
|
154
|
+
if (data.length > this.MESSAGE_BODY_MAX_LENGTH) {
|
|
75
155
|
return [];
|
|
76
156
|
}
|
|
77
157
|
/**
|
|
@@ -133,7 +213,7 @@ export class KilterBoard extends Device {
|
|
|
133
213
|
const resultArray = [];
|
|
134
214
|
let tempArray = [KilterBoardPacket.V3_MIDDLE];
|
|
135
215
|
for (const climbPlacement of climbPlacementList) {
|
|
136
|
-
if (tempArray.length + 3 > MESSAGE_BODY_MAX_LENGTH) {
|
|
216
|
+
if (tempArray.length + 3 > this.MESSAGE_BODY_MAX_LENGTH) {
|
|
137
217
|
resultArray.push(tempArray);
|
|
138
218
|
tempArray = [KilterBoardPacket.V3_MIDDLE];
|
|
139
219
|
}
|
|
@@ -183,7 +263,7 @@ export class KilterBoard extends Device {
|
|
|
183
263
|
*
|
|
184
264
|
* @param buffer
|
|
185
265
|
*/
|
|
186
|
-
splitMessages = (buffer) => this.splitEvery(MAX_BLUETOOTH_MESSAGE_SIZE, buffer).map((arr) => new Uint8Array(arr));
|
|
266
|
+
splitMessages = (buffer) => this.splitEvery(this.MAX_BLUETOOTH_MESSAGE_SIZE, buffer).map((arr) => new Uint8Array(arr));
|
|
187
267
|
/**
|
|
188
268
|
* Sends a series of messages to a device.
|
|
189
269
|
*/
|