@hangtime/grip-connect 0.5.11 → 0.6.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 (59) hide show
  1. package/README.md +14 -5
  2. package/deno.json +1 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +1 -1
  5. package/dist/interfaces/device/climbro.interface.d.ts +1 -1
  6. package/dist/interfaces/device/entralpi.interface.d.ts +1 -1
  7. package/dist/interfaces/device/forceboard.interface.d.ts +1 -1
  8. package/dist/interfaces/device/kilterboard.interface.d.ts +1 -1
  9. package/dist/interfaces/device/motherboard.interface.d.ts +2 -2
  10. package/dist/interfaces/device/mysmartboard.interface.d.ts +2 -2
  11. package/dist/interfaces/device/progressor.interface.d.ts +2 -2
  12. package/dist/interfaces/device/wh-c06.interface.d.ts +2 -2
  13. package/dist/interfaces/device.interface.d.ts +3 -3
  14. package/dist/interfaces/index.d.ts +8 -0
  15. package/dist/interfaces/index.js +1 -0
  16. package/dist/models/base.model.d.ts +1 -1
  17. package/dist/models/device/climbro.model.d.ts +4 -3
  18. package/dist/models/device/climbro.model.js +3 -2
  19. package/dist/models/device/entralpi.model.d.ts +6 -2
  20. package/dist/models/device/entralpi.model.js +5 -1
  21. package/dist/models/device/forceboard.model.d.ts +4 -3
  22. package/dist/models/device/forceboard.model.js +3 -2
  23. package/dist/models/device/kilterboard.model.d.ts +8 -7
  24. package/dist/models/device/kilterboard.model.js +7 -6
  25. package/dist/models/device/motherboard.model.d.ts +4 -3
  26. package/dist/models/device/motherboard.model.js +3 -2
  27. package/dist/models/device/mysmartboard.model.d.ts +4 -3
  28. package/dist/models/device/mysmartboard.model.js +3 -2
  29. package/dist/models/device/progressor.model.d.ts +4 -3
  30. package/dist/models/device/progressor.model.js +4 -3
  31. package/dist/models/device/wh-c06.model.d.ts +6 -4
  32. package/dist/models/device/wh-c06.model.js +7 -4
  33. package/dist/models/device.model.d.ts +15 -9
  34. package/dist/models/device.model.js +51 -35
  35. package/dist/models/index.d.ts +8 -8
  36. package/dist/models/index.js +8 -9
  37. package/package.json +6 -3
  38. package/src/index.ts +12 -1
  39. package/src/interfaces/device/climbro.interface.ts +1 -1
  40. package/src/interfaces/device/entralpi.interface.ts +1 -1
  41. package/src/interfaces/device/forceboard.interface.ts +1 -1
  42. package/src/interfaces/device/kilterboard.interface.ts +1 -1
  43. package/src/interfaces/device/motherboard.interface.ts +2 -2
  44. package/src/interfaces/device/mysmartboard.interface.ts +2 -2
  45. package/src/interfaces/device/progressor.interface.ts +2 -2
  46. package/src/interfaces/device/wh-c06.interface.ts +2 -2
  47. package/src/interfaces/device.interface.ts +3 -3
  48. package/src/interfaces/index.ts +15 -0
  49. package/src/models/base.model.ts +1 -1
  50. package/src/models/device/climbro.model.ts +4 -3
  51. package/src/models/device/entralpi.model.ts +6 -2
  52. package/src/models/device/forceboard.model.ts +4 -3
  53. package/src/models/device/kilterboard.model.ts +15 -14
  54. package/src/models/device/motherboard.model.ts +5 -4
  55. package/src/models/device/mysmartboard.model.ts +4 -3
  56. package/src/models/device/progressor.model.ts +5 -4
  57. package/src/models/device/wh-c06.model.ts +10 -6
  58. package/src/models/device.model.ts +57 -39
  59. package/src/models/index.ts +8 -10
