@stoprocent/noble 1.16.0 → 1.16.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.
@@ -9,7 +9,7 @@ noble.on('stateChange', async (state) => {
9
9
  if (state === 'poweredOn') {
10
10
  if (directConnect === '1') {
11
11
  await noble.stopScanningAsync();
12
- await noble.connectAsync(peripheralIdOrAddress.replace(/:/g, ''))
12
+ await noble.connectAsync(peripheralIdOrAddress.replace(/:/g, ''));
13
13
  } else {
14
14
  await noble.startScanningAsync();
15
15
  }
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@
13
13
 
14
14
  import events = require("events");
15
15
 
16
+ export declare function waitForPoweredOn(timeout?: number): Promise<void>;
16
17
  /**
17
18
  * @deprecated
18
19
  */
@@ -928,8 +928,10 @@ Hci.prototype.processCmdCompleteEvent = function (cmd, status, result) {
928
928
  this.readBdAddr();
929
929
  } else if (cmd === LE_READ_LOCAL_SUPPORTED_FEATURES) {
930
930
  if (status === 0) {
931
- const featuresLow = result.readUInt32LE(0);
932
- this._isExtended = (featuresLow & (1 << 6)) !== 0;
931
+ // Set _isExtended based on leExtendedAdvertising bit (12)
932
+ this._isExtended = !!(result.readUInt32LE(0) & (1 << 12));
933
+
934
+ this.emit('leFeatures', result);
933
935
 
934
936
  if (this._isExtended) {
935
937
  this.setCodedPhySupport();
package/lib/noble.js CHANGED
@@ -118,6 +118,26 @@ Noble.prototype.setAddress = function (address) {
118
118
  }
119
119
  };
120
120
 
121
+ Noble.prototype.waitForPoweredOn = function (timeout = 10000) {
122
+ return new Promise((resolve, reject) => {
123
+ const timeoutId = setTimeout(() => {
124
+ reject(new Error('Timeout waiting for Noble to be powered on'));
125
+ }, timeout);
126
+
127
+ let listener;
128
+ listener = (state) => {
129
+ clearTimeout(timeoutId);
130
+ if (state === 'poweredOn') {
131
+ resolve();
132
+ } else {
133
+ this.once('stateChange', listener);
134
+ }
135
+ };
136
+
137
+ this.once('stateChange', listener);
138
+ });
139
+ };
140
+
121
141
  const startScanning = function (serviceUuids, allowDuplicates, callback) {
122
142
  if (typeof serviceUuids === 'function') {
123
143
  this.emit('warning', 'calling startScanning(callback) is deprecated');
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.16.0",
9
+ "version": "1.16.1",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/stoprocent/noble.git"
@@ -744,7 +744,7 @@ describe('hci-socket hci', () => {
744
744
  it('should process with extended features', () => {
745
745
  const cmd = 8195;
746
746
  const status = 0;
747
- const result = Buffer.from([0x40, 0x00, 0x00, 0x00]); // Bit 6 set for extended features
747
+ const result = Buffer.from("bd5f660000000000", "hex");
748
748
 
749
749
  hci.processCmdCompleteEvent(cmd, status, result);
750
750