@hangtime/grip-connect 0.5.0 → 0.5.2

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.
Files changed (65) hide show
  1. package/README.md +17 -38
  2. package/dist/{is-device.d.ts → helpers/is-device.d.ts} +1 -1
  3. package/dist/{is-device.js → helpers/is-device.js} +1 -1
  4. package/dist/index.d.ts +1 -3
  5. package/dist/index.js +2 -4
  6. package/dist/interfaces/base.interface.d.ts +12 -0
  7. package/dist/interfaces/device/climbro.interface.d.ts +3 -0
  8. package/dist/interfaces/device/entralpi.interface.d.ts +49 -0
  9. package/dist/interfaces/device/forceboard.interface.d.ts +18 -0
  10. package/dist/interfaces/device/kilterboard.interface.d.ts +73 -0
  11. package/dist/interfaces/device/motherboard.interface.d.ts +53 -3
  12. package/dist/interfaces/device/mysmartboard.interface.d.ts +3 -0
  13. package/dist/interfaces/device/progressor.interface.d.ts +24 -0
  14. package/dist/interfaces/device/wh-c06.interface.d.ts +3 -0
  15. package/dist/interfaces/device.interface.d.ts +73 -17
  16. package/dist/models/device/entralpi.model.d.ts +22 -6
  17. package/dist/models/device/entralpi.model.js +54 -16
  18. package/dist/models/device/forceboard.model.js +3 -4
  19. package/dist/models/device/kilterboard.model.d.ts +1 -1
  20. package/dist/models/device/kilterboard.model.js +1 -2
  21. package/dist/models/device/motherboard.model.d.ts +5 -0
  22. package/dist/models/device/motherboard.model.js +24 -19
  23. package/dist/models/device/progressor.model.d.ts +5 -0
  24. package/dist/models/device/progressor.model.js +23 -16
  25. package/dist/models/device/wh-c06.model.js +3 -4
  26. package/dist/models/device.model.d.ts +78 -17
  27. package/dist/models/device.model.js +181 -51
  28. package/package.json +1 -1
  29. package/src/{is-device.ts → helpers/is-device.ts} +2 -2
  30. package/src/index.ts +2 -6
  31. package/src/interfaces/base.interface.ts +14 -0
  32. package/src/interfaces/device/climbro.interface.ts +3 -1
  33. package/src/interfaces/device/entralpi.interface.ts +59 -2
  34. package/src/interfaces/device/forceboard.interface.ts +22 -2
  35. package/src/interfaces/device/kilterboard.interface.ts +83 -2
  36. package/src/interfaces/device/motherboard.interface.ts +62 -3
  37. package/src/interfaces/device/mysmartboard.interface.ts +3 -1
  38. package/src/interfaces/device/progressor.interface.ts +29 -2
  39. package/src/interfaces/device/wh-c06.interface.ts +3 -1
  40. package/src/interfaces/device.interface.ts +85 -17
  41. package/src/models/device/entralpi.model.ts +57 -16
  42. package/src/models/device/forceboard.model.ts +3 -4
  43. package/src/models/device/kilterboard.model.ts +2 -3
  44. package/src/models/device/motherboard.model.ts +25 -19
  45. package/src/models/device/progressor.model.ts +24 -16
  46. package/src/models/device/wh-c06.model.ts +4 -4
  47. package/src/models/device.model.ts +201 -55
  48. package/dist/characteristic.d.ts +0 -9
  49. package/dist/characteristic.js +0 -21
  50. package/dist/notify.d.ts +0 -16
  51. package/dist/notify.js +0 -14
  52. package/dist/read.d.ts +0 -10
  53. package/dist/read.js +0 -43
  54. package/dist/stop.d.ts +0 -7
  55. package/dist/stop.js +0 -20
  56. package/dist/write.d.ts +0 -34
  57. package/dist/write.js +0 -58
  58. package/src/characteristic.ts +0 -29
  59. package/src/notify.ts +0 -18
  60. package/src/read.ts +0 -45
  61. package/src/stop.ts +0 -22
  62. package/src/write.ts +0 -74
  63. /package/dist/{struct/index.d.ts → helpers/struct.d.ts} +0 -0
  64. /package/dist/{struct/index.js → helpers/struct.js} +0 -0
  65. /package/src/{struct/index.ts → helpers/struct.ts} +0 -0