package/README.md CHANGED
@@ -35,13 +35,22 @@ Learn more: [Documentation](https://stevie-ray.github.io/hangtime-grip-connect/)
35
35
 
36
36
  ## Install
37
37
 
38
- This project can be found in the [NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and
39
- [JSR](https://jsr.io/@hangtime/grip-connect) package registries.
38
+ This package is compatible with both Node.js and browser environments. It can be found in the
39
+ [NPM](https://www.npmjs.com/package/@hangtime/grip-connect) and [JSR](https://jsr.io/@hangtime/grip-connect) package
40
+ registries.
40
41
 
41
42
  ```sh [npm]
42
43
  $ npm install @hangtime/grip-connect
43
44
  ```
44
45
 
46
+ ```sh [yarn]
47
+ $ yarn add @hangtime/grip-connect
48
+ ```
49
+
50
+ ```sh [pnpm]
51
+ $ pnpm add @hangtime/grip-connect
52
+ ```
53
+
45
54
  ## Example usage (with a Motherboard)
46
55
 
47
56
  Simply importing the device you need from `@hangtime/grip-connect`.
@@ -93,10 +102,10 @@ document.querySelector("#motherboard").addEventListener("click", async () => {
93
102
  // await motherboard.stop()
94
103
 
95
104
  // Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
96
- // motherboard.download('json')
105
+ // await motherboard.download('json')
97
106
 
98
107
  // Optionally disconnect from device after we are done
99
- motherboard.disconnect(Motherboard)
108
+ motherboard.disconnect()
100
109
  },
101
110
  (error) => {
102
111
  // Optinal custom error handeling
@@ -115,7 +124,7 @@ document.querySelector("#motherboard").addEventListener("click", async () => {
115
124
  enable it at `chrome://flags/#enable-experimental-web-platform-features`.
116
125
  - ✅ [Kilter Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/kilterboard.html)
117
126
  - ✅ [Entralpi](https://stevie-ray.github.io/hangtime-grip-connect/devices/entralpi.html) / Lefu / Unique CW275 Scale
118
- - ✅ [PitchSix Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html)
127
+ - ✅ [PitchSix - Force Board](https://stevie-ray.github.io/hangtime-grip-connect/devices/forceboard.html)
119
128
  - ➡️ [Climbro](https://stevie-ray.github.io/hangtime-grip-connect/devices/climbro.html)
120
129
  - ➡️ [Smartboard Climbing - mySmartBoard](https://stevie-ray.github.io/hangtime-grip-connect/devices/mysmartboard.html)
121
130
 
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hangtime/grip-connect",
3
- "version": "0.5.11",
3
+ "version": "0.6.1",
4
4
  "license": "BSD-2-Clause",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index";
1
+ export type { IClimbro, IEntralpi, IForceBoard, IKilterBoard, IMotherboard, ImySmartBoard, IProgressor, IWHC06, } from "./interfaces/index.js";
2
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index";
1
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, Progressor, WHC06, } from "./models/index.js";
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
3
  * Interface representing the Climbro device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
3
  * Interface representing the Entralpi device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
3
  * Interface representing the PitchSix ForceBoard device, extending the base Device interface.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
3
  * Interface representing the KilterBoard device, extending the base Device interface.
4
4
  */
@@ -1,6 +1,6 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
- * Interface representing the Griptonite Motherboard device.
3
+ * Interface representing the Griptonite Motherboard device, extending the base Device interface.
4
4
  */
5
5
  export interface IMotherboard extends IDevice {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
- * Interface representing the mySmartBoard device, extending the base Device interface.
3
+ * Interface representing the Smartboard Climbing mySmartBoard device, extending the base Device interface.
4
4
  */
5
5
  export interface ImySmartBoard extends IDevice {
6
6
  }
@@ -1,6 +1,6 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
- * Interface representing the Tindeq Progressor device.
3
+ * Interface representing the Tindeq Progressor device, extending the base Device interface.
4
4
  */
5
5
  export interface IProgressor extends IDevice {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import type { IDevice } from "../device.interface";
1
+ import type { IDevice } from "../device.interface.js";
2
2
  /**
3
- * Interface representing the Weiheng WH-C06 device.
3
+ * Interface representing the Weiheng WH-C06 device, extending the base Device interface.
4
4
  */
5
5
  export interface IWHC06 extends IDevice {
6
6
  }
@@ -1,6 +1,6 @@
1
- import type { IBase } from "./base.interface";
2
- import type { massObject } from "./callback.interface";
3
- import type { Commands } from "./command.interface";
1
+ import type { IBase } from "./base.interface.js";
2
+ import type { massObject } from "./callback.interface.js";
3
+ import type { Commands } from "./command.interface.js";
4
4
  /**
5
5
  * Represents a characteristic of a Bluetooth service.
6
6
  */
@@ -0,0 +1,8 @@
1
+ export type { IClimbro } from "./device/climbro.interface.js";
2
+ export type { IEntralpi } from "./device/entralpi.interface.js";
3
+ export type { IForceBoard } from "./device/forceboard.interface.js";
4
+ export type { IKilterBoard } from "./device/kilterboard.interface.js";
5
+ export type { IMotherboard } from "./device/motherboard.interface.js";
6
+ export type { ImySmartBoard } from "./device/mysmartboard.interface.js";
7
+ export type { IProgressor } from "./device/progressor.interface.js";
8
+ export type { IWHC06 } from "./device/wh-c06.interface.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { IBase } from "../interfaces/base.interface";
1
+ import type { IBase } from "../interfaces/base.interface.js";
2
2
  export declare abstract class BaseModel {
3
3
  id?: string;
4
4
  createdAt?: Date;
@@ -1,8 +1,9 @@
1
- import { Device } from "../device.model";
2
- import type { IClimbro } from "../../interfaces/device/climbro.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IClimbro } from "../../interfaces/device/climbro.interface.js";
3
3
  /**
4
- * Represents a Climbro device
4
+ * Represents a Climbro device.
5
5
  * TODO: Add services, do you own a Climbro? Help us!
6
+ * {@link https://climbro.com/}
6
7
  */
7
8
  export declare class Climbro extends Device implements IClimbro {
8
9
  constructor();
@@ -1,7 +1,8 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents a Climbro device
3
+ * Represents a Climbro device.
4
4
  * TODO: Add services, do you own a Climbro? Help us!
5
+ * {@link https://climbro.com/}
5
6
  */
6
7
  export class Climbro extends Device {
7
8
  constructor() {
@@ -1,5 +1,9 @@
1
- import { Device } from "../device.model";
2
- import type { IEntralpi } from "../../interfaces/device/entralpi.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IEntralpi } from "../../interfaces/device/entralpi.interface.js";
3
+ /**
4
+ * Represents a Entralpi device.
5
+ * {@link https://entralpi.com}
6
+ */
3
7
  export declare class Entralpi extends Device implements IEntralpi {
4
8
  constructor();
5
9
  /**
@@ -1,4 +1,8 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
+ /**
3
+ * Represents a Entralpi device.
4
+ * {@link https://entralpi.com}
5
+ */
2
6
  export class Entralpi extends Device {
3
7
  constructor() {
4
8
  super({
@@ -1,7 +1,8 @@
1
- import { Device } from "../device.model";
2
- import type { IForceBoard } from "../../interfaces/device/forceboard.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IForceBoard } from "../../interfaces/device/forceboard.interface.js";
3
3
  /**
4
- * Represents a PitchSix Force Board device
4
+ * Represents a PitchSix Force Board device.
5
+ * {@link https://pitchsix.com}
5
6
  */
6
7
  export declare class ForceBoard extends Device implements IForceBoard {
7
8
  constructor();
@@ -1,6 +1,7 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents a PitchSix Force Board device
3
+ * Represents a PitchSix Force Board device.
4
+ * {@link https://pitchsix.com}
4
5
  */
5
6
  export class ForceBoard extends Device {
6
7
  constructor() {
@@ -1,5 +1,5 @@
1
- import { Device } from "../device.model";
2
- import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IKilterBoard } from "../../interfaces/device/kilterboard.interface.js";
3
3
  /**
4
4
  * For API level 2 and API level 3.
5
5
  * The first byte in the data is dependent on where the packet is in the message as a whole.
@@ -36,8 +36,9 @@ export declare const KilterBoardPlacementRoles: {
36
36
  screen_color: string;
37
37
  }[];
38
38
  /**
39
- * Represents a Aurora Climbing device
39
+ * Represents a Aurora Climbing device.
40
40
  * Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
41
+ * {@link https://auroraclimbing.com}
41
42
  */
42
43
  export declare class KilterBoard extends Device implements IKilterBoard {
43
44
  /**
@@ -73,13 +74,13 @@ export declare class KilterBoard extends Device implements IKilterBoard {
73
74
  /**
74
75
  * Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
75
76
  * @param data - The array of bytes to calculate the checksum for.
76
- * @returns The calculated checksum value.
77
+ * @returns {number} The calculated checksum value.
77
78
  */
78
79
  private checksum;
79
80
  /**
80
81
  * Wraps a byte array with header and footer bytes for transmission.
81
82
  * @param data - The array of bytes to wrap.
82
- * @returns The wrapped byte array.
83
+ * @returns {number[]} The wrapped byte array.
83
84
  */
84
85
  private wrapBytes;
85
86
  /**
@@ -87,7 +88,7 @@ export declare class KilterBoard extends Device implements IKilterBoard {
87
88
  * The lowest 8 bits of the position get put in the first byte of the group.
88
89
  * The highest 8 bits of the position get put in the second byte of the group.
89
90
  * @param position - The position to encode.
90
- * @returns The encoded byte array representing the position.
91
+ * @returns {number[]} The encoded byte array representing the position.
91
92
  */
92
93
  private encodePosition;
93
94
  /**
@@ -115,7 +116,7 @@ export declare class KilterBoard extends Device implements IKilterBoard {
115
116
  * https://github.com/ramda/ramda/blob/master/source/splitEvery.js
116
117
  * @param {Number} n
117
118
  * @param {Array} list
118
- * @return {Array}
119
+ * @return {Array<number[]>}
119
120
  */
120
121
  private splitEvery;
121
122
  /**
@@ -1,4 +1,4 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
3
  * For API level 2 and API level 3.
4
4
  * The first byte in the data is dependent on where the packet is in the message as a whole.
@@ -65,8 +65,9 @@ export const KilterBoardPlacementRoles = [
65
65
  },
66
66
  ];
67
67
  /**
68
- * Represents a Aurora Climbing device
68
+ * Represents a Aurora Climbing device.
69
69
  * Kilter Board, Tension Board, Decoy Board, Touchstone Board, Grasshopper Board, Aurora Board, So iLL Board
70
+ * {@link https://auroraclimbing.com}
70
71
  */
71
72
  export class KilterBoard extends Device {
72
73
  /**
@@ -129,7 +130,7 @@ export class KilterBoard extends Device {
129
130
  /**
130
131
  * Calculates the checksum for a byte array by summing up all bytes ot hre packet in a single-byte variable.
131
132
  * @param data - The array of bytes to calculate the checksum for.
132
- * @returns The calculated checksum value.
133
+ * @returns {number} The calculated checksum value.
133
134
  */
134
135
  checksum(data) {
135
136
  let i = 0;
@@ -141,7 +142,7 @@ export class KilterBoard extends Device {
141
142
  /**
142
143
  * Wraps a byte array with header and footer bytes for transmission.
143
144
  * @param data - The array of bytes to wrap.
144
- * @returns The wrapped byte array.
145
+ * @returns {number[]} The wrapped byte array.
145
146
  */
146
147
  wrapBytes(data) {
147
148
  if (data.length > KilterBoard.messageBodyMaxLength) {
@@ -164,7 +165,7 @@ export class KilterBoard extends Device {
164
165
  * The lowest 8 bits of the position get put in the first byte of the group.
165
166
  * The highest 8 bits of the position get put in the second byte of the group.
166
167
  * @param position - The position to encode.
167
- * @returns The encoded byte array representing the position.
168
+ * @returns {number[]} The encoded byte array representing the position.
168
169
  */
169
170
  encodePosition(position) {
170
171
  const position1 = position & 255;
@@ -236,7 +237,7 @@ export class KilterBoard extends Device {
236
237
  * https://github.com/ramda/ramda/blob/master/source/splitEvery.js
237
238
  * @param {Number} n
238
239
  * @param {Array} list
239
- * @return {Array}
240
+ * @return {Array<number[]>}
240
241
  */
241
242
  splitEvery(n, list) {
242
243
  if (n <= 0) {
@@ -1,7 +1,8 @@
1
- import { Device } from "../device.model";
2
- import type { IMotherboard } from "../../interfaces/device/motherboard.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IMotherboard } from "../../interfaces/device/motherboard.interface.js";
3
3
  /**
4
- * Represents a Griptonite Motherboard device
4
+ * Represents a Griptonite Motherboard device.
5
+ * {@link https://griptonite.io}
5
6
  */
6
7
  export declare class Motherboard extends Device implements IMotherboard {
7
8
  /**
@@ -1,6 +1,7 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents a Griptonite Motherboard device
3
+ * Represents a Griptonite Motherboard device.
4
+ * {@link https://griptonite.io}
4
5
  */
5
6
  export class Motherboard extends Device {
6
7
  /**
@@ -1,8 +1,9 @@
1
- import { Device } from "../device.model";
2
- import type { ImySmartBoard } from "../../interfaces/device/mysmartboard.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { ImySmartBoard } from "../../interfaces/device/mysmartboard.interface.js";
3
3
  /**
4
- * Represents a mySmartBoard device
4
+ * Represents a Smartboard Climbing mySmartBoard device.
5
5
  * TODO: Add services, do you own a mySmartBoard? Help us!
6
+ * {@link https://www.smartboard-climbing.com}
6
7
  */
7
8
  export declare class mySmartBoard extends Device implements ImySmartBoard {
8
9
  constructor();
@@ -1,7 +1,8 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents a mySmartBoard device
3
+ * Represents a Smartboard Climbing mySmartBoard device.
4
4
  * TODO: Add services, do you own a mySmartBoard? Help us!
5
+ * {@link https://www.smartboard-climbing.com}
5
6
  */
6
7
  export class mySmartBoard extends Device {
7
8
  constructor() {
@@ -1,7 +1,8 @@
1
- import { Device } from "../device.model";
2
- import type { IProgressor } from "../../interfaces/device/progressor.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IProgressor } from "../../interfaces/device/progressor.interface.js";
3
3
  /**
4
- * Represents a Tindeq Progressor device
4
+ * Represents a Tindeq Progressor device.
5
+ * {@link https://tindeq.com}
5
6
  */
6
7
  export declare class Progressor extends Device implements IProgressor {
7
8
  constructor();
@@ -1,6 +1,6 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents the possible responses of a Tindeq Progressor device.
3
+ * Progressor responses
4
4
  */
5
5
  var ProgressorResponses;
6
6
  (function (ProgressorResponses) {
@@ -31,7 +31,8 @@ var ProgressorResponses;
31
31
  ProgressorResponses[ProgressorResponses["LOW_BATTERY_WARNING"] = 4] = "LOW_BATTERY_WARNING";
32
32
  })(ProgressorResponses || (ProgressorResponses = {}));
33
33
  /**
34
- * Represents a Tindeq Progressor device
34
+ * Represents a Tindeq Progressor device.
35
+ * {@link https://tindeq.com}
35
36
  */
36
37
  export class Progressor extends Device {
37
38
  constructor() {
@@ -1,8 +1,10 @@
1
- import { Device } from "../device.model";
2
- import type { IWHC06 } from "../../interfaces/device/wh-c06.interface";
1
+ import { Device } from "../device.model.js";
2
+ import type { IWHC06 } from "../../interfaces/device/wh-c06.interface.js";
3
3
  /**
4
- * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device
5
- * Enable 'Experimental Web Platform features' Chrome Flags.
4
+ * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device.
5
+ * To use this device enable: `chrome://flags/#enable-experimental-web-platform-features`.
6
+ * {@link https://googlechrome.github.io/samples/web-bluetooth/scan.html| Web Bluetooth}
7
+ * {@link https://weihengmanufacturer.com}
6
8
  */
7
9
  export declare class WHC06 extends Device implements IWHC06 {
8
10
  /**
@@ -1,7 +1,9 @@
1
- import { Device } from "../device.model";
1
+ import { Device } from "../device.model.js";
2
2
  /**
3
- * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device
4
- * Enable 'Experimental Web Platform features' Chrome Flags.
3
+ * Represents a Weiheng - WH-C06 (or MAT Muscle Meter) device.
4
+ * To use this device enable: `chrome://flags/#enable-experimental-web-platform-features`.
5
+ * {@link https://googlechrome.github.io/samples/web-bluetooth/scan.html| Web Bluetooth}
6
+ * {@link https://weihengmanufacturer.com}
5
7
  */
6
8
  export class WHC06 extends Device {
7
9
  /**
@@ -65,7 +67,8 @@ export class WHC06 extends Device {
65
67
  try {
66
68
  // Only data matching the optionalManufacturerData parameter to requestDevice is included in the advertisement event: https://github.com/WebBluetoothCG/web-bluetooth/issues/598
67
69
  const optionalManufacturerData = this.filters.flatMap((filter) => filter.manufacturerData?.map((data) => data.companyIdentifier) || []);
68
- this.bluetooth = await navigator.bluetooth.requestDevice({
70
+ const bluetooth = await this.getBluetooth();
71
+ this.bluetooth = await bluetooth.requestDevice({
69
72
  filters: this.filters,
70
73
  optionalManufacturerData,
71
74
  });
@@ -1,8 +1,8 @@
1
- import { BaseModel } from "./../models/base.model";
2
- import type { IDevice, Service } from "../interfaces/device.interface";
3
- import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface";
4
- import type { DownloadPacket } from "../interfaces/download.interface";
5
- import type { Commands } from "../interfaces/command.interface";
1
+ import { BaseModel } from "./../models/base.model.js";
2
+ import type { IDevice, Service } from "../interfaces/device.interface.js";
3
+ import type { ActiveCallback, NotifyCallback, WriteCallback } from "../interfaces/callback.interface.js";
4
+ import type { DownloadPacket } from "../interfaces/download.interface.js";
5
+ import type { Commands } from "../interfaces/command.interface.js";
6
6
  export declare abstract class Device extends BaseModel implements IDevice {
7
7
  /**
8
8
  * Filters to identify the device during Bluetooth scanning.
@@ -257,13 +257,13 @@ export declare abstract class Device extends BaseModel implements IDevice {
257
257
  * @param {('csv' | 'json' | 'xml')} [format='csv'] - The format in which to download the data.
258
258
  * Defaults to 'csv'. Accepted values are 'csv', 'json', and 'xml'.
259
259
  *
260
- * @returns {void} Initiates a download of the data in the specified format.
261
- * @private
260
+ * @returns {Promise<void>} Resolves when the data has been downloaded/written
261
+ * @public
262
262
  *
263
263
  * @example
264
- * device.download('json');
264
+ * await device.download('json');
265
265
  */
266
- download: (format?: "csv" | "json" | "xml") => void;
266
+ download: (format?: "csv" | "json" | "xml") => Promise<void>;
267
267
  /**
268
268
  * Returns UUIDs of all services associated with the device.
269
269
  * @returns {string[]} Array of service UUIDs.
@@ -274,6 +274,12 @@ export declare abstract class Device extends BaseModel implements IDevice {
274
274
  * console.log(serviceUUIDs);
275
275
  */
276
276
  protected getAllServiceUUIDs: () => string[];
277
+ /**
278
+ * Attempt to use ES module import rather than require.
279
+ * This approach uses an async dynamic import for `webbluetooth`,
280
+ * so we can fallback if `navigator.bluetooth` is unavailable.
281
+ */
282
+ protected getBluetooth(): Promise<Bluetooth | import("webbluetooth").Bluetooth>;
277
283
  /**
278
284
  * Retrieves the characteristic from the device's service.
279
285
  * @param {string} serviceId - The UUID of the service.