@stoprocent/noble 2.1.4 → 2.1.6
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/lib/hci-socket/bindings.js +5 -5
- package/lib/hci-socket/gap.js +5 -0
- package/lib/hci-socket/hci.js +1 -1
- 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/bindings.test.js +1 -1
- package/test/lib/hci-socket/gap.test.js +17 -0
- package/test/lib/hci-socket/hci.test.js +20 -4
|
@@ -104,10 +104,8 @@ NobleBindings.prototype.startScanning = function (
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
NobleBindings.prototype.stopScanning = function () {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
107
|
+
this._gap.stopScanning();
|
|
108
|
+
if (!this._isScanning) {
|
|
111
109
|
this.emit('scanStop');
|
|
112
110
|
}
|
|
113
111
|
};
|
|
@@ -215,7 +213,9 @@ NobleBindings.prototype.onScanParametersSet = function () {
|
|
|
215
213
|
};
|
|
216
214
|
|
|
217
215
|
NobleBindings.prototype.onScanStart = function (filterDuplicates) {
|
|
218
|
-
this.
|
|
216
|
+
if (this._isScanningStarted) {
|
|
217
|
+
this._isScanning = true;
|
|
218
|
+
}
|
|
219
219
|
this.emit('scanStart', filterDuplicates);
|
|
220
220
|
};
|
|
221
221
|
|
package/lib/hci-socket/gap.js
CHANGED
|
@@ -40,6 +40,11 @@ Gap.prototype.setScanParameters = function (interval, window) {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
Gap.prototype.startScanning = function (allowDuplicates) {
|
|
43
|
+
this._hci.once('reset', () => this.startScanningAfterReset(allowDuplicates));
|
|
44
|
+
this._hci.reset();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Gap.prototype.startScanningAfterReset = function (allowDuplicates) {
|
|
43
48
|
this._scanState = 'starting';
|
|
44
49
|
this._scanFilterDuplicates = !allowDuplicates;
|
|
45
50
|
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -511,7 +511,7 @@ Hci.prototype.setScanEnabled = function (enabled, filterDuplicates) {
|
|
|
511
511
|
Hci.prototype.createLeConn = function (address, addressType, parameters = {}) {
|
|
512
512
|
this.once('reset', () => this.createLeConnAfterReset(address, addressType, parameters));
|
|
513
513
|
this.reset();
|
|
514
|
-
}
|
|
514
|
+
};
|
|
515
515
|
|
|
516
516
|
Hci.prototype.createLeConnAfterReset = function (address, addressType, parameters = {}) {
|
|
517
517
|
const {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -216,7 +216,7 @@ describe('hci-socket bindings', () => {
|
|
|
216
216
|
|
|
217
217
|
bindings.stopScanning();
|
|
218
218
|
|
|
219
|
-
expect(bindings._gap.stopScanning).
|
|
219
|
+
expect(bindings._gap.stopScanning).toHaveBeenCalledTimes(1);
|
|
220
220
|
expect(scanStopSpy).toHaveBeenCalledTimes(1);
|
|
221
221
|
});
|
|
222
222
|
});
|
|
@@ -45,6 +45,8 @@ describe('hci-socket gap', () => {
|
|
|
45
45
|
it('startScanning', () => {
|
|
46
46
|
const hci = {
|
|
47
47
|
on: sinon.spy(),
|
|
48
|
+
once: sinon.spy(),
|
|
49
|
+
reset: sinon.spy(),
|
|
48
50
|
setScanEnabled: sinon.spy(),
|
|
49
51
|
setScanParameters: sinon.spy()
|
|
50
52
|
};
|
|
@@ -52,6 +54,21 @@ describe('hci-socket gap', () => {
|
|
|
52
54
|
const gap = new Gap(hci);
|
|
53
55
|
gap.startScanning(true);
|
|
54
56
|
|
|
57
|
+
assert.callCount(hci.once, 1);
|
|
58
|
+
assert.calledWithExactly(hci.reset);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('startScanningAfterReset', () => {
|
|
62
|
+
const hci = {
|
|
63
|
+
on: sinon.spy(),
|
|
64
|
+
once: sinon.spy(),
|
|
65
|
+
setScanEnabled: sinon.spy(),
|
|
66
|
+
setScanParameters: sinon.spy()
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const gap = new Gap(hci);
|
|
70
|
+
gap.startScanningAfterReset(true);
|
|
71
|
+
|
|
55
72
|
should(gap._scanState).equal('starting');
|
|
56
73
|
should(gap._scanFilterDuplicates).equal(false);
|
|
57
74
|
|
|
@@ -386,10 +386,26 @@ describe('hci-socket hci', () => {
|
|
|
386
386
|
});
|
|
387
387
|
|
|
388
388
|
describe('createLeConn', () => {
|
|
389
|
+
it('should emit reset event and call createLeConnAfterReset', () => {
|
|
390
|
+
const address = 'aa:bb:cc:dd:ee:ff';
|
|
391
|
+
const addressType = 'random';
|
|
392
|
+
const parameters = { minInterval: 0x0060, maxInterval: 0x00c0 };
|
|
393
|
+
|
|
394
|
+
hci.createLeConnAfterReset = jest.fn();
|
|
395
|
+
hci.createLeConn(address, addressType, parameters);
|
|
396
|
+
hci.emit('reset');
|
|
397
|
+
|
|
398
|
+
expect(hci.createLeConnAfterReset).toHaveBeenCalledWith(
|
|
399
|
+
address, addressType, parameters
|
|
400
|
+
);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe('createLeConnAfterReset', () => {
|
|
389
405
|
it('should keep default parameters', () => {
|
|
390
406
|
const address = 'aa:bb:cc:dd:ee';
|
|
391
407
|
const addressType = 'random';
|
|
392
|
-
hci.
|
|
408
|
+
hci.createLeConnAfterReset(address, addressType);
|
|
393
409
|
assert.calledOnceWithExactly(hci._socket.write, Buffer.from([0x01, 0x0d, 0x20, 0x19, 0x60, 0x00, 0x30, 0x00, 0x00, 0x01, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x00, 0x00, 0x06, 0x00, 0x12, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x04, 0x00, 0x06, 0x00]));
|
|
394
410
|
});
|
|
395
411
|
|
|
@@ -397,7 +413,7 @@ describe('hci-socket hci', () => {
|
|
|
397
413
|
const address = 'aa:bb:cc:dd:ee';
|
|
398
414
|
const addressType = 'random';
|
|
399
415
|
hci._isExtended = true;
|
|
400
|
-
hci.
|
|
416
|
+
hci.createLeConnAfterReset(address, addressType);
|
|
401
417
|
assert.calledOnceWithExactly(hci._socket.write, Buffer.from([0x01, 0x43, 0x20, 0x2a, 0x00, 0x00, 0x01, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x00, 0x05, 0x60, 0x00, 0x60, 0x00, 0x06, 0x00, 0x12, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x06, 0x00, 0x12, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00]));
|
|
402
418
|
});
|
|
403
419
|
|
|
@@ -405,7 +421,7 @@ describe('hci-socket hci', () => {
|
|
|
405
421
|
const address = 'ee:dd:cc:bb:aa';
|
|
406
422
|
const addressType = 'not_random';
|
|
407
423
|
const parameters = { minInterval: 0x0060, maxInterval: 0x00c0, latency: 0x0010, timeout: 0x0c80 };
|
|
408
|
-
hci.
|
|
424
|
+
hci.createLeConnAfterReset(address, addressType, parameters);
|
|
409
425
|
assert.calledOnceWithExactly(hci._socket.write, Buffer.from([0x01, 0x0d, 0x20, 0x19, 0x60, 0x00, 0x30, 0x00, 0x00, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x00, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x10, 0x00, 0x80, 0x0c, 0x04, 0x00, 0x06, 0x00]));
|
|
410
426
|
});
|
|
411
427
|
|
|
@@ -414,7 +430,7 @@ describe('hci-socket hci', () => {
|
|
|
414
430
|
const addressType = 'not_random';
|
|
415
431
|
const parameters = { minInterval: 0x0060, maxInterval: 0x00c0, latency: 0x0010, timeout: 0x0c80 };
|
|
416
432
|
hci._isExtended = true;
|
|
417
|
-
hci.
|
|
433
|
+
hci.createLeConnAfterReset(address, addressType, parameters);
|
|
418
434
|
assert.calledOnceWithExactly(hci._socket.write, Buffer.from([0x01, 0x43, 0x20, 0x2a, 0x00, 0x00, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x00, 0x05, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x10, 0x00, 0x80, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x10, 0x00, 0x80, 0x0c, 0x00, 0x00, 0x00, 0x00]));
|
|
419
435
|
});
|
|
420
436
|
});
|