package/README.md CHANGED
@@ -18,7 +18,7 @@ And LED system boards from [Aurora Climbing](https://auroraclimbing.com/) like t
18
18
  [Decoy Board](https://decoy-holds.com/pages/decoy-board), [Touchstone Board](https://touchstoneboardapp.com/) and
19
19
  [So iLL Board](https://apps.apple.com/us/app/so-ill-board/id1358056082).
20
20
 
21
- Learn more: [Docs](https://stevie-ray.github.io/hangtime-grip-connect/) -
21
+ Learn more: [Documentation](https://stevie-ray.github.io/hangtime-grip-connect/) -
22
22
  [Browser Support](https://caniuse.com/web-bluetooth)
23
23
 
24
24
  > This project is provided "as-is" without any express or implied warranties. By using this software, you assume all
@@ -50,7 +50,7 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
50
50
  ```
51
51
 
52
52
  ```js
53
- import { Motherboard, active, connect, disconnect, notify } from "@hangtime/grip-connect"
53
+ import { Motherboard, active } from "@hangtime/grip-connect"
54
54
 
55
55
  const motherboardButton = document.querySelector("#motherboard")
56
56
 
@@ -61,7 +61,7 @@ motherboardButton.addEventListener("click", () => {
61
61
  motherboard.connect(
62
62
  async () => {
63
63
  // Listen for stream notifications
64
- notify((data) => {
64
+ motherboard.notify((data) => {
65
65
  // { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
66
66
  console.log(data)
67
67
  })
@@ -93,7 +93,7 @@ motherboardButton.addEventListener("click", () => {
93
93
  // await tare(5000)
94
94
 
95
95
  // Manually call stop method if stream is continues
96
- // await stop(Motherboard)
96
+ // await motherboard.stop()
97
97
 
98
98
  // Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
99
99
  // download('json')
@@ -110,49 +110,28 @@ 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
 
126
+ All devices provide some default features such as `connect`, `isConnected`, and `disconnect`. Additionally, each device
127
+ offers specific features—refer to the [documentation](https://stevie-ray.github.io/hangtime-grip-connect/devices/) for
128
+ more details on individual devices. There are also extra features that are not part of the device itself, like a
129
+ reactive `isActive` check and a `download` feature.
130
+
126
131
  **Help wanted:** Do you own any of the missing devices? Use Google Chrome's Bluetooth Internals
127
132
  `chrome://bluetooth-internals/#devices` and press `Start Scan` to look for your device, click on `Inspect` and share all
128
133
  available services with us.
129
134
 
130
- | | Motherboard | Progressor | WH-C06 | Entralpi | Kilter Board | Force Board | Climbro | mySmartBoard |
131
- | ---------------------------------------------------------------------------------------- | ----------- | ---------- | ------ | -------- | ------------ | ----------- | ------- | ------------ |
132
- | [Battery](https://stevie-ray.github.io/hangtime-grip-connect/api/battery.html) | ✅ | ✅ | | ✅ | | ✅ | | |
133
- | [Calibration](https://stevie-ray.github.io/hangtime-grip-connect/api/calibration.html) | ✅ | | | | | | | |
134
- | [Connect](https://stevie-ray.github.io/hangtime-grip-connect/api/connect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | |
135
- | [Disconnect](https://stevie-ray.github.io/hangtime-grip-connect/api/disconnect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
136
- | [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | | |
137
- | [Firmware](https://stevie-ray.github.io/hangtime-grip-connect/api/firmware.html) | ✅ | ✅ | | ✅ | | | | |
138
- | [Hardware](https://stevie-ray.github.io/hangtime-grip-connect/api/hardware.html) | ✅ | | | ✅ | | | | |
139
- | [Humidity](https://stevie-ray.github.io/hangtime-grip-connect/api/humidity.html) | | | | | | ✅ | | |
140
- | [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | ✅ | ✅ | ✅ | ✅ | | | | |
141
- | [isConnected](https://stevie-ray.github.io/hangtime-grip-connect/api/is-connected.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
142
- | [isDevice](https://stevie-ray.github.io/hangtime-grip-connect/api/is-device.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
143
- | [Led](https://stevie-ray.github.io/hangtime-grip-connect/api/led.html) | ✅ | | | | ✅ | | | |
144
- | [Manufacturer](https://stevie-ray.github.io/hangtime-grip-connect/api/manufacturer.html) | ✅ | | | ✅ | | ✅ | | |
145
- | [Model](#) | | | | ✅ | | | | |
146
- | [Notify](https://stevie-ray.github.io/hangtime-grip-connect/api/notify.html) | ✅ | ✅ | ✅ | ✅ | | | | |
147
- | [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) | ✅ | | | | | | | |
148
- | [Serial](https://stevie-ray.github.io/hangtime-grip-connect/api/serial.html) | ✅ | | | | | | | |
149
- | [Software](#) | | | | ✅ | | | | |
150
- | [Stop](https://stevie-ray.github.io/hangtime-grip-connect/api/stop.html) | ✅ | ✅ | | | | | | |
151
- | [Stream](https://stevie-ray.github.io/hangtime-grip-connect/api/stream.html) | ✅ | ✅ | | | | | | |
152
- | [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) | ✅ | ✅ | ✅ | ✅ | | | | |
153
- | [Text](https://stevie-ray.github.io/hangtime-grip-connect/api/text.html) | ✅ | | | | | | | |
154
- | [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ | ✅ | | | | | | |
155
-
156
135
  ## Development
157
136
 
158
137
  ```bash
@@ -1,4 +1,4 @@
1
- import type { Device } from "./models/device.model";
1
+ import type { Device } from "./../models/device.model";
2
2
  /**
3
3
  * Checks if the given device is an Entralpi device.
4
4
  * @param {Device} [board] - The device to check.
@@ -1,4 +1,4 @@
1
- import { AuroraUUID } from "./models/device/kilterboard.model";
1
+ import { AuroraUUID } from "./../models/device/kilterboard.model";
2
2
  /**
3
3
  * Checks if the given device is an Entralpi device.
4
4
  * @param {Device} [board] - The device to check.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
2
- export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
2
+ export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./helpers/is-device";
3
3
  export { download } from "./download";
4
4
  export { active, isActive } from "./is-active";
5
- export { notify } from "./notify";
6
- export { stop } from "./stop";
7
5
  export { tare } from "./tare";
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
2
2
  // helpers
3
- export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
4
- // functions
3
+ export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./helpers/is-device";
4
+ // TODO: Make functions device specific
5
5
  export { download } from "./download";
6
6
  export { active, isActive } from "./is-active";
7
- export { notify } from "./notify";
8
- export { stop } from "./stop";
9
7
  export { tare } from "./tare";
@@ -1,5 +1,17 @@
1
+ /**
2
+ * Represents the base properties for an entity.
3
+ */
1
4
  export interface IBase {
5
+ /**
6
+ * Unique identifier for the entity (optional).
7
+ */
2
8
  id?: string;
9
+ /**
10
+ * The date and time when the entity was created (optional).
11
+ */
3
12
  createdAt?: Date;
13
+ /**
14
+ * The date and time when the entity was last updated (optional).
15
+ */
4
16
  updatedAt?: Date;
5
17
  }
@@ -1,3 +1,6 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the Climbro device, extending the base Device interface.
4
+ */
2
5
  export interface IClimbro extends IDevice {
3
6
  }
@@ -1,3 +1,52 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the Entralpi device, extending the base Device interface.
4
+ */
2
5
  export interface IEntralpi extends IDevice {
6
+ /**
7
+ * Retrieves battery or voltage information from the device.
8
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
9
+ */
10
+ battery(): Promise<string | undefined>;
11
+ /**
12
+ * Retrieves IEEE 11073-20601 Regulatory Certification from the device.
13
+ * @returns {Promise<string | undefined>} A Promise that resolves with the firmware version.
14
+ */
15
+ certification(): Promise<string | undefined>;
16
+ /**
17
+ * Retrieves firmware version from the device.
18
+ * @returns {Promise<string | undefined>} A Promise that resolves with the firmware version.
19
+ */
20
+ firmware(): Promise<string | undefined>;
21
+ /**
22
+ * Retrieves hardware version from the device.
23
+ * @returns {Promise<string | undefined>} A Promise that resolves with the hardware version.
24
+ */
25
+ hardware(): Promise<string | undefined>;
26
+ /**
27
+ * Retrieves manufacturer information from the device.
28
+ * @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
29
+ */
30
+ manufacturer(): Promise<string | undefined>;
31
+ /**
32
+ * Retrieves model number from the device.
33
+ * @returns {Promise<string | undefined>} A Promise that resolves with the model number.
34
+ */
35
+ model(): Promise<string | undefined>;
36
+ /**
37
+ * Retrieves PnP ID from the device, a set of values that used to create a device ID value that is unique for this device.
38
+ * Included in the characteristic is a Vendor ID Source field, a Vendor ID field, a Product ID field and a Product Version field
39
+ * @returns {Promise<string | undefined>} A Promise that resolves with the PnP ID.
40
+ */
41
+ pnp(): Promise<string | undefined>;
42
+ /**
43
+ * Retrieves software version from the device.
44
+ * @returns {Promise<string | undefined>} A Promise that resolves with the software version.
45
+ */
46
+ software(): Promise<string | undefined>;
47
+ /**
48
+ * Retrieves system id from the device.
49
+ * @returns {Promise<string | undefined>} A Promise that resolves with the system id.
50
+ */
51
+ system(): Promise<string | undefined>;
3
52
  }
@@ -1,3 +1,21 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the PitchSix ForceBoard device, extending the base Device interface.
4
+ */
2
5
  export interface IForceBoard extends IDevice {
6
+ /**
7
+ * Retrieves battery or voltage information from the device.
8
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
9
+ */
10
+ battery(): Promise<string | undefined>;
11
+ /**
12
+ * Retrieves humidity level from the device.
13
+ * @returns {Promise<string | undefined>} A Promise that resolves with the humidity level.
14
+ */
15
+ humidity(): Promise<string | undefined>;
16
+ /**
17
+ * Retrieves manufacturer information from the device.
18
+ * @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
19
+ */
20
+ manufacturer(): Promise<string | undefined>;
3
21
  }
@@ -1,3 +1,76 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Represents a climbing placement with a position and role identifier.
4
+ */
5
+ export interface ClimbPlacement {
6
+ /** The position of the hold placement. */
7
+ position: number;
8
+ /** The role ID associated with the climb placement. */
9
+ role_id: number;
10
+ }
11
+ /**
12
+ * Interface representing the KilterBoard device, extending the base Device interface.
13
+ */
2
14
  export interface IKilterBoard extends IDevice {
15
+ /**
16
+ * Calculates the checksum for a byte array.
17
+ * @param data - The array of bytes to calculate the checksum for.
18
+ * @returns The calculated checksum value.
19
+ */
20
+ checksum(data: number[]): number;
21
+ /**
22
+ * Wraps a byte array with header and footer bytes for transmission.
23
+ * @param data - The array of bytes to wrap.
24
+ * @returns The wrapped byte array.
25
+ */
26
+ wrapBytes(data: number[]): number[];
27
+ /**
28
+ * Encodes a position into a byte array.
29
+ * @param position - The position to encode.
30
+ * @returns The encoded byte array representing the position.
31
+ */
32
+ encodePosition(position: number): number[];
33
+ /**
34
+ * Encodes a color string into a numeric representation.
35
+ * @param color - The color string in hexadecimal format.
36
+ * @returns The encoded/compressed color value.
37
+ */
38
+ encodeColor(color: string): number;
39
+ /**
40
+ * Encodes a placement into a byte array.
41
+ * @param position - The position to encode.
42
+ * @param ledColor - The color of the LED in hexadecimal format.
43
+ * @returns The encoded byte array representing the placement.
44
+ */
45
+ encodePlacement(position: number, ledColor: string): number[];
46
+ /**
47
+ * Prepares byte arrays for transmission based on a list of climb placements.
48
+ * @param climbPlacementList - The list of climb placements.
49
+ * @returns The final byte array ready for transmission.
50
+ */
51
+ prepBytesV3(climbPlacementList: ClimbPlacement[]): number[];
52
+ /**
53
+ * Splits a collection into slices of the specified length.
54
+ * @param n - Number of elements per slice.
55
+ * @param list - Array to be sliced.
56
+ * @returns The sliced array.
57
+ */
58
+ splitEvery(n: number, list: number[]): number[][];
59
+ /**
60
+ * Splits a message into 20-byte chunks for Bluetooth transmission.
61
+ * @param buffer - The message to split.
62
+ * @returns The array of Uint8Arrays.
63
+ */
64
+ splitMessages(buffer: number[]): Uint8Array[];
65
+ /**
66
+ * Sends a series of messages to the device.
67
+ * @param messages - Array of Uint8Arrays to send.
68
+ */
69
+ writeMessageSeries(messages: Uint8Array[]): Promise<void>;
70
+ /**
71
+ * Configures the LEDs based on an array of climb placements.
72
+ * @param config - Optional color or array of climb placements.
73
+ * @returns The prepared payload or undefined.
74
+ */
75
+ led(config?: ClimbPlacement[]): Promise<number[] | undefined>;
3
76
  }
@@ -1,10 +1,60 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the Griptonite Motherboard device.
4
+ */
2
5
  export interface IMotherboard extends IDevice {
3
6
  /**
4
7
  * Applies calibration to a sample value.
5
- * @param sample - The sample value to calibrate.
6
- * @param calibration - The calibration data.
7
- * @returns The calibrated sample value.
8
+ * @param {number} sample - The sample value to calibrate.
9
+ * @param {number[][]} calibration - The calibration data.
10
+ * @returns {number} The calibrated sample value.
8
11
  */
9
12
  applyCalibration(sample: number, calibration: number[][]): number;
13
+ /**
14
+ * Retrieves battery or voltage information from the device.
15
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
16
+ */
17
+ battery(): Promise<string | undefined>;
18
+ /**
19
+ * Writes a command to get calibration data from the device.
20
+ * @returns {Promise<void>} A Promise that resolves when the command is successfully sent.
21
+ */
22
+ calibration(): Promise<void>;
23
+ /**
24
+ * Retrieves firmware version from the device.
25
+ * @returns {Promise<string | undefined>} A Promise that resolves with the firmware version.
26
+ */
27
+ firmware(): Promise<string | undefined>;
28
+ /**
29
+ * Retrieves hardware version from the device.
30
+ * @returns {Promise<string | undefined>} A Promise that resolves with the hardware version.
31
+ */
32
+ hardware(): Promise<string | undefined>;
33
+ /**
34
+ * Sets the LED color based on a single color option.
35
+ * @param {"green" | "red" | "orange"} [config] - Optional color for the LEDs.
36
+ * @returns {Promise<number[] | undefined>} A promise that resolves with the payload array for the Kilter Board if LED settings were applied.
37
+ */
38
+ led(config?: "green" | "red" | "orange"): Promise<number[] | undefined>;
39
+ /**
40
+ * Retrieves manufacturer information from the device.
41
+ * @returns {Promise<string | undefined>} A Promise that resolves with the manufacturer information.
42
+ */
43
+ manufacturer(): Promise<string | undefined>;
44
+ /**
45
+ * Retrieves serial number from the device.
46
+ * @returns {Promise<string | undefined>} A Promise that resolves with the serial number.
47
+ */
48
+ serial(): Promise<string | undefined>;
49
+ /**
50
+ * Stops the data stream on the specified device.
51
+ * @returns {Promise<void>} A promise that resolves when the stream is stopped.
52
+ */
53
+ stop(): Promise<void>;
54
+ /**
55
+ * Starts streaming data from the specified device.
56
+ * @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
57
+ * @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
58
+ */
59
+ stream(duration?: number): Promise<void>;
10
60
  }
@@ -1,3 +1,6 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the mySmartBoard device, extending the base Device interface.
4
+ */
2
5
  export interface ImySmartBoard extends IDevice {
3
6
  }
@@ -1,3 +1,27 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the Tindeq Progressor device.
4
+ */
2
5
  export interface IProgressor extends IDevice {
6
+ /**
7
+ * Retrieves battery or voltage information from the device.
8
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
9
+ */
10
+ battery(): Promise<string | undefined>;
11
+ /**
12
+ * Retrieves firmware version from the device.
13
+ * @returns {Promise<string>} A Promise that resolves with the firmware version.
14
+ */
15
+ firmware(): Promise<string | undefined>;
16
+ /**
17
+ * Stops the data stream on the specified device.
18
+ * @returns {Promise<void>} A promise that resolves when the stream is stopped.
19
+ */
20
+ stop(): Promise<void>;
21
+ /**
22
+ * Starts streaming data from the specified device.
23
+ * @param {number} [duration=0] - The duration of the stream in milliseconds. If set to 0, stream will continue indefinitely.
24
+ * @returns {Promise<void>} A promise that resolves when the streaming operation is completed.
25
+ */
26
+ stream(duration?: number): Promise<void>;
3
27
  }
@@ -1,3 +1,6 @@
1
1
  import type { IDevice } from "../device.interface";
2
+ /**
3
+ * Interface representing the Weiheng WH-C06 device.
4
+ */
2
5
  export interface IWHC06 extends IDevice {
3
6
  }
@@ -1,4 +1,5 @@
1
1
  import type { IBase } from "./base.interface";
2
+ import type { massObject } from "../types/notify";
2
3
  /**
3
4
  * Represents a characteristic of a Bluetooth service.
4
5
  */
@@ -36,41 +37,96 @@ export interface IDevice extends IBase {
36
37
  /** Reference to the BluetoothDevice object representing this device */
37
38
  bluetooth?: BluetoothDevice;
38
39
  /**
39
- * Handles the 'disconnected' event.
40
- * @param {Event} event - The 'disconnected' event.
40
+ * Connects to a Bluetooth device.
41
+ * @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
42
+ * @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
41
43
  */
42
- onDisconnected(event: Event): void;
44
+ connect(onSuccess?: () => void, onError?: (error: Error) => void): Promise<void>;
45
+ /**
46
+ * Disconnects the device if it is currently connected.
47
+ * - Checks if the device is connected via it's GATT server.
48
+ * - If the device is connected, it attempts to gracefully disconnect.
49
+ */
50
+ disconnect(): void;
51
+ /**
52
+ * Returns UUIDs of all services associated with the device.
53
+ * @returns {string[]} Array of service UUIDs.
54
+ */
55
+ getAllServiceUUIDs(): string[];
56
+ /**
57
+ * Retrieves the characteristic from the device's service.
58
+ * @param {string} serviceId - The UUID of the service.
59
+ * @param {string} characteristicId - The UUID of the characteristic.
60
+ * @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
61
+ */
62
+ getCharacteristic(serviceId: string, characteristicId: string): BluetoothRemoteGATTCharacteristic | undefined;
43
63
  /**
44
64
  * Handles notifications received from a characteristic.
45
65
  * @param {Event} event - The notification event.
46
66
  */
47
67
  handleNotifications(event: Event): void;
68
+ /**
69
+ * Checks if a Bluetooth device is connected.
70
+ * @returns {boolean} A boolean indicating whether the device is connected.
71
+ */
72
+ isConnected(): boolean;
73
+ /**
74
+ * Sets the callback function to be called when notifications are received.
75
+ * @param {NotifyCallback} callback - The callback function to be set.
76
+ * @returns {void}
77
+ */
78
+ 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;
48
85
  /**
49
86
  * Handles the 'connected' event.
50
87
  * @param {Function} onSuccess - Callback function to execute on successful connection.
51
88
  */
52
89
  onConnected(onSuccess: () => void): Promise<void>;
53
90
  /**
54
- * Returns UUIDs of all services associated with the device.
55
- * @returns {string[]} Array of service UUIDs.
91
+ * Handles the 'disconnected' event.
92
+ * @param {Event} event - The 'disconnected' event.
56
93
  */
57
- getAllServiceUUIDs(): string[];
94
+ onDisconnected(event: Event): void;
58
95
  /**
59
- * Connects to a Bluetooth device.
60
- * @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
61
- * @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
96
+ * Reads the value of the specified characteristic from the device.
97
+ * @param {string} serviceId - The service ID where the characteristic belongs.
98
+ * @param {string} characteristicId - The characteristic ID to read from.
99
+ * @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.
62
101
  */
63
- connect(onSuccess?: () => void, onError?: (error: Error) => void): Promise<void>;
102
+ read(serviceId: string, characteristicId: string, duration?: number): Promise<string>;
64
103
  /**
65
- * Checks if a Bluetooth device is connected.
66
- * @returns {boolean} A boolean indicating whether the device is connected.
104
+ * Writes a message to the specified characteristic of a Bluetooth device and optionally provides a callback to handle responses.
105
+ * @param {string} serviceId - The service UUID of the Bluetooth device containing the target characteristic.
106
+ * @param {string} characteristicId - The characteristic UUID where the message will be written.
107
+ * @param {string | Uint8Array | undefined} message - The message to be written to the characteristic. It can be a string or a Uint8Array.
108
+ * @param {number} [duration=0] - Optional. The time in milliseconds to wait before resolving the promise. Defaults to 0 for immediate resolution.
109
+ * @param {WriteCallback} [callback=writeCallback] - Optional. A custom callback to handle the response after the write operation is successful.
110
+ *
111
+ * @returns {Promise<void>} A promise that resolves once the write operation is complete.
112
+ *
113
+ * @throws {Error} Throws an error if the characteristic is undefined.
114
+ *
115
+ * @example
116
+ * // Example usage of the write function with a custom callback
117
+ * await Progressor.write("progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250, (data) => {
118
+ * console.log(`Battery voltage: ${data}`);
119
+ * });
67
120
  */
68
- isConnected(): boolean;
121
+ write(serviceId: string, characteristicId: string, message: string | Uint8Array | undefined, duration?: number, callback?: (data: string) => void): Promise<void>;
69
122
  /**
70
- * Disconnects the device if it is currently connected.
71
- * - Checks if the device is connected via it's GATT server.
72
- * - If the device is connected, it attempts to gracefully disconnect.
123
+ * A default write callback that logs the response
73
124
  */
74
- disconnect(): void;
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;
75
131
  }
76
132
  export {};
@@ -4,12 +4,17 @@ export declare class Entralpi extends Device implements IEntralpi {
4
4
  constructor();
5
5
  /**
6
6
  * Retrieves battery or voltage information from the device.
7
- * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
7
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information.
8
8
  */
9
9
  battery: () => Promise<string | undefined>;
10
+ /**
11
+ * Retrieves IEEE 11073-20601 Regulatory Certification from the device.
12
+ * @returns {Promise<string>} A Promise that resolves with the certification.
13
+ */
14
+ certification: () => Promise<string | undefined>;
10
15
  /**
11
16
  * Retrieves firmware version from the device.
12
- * @returns {Promise<string>} A Promise that resolves with the firmware version,
17
+ * @returns {Promise<string>} A Promise that resolves with the firmware version.
13
18
  */
14
19
  firmware: () => Promise<string | undefined>;
15
20
  /**
@@ -22,22 +27,33 @@ export declare class Entralpi extends Device implements IEntralpi {
22
27
  handleNotifications: (event: Event) => void;
23
28
  /**
24
29
  * Retrieves hardware version from the device.
25
- * @returns {Promise<string>} A Promise that resolves with the hardware version,
30
+ * @returns {Promise<string>} A Promise that resolves with the hardware version.
26
31
  */
27
32
  hardware: () => Promise<string | undefined>;
28
33
  /**
29
34
  * Retrieves manufacturer information from the device.
30
- * @returns {Promise<string>} A Promise that resolves with the manufacturer information,
35
+ * @returns {Promise<string>} A Promise that resolves with the manufacturer information.
31
36
  */
32
37
  manufacturer: () => Promise<string | undefined>;
33
38
  /**
34
39
  * Retrieves model number from the device.
35
- * @returns {Promise<string>} A Promise that resolves with the model number,
40
+ * @returns {Promise<string>} A Promise that resolves with the model number.
36
41
  */
37
42
  model: () => Promise<string | undefined>;
43
+ /**
44
+ * Retrieves PnP ID from the device, a set of values that used to create a device ID value that is unique for this device.
45
+ * Included in the characteristic is a Vendor ID Source field, a Vendor ID field, a Product ID field and a Product Version field
46
+ * @returns {Promise<string>} A Promise that resolves with the PnP ID.
47
+ */
48
+ pnp: () => Promise<string | undefined>;
38
49
  /**
39
50
  * Retrieves software version from the device.
40
- * @returns {Promise<string>} A Promise that resolves with the software version,
51
+ * @returns {Promise<string>} A Promise that resolves with the software version.
41
52
  */
42
53
  software: () => Promise<string | undefined>;
54
+ /**
55
+ * Retrieves system id from the device.
56
+ * @returns {Promise<string>} A Promise that resolves with the system id.
57
+ */
58
+ system: () => Promise<string | undefined>;
43
59
  }