@stoprocent/noble 1.17.0 → 1.17.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.
package/README.md CHANGED
@@ -16,9 +16,12 @@ This fork of `noble` was created to introduce several key improvements and new f
16
16
 
17
17
  2. **macOS Native Bindings Fix**: I have fixed the native bindings for macOS, ensuring better compatibility and performance on Apple devices.
18
18
 
19
- 3. **New Features**:
20
- - A `setAddress` function has been added, allowing users to set the MAC address of the central device.
19
+ 3. **Windows Native Bindings Fix**: I have fixed the native bindings for Windows, adding support for `Service Data` from advertisements.
20
+
21
+ 4. **New Features**:
22
+ - A `setAddress(...)` function has been added, allowing users to set the MAC address of the central device.
21
23
  - A `connect(...)/connectAsync(...)` function has been added, allowing users to connect directly to specific device by address/identifier without a need to prior scan.
24
+ - A `waitForPoweredOn(...)` function to wait for the adapter to be powered on in await/async functions.
22
25
  - Additionally, I plan to add raw L2CAP channel support, enhancing low-level Bluetooth communication capabilities.
23
26
 
24
27
  If you appreciate these enhancements and the continued development of this project, please consider supporting my work.
@@ -49,14 +52,16 @@ const noble = require('@stoprocent/noble');
49
52
 
50
53
  ```javascript
51
54
  // Read the battery level of the first found peripheral exposing the Battery Level characteristic
55
+ const noble = require('../');
52
56
 
53
- const noble = require('@stoprocent/noble');
54
-
55
- noble.on('stateChange', async (state) => {
56
- if (state === 'poweredOn') {
57
+ async function run() {
58
+ try {
59
+ await noble.waitForPoweredOn();
57
60
  await noble.startScanningAsync(['180f'], false);
61
+ } catch (error) {
62
+ console.error(error);
58
63
  }
59
- });
64
+ }
60
65
 
61
66
  noble.on('discover', async (peripheral) => {
62
67
  await noble.stopScanningAsync();
@@ -69,6 +74,9 @@ noble.on('discover', async (peripheral) => {
69
74
  await peripheral.disconnectAsync();
70
75
  process.exit(0);
71
76
  });
77
+
78
+ run();
79
+
72
80
  ```
73
81
  ## Use Noble With BLE5 Extended Features With HCI
74
82
 
package/index.d.ts CHANGED
@@ -54,6 +54,10 @@ export declare function removeListener(event: string, listener: Function): event
54
54
 
55
55
  export declare function removeAllListeners(event?: string): events.EventEmitter;
56
56
 
57
+ export var state: "unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn";
58
+ /**
59
+ * @deprecated Use `state` instead.
60
+ */
57
61
  export var _state: "unknown" | "resetting" | "unsupported" | "unauthorized" | "poweredOff" | "poweredOn";
58
62
 
59
63
  export var _bindings: any;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "license": "MIT",
7
7
  "name": "@stoprocent/noble",
8
8
  "description": "A Node.js BLE (Bluetooth Low Energy) central library.",
9
- "version": "1.17.0",
9
+ "version": "1.17.1",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/stoprocent/noble.git"
@@ -34,7 +34,7 @@
34
34
  "node-gyp-build": "^4.8.1"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@stoprocent/bluetooth-hci-socket": "^1.4.2"
37
+ "@stoprocent/bluetooth-hci-socket": "^1.4.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@commitlint/cli": "^19.3.0",