@stoprocent/noble 2.1.4 → 2.1.5
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 +4 -0
- 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/gap.test.js +17 -0
- package/test/lib/hci-socket/hci.test.js +20 -4
|
@@ -292,6 +292,10 @@ NobleBindings.prototype.onLeConnComplete = function (
|
|
|
292
292
|
supervisionTimeout,
|
|
293
293
|
masterClockAccuracy
|
|
294
294
|
) {
|
|
295
|
+
//
|
|
296
|
+
this._isScanning = false;
|
|
297
|
+
this._isScanningStarted = false;
|
|
298
|
+
|
|
295
299
|
if (role !== 0 && role !== undefined) {
|
|
296
300
|
// not master, ignore
|
|
297
301
|
return;
|
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
|
|
@@ -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
|
});
|