@hangtime/grip-connect 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +8 -17
  2. package/dist/{download.d.ts → helpers/download.d.ts} +1 -1
  3. package/dist/helpers/is-device.d.ts +37 -0
  4. package/dist/helpers/is-device.js +39 -0
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.js +4 -5
  7. package/dist/interfaces/callback.interface.d.ts +49 -0
  8. package/dist/interfaces/command.interface.d.ts +85 -0
  9. package/dist/interfaces/device.interface.d.ts +54 -12
  10. package/dist/models/device/entralpi.model.js +18 -24
  11. package/dist/models/device/forceboard.model.js +7 -8
  12. package/dist/models/device/kilterboard.model.d.ts +61 -2
  13. package/dist/models/device/kilterboard.model.js +92 -13
  14. package/dist/models/device/motherboard.model.d.ts +24 -1
  15. package/dist/models/device/motherboard.model.js +63 -43
  16. package/dist/models/device/progressor.model.js +64 -26
  17. package/dist/models/device/wh-c06.model.d.ts +7 -0
  18. package/dist/models/device/wh-c06.model.js +18 -17
  19. package/dist/models/device.model.d.ts +105 -11
  20. package/dist/models/device.model.js +181 -10
  21. package/package.json +1 -1
  22. package/src/{download.ts → helpers/download.ts} +1 -1
  23. package/src/helpers/is-device.ts +50 -0
  24. package/src/index.ts +4 -5
  25. package/src/interfaces/callback.interface.ts +56 -0
  26. package/src/interfaces/command.interface.ts +106 -0
  27. package/src/interfaces/device.interface.ts +66 -13
  28. package/src/models/device/entralpi.model.ts +18 -25
  29. package/src/models/device/forceboard.model.ts +7 -8
  30. package/src/models/device/kilterboard.model.ts +94 -15
  31. package/src/models/device/motherboard.model.ts +68 -47
  32. package/src/models/device/progressor.model.ts +68 -27
  33. package/src/models/device/wh-c06.model.ts +20 -18
  34. package/src/models/device.model.ts +207 -17
  35. package/dist/characteristic.d.ts +0 -9
  36. package/dist/characteristic.js +0 -21
  37. package/dist/commands/climbro.d.ts +0 -6
  38. package/dist/commands/climbro.js +0 -5
  39. package/dist/commands/entralpi.d.ts +0 -6
  40. package/dist/commands/entralpi.js +0 -5
  41. package/dist/commands/forceboard.d.ts +0 -6
  42. package/dist/commands/forceboard.js +0 -5
  43. package/dist/commands/index.d.ts +0 -7
  44. package/dist/commands/index.js +0 -7
  45. package/dist/commands/kilterboard.d.ts +0 -35
  46. package/dist/commands/kilterboard.js +0 -65
  47. package/dist/commands/motherboard.d.ts +0 -6
  48. package/dist/commands/motherboard.js +0 -13
  49. package/dist/commands/mysmartboard.d.ts +0 -6
  50. package/dist/commands/mysmartboard.js +0 -5
  51. package/dist/commands/progressor.d.ts +0 -17
  52. package/dist/commands/progressor.js +0 -30
  53. package/dist/commands/wh-c06.d.ts +0 -6
  54. package/dist/commands/wh-c06.js +0 -5
  55. package/dist/is-device.d.ts +0 -37
  56. package/dist/is-device.js +0 -39
  57. package/dist/read.d.ts +0 -10
  58. package/dist/read.js +0 -43
  59. package/dist/types/commands.d.ts +0 -18
  60. package/dist/types/notify.d.ts +0 -14
  61. package/dist/write.d.ts +0 -34
  62. package/dist/write.js +0 -58
  63. package/src/characteristic.ts +0 -29
  64. package/src/commands/climbro.ts +0 -6
  65. package/src/commands/entralpi.ts +0 -6
  66. package/src/commands/forceboard.ts +0 -6
  67. package/src/commands/index.ts +0 -13
  68. package/src/commands/kilterboard.ts +0 -64
  69. package/src/commands/motherboard.ts +0 -14
  70. package/src/commands/mysmartboard.ts +0 -6
  71. package/src/commands/progressor.ts +0 -31
  72. package/src/commands/wh-c06.ts +0 -6
  73. package/src/is-device.ts +0 -50
  74. package/src/read.ts +0 -45
  75. package/src/types/commands.ts +0 -21
  76. package/src/types/notify.ts +0 -14
  77. package/src/write.ts +0 -74
  78. /package/dist/{download.js → helpers/download.js} +0 -0
  79. /package/dist/{is-active.d.ts → helpers/is-active.d.ts} +0 -0
  80. /package/dist/{is-active.js → helpers/is-active.js} +0 -0
  81. /package/dist/{struct/index.d.ts → helpers/struct.d.ts} +0 -0
  82. /package/dist/{struct/index.js → helpers/struct.js} +0 -0
  83. /package/dist/{tare.d.ts → helpers/tare.d.ts} +0 -0
  84. /package/dist/{tare.js → helpers/tare.js} +0 -0
  85. /package/dist/{types/commands.js → interfaces/callback.interface.js} +0 -0
  86. /package/dist/{types/download.js → interfaces/command.interface.js} +0 -0
  87. /package/dist/{types/download.d.ts → interfaces/download.interface.d.ts} +0 -0
  88. /package/dist/{types/notify.js → interfaces/download.interface.js} +0 -0
  89. /package/src/{is-active.ts → helpers/is-active.ts} +0 -0
  90. /package/src/{struct/index.ts → helpers/struct.ts} +0 -0
  91. /package/src/{tare.ts → helpers/tare.ts} +0 -0
  92. /package/src/{types/download.ts → interfaces/download.interface.ts} +0 -0
