@hangtime/grip-connect 0.3.10 → 0.4.1

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 (58) hide show
  1. package/README.md +32 -23
  2. package/dist/battery.d.ts +8 -3
  3. package/dist/battery.js +19 -7
  4. package/dist/calibration.js +5 -3
  5. package/dist/commands/kilterboard.js +1 -1
  6. package/dist/connect.js +4 -3
  7. package/dist/data/motherboard.d.ts +6 -2
  8. package/dist/data/motherboard.js +8 -3
  9. package/dist/data/progressor.d.ts +6 -2
  10. package/dist/data/progressor.js +10 -7
  11. package/dist/devices/kilterboard.d.ts +4 -0
  12. package/dist/devices/kilterboard.js +5 -1
  13. package/dist/firmware.d.ts +12 -0
  14. package/dist/firmware.js +37 -0
  15. package/dist/hardware.d.ts +11 -0
  16. package/dist/hardware.js +25 -0
  17. package/dist/index.d.ts +7 -2
  18. package/dist/index.js +10 -4
  19. package/dist/is-device.d.ts +31 -0
  20. package/dist/is-device.js +33 -0
  21. package/dist/led.d.ts +7 -3
  22. package/dist/led.js +32 -31
  23. package/dist/manufacturer.d.ts +11 -0
  24. package/dist/manufacturer.js +25 -0
  25. package/dist/read.d.ts +2 -2
  26. package/dist/read.js +3 -5
  27. package/dist/serial.d.ts +11 -0
  28. package/dist/serial.js +30 -0
  29. package/dist/stop.js +5 -5
  30. package/dist/stream.js +8 -8
  31. package/dist/text.d.ts +14 -0
  32. package/dist/text.js +33 -0
  33. package/dist/write.d.ts +26 -8
  34. package/dist/write.js +50 -47
  35. package/package.json +1 -1
  36. package/src/battery.ts +20 -8
  37. package/src/calibration.ts +5 -3
  38. package/src/commands/kilterboard.ts +1 -1
  39. package/src/connect.ts +4 -3
  40. package/src/data/motherboard.ts +8 -3
  41. package/src/data/progressor.ts +10 -7
  42. package/src/devices/kilterboard.ts +6 -1
  43. package/src/firmware.ts +39 -0
  44. package/src/hardware.ts +27 -0
  45. package/src/index.ts +10 -4
  46. package/src/is-device.ts +43 -0
  47. package/src/led.ts +35 -31
  48. package/src/manufacturer.ts +27 -0
  49. package/src/read.ts +5 -7
  50. package/src/serial.ts +32 -0
  51. package/src/stop.ts +5 -5
  52. package/src/stream.ts +8 -8
  53. package/src/text.ts +35 -0
  54. package/src/types/download.ts +1 -1
  55. package/src/write.ts +57 -45
  56. package/dist/info.d.ts +0 -7
  57. package/dist/info.js +0 -30
  58. package/src/info.ts +0 -32
package/README.md CHANGED
@@ -46,7 +46,7 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
46
46
  ```
47
47
 
48
48
  ```js
49
- import { Motherboard, active, battery, connect, disconnect, info, notify, stream } from "@hangtime/grip-connect"
49
+ import { Motherboard, active, battery, connect, disconnect, firmware, notify, stream } from "@hangtime/grip-connect"
50
50
 
51
51
  const motherboardButton = document.querySelector("#motherboard")
52
52
 
@@ -65,12 +65,16 @@ motherboardButton.addEventListener("click", () => {
65
65
  console.log(value)
66
66
  })
67
67
 
68
- // Read battery + device info
69
- await battery(Motherboard)
70
- await info(Motherboard)
68
+ // Read info: battery + firmware
69
+ const batteryLevel = await battery(Motherboard)
70
+ console.log(batteryLevel)
71
71
 
