@stoprocent/noble 1.15.1 → 1.15.2
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/index.d.ts +1 -0
- package/lib/hci-socket/bindings.js +4 -3
- package/lib/hci-socket/hci.js +4 -0
- package/lib/noble.js +9 -1
- package/package.json +2 -2
- package/prebuilds/darwin-x64+arm64/@stoprocent+noble.node +0 -0
- package/prebuilds/linux-x64/@stoprocent+noble.musl.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 +9 -3
package/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare function connect(peripheralUuid: string, options?: object, callba
|
|
|
29
29
|
export declare function connectAsync(peripheralUuid: string, options?: object): Promise<Peripheral>;
|
|
30
30
|
export declare function cancelConnect(peripheralUuid: string, options?: object): void;
|
|
31
31
|
export declare function reset(): void;
|
|
32
|
+
export declare function stop(): void;
|
|
32
33
|
|
|
33
34
|
export declare function setAddress(address: string): void;
|
|
34
35
|
|
|
@@ -113,7 +113,7 @@ NobleBindings.prototype.init = function () {
|
|
|
113
113
|
is present it can throw an exception - in which case we don't
|
|
114
114
|
want to try and clear up afterwards (issue #502) */
|
|
115
115
|
process.on('SIGINT', this.onSigIntBinded);
|
|
116
|
-
process.on('exit', this.
|
|
116
|
+
process.on('exit', this.stop.bind(this));
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
NobleBindings.prototype.onSigInt = function () {
|
|
@@ -126,12 +126,13 @@ NobleBindings.prototype.onSigInt = function () {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
NobleBindings.prototype.
|
|
129
|
+
NobleBindings.prototype.stop = function () {
|
|
130
130
|
this.stopScanning();
|
|
131
|
-
|
|
132
131
|
for (const handle in this._aclStreams) {
|
|
133
132
|
this._hci.disconnect(handle);
|
|
134
133
|
}
|
|
134
|
+
this._hci.reset();
|
|
135
|
+
this._hci.stop();
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
NobleBindings.prototype.onStateChange = function (state) {
|
package/lib/hci-socket/hci.js
CHANGED
package/lib/noble.js
CHANGED
|
@@ -190,7 +190,15 @@ Noble.prototype.onScanStop = function () {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
Noble.prototype.reset = function () {
|
|
193
|
-
this._bindings.reset
|
|
193
|
+
if (this._bindings.reset) {
|
|
194
|
+
this._bindings.reset();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
Noble.prototype.stop = function () {
|
|
199
|
+
if (this._bindings.stop) {
|
|
200
|
+
this._bindings.stop();
|
|
201
|
+
}
|
|
194
202
|
};
|
|
195
203
|
|
|
196
204
|
Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, advertisement, rssi, scannable) {
|
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.15.
|
|
9
|
+
"version": "1.15.2",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/stoprocent/noble.git"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node-gyp-build": "^4.8.1"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@stoprocent/bluetooth-hci-socket": "^1.4.
|
|
37
|
+
"@stoprocent/bluetooth-hci-socket": "^1.4.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@commitlint/cli": "^19.3.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -268,22 +268,28 @@ describe('hci-socket bindings', () => {
|
|
|
268
268
|
assert.calledTwice(process.on);
|
|
269
269
|
});
|
|
270
270
|
|
|
271
|
-
describe('
|
|
271
|
+
describe('stop', () => {
|
|
272
272
|
it('no handles', () => {
|
|
273
273
|
bindings._gap.stopScanning = fake.resolves(null);
|
|
274
|
+
bindings._hci.reset = fake.resolves(null);
|
|
275
|
+
bindings._hci.stop = fake.resolves(null);
|
|
274
276
|
|
|
275
|
-
bindings.
|
|
277
|
+
bindings.stop();
|
|
276
278
|
|
|
277
279
|
assert.calledOnce(bindings._gap.stopScanning);
|
|
280
|
+
assert.calledOnce(bindings._hci.reset);
|
|
281
|
+
assert.calledOnce(bindings._hci.stop);
|
|
278
282
|
});
|
|
279
283
|
|
|
280
284
|
it('with handles', () => {
|
|
281
285
|
bindings._gap.stopScanning = fake.resolves(null);
|
|
282
286
|
bindings._hci.disconnect = fake.resolves(null);
|
|
287
|
+
bindings._hci.reset = fake.resolves(null);
|
|
288
|
+
bindings._hci.stop = fake.resolves(null);
|
|
283
289
|
|
|
284
290
|
bindings._aclStreams = [1, 2, 3];
|
|
285
291
|
|
|
286
|
-
bindings.
|
|
292
|
+
bindings.stop();
|
|
287
293
|
|
|
288
294
|
assert.calledOnce(bindings._gap.stopScanning);
|
|
289
295
|
assert.calledThrice(bindings._hci.disconnect);
|