@hangtime/grip-connect 0.5.2 → 0.5.4
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 +1 -1
- 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/forceboard.interface.d.ts +16 -0
- package/dist/interfaces/device.interface.d.ts +21 -21
- package/dist/models/device/entralpi.model.d.ts +1 -1
- package/dist/models/device/entralpi.model.js +19 -76
- package/dist/models/device/forceboard.model.d.ts +24 -0
- package/dist/models/device/forceboard.model.js +81 -23
- 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 +79 -100
- package/dist/models/device/progressor.model.d.ts +1 -1
- package/dist/models/device/progressor.model.js +76 -52
- 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 +73 -24
- package/dist/models/device.model.js +125 -78
- 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/forceboard.interface.ts +19 -0
- package/src/interfaces/device.interface.ts +24 -23
- package/src/models/device/entralpi.model.ts +19 -77
- package/src/models/device/forceboard.model.ts +93 -23
- package/src/models/device/kilterboard.model.ts +93 -13
- package/src/models/device/motherboard.model.ts +84 -105
- package/src/models/device/progressor.model.ts +79 -52
- package/src/models/device/wh-c06.model.ts +20 -18
- package/src/models/device.model.ts +143 -88
- 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
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ motherboardButton.addEventListener("click", () => {
|
|
|
117
117
|
enable it at `chrome://flags/#enable-experimental-web-platform-features`.
|
|
118
118
|
- ✅ [Kilter Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/kilterboard.html)
|
|
119
119
|
- ✅ [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) / Lefu Scale
|
|
120
|
-
-
|
|
120
|
+
- ✅ [PitchSix Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html)
|
|
121
121
|
- ➡️ [Climbro](https://stevie-ray.github.io/hangtime-grip-connect/devices/climbro.html)
|
|
122
122
|
- ➡️ [Smartboard Climbing - mySmartBoard](https://stevie-ray.github.io/hangtime-grip-connect/devices/mysmartboard.html)
|
|
123
123
|
|
|
@@ -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
|
+
}
|
|
@@ -18,4 +18,20 @@ export interface IForceBoard extends IDevice {
|
|
|
18
18
|
* @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
|
|
19
19
|
*/
|
|
20
20
|
manufacturer(): Promise<string | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Stops the data stream on the specified device.
|
|
23
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
24
|
+
*/
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Starts streaming data from the specified device.
|
|
28
|
+
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
30
|
+
*/
|
|
31
|
+
stream(duration?: number): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves temperature information from the device.
|
|
34
|
+
* @returns {Promise<string | undefined>} A Promise that resolves with the humidity level.
|
|
35
|
+
*/
|
|
36
|
+
temperature(): Promise<string | undefined>;
|
|
21
37
|
}
|
|
@@ -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.
|
|
@@ -97,9 +106,9 @@ export interface IDevice extends IBase {
|
|
|
97
106
|
* @param {string} serviceId - The service ID where the characteristic belongs.
|
|
98
107
|
* @param {string} characteristicId - The characteristic ID to read from.
|
|
99
108
|
* @param {number} [duration=0] - The duration to wait before resolving the promise, in milliseconds.
|
|
100
|
-
* @returns {Promise<string>} A promise that resolves when the read operation is completed.
|
|
109
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the read operation is completed.
|
|
101
110
|
*/
|
|
102
|
-
read(serviceId: string, characteristicId: string, duration?: number): Promise<string>;
|
|
111
|
+
read(serviceId: string, characteristicId: string, duration?: number): Promise<string | undefined>;
|
|
103
112
|
/**
|
|
104
113
|
* Writes a message to the specified characteristic of a Bluetooth device and optionally provides a callback to handle responses.
|
|
105
114
|
* @param {string} serviceId - The service UUID of the Bluetooth device containing the target characteristic.
|
|
@@ -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 {};
|
|
@@ -18,7 +18,7 @@ export declare class Entralpi extends Device implements IEntralpi {
|
|
|
18
18
|
*/
|
|
19
19
|
firmware: () => Promise<string | undefined>;
|
|
20
20
|
/**
|
|
21
|
-
* Handles data received from the
|
|
21
|
+
* Handles data received from the device, processes weight measurements,
|
|
22
22
|
* and updates mass data including maximum and average values.
|
|
23
23
|
* It also handles command responses for retrieving device information.
|
|
24
24
|
*
|
|
@@ -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({
|
|
@@ -133,40 +128,24 @@ export class Entralpi extends Device {
|
|
|
133
128
|
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
|
|
134
129
|
*/
|
|
135
130
|
battery = async () => {
|
|
136
|
-
|
|
137
|
-
return await this.read("battery", "level", 250);
|
|
138
|
-
}
|
|
139
|
-
// If device is not found, return undefined
|
|
140
|
-
return undefined;
|
|
131
|
+
return await this.read("battery", "level", 250);
|
|
141
132
|
};
|
|
142
133
|
/**
|
|
143
134
|
* Retrieves IEEE 11073-20601 Regulatory Certification from the device.
|
|
144
135
|
* @returns {Promise<string>} A Promise that resolves with the certification.
|
|
145
136
|
*/
|
|
146
137
|
certification = async () => {
|
|
147
|
-
|
|
148
|
-
if (this.isConnected()) {
|
|
149
|
-
// Read certification from the device
|
|
150
|
-
return await this.read("device", "certification", 250);
|
|
151
|
-
}
|
|
152
|
-
// If device is not found, return undefined
|
|
153
|
-
return undefined;
|
|
138
|
+
return await this.read("device", "certification", 250);
|
|
154
139
|
};
|
|
155
140
|
/**
|
|
156
141
|
* Retrieves firmware version from the device.
|
|
157
142
|
* @returns {Promise<string>} A Promise that resolves with the firmware version.
|
|
158
143
|
*/
|
|
159
144
|
firmware = async () => {
|
|
160
|
-
|
|
161
|
-
if (this.isConnected()) {
|
|
162
|
-
// Read firmware version from the Motherboard
|
|
163
|
-
return await this.read("device", "firmware", 250);
|
|
164
|
-
}
|
|
165
|
-
// If device is not found, return undefined
|
|
166
|
-
return undefined;
|
|
145
|
+
return await this.read("device", "firmware", 250);
|
|
167
146
|
};
|
|
168
147
|
/**
|
|
169
|
-
* Handles data received from the
|
|
148
|
+
* Handles data received from the device, processes weight measurements,
|
|
170
149
|
* and updates mass data including maximum and average values.
|
|
171
150
|
* It also handles command responses for retrieving device information.
|
|
172
151
|
*
|
|
@@ -183,20 +162,20 @@ export class Entralpi extends Device {
|
|
|
183
162
|
let numericData = Number(receivedData);
|
|
184
163
|
// Tare correction
|
|
185
164
|
numericData -= applyTare(numericData);
|
|
186
|
-
// Update
|
|
187
|
-
|
|
165
|
+
// Update massMax
|
|
166
|
+
this.massMax = Math.max(Number(this.massMax), numericData).toFixed(1);
|
|
188
167
|
// Update running sum and count
|
|
189
168
|
const currentMassTotal = Math.max(-1000, numericData);
|
|
190
|
-
|
|
191
|
-
|
|
169
|
+
this.massTotalSum += currentMassTotal;
|
|
170
|
+
this.dataPointCount++;
|
|
192
171
|
// Calculate the average dynamically
|
|
193
|
-
|
|
172
|
+
this.massAverage = (this.massTotalSum / this.dataPointCount).toFixed(1);
|
|
194
173
|
// Check if device is being used
|
|
195
174
|
checkActivity(numericData);
|
|
196
175
|
// Notify with weight data
|
|
197
176
|
this.notifyCallback({
|
|
198
|
-
massMax:
|
|
199
|
-
massAverage:
|
|
177
|
+
massMax: this.massMax,
|
|
178
|
+
massAverage: this.massAverage,
|
|
200
179
|
massTotal: Math.max(-1000, numericData).toFixed(1),
|
|
201
180
|
});
|
|
202
181
|
}
|
|
@@ -207,39 +186,21 @@ export class Entralpi extends Device {
|
|
|
207
186
|
* @returns {Promise<string>} A Promise that resolves with the hardware version.
|
|
208
187
|
*/
|
|
209
188
|
hardware = async () => {
|
|
210
|
-
|
|
211
|
-
if (this.isConnected()) {
|
|
212
|
-
// Read hardware version from the device
|
|
213
|
-
return await this.read("device", "hardware", 250);
|
|
214
|
-
}
|
|
215
|
-
// If device is not found, return undefined
|
|
216
|
-
return undefined;
|
|
189
|
+
return await this.read("device", "hardware", 250);
|
|
217
190
|
};
|
|
218
191
|
/**
|
|
219
192
|
* Retrieves manufacturer information from the device.
|
|
220
193
|
* @returns {Promise<string>} A Promise that resolves with the manufacturer information.
|
|
221
194
|
*/
|
|
222
195
|
manufacturer = async () => {
|
|
223
|
-
|
|
224
|
-
if (this.isConnected()) {
|
|
225
|
-
// Read manufacturer information from the device
|
|
226
|
-
return await this.read("device", "manufacturer", 250);
|
|
227
|
-
}
|
|
228
|
-
// If device is not found, return undefined
|
|
229
|
-
return undefined;
|
|
196
|
+
return await this.read("device", "manufacturer", 250);
|
|
230
197
|
};
|
|
231
198
|
/**
|
|
232
199
|
* Retrieves model number from the device.
|
|
233
200
|
* @returns {Promise<string>} A Promise that resolves with the model number.
|
|
234
201
|
*/
|
|
235
202
|
model = async () => {
|
|
236
|
-
|
|
237
|
-
if (this.isConnected()) {
|
|
238
|
-
// Read model number from the Entralpi
|
|
239
|
-
return await this.read("device", "model", 250);
|
|
240
|
-
}
|
|
241
|
-
// If device is not found, return undefined
|
|
242
|
-
return undefined;
|
|
203
|
+
return await this.read("device", "model", 250);
|
|
243
204
|
};
|
|
244
205
|
/**
|
|
245
206
|
* Retrieves PnP ID from the device, a set of values that used to create a device ID value that is unique for this device.
|
|
@@ -247,38 +208,20 @@ export class Entralpi extends Device {
|
|
|
247
208
|
* @returns {Promise<string>} A Promise that resolves with the PnP ID.
|
|
248
209
|
*/
|
|
249
210
|
pnp = async () => {
|
|
250
|
-
|
|
251
|
-
if (this.isConnected()) {
|
|
252
|
-
// Read software version from the Entralpi
|
|
253
|
-
return await this.read("device", "pnp", 250);
|
|
254
|
-
}
|
|
255
|
-
// If device is not found, return undefined
|
|
256
|
-
return undefined;
|
|
211
|
+
return await this.read("device", "pnp", 250);
|
|
257
212
|
};
|
|
258
213
|
/**
|
|
259
214
|
* Retrieves software version from the device.
|
|
260
215
|
* @returns {Promise<string>} A Promise that resolves with the software version.
|
|
261
216
|
*/
|
|
262
217
|
software = async () => {
|
|
263
|
-
|
|
264
|
-
if (this.isConnected()) {
|
|
265
|
-
// Read software version from the Entralpi
|
|
266
|
-
return await this.read("device", "software", 250);
|
|
267
|
-
}
|
|
268
|
-
// If device is not found, return undefined
|
|
269
|
-
return undefined;
|
|
218
|
+
return await this.read("device", "software", 250);
|
|
270
219
|
};
|
|
271
220
|
/**
|
|
272
221
|
* Retrieves system id from the device.
|
|
273
222
|
* @returns {Promise<string>} A Promise that resolves with the system id.
|
|
274
223
|
*/
|
|
275
224
|
system = async () => {
|
|
276
|
-
|
|
277
|
-
if (this.isConnected()) {
|
|
278
|
-
// Read system id from the device
|
|
279
|
-
return await this.read("device", "system", 250);
|
|
280
|
-
}
|
|
281
|
-
// If device is not found, return undefined
|
|
282
|
-
return undefined;
|
|
225
|
+
return await this.read("device", "system", 250);
|
|
283
226
|
};
|
|
284
227
|
}
|
|
@@ -10,6 +10,14 @@ export declare class ForceBoard extends Device implements IForceBoard {
|
|
|
10
10
|
* @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
|
|
11
11
|
*/
|
|
12
12
|
battery: () => Promise<string | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Handles data received from the device, processes weight measurements,
|
|
15
|
+
* and updates mass data including maximum and average values.
|
|
16
|
+
* It also handles command responses for retrieving device information.
|
|
17
|
+
*
|
|
18
|
+
* @param {Event} event - The notification event.
|
|
19
|
+
*/
|
|
20
|
+
handleNotifications: (event: Event) => void;
|
|
13
21
|
/**
|
|
14
22
|
* Retrieves humidity level from the device.
|
|
15
23
|
* @returns {Promise<string>} A Promise that resolves with the humidity level,
|
|
@@ -20,4 +28,20 @@ export declare class ForceBoard extends Device implements IForceBoard {
|
|
|
20
28
|
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
21
29
|
*/
|
|
22
30
|
manufacturer: () => Promise<string | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Stops the data stream on the specified device.
|
|
33
|
+
* @returns {Promise<void>} A promise that resolves when the stream is stopped.
|
|
34
|
+
*/
|
|
35
|
+
stop: () => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Starts streaming data from the specified device.
|
|
38
|
+
* @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
|
|
39
|
+
* @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
|
|
40
|
+
*/
|
|
41
|
+
stream: (duration?: number) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves temperature information from the device.
|
|
44
|
+
* @returns {Promise<string>} A Promise that resolves with the manufacturer information,
|
|
45
|
+
*/
|
|
46
|
+
temperature: () => Promise<string | undefined>;
|
|
23
47
|
}
|