@stoprocent/noble 1.17.2 → 1.17.4
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 +3 -0
- package/lib/hci-socket/bindings.js +20 -11
- package/lib/hci-socket/gap.js +1 -7
- 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
|
@@ -9,6 +9,7 @@ const Signaling = require('./signaling');
|
|
|
9
9
|
|
|
10
10
|
const NobleBindings = function (options) {
|
|
11
11
|
this._state = null;
|
|
12
|
+
this._isScanning = false;
|
|
12
13
|
|
|
13
14
|
this._addresses = {};
|
|
14
15
|
this._addresseTypes = {};
|
|
@@ -53,21 +54,27 @@ NobleBindings.prototype.stopScanning = function () {
|
|
|
53
54
|
|
|
54
55
|
NobleBindings.prototype.connect = function (peripheralUuid, parameters = {}) {
|
|
55
56
|
let address = this._addresses[peripheralUuid];
|
|
56
|
-
let addressType = this._addresseTypes[peripheralUuid] || 'random';
|
|
57
|
+
let addressType = this._addresseTypes[peripheralUuid] || 'random';
|
|
57
58
|
|
|
58
|
-
// If address is not available, generate it from the UUID using the transformation logic inline
|
|
59
59
|
if (!address) {
|
|
60
|
-
address = peripheralUuid.match(/.{1,2}/g).join(':');
|
|
61
|
-
addressType =
|
|
60
|
+
address = peripheralUuid.match(/.{1,2}/g).join(':');
|
|
61
|
+
addressType = parameters && parameters.addressType ? parameters.addressType : 'random';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const createConnection = () => {
|
|
65
|
+
if (!this._pendingConnectionUuid) {
|
|
66
|
+
this._pendingConnectionUuid = peripheralUuid;
|
|
67
|
+
this._hci.createLeConn(address, addressType, parameters);
|
|
68
|
+
} else {
|
|
69
|
+
this._connectionQueue.push({ id: peripheralUuid, params: parameters });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (this._isScanning) {
|
|
74
|
+
this.once('scanStop', createConnection);
|
|
75
|
+
this.stopScanning();
|
|
68
76
|
} else {
|
|
69
|
-
|
|
70
|
-
this._connectionQueue.push({ id: peripheralUuid, params: parameters });
|
|
77
|
+
createConnection();
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
80
|
|
|
@@ -158,7 +165,7 @@ NobleBindings.prototype.onStateChange = function (state) {
|
|
|
158
165
|
);
|
|
159
166
|
console.log(' Try to run with environment variable:');
|
|
160
167
|
console.log(' [sudo] NOBLE_HCI_DEVICE_ID=x node ...');
|
|
161
|
-
}
|
|
168
|
+
}
|
|
162
169
|
|
|
163
170
|
this.emit('stateChange', state);
|
|
164
171
|
};
|
|
@@ -172,10 +179,12 @@ NobleBindings.prototype.onScanParametersSet = function () {
|
|
|
172
179
|
};
|
|
173
180
|
|
|
174
181
|
NobleBindings.prototype.onScanStart = function (filterDuplicates) {
|
|
182
|
+
this._isScanning = true;
|
|
175
183
|
this.emit('scanStart', filterDuplicates);
|
|
176
184
|
};
|
|
177
185
|
|
|
178
186
|
NobleBindings.prototype.onScanStop = function () {
|
|
187
|
+
this._isScanning = false;
|
|
179
188
|
this.emit('scanStop');
|
|
180
189
|
};
|
|
181
190
|
|
package/lib/hci-socket/gap.js
CHANGED
|
@@ -276,13 +276,7 @@ Gap.prototype.parseServices = function (
|
|
|
276
276
|
serviceUuids: [],
|
|
277
277
|
solicitationServiceUuids: []
|
|
278
278
|
};
|
|
279
|
-
|
|
280
|
-
if (leMetaEventType !== LE_META_EVENT_TYPE_SCAN_RESPONSE) {
|
|
281
|
-
// reset service data every non-scan response event
|
|
282
|
-
advertisement.serviceUuids = [];
|
|
283
|
-
advertisement.serviceSolicitationUuids = [];
|
|
284
|
-
}
|
|
285
|
-
|
|
279
|
+
|
|
286
280
|
while (i + 1 < eir.length) {
|
|
287
281
|
const length = eir.readUInt8(i);
|
|
288
282
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|