72
- // trigger LEDs
73
- // await led(device)
72
+ const firmwareVersion = await firmware(Motherboard)
73
+ console.log(firmwareVersion)
74
+
75
+ // LEDs: "green", "red", "orange", or no argument to turn off
76
+ // await led(Motherboard, "red")
77
+ // await led(Motherboard)
74
78
 
75
79
  // Start weight streaming (for a minute) remove parameter for a continues stream
76
80
  await stream(Motherboard, 60000)
@@ -113,23 +117,28 @@ motherboardButton.addEventListener("click", () => {
113
117
  `chrome://bluetooth-internals/#devices` and press `Start Scan` to look for your device, click on `Inspect` and share all
114
118
  available services with us.
115
119
 
116
- | | Motherboard | Progressor | WH-C06 | Entralpi | Kilter Board | Climbro | mySmartBoard |
117
- | --------------------------------------------------------------------------------------- | ----------- | ---------- | ------ | -------- | ------------ | ------- | ------------ |
118
- | [Battery](https://stevie-ray.github.io/hangtime-grip-connect/api/battery.html) | ✅ | ✅ | | | | | |
119
- | [Calibration](https://stevie-ray.github.io/hangtime-grip-connect/api/calibration.html) | ✅ | | | | | | |
120
- | [Connect](https://stevie-ray.github.io/hangtime-grip-connect/api/connect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
121
- | [Disconnect](https://stevie-ray.github.io/hangtime-grip-connect/api/disconnect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
122
- | [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | |
123
- | [Info](https://stevie-ray.github.io/hangtime-grip-connect/api/info.html) | ✅ | ✅ | | | | | |
124
- | [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | ✅ |||| | | |
125
- | [isConnected](https://stevie-ray.github.io/hangtime-grip-connect/api/is-connected.html) | ✅ | ✅ | ✅ | ✅ || | |
126
- | [Led](https://stevie-ray.github.io/hangtime-grip-connect/api/led.html) | ✅ | | | | ✅ | | |
127
- | [Notify](https://stevie-ray.github.io/hangtime-grip-connect/api/notify.html) | ✅ | ✅ | ✅ | ✅ | | | |
128
- | [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) | ✅ | | | | | | |
129
- | [Stop](https://stevie-ray.github.io/hangtime-grip-connect/api/stop.html) | ✅ || | | | | |
130
- | [Stream](https://stevie-ray.github.io/hangtime-grip-connect/api/stream.html) | ✅ | ✅ | | | | | |
131
- | [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) | ✅ |||| | | |
132
- | [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ || | | | | |
120
+ | | Motherboard | Progressor | WH-C06 | Entralpi | Kilter Board | Climbro | mySmartBoard |
121
+ | ---------------------------------------------------------------------------------------- | ----------- | ---------- | ------ | -------- | ------------ | ------- | ------------ |
122
+ | [Battery](https://stevie-ray.github.io/hangtime-grip-connect/api/battery.html) | ✅ | ✅ | | | | | |
123
+ | [Calibration](https://stevie-ray.github.io/hangtime-grip-connect/api/calibration.html) | ✅ | | | | | | |
124
+ | [Connect](https://stevie-ray.github.io/hangtime-grip-connect/api/connect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
125
+ | [Disconnect](https://stevie-ray.github.io/hangtime-grip-connect/api/disconnect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
126
+ | [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | |
127
+ | [Firmware](https://stevie-ray.github.io/hangtime-grip-connect/api/firmware.html) | ✅ | ✅ | | | | | |
128
+ | [Hardware](https://stevie-ray.github.io/hangtime-grip-connect/api/hardware.html) | ✅ | | | | | | |
129
+ | [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | ✅ | ✅ | ✅ | ✅ | | | |
130
+ | [isConnected](https://stevie-ray.github.io/hangtime-grip-connect/api/is-connected.html) | ✅ |||| ✅ | | |
131
+ | [isDevice](https://stevie-ray.github.io/hangtime-grip-connect/api/is-device.html) | ✅ | ✅ | ✅ | ✅ || | |
132
+ | [Led](https://stevie-ray.github.io/hangtime-grip-connect/api/led.html) | ✅ | | | || | |
133
+ | [Manufacturer](https://stevie-ray.github.io/hangtime-grip-connect/api/manufacturer.html) | ✅ | | | | | | |
134
+ | [Notify](https://stevie-ray.github.io/hangtime-grip-connect/api/notify.html) | ✅ | ✅ ||| | | |
135
+ | [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) | ✅ | | | | | | |
136
+ | [Serial](https://stevie-ray.github.io/hangtime-grip-connect/api/serial.html) | ✅ | | | | | | |
137
+ | [Stop](https://stevie-ray.github.io/hangtime-grip-connect/api/stop.html) | ✅ | ✅ | | | | | |
138
+ | [Stream](https://stevie-ray.github.io/hangtime-grip-connect/api/stream.html) | ✅ | ✅ | | | | | |
139
+ | [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) | ✅ | ✅ | ✅ | ✅ | | | |
140
+ | [Text](https://stevie-ray.github.io/hangtime-grip-connect/api/text.html) | ✅ | | | | | | |
141
+ | [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ | ✅ | | | | | |
133
142
 
134
143
  ## Development
135
144
 
package/dist/battery.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import type { Device } from "./types/devices";
2
2
  /**
3
3
  * Retrieves battery or voltage information from the device.
4
- * @param {Device} board - The device.
5
- * @returns {Promise<void>} A Promise that resolves when the information is successfully retrieved.
4
+ * - For Motherboard devices, it reads the battery level.
5
+ * - For Progressor devices, it sends a command to retrieve battery voltage information.
6
+ *
7
+ * @param {Device} board - The device from which to retrieve battery information.
8
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
9
+ * or rejects with an error if the device is not connected.
10
+ * @throws {Error} Throws an error if the device is not connected.
6
11
  */
7
- export declare const battery: (board: Device) => Promise<void>;
12
+ export declare const battery: (board: Device) => Promise<string | undefined>;
package/dist/battery.js CHANGED
@@ -1,25 +1,37 @@
1
1
  import { write } from "./write";
2
2
  import { read } from "./read";
3
3
  import { isConnected } from "./is-connected";
4
- import { Motherboard, Progressor } from "./devices";
4
+ import { isMotherboard, isProgressor } from "./is-device";
5
5
  import { ProgressorCommands } from "./commands";
6
6
  /**
7
7
  * Retrieves battery or voltage information from the device.
8
- * @param {Device} board - The device.
9
- * @returns {Promise<void>} A Promise that resolves when the information is successfully retrieved.
8
+ * - For Motherboard devices, it reads the battery level.
9
+ * - For Progressor devices, it sends a command to retrieve battery voltage information.
10
+ *
11
+ * @param {Device} board - The device from which to retrieve battery information.
12
+ * @returns {Promise<string | undefined>} A Promise that resolves with the battery or voltage information,
13
+ * or rejects with an error if the device is not connected.
14
+ * @throws {Error} Throws an error if the device is not connected.
10
15
  */
11
16
  export const battery = async (board) => {
12
17
  // Check if the device is connected
13
18
  if (isConnected(board)) {
14
19
  // If the device is connected and it is a Motherboard device
15
- if (board.filters.some((filter) => filter.name === "Motherboard")) {
20
+ if (isMotherboard(board)) {
16
21
  // Read battery level information from the Motherboard
17
- await read(Motherboard, "battery", "level", 250);
22
+ return await read(board, "battery", "level", 250);
18
23
  }
19
24
  // If the device is connected and its name starts with "Progressor"
20
- if (board.filters.some((filter) => filter.namePrefix === "Progressor")) {
25
+ if (isProgressor(board)) {
21
26
  // Write command to get battery voltage information to the Progressor
22
- await write(Progressor, "progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250);
27
+ let response = undefined;
28
+ await write(board, "progressor", "tx", ProgressorCommands.GET_BATT_VLTG, 250, (data) => {
29
+ response = data;
30
+ });
31
+ return response;
23
32
  }
33
+ // If device is not found, return undefined
34
+ return;
24
35
  }
36
+ throw new Error("Not connected.");
25
37
  };
@@ -1,6 +1,6 @@
1
1
  import { isConnected } from "./is-connected";
2
2
  import { write } from "./write";
3
- import { Motherboard } from "./devices";
3
+ import { isMotherboard } from "./is-device";
4
4
  import { MotherboardCommands } from "./commands";
5
5
  /**
6
6
  * Writes a command to get calibration data from the device.
@@ -11,9 +11,11 @@ export const calibration = async (board) => {
11
11
  // Check if the device is connected
12
12
  if (isConnected(board)) {
13
13
  // If the device is connected, and it is a Motherboard device
14
- if (board.filters.some((filter) => filter.name === "Motherboard")) {
14
+ if (isMotherboard(board)) {
15
15
  // Write the command to get calibration data to the device
16
- await write(Motherboard, "uart", "tx", MotherboardCommands.GET_CALIBRATION, 2500);
16
+ await write(board, "uart", "tx", MotherboardCommands.GET_CALIBRATION, 2500, (data) => {
17
+ console.log(data);
18
+ });
17
19
  }
18
20
  }
19
21
  };
@@ -59,7 +59,7 @@ export const KilterBoardPlacementRoles = [
59
59
  position: 4,
60
60
  name: "foot",
61
61
  full_name: "Foot Only",
62
- led_color: "FFA500",
62
+ led_color: "FFB600",
63
63
  screen_color: "FFA500",
64
64
  },
65
65
  ];
package/dist/connect.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { handleEntralpiData, handleMotherboardData, handleProgressorData, handleWHC06Data } from "./data";
2
+ import { isEntralpi, isMotherboard, isProgressor } from "./is-device";
2
3
  let server;
3
4
  const receiveBuffer = [];
4
5
  /**
@@ -21,7 +22,7 @@ const handleNotifications = (event, board) => {
21
22
  const value = characteristic.value;
22
23
  if (value) {
23
24
  // If the device is connected and it is a Motherboard device
24
- if (board.filters.some((filter) => filter.name === "Motherboard")) {
25
+ if (isMotherboard(board)) {
25
26
  for (let i = 0; i < value.byteLength; i++) {
26
27
  receiveBuffer.push(value.getUint8(i));
27
28
  }
@@ -35,7 +36,7 @@ const handleNotifications = (event, board) => {
35
36
  handleMotherboardData(receivedData);
36
37
  }
37
38
  }
38
- else if (board.filters.some((filter) => filter.name === "ENTRALPI")) {
39
+ else if (isEntralpi(board)) {
39
40
  if (value.buffer) {
40
41
  const buffer = value.buffer;
41
42
  const rawData = new DataView(buffer);
@@ -43,7 +44,7 @@ const handleNotifications = (event, board) => {
43
44
  handleEntralpiData(receivedData);
44
45
  }
45
46
  }
46
- else if (board.filters.some((filter) => filter.namePrefix === "Progressor")) {
47
+ else if (isProgressor(board)) {
47
48
  if (value.buffer) {
48
49
  const buffer = value.buffer;
49
50
  const rawData = new DataView(buffer);
@@ -1,6 +1,10 @@
1
1
  export declare const CALIBRATION: never[][];
2
2
  /**
3
- * Handles data received from the Motherboard device.
4
- * @param {string} receivedData - The received data string.
3
+ * Handles data received from the Motherboard device. Processes hex-encoded streaming packets
4
+ * to extract samples, calibrate masses, and update running averages of mass data.
5
+ * If the received data is not a valid hex packet, it returns the unprocessed data.
6
+ *
7
+ * @param {string} receivedData - The raw data received from the Motherboard device.
8
+ * @returns {void}
5
9
  */
6
10
  export declare const handleMotherboardData: (receivedData: string) => void;
@@ -1,4 +1,5 @@
1
1
  import { notifyCallback } from "./../notify";
2
+ import { writeCallback } from "./../write";
2
3
  import { applyTare } from "./../tare";
3
4
  import { MotherboardCommands } from "./../commands";
4
5
  import { checkActivity } from "./../is-active";
@@ -51,8 +52,12 @@ const applyCalibration = (sample, calibration) => {
51
52
  return sign * final;
52
53
  };
53
54
  /**
54
- * Handles data received from the Motherboard device.
55
- * @param {string} receivedData - The received data string.
55
+ * Handles data received from the Motherboard device. Processes hex-encoded streaming packets
56
+ * to extract samples, calibrate masses, and update running averages of mass data.
57
+ * If the received data is not a valid hex packet, it returns the unprocessed data.
58
+ *
59
+ * @param {string} receivedData - The raw data received from the Motherboard device.
60
+ * @returns {void}
56
61
  */
57
62
  export const handleMotherboardData = (receivedData) => {
58
63
  const receivedTime = Date.now();
@@ -131,6 +136,6 @@ export const handleMotherboardData = (receivedData) => {
131
136
  }
132
137
  else {
133
138
  // unhandled data
134
- console.log(receivedData);
139
+ writeCallback(receivedData);
135
140
  }
136
141
  };
@@ -1,5 +1,9 @@
1
1
  /**
2
- * Handles data received from the Progressor device.
3
- * @param {DataView} data - The received data.
2
+ * Handles data received from the Progressor device, processes weight measurements,
3
+ * and updates mass data including maximum and average values.
4
+ * It also handles command responses for retrieving device information.
5
+ *
6
+ * @param {DataView} data - The raw binary data received from the Progressor device.
7
+ * @returns {void}
4
8
  */
5
9
  export declare const handleProgressorData: (data: DataView) => void;
@@ -2,7 +2,7 @@ import { notifyCallback } from "./../notify";
2
2
  import { applyTare } from "./../tare";
3
3
  import { checkActivity } from "./../is-active";
4
4
  import { ProgressorCommands, ProgressorResponses } from "./../commands/progressor";
5
- import { lastWrite } from "./../write";
5
+ import { lastWrite, writeCallback } from "./../write";
6
6
  import struct from "./../struct";
7
7
  import { DownloadPackets } from "./../download";
8
8
  // Constants
@@ -11,8 +11,12 @@ let MASS_AVERAGE = "0";
11
11
  let MASS_TOTAL_SUM = 0;
12
12
  let DATAPOINT_COUNT = 0;
13
13
  /**
14
- * Handles data received from the Progressor device.
15
- * @param {DataView} data - The received data.
14
+ * Handles data received from the Progressor 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 {DataView} data - The raw binary data received from the Progressor device.
19
+ * @returns {void}
16
20
  */
17
21
  export const handleProgressorData = (data) => {
18
22
  const receivedTime = Date.now();
@@ -55,8 +59,7 @@ export const handleProgressorData = (data) => {
55
59
  return;
56
60
  let value = "";
57
61
  if (lastWrite === ProgressorCommands.GET_BATT_VLTG) {
58
- const vdd = new DataView(data.buffer, 2).getUint32(0, true);
59
- value = `ℹ️ Battery level: ${vdd} mV`;
62
+ value = new DataView(data.buffer, 2).getUint32(0, true).toString();
60
63
  }
61
64
  else if (lastWrite === ProgressorCommands.GET_FW_VERSION) {
62
65
  value = new TextDecoder().decode(data.buffer.slice(2));
@@ -64,12 +67,12 @@ export const handleProgressorData = (data) => {
64
67
  else if (lastWrite === ProgressorCommands.GET_ERR_INFO) {
65
68
  value = new TextDecoder().decode(data.buffer.slice(2));
66
69
  }
67
- console.log(value);
70
+ writeCallback(value);
68
71
  }
69
72
  else if (kind === ProgressorResponses.LOW_BATTERY_WARNING) {
70
73
  console.warn("⚠️ Low power detected. Please consider connecting to a power source.");
71
74
  }
72
75
  else {
73
- console.error(`❌ Error: Unknown message kind detected: ${kind}`);
76
+ throw new Error(`Unknown message kind detected: ${kind}`);
74
77
  }
75
78
  };
@@ -1,4 +1,8 @@
1
1
  import type { Device } from "../types/devices";
2
+ /**
3
+ * Aurora Climbing Advertising service
4
+ */
5
+ export declare const AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
2
6
  /**
3
7
  * Represents a Aurora Climbing device
4
8
  * Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Aurora Climbing Advertising service
3
+ */
4
+ export const AuroraUUID = "4488b571-7806-4df6-bcff-a2897e4953ff";
1
5
  /**
2
6
  * Represents a Aurora Climbing device
3
7
  * Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
@@ -5,7 +9,7 @@
5
9
  export const KilterBoard = {
6
10
  filters: [
7
11
  {
8
- services: ["4488b571-7806-4df6-bcff-a2897e4953ff"], // Aurora Climbing Advertising service
12
+ services: [AuroraUUID],
9
13
  },
10
14
  ],
11
15
  services: [
@@ -0,0 +1,12 @@
1
+ import type { Device } from "./types/devices";
2
+ /**
3
+ * Retrieves firmware version from the device.
4
+ * - For Motherboard devices, it reads the firmare version.
5
+ * - For Progressor devices, it sends a command to retrieve firware version.
6
+ *
7
+ * @param {Device} board - The device from which to retrieve firmware version.
8
+ * @returns {Promise<string>} A Promise that resolves with the firmware version,
9
+ * or rejects with an error if the device is not connected.
10
+ * @throws {Error} Throws an error if the device is not connected.
11
+ */
12
+ export declare const firmware: (board: Device) => Promise<string | undefined>;
@@ -0,0 +1,37 @@
1
+ import { write } from "./write";
2
+ import { read } from "./read";
3
+ import { isConnected } from "./is-connected";
4
+ import { ProgressorCommands } from "./commands";
5
+ import { isMotherboard, isProgressor } from "./is-device";
6
+ /**
7
+ * Retrieves firmware version from the device.
8
+ * - For Motherboard devices, it reads the firmare version.
9
+ * - For Progressor devices, it sends a command to retrieve firware version.
10
+ *
11
+ * @param {Device} board - The device from which to retrieve firmware version.
12
+ * @returns {Promise<string>} A Promise that resolves with the firmware version,
13
+ * or rejects with an error if the device is not connected.
14
+ * @throws {Error} Throws an error if the device is not connected.
15
+ */
16
+ export const firmware = async (board) => {
17
+ // Check if the device is connected
18
+ if (isConnected(board)) {
19
+ // If the device is connected and it is a Motherboard device
20
+ if (isMotherboard(board)) {
21
+ // Read firmware version from the Motherboard
22
+ return await read(board, "device", "firmware", 250);
23
+ }
24
+ // If the device is connected and its name starts with "Progressor"
25
+ if (isProgressor(board)) {
26
+ // Write command to get firmware version information to the Progressor
27
+ let response = undefined;
28
+ await write(board, "progressor", "tx", ProgressorCommands.GET_FW_VERSION, 250, (data) => {
29
+ response = data;
30
+ });
31
+ return response;
32
+ }
33
+ // If device is not found, return undefined
34
+ return;
35
+ }
36
+ throw new Error("Not connected.");
37
+ };
@@ -0,0 +1,11 @@
1
+ import type { Device } from "./types/devices";
2
+ /**
3
+ * Retrieves hardware version from the device.
4
+ * - For Motherboard devices, it reads the hardware version.
5
+ *
6
+ * @param {Device} board - The device from which to retrieve hardware version.
7
+ * @returns {Promise<string>} A Promise that resolves with the hardware version,
8
+ * or rejects with an error if the device is not connected.
9
+ * @throws {Error} Throws an error if the device is not connected.
10
+ */
11
+ export declare const hardware: (board: Device) => Promise<string | undefined>;
@@ -0,0 +1,25 @@
1
+ import { read } from "./read";
2
+ import { isConnected } from "./is-connected";
3
+ import { isMotherboard } from "./is-device";
4
+ /**
5
+ * Retrieves hardware version from the device.
6
+ * - For Motherboard devices, it reads the hardware version.
7
+ *
8
+ * @param {Device} board - The device from which to retrieve hardware version.
9
+ * @returns {Promise<string>} A Promise that resolves with the hardware version,
10
+ * or rejects with an error if the device is not connected.
11
+ * @throws {Error} Throws an error if the device is not connected.
12
+ */
13
+ export const hardware = async (board) => {
14
+ // Check if the device is connected
15
+ if (isConnected(board)) {
16
+ // If the device is connected and it is a Motherboard device
17
+ if (isMotherboard(board)) {
18
+ // Read hardware version from the Motherboard
19
+ return await read(board, "device", "hardware", 250);
20
+ }
21
+ // If device is not found, return undefined
22
+ return;
23
+ }
24
+ throw new Error("Not connected.");
25
+ };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  export { Climbro, Entralpi, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor } from "./devices/index";
2
- export { battery } from "./battery";
2
+ export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
3
3
  export { calibration } from "./calibration";
4
4
  export { download } from "./download";
5
5
  export { connect } from "./connect";
6
6
  export { disconnect } from "./disconnect";
7
7
  export { active, isActive } from "./is-active";
8
8
  export { isConnected } from "./is-connected";
9
- export { info } from "./info";
9
+ export { battery } from "./battery";
10
+ export { firmware } from "./firmware";
11
+ export { hardware } from "./hardware";
12
+ export { manufacturer } from "./manufacturer";
13
+ export { text } from "./text";
14
+ export { serial } from "./serial";
10
15
  export { led } from "./led";
11
16
  export { notify } from "./notify";
12
17
  export { stop } from "./stop";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Export device types
2
2
  export { Climbro, Entralpi, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor } from "./devices/index";
3
- // Export battery related functions
4
- export { battery } from "./battery";
3
+ // Export isDevice functions
4
+ export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
5
5
  // Export calibration function
6
6
  export { calibration } from "./calibration";
7
7
  // Export download function
@@ -11,8 +11,14 @@ export { connect } from "./connect";
11
11
  export { disconnect } from "./disconnect";
12
12
  export { active, isActive } from "./is-active";
13
13
  export { isConnected } from "./is-connected";
14
- // Export information retrieval function
15
- export { info } from "./info";
14
+ // Export information retrieval functions
15
+ export { battery } from "./battery";
16
+ export { firmware } from "./firmware";
17
+ // Export "Motherboard exclusive" functions
18
+ export { hardware } from "./hardware";
19
+ export { manufacturer } from "./manufacturer";
20
+ export { text } from "./text";
21
+ export { serial } from "./serial";
16
22
  // Export led retrieval function
17
23
  export { led } from "./led";
18
24
  // Export notification related function
@@ -0,0 +1,31 @@
1
+ import type { Device } from "./types/devices";
2
+ /**
3
+ * Checks if the given device is a Motherboard.
4
+ * @param {Device} [board] - The device to check.
5
+ * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
6
+ */
7
+ export declare const isMotherboard: (board?: Device) => boolean;
8
+ /**
9
+ * Checks if the given device is a Progressor.
10
+ * @param {Device} [board] - The device to check.
11
+ * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
12
+ */
13
+ export declare const isProgressor: (board?: Device) => boolean;
14
+ /**
15
+ * Checks if the given device is an Entralpi device.
16
+ * @param {Device} [board] - The device to check.
17
+ * @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
18
+ */
19
+ export declare const isEntralpi: (board?: Device) => boolean;
20
+ /**
21
+ * Checks if the given device is a Kilterboard.
22
+ * @param {Device} [board] - The device to check.
23
+ * @returns {boolean} `true` if the device has a service UUID matching the Kilterboard Aurora UUID, otherwise `false`.
24
+ */
25
+ export declare const isKilterboard: (board?: Device) => boolean;
26
+ /**
27
+ * Checks if the given device is a WH-C06.
28
+ * @param {Device} [board] - The device to check.
29
+ * @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
30
+ */
31
+ export declare const isWHC06: (board?: Device) => boolean;
@@ -0,0 +1,33 @@
1
+ import { AuroraUUID } from "./devices/kilterboard";
2
+ /**
3
+ * Checks if the given device is a Motherboard.
4
+ * @param {Device} [board] - The device to check.
5
+ * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
6
+ */
7
+ export const isMotherboard = (board) => board?.filters.some((filter) => filter.name === "Motherboard") ?? false;
8
+ /**
9
+ * Checks if the given device is a Progressor.
10
+ * @param {Device} [board] - The device to check.
11
+ * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
12
+ */
13
+ export const isProgressor = (board) => board?.filters.some((filter) => filter.namePrefix === "Progressor") ?? false;
14
+ /**
15
+ * Checks if the given device is an Entralpi device.
16
+ * @param {Device} [board] - The device to check.
17
+ * @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
18
+ */
19
+ export const isEntralpi = (board) => board?.filters.some((filter) => filter.name === "ENTRALPI") ?? false;
20
+ /**
21
+ * Checks if the given device is a Kilterboard.
22
+ * @param {Device} [board] - The device to check.
23
+ * @returns {boolean} `true` if the device has a service UUID matching the Kilterboard Aurora UUID, otherwise `false`.
24
+ */
25
+ export const isKilterboard = (board) => {
26
+ return board?.filters.some((filter) => filter.services?.includes(AuroraUUID)) ?? false;
27
+ };
28
+ /**
29
+ * Checks if the given device is a WH-C06.
30
+ * @param {Device} [board] - The device to check.
31
+ * @returns {boolean} `true` if the device has a filter with the company identifier 0x0100, otherwise `false`.
32
+ */
33
+ export const isWHC06 = (board) => board?.filters.some((filter) => filter.manufacturerData?.some((data) => data.companyIdentifier === 0x0100)) ?? false;
package/dist/led.d.ts CHANGED
@@ -12,9 +12,13 @@ declare class ClimbPlacement {
12
12
  export declare function prepBytesV3(climbPlacementList: ClimbPlacement[]): number[];
13
13
  /**
14
14
  * Sets the LEDs on the specified device.
15
+ *
16
+ * - For Kilter Board: Configures the LEDs based on an array of climb placements. If a configuration is provided, it prepares and sends a payload to the device.
17
+ * - For Motherboard: Sets the LED color based on a single color option. Defaults to turning the LEDs off if no configuration is provided.
18
+ *
15
19
  * @param {Device} board - The device on which to set the LEDs.
16
- * @param {ClimbPlacement[]} [placement] - An optional array of climb placements for LED positioning.
17
- * @returns {Promise<number[] | undefined>} A promise that resolves with the payload array if LED settings were applied, or `undefined` if no action was taken.
20
+ * @param {"green" | "red" | "orange" | ClimbPlacement[]} [config] - Optional color or array of climb placements for the LEDs. Ignored if placements are provided.
21
+ * @returns {Promise<number[] | undefined>} A promise that resolves with the payload array for the Kilter Board if LED settings were applied, or `undefined` if no action was taken or for the Motherboard.
18
22
  */
19
- export declare const led: (board: Device, placement?: ClimbPlacement[]) => Promise<number[] | undefined>;
23
+ export declare const led: (board: Device, config?: "green" | "red" | "orange" | ClimbPlacement[]) => Promise<number[] | undefined>;
20
24
  export {};