@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.
- package/examples/peripheral-explorer-async.js +1 -1
- package/index.d.ts +1 -0
- package/lib/hci-socket/hci.js +4 -2
- package/lib/noble.js +20 -0
- package/package.json +1 -1
- package/prebuilds/darwin-x64+arm64/@stoprocent+noble.node +0 -0
- package/prebuilds/win32-ia32/@stoprocent+noble.node +0 -0
- package/prebuilds/win32-x64/@stoprocent+noble.node +0 -0
- package/test/lib/hci-socket/hci.test.js +1 -1
|
@@ -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
package/lib/hci-socket/hci.js
CHANGED
|
@@ -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
|
-
|
|
932
|
-
this._isExtended = (
|
|
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
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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(
|
|
747
|
+
const result = Buffer.from("bd5f660000000000", "hex");
|
|
748
748
|
|
|
749
749
|
hci.processCmdCompleteEvent(cmd, status, result);
|
|
750
750
|
|