@@ -1,23 +1,104 @@
1
1
  import { BaseModel } from "./../models/base.model"
2
2
  import type { IDevice, Service } from "../interfaces/device.interface"
3
- import type { massObject } from "./../types/notify"
3
+ import type { NotifyCallback, massObject, WriteCallback } from "../interfaces/callback.interface"
4
+ import type { Commands } from "../interfaces/command.interface"
4
5
 
5
- let server: BluetoothRemoteGATTServer
6
+ export abstract class Device extends BaseModel implements IDevice {
7
+ /**
8
+ * Filters to identify the device during Bluetooth scanning.
9
+ * Used to match devices that meet specific criteria such as name, service UUIDs, etc.
10
+ */
11
+ public filters: BluetoothLEScanFilter[]
12
+
13
+ /**
14
+ * Array of services provided by the device.
15
+ * Services represent functionalities that the device supports, such as weight measurement, battery information, or custom services.
16
+ */
17
+ public services: Service[]
18
+
19
+ /**
20
+ * Reference to the `BluetoothDevice` object representing this device.
21
+ * This is the actual device object obtained from the Web Bluetooth API after a successful connection.
22
+ */
23
+ public bluetooth?: BluetoothDevice | undefined
24
+
25
+ /**
26
+ * Object representing the set of commands available for this device.
27
+ * These commands allow communication with the device to perform various operations such as starting measurements, retrieving data, or calibrating the device.
28
+ */
29
+ public commands: Commands
30
+
31
+ /**
32
+ * The BluetoothRemoteGATTServer interface of the Web Bluetooth API represents a GATT Server on a remote device.
33
+ */
34
+ private server: BluetoothRemoteGATTServer | undefined
35
+
36
+ /**
37
+ * Maximum mass recorded from the device, initialized to "0".
38
+ * @type {string}
39
+ * @protected
40
+ */
41
+ protected massMax: string
42
+
43
+ /**
44
+ * Average mass calculated from the device data, initialized to "0".
45
+ * @type {string}
46
+ * @protected
47
+ */
48
+ protected massAverage: string
49
+
50
+ /**
51
+ * Total sum of all mass data points recorded from the device.
52
+ * Used to calculate the average mass.
53
+ * @type {number}
54
+ * @protected
55
+ */
56
+ protected massTotalSum: number
57
+
58
+ /**
59
+ * Number of data points received from the device.
60
+ * Used to calculate the average mass.
61
+ * @type {number}
62
+ * @protected
63
+ */
64
+ protected dataPointCount: number
6
65
 
7
- /** Define the type for the callback function */
8
- type NotifyCallback = (data: massObject) => void
66
+ /**
67
+ * Optional callback for handling write operations.
68
+ * @callback NotifyCallback
69
+ * @param {massObject} data - The data passed to the callback.
70
+ * @type {NotifyCallback | undefined}
71
+ * @protected
72
+ */
73
+ protected notifyCallback: NotifyCallback = (data: massObject) => console.log(data)
9
74
 
10
- export class Device extends BaseModel implements IDevice {
11
- filters: BluetoothLEScanFilter[]
12
- services: Service[]
13
- bluetooth?: BluetoothDevice | undefined
75
+ /**
76
+ * Optional callback for handling write operations.
77
+ * @callback WriteCallback
78
+ * @param {string} data - The data passed to the callback.
79
+ * @type {WriteCallback | undefined}
80
+ * @protected
81
+ */
82
+ protected writeCallback: WriteCallback = (data: string) => console.log(data)
83
+
84
+ /**
85
+ * The last message written to the device.
86
+ * @type {string | Uint8Array | null}
87
+ */
88
+ protected writeLast: string | Uint8Array | null = null
14
89
 
15
90
  constructor(device: Partial<IDevice>) {
16
91
  super(device)
17
92
 
18
93
  this.filters = device.filters || []
19
94
  this.services = device.services || []
95
+ this.commands = device.commands || {}
20
96
  this.bluetooth = device.bluetooth
97
+
98
+ this.massMax = "0"
99
+ this.massAverage = "0"
100
+ this.massTotalSum = 0
101
+ this.dataPointCount = 0
21
102
  }
22
103
  /**
23
104
  * Connects to a Bluetooth device.
@@ -45,9 +126,9 @@ export class Device extends BaseModel implements IDevice {
45
126
  this.onDisconnected(event)
46
127
  })
47
128
 
48
- server = await this.bluetooth.gatt.connect()
129
+ this.server = await this.bluetooth.gatt.connect()
49
130
 
50
- if (server.connected) {
131
+ if (this.server.connected) {
51
132
  await this.onConnected(onSuccess)
52
133
  }
53
134
  } catch (error) {
@@ -73,6 +154,28 @@ export class Device extends BaseModel implements IDevice {
73
154
  getAllServiceUUIDs = () => {
74
155
  return this.services.map((service) => service.uuid)
75
156
  }
157
+ /**
158
+ * Retrieves the characteristic from the device's service.
159
+ * @param {string} serviceId - The UUID of the service.
160
+ * @param {string} characteristicId - The UUID of the characteristic.
161
+ * @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
162
+ */
163
+ getCharacteristic = (serviceId: string, characteristicId: string): BluetoothRemoteGATTCharacteristic | undefined => {
164
+ // Find the service with the specified serviceId
165
+ const boardService = this.services.find((service) => service.id === serviceId)
166
+ if (boardService) {
167
+ // If the service is found, find the characteristic with the specified characteristicId
168
+ const boardCharacteristic = boardService.characteristics.find(
169
+ (characteristic) => characteristic.id === characteristicId,
170
+ )
171
+ if (boardCharacteristic) {
172
+ // If the characteristic is found, return it
173
+ return boardCharacteristic.characteristic
174
+ }
175
+ }
176
+ // Return undefined if the service or characteristic is not found
177
+ return undefined
178
+ }
76
179
  /**
77
180
  * Handles notifications received from a characteristic.
78
181
  * @param {Event} event - The notification event.
@@ -112,19 +215,13 @@ export class Device extends BaseModel implements IDevice {
112
215
  notify = (callback: NotifyCallback): void => {
113
216
  this.notifyCallback = callback
114
217
  }
115
- /**
116
- * Defines the type for the callback function.
117
- * @callback NotifyCallback
118
- * @param {massObject} data - The data passed to the callback.
119
- */
120
- notifyCallback: NotifyCallback = (data) => console.log(data)
121
218
  /**
122
219
  * Handles the 'connected' event.
123
220
  * @param {Function} onSuccess - Callback function to execute on successful connection.
124
221
  */
125
222
  onConnected = async (onSuccess: () => void): Promise<void> => {
126
223
  // Connect to GATT server and set up characteristics
127
- const services: BluetoothRemoteGATTService[] = await server.getPrimaryServices()
224
+ const services: BluetoothRemoteGATTService[] | undefined = await this.server?.getPrimaryServices()
128
225
 
129
226
  if (!services || services.length === 0) {
130
227
  throw new Error("No services found")
@@ -174,4 +271,97 @@ export class Device extends BaseModel implements IDevice {
174
271
  const device = event.target as BluetoothDevice
175
272
  throw new Error(`Device ${device.name} is disconnected.`)
176
273
  }
274
+ /**
275
+ * Reads the value of the specified characteristic from the device.
276
+ * @param {string} serviceId - The service ID where the characteristic belongs.
277
+ * @param {string} characteristicId - The characteristic ID to read from.
278
+ * @param {number} [duration=0] - The duration to wait before resolving the promise, in milliseconds.
279
+ * @returns {Promise<string>} A promise that resolves when the read operation is completed.
280
+ */
281
+ read = (serviceId: string, characteristicId: string, duration = 0): Promise<string> => {
282
+ return new Promise((resolve, reject) => {
283
+ if (this.isConnected()) {
284
+ const characteristic = this.getCharacteristic(serviceId, characteristicId)
285
+
286
+ if (characteristic) {
287
+ characteristic
288
+ .readValue()
289
+ .then((value) => {
290
+ let decodedValue: string
291
+ const decoder = new TextDecoder("utf-8")
292
+ switch (characteristicId) {
293
+ case "level":
294
+ // TODO: This is battery specific.
295
+ decodedValue = value.getUint8(0).toString()
296
+ break
297
+ default:
298
+ decodedValue = decoder.decode(value)
299
+ break
300
+ }
301
+ // Resolve after specified duration
302
+ setTimeout(() => {
303
+ return resolve(decodedValue)
304
+ }, duration)
305
+ })
306
+ .catch((error) => {
307
+ reject(error)
308
+ })
309
+ } else {
310
+ reject(new Error("Characteristic is undefined"))
311
+ }
312
+ }
313
+ })
314
+ }
315
+ /**
316
+ * Writes a message to the specified characteristic of a Bluetooth device and optionally provides a callback to handle responses.
317
+ * @param {string} serviceId - The service UUID of the Bluetooth device containing the target characteristic.
318
+ * @param {string} characteristicId - The characteristic UUID where the message will be written.
319
+ * @param {string | Uint8Array | undefined} message - The message to be written to the characteristic. It can be a string or a Uint8Array.
320
+ * @param {number} [duration=0] - Optional. The time in milliseconds to wait before resolving the promise. Defaults to 0 for immediate resolution.
321
+ * @param {WriteCallback} [callback=writeCallback] - Optional. A custom callback to handle the response after the write operation is successful.
322
+ *
323
+ * @returns {Promise<void>} A promise that resolves once the write operation is complete.
324
+ *
325
+ * @throws {Error} Throws an error if the characteristic is undefined.
326
+ *
327
+ * @example
328
+ * // Example usage of the write function with a custom callback
329
+ * await Progressor.write("progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250, (data) => {
330
+ * console.log(`Battery voltage: ${data}`);
331
+ * });
332
+ */
333
+ write = async (
334
+ serviceId: string,
335
+ characteristicId: string,
336
+ message: string | Uint8Array | undefined,
337
+ duration = 0,
338
+ callback: WriteCallback = this.writeCallback,
339
+ ): Promise<void> => {
340
+ if (this.isConnected()) {
341
+ // Check if message is provided
342
+ if (message === undefined) {
343
+ // If not provided, return without performing write operation
344
+ return
345
+ }
346
+ // Get the characteristic from the device using serviceId and characteristicId
347
+ const characteristic = this.getCharacteristic(serviceId, characteristicId)
348
+ if (!characteristic) {
349
+ throw new Error("Characteristic is undefined")
350
+ }
351
+ // Convert the message to Uint8Array if it's a string
352
+ const valueToWrite: Uint8Array = typeof message === "string" ? new TextEncoder().encode(message) : message
353
+ // Write the value to the characteristic
354
+ await characteristic.writeValue(valueToWrite)
355
+ // Update the last written message
356
+ this.writeLast = message
357
+ // Assign the provided callback to `writeCallback`
358
+
359
+ this.writeCallback = callback
360
+ // If a duration is specified, resolve the promise after the duration
361
+
362
+ if (duration > 0) {
363
+ await new Promise<void>((resolve) => setTimeout(resolve, duration))
364
+ }
365
+ }
366
+ }
177
367
  }
@@ -1,9 +0,0 @@
1
- import type { Device } from "./models/device.model";
2
- /**
3
- * Retrieves the characteristic from the device's service.
4
- * @param {Device} board - The device.
5
- * @param {string} serviceId - The UUID of the service.
6
- * @param {string} characteristicId - The UUID of the characteristic.
7
- * @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
8
- */
9
- export declare const getCharacteristic: (board: Device, serviceId: string, characteristicId: string) => BluetoothRemoteGATTCharacteristic | undefined;
@@ -1,21 +0,0 @@
1
- /**
2
- * Retrieves the characteristic from the device's service.
3
- * @param {Device} board - The device.
4
- * @param {string} serviceId - The UUID of the service.
5
- * @param {string} characteristicId - The UUID of the characteristic.
6
- * @returns {BluetoothRemoteGATTCharacteristic | undefined} The characteristic, if found.
7
- */
8
- export const getCharacteristic = (board, serviceId, characteristicId) => {
9
- // Find the service with the specified serviceId
10
- const boardService = board.services.find((service) => service.id === serviceId);
11
- if (boardService) {
12
- // If the service is found, find the characteristic with the specified characteristicId
13
- const boardCharacteristic = boardService.characteristics.find((characteristic) => characteristic.id === characteristicId);
14
- if (boardCharacteristic) {
15
- // If the characteristic is found, return it
16
- return boardCharacteristic.characteristic;
17
- }
18
- }
19
- // Return undefined if the service or characteristic is not found
20
- return undefined;
21
- };
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const ClimbroCommands: Commands;
@@ -1,5 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const ClimbroCommands = {};
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const EntralpiCommands: Commands;
@@ -1,5 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const EntralpiCommands = {};
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const ForceBoardCommands: Commands;
@@ -1,5 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const ForceBoardCommands = {};
@@ -1,7 +0,0 @@
1
- export { ClimbroCommands } from "./climbro";
2
- export { EntralpiCommands } from "./entralpi";
3
- export { ForceBoardCommands } from "./forceboard";
4
- export { MotherboardCommands } from "./motherboard";
5
- export { mySmartBoardCommands } from "./mysmartboard";
6
- export { ProgressorCommands } from "./progressor";
7
- export { WHC06Commands } from "./wh-c06";
@@ -1,7 +0,0 @@
1
- export { ClimbroCommands } from "./climbro";
2
- export { EntralpiCommands } from "./entralpi";
3
- export { ForceBoardCommands } from "./forceboard";
4
- export { MotherboardCommands } from "./motherboard";
5
- export { mySmartBoardCommands } from "./mysmartboard";
6
- export { ProgressorCommands } from "./progressor";
7
- export { WHC06Commands } from "./wh-c06";
@@ -1,35 +0,0 @@
1
- /**
2
- * For API level 2 and API level 3.
3
- * The first byte in the data is dependent on where the packet is in the message as a whole.
4
- * More details: https://github.com/1-max-1/fake_kilter_board
5
- */
6
- export declare enum KilterBoardPacket {
7
- /** If this packet is in the middle, the byte gets set to 77 (M). */
8
- V2_MIDDLE = 77,
9
- /** If this packet is the first packet in the message, then this byte gets set to 78 (N). */
10
- V2_FIRST = 78,
11
- /** If this is the last packet in the message, this byte gets set to 79 (0). */
12
- V2_LAST = 79,
13
- /** 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. */
14
- V2_ONLY = 80,
15
- /** If this packet is in the middle, the byte gets set to 81 (Q). */
16
- V3_MIDDLE = 81,
17
- /** If this packet is the first packet in the message, then this byte gets set to 82 (R). */
18
- V3_FIRST = 82,
19
- /** If this is the last packet in the message, this byte gets set to 83 (S). */
20
- V3_LAST = 83,
21
- /** 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. */
22
- V3_ONLY = 84
23
- }
24
- /**
25
- * Extracted from placement_roles database table.
26
- */
27
- export declare const KilterBoardPlacementRoles: {
28
- id: number;
29
- product_id: number;
30
- position: number;
31
- name: string;
32
- full_name: string;
33
- led_color: string;
34
- screen_color: string;
35
- }[];
@@ -1,65 +0,0 @@
1
- /**
2
- * For API level 2 and API level 3.
3
- * The first byte in the data is dependent on where the packet is in the message as a whole.
4
- * More details: https://github.com/1-max-1/fake_kilter_board
5
- */
6
- export var KilterBoardPacket;
7
- (function (KilterBoardPacket) {
8
- /** If this packet is in the middle, the byte gets set to 77 (M). */
9
- KilterBoardPacket[KilterBoardPacket["V2_MIDDLE"] = 77] = "V2_MIDDLE";
10
- /** If this packet is the first packet in the message, then this byte gets set to 78 (N). */
11
- KilterBoardPacket[KilterBoardPacket["V2_FIRST"] = 78] = "V2_FIRST";
12
- /** If this is the last packet in the message, this byte gets set to 79 (0). */
13
- KilterBoardPacket[KilterBoardPacket["V2_LAST"] = 79] = "V2_LAST";
14
- /** 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. */
15
- KilterBoardPacket[KilterBoardPacket["V2_ONLY"] = 80] = "V2_ONLY";
16
- /** If this packet is in the middle, the byte gets set to 81 (Q). */
17
- KilterBoardPacket[KilterBoardPacket["V3_MIDDLE"] = 81] = "V3_MIDDLE";
18
- /** If this packet is the first packet in the message, then this byte gets set to 82 (R). */
19
- KilterBoardPacket[KilterBoardPacket["V3_FIRST"] = 82] = "V3_FIRST";
20
- /** If this is the last packet in the message, this byte gets set to 83 (S). */
21
- KilterBoardPacket[KilterBoardPacket["V3_LAST"] = 83] = "V3_LAST";
22
- /** 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. */
23
- KilterBoardPacket[KilterBoardPacket["V3_ONLY"] = 84] = "V3_ONLY";
24
- })(KilterBoardPacket || (KilterBoardPacket = {}));
25
- /**
26
- * Extracted from placement_roles database table.
27
- */
28
- export const KilterBoardPlacementRoles = [
29
- {
30
- id: 12,
31
- product_id: 1,
32
- position: 1,
33
- name: "start",
34
- full_name: "Start",
35
- led_color: "00FF00",
36
- screen_color: "00DD00",
37
- },
38
- {
39
- id: 13,
40
- product_id: 1,
41
- position: 2,
42
- name: "middle",
43
- full_name: "Middle",
44
- led_color: "00FFFF",
45
- screen_color: "00FFFF",
46
- },
47
- {
48
- id: 14,
49
- product_id: 1,
50
- position: 3,
51
- name: "finish",
52
- full_name: "Finish",
53
- led_color: "FF00FF",
54
- screen_color: "FF00FF",
55
- },
56
- {
57
- id: 15,
58
- product_id: 1,
59
- position: 4,
60
- name: "foot",
61
- full_name: "Foot Only",
62
- led_color: "FFB600",
63
- screen_color: "FFA500",
64
- },
65
- ];
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const MotherboardCommands: Commands;
@@ -1,13 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const MotherboardCommands = {
6
- GET_SERIAL: "#",
7
- START_WEIGHT_MEAS: "S30",
8
- STOP_WEIGHT_MEAS: "", // All commands will stop the data stream.
9
- GET_CALIBRATION: "C",
10
- SLEEP: 0,
11
- GET_TEXT: "T",
12
- DEBUG_STREAM: "D",
13
- };
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const mySmartBoardCommands: Commands;
@@ -1,5 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const mySmartBoardCommands = {};
@@ -1,17 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const ProgressorCommands: Commands;
7
- /**
8
- * The Progressor returns a Uint8Array.
9
- * The first item [0] is the type of response it returns
10
- */
11
- export declare enum ProgressorResponses {
12
- COMMAND_RESPONSE = 0,
13
- WEIGHT_MEASURE = 1,
14
- PEAK_RFD_MEAS = 2,
15
- PEAK_RFD_MEAS_SERIES = 3,
16
- LOW_BATTERY_WARNING = 4
17
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const ProgressorCommands = {
6
- TARE_SCALE: "d", // 0x64,
7
- START_WEIGHT_MEAS: "e", // 0x65,
8
- STOP_WEIGHT_MEAS: "f", // 0x66,
9
- START_PEAK_RFD_MEAS: "g", // 0x67,
10
- START_PEAK_RFD_MEAS_SERIES: "h", // 0x68,
11
- ADD_CALIB_POINT: "i", // 0x69,
12
- SAVE_CALIB: "j", // 0x6a,
13
- GET_FW_VERSION: "k", // 0x6b,
14
- GET_ERR_INFO: "l", // 0x6c,
15
- CLR_ERR_INFO: "m", // 0x6d,
16
- SLEEP: "n", // 0x6e,
17
- GET_BATT_VLTG: "o", // 0x6f,
18
- };
19
- /**
20
- * The Progressor returns a Uint8Array.
21
- * The first item [0] is the type of response it returns
22
- */
23
- export var ProgressorResponses;
24
- (function (ProgressorResponses) {
25
- ProgressorResponses[ProgressorResponses["COMMAND_RESPONSE"] = 0] = "COMMAND_RESPONSE";
26
- ProgressorResponses[ProgressorResponses["WEIGHT_MEASURE"] = 1] = "WEIGHT_MEASURE";
27
- ProgressorResponses[ProgressorResponses["PEAK_RFD_MEAS"] = 2] = "PEAK_RFD_MEAS";
28
- ProgressorResponses[ProgressorResponses["PEAK_RFD_MEAS_SERIES"] = 3] = "PEAK_RFD_MEAS_SERIES";
29
- ProgressorResponses[ProgressorResponses["LOW_BATTERY_WARNING"] = 4] = "LOW_BATTERY_WARNING";
30
- })(ProgressorResponses || (ProgressorResponses = {}));
@@ -1,6 +0,0 @@
1
- import type { Commands } from "../types/commands";
2
- /**
3
- * Warning:
4
- * Using other commands can seriously harm your device
5
- */
6
- export declare const WHC06Commands: Commands;
@@ -1,5 +0,0 @@
1
- /**
2
- * Warning:
3
- * Using other commands can seriously harm your device
4
- */
5
- export const WHC06Commands = {};
@@ -1,37 +0,0 @@
1
- import type { Device } from "./models/device.model";
2
- /**
3
- * Checks if the given device is an Entralpi device.
4
- * @param {Device} [board] - The device to check.
5
- * @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
6
- */
7
- export declare const isEntralpi: (board?: Device) => boolean;
8
- /**
9
- * Checks if the given device is a Force Board.
10
- * @param {Device} [board] - The device to check.
11
- * @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
12
- */
13
- export declare const isForceBoard: (board?: Device) => boolean;
14
- /**
15
- * Checks if the given device is a Kilterboard.
16
- * @param {Device} [board] - The device to check.
17
- * @returns {boolean} `true` if the device has a service UUID matching the Kilterboard Aurora UUID, otherwise `false`.
18
- */
19
- export declare const isKilterboard: (board?: Device) => boolean;
20
- /**
21
- * Checks if the given device is a Motherboard.
22
- * @param {Device} [board] - The device to check.
23
- * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
24
- */
25
- export declare const isMotherboard: (board?: Device) => boolean;
26
- /**
27
- * Checks if the given device is a Progressor.
28
- * @param {Device} [board] - The device to check.
29
- * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
30
- */
31
- export declare const isProgressor: (board?: Device) => boolean;
32
- /**
33
- * Checks if the given device is a WH-C06.
34
- * @param {Device} [board] - The device to check.
35
- * @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
36
- */
37
- export declare const isWHC06: (board?: Device) => boolean;
package/dist/is-device.js DELETED
@@ -1,39 +0,0 @@
1
- import { AuroraUUID } from "./models/device/kilterboard.model";
2
- /**
3
- * Checks if the given device is an Entralpi device.
4
- * @param {Device} [board] - The device to check.
5
- * @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
6
- */
7
- export const isEntralpi = (board) => board?.filters.some((filter) => filter.name === "ENTRALPI") ?? false;
8
- /**
9
- * Checks if the given device is a Force Board.
10
- * @param {Device} [board] - The device to check.
11
- * @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
12
- */
13
- export const isForceBoard = (board) => board?.filters.some((filter) => filter.name === "Force Board") ?? false;
14
- /**
15
- * Checks if the given device is a Kilterboard.
16
- * @param {Device} [board] - The device to check.
17
- * @returns {boolean} `true` if the device has a service UUID matching the Kilterboard Aurora UUID, otherwise `false`.
18
- */
19
- export const isKilterboard = (board) => {
20
- return board?.filters.some((filter) => filter.services?.includes(AuroraUUID)) ?? false;
21
- };
22
- /**
23
- * Checks if the given device is a Motherboard.
24
- * @param {Device} [board] - The device to check.
25
- * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
26
- */
27
- export const isMotherboard = (board) => board?.filters.some((filter) => filter.name === "Motherboard") ?? false;
28
- /**
29
- * Checks if the given device is a Progressor.
30
- * @param {Device} [board] - The device to check.
31
- * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
32
- */
33
- export const isProgressor = (board) => board?.filters.some((filter) => filter.namePrefix === "Progressor") ?? false;
34
- /**
35
- * Checks if the given device is a WH-C06.
36
- * @param {Device} [board] - The device to check.
37
- * @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
38
- */
39
- export const isWHC06 = (board) => board?.filters.some((filter) => filter.manufacturerData?.some((data) => data.companyIdentifier === 0x0100)) ?? false;
package/dist/read.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { Device } from "./models/device.model";
2
- /**
3
- * Reads the value of the specified characteristic from the device.
4
- * @param {Device} board - The device to read from.
5
- * @param {string} serviceId - The service ID where the characteristic belongs.
6
- * @param {string} characteristicId - The characteristic ID to read from.
7
- * @param {number} [duration=0] - The duration to wait before resolving the promise, in milliseconds.
8
- * @returns {Promise<string>} A promise that resolves when the read operation is completed.
9
- */
10
- export declare const read: (board: Device, serviceId: string, characteristicId: string, duration?: number) => Promise<string>;