@stoprocent/bleno 0.8.1 → 0.8.3
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 +3 -1
- package/lib/bleno.js +5 -0
- package/lib/hci-socket/bindings.js +14 -7
- package/lib/hci-socket/hci.js +6 -0
- package/lib/mac/src/noble_mac.mm +7 -0
- package/package.json +2 -2
- package/prebuilds/darwin-x64+arm64/@stoprocent+bleno.node +0 -0
- package/prebuilds/linux-x64/@stoprocent+bleno.musl.node +0 -0
- package/prebuilds/win32-ia32/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-x64/@stoprocent+bleno.node +0 -0
package/index.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ declare class PrimaryService {
|
|
|
103
103
|
toString(): string;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
interface Bleno extends NodeJS.EventEmitter {
|
|
106
|
+
export interface Bleno extends NodeJS.EventEmitter {
|
|
107
107
|
readonly Characteristic: typeof Characteristic;
|
|
108
108
|
readonly Descriptor: typeof Descriptor;
|
|
109
109
|
readonly PrimaryService: typeof PrimaryService;
|
|
@@ -120,6 +120,8 @@ interface Bleno extends NodeJS.EventEmitter {
|
|
|
120
120
|
|
|
121
121
|
disconnect(): void;
|
|
122
122
|
|
|
123
|
+
stop(): void;
|
|
124
|
+
|
|
123
125
|
setAddress(address: string): void;
|
|
124
126
|
|
|
125
127
|
setServices(services: ReadonlyArray<PrimaryService>, callback?: (arg: Error | undefined | null) => void): void;
|
package/lib/bleno.js
CHANGED
|
@@ -211,6 +211,11 @@ class Bleno extends EventEmitter {
|
|
|
211
211
|
this._bindings.disconnect();
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
stop () {
|
|
215
|
+
debug('stop');
|
|
216
|
+
this._bindings.stop();
|
|
217
|
+
}
|
|
218
|
+
|
|
214
219
|
updateRssi (callback) {
|
|
215
220
|
if (typeof callback === 'function') {
|
|
216
221
|
this.once('rssiUpdate', (rssi) => callback(null, rssi));
|
|
@@ -74,10 +74,11 @@ class BlenoBindings extends EventEmitter {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
init () {
|
|
77
|
-
this.
|
|
77
|
+
this._sigIntHandler = this.onSigInt.bind(this);
|
|
78
|
+
this._exitHandler = this.onExit.bind(this);
|
|
78
79
|
|
|
79
|
-
process.on('SIGINT', this.
|
|
80
|
-
process.on('exit', this.
|
|
80
|
+
process.on('SIGINT', this._sigIntHandler);
|
|
81
|
+
process.on('exit', this._exitHandler);
|
|
81
82
|
|
|
82
83
|
this._gap.on('advertisingStart', this.onAdvertisingStart.bind(this));
|
|
83
84
|
this._gap.on('advertisingStop', this.onAdvertisingStop.bind(this));
|
|
@@ -101,6 +102,14 @@ class BlenoBindings extends EventEmitter {
|
|
|
101
102
|
this._hci.init();
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
stop () {
|
|
106
|
+
process.removeListener('SIGINT', this._sigIntHandler);
|
|
107
|
+
process.removeListener('exit', this._exitHandler);
|
|
108
|
+
this.stopAdvertising();
|
|
109
|
+
this.disconnect();
|
|
110
|
+
this._hci.stop();
|
|
111
|
+
}
|
|
112
|
+
|
|
104
113
|
onStateChange (state) {
|
|
105
114
|
if (this._state === state) {
|
|
106
115
|
return;
|
|
@@ -202,7 +211,7 @@ class BlenoBindings extends EventEmitter {
|
|
|
202
211
|
onSigInt () {
|
|
203
212
|
const sigIntListeners = process.listeners('SIGINT');
|
|
204
213
|
|
|
205
|
-
if (sigIntListeners[sigIntListeners.length - 1] === this.
|
|
214
|
+
if (sigIntListeners[sigIntListeners.length - 1] === this._sigIntHandler) {
|
|
206
215
|
// we are the last listener, so exit
|
|
207
216
|
// this will trigger onExit, and clean up
|
|
208
217
|
process.exit(1);
|
|
@@ -210,9 +219,7 @@ class BlenoBindings extends EventEmitter {
|
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
onExit () {
|
|
213
|
-
this.
|
|
214
|
-
|
|
215
|
-
this.disconnect();
|
|
222
|
+
this.stop();
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
225
|
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -116,6 +116,11 @@ class Hci extends EventEmitter {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
stop () {
|
|
120
|
+
this._socket.removeAllListeners();
|
|
121
|
+
this._socket.stop();
|
|
122
|
+
}
|
|
123
|
+
|
|
119
124
|
resetBuffers () {
|
|
120
125
|
this._mainHandle = null;
|
|
121
126
|
this._handleAclsInProgress = {};
|
|
@@ -584,6 +589,7 @@ class Hci extends EventEmitter {
|
|
|
584
589
|
debug('\t\talready closed');
|
|
585
590
|
continue;
|
|
586
591
|
}
|
|
592
|
+
|
|
587
593
|
if (pkts > this._handleAclsInProgress[handle_]) {
|
|
588
594
|
// Linux kernel may send acl packets by itself, so be ready for underflow
|
|
589
595
|
this._handleAclsInProgress[handle_] = 0;
|
package/lib/mac/src/noble_mac.mm
CHANGED
|
@@ -228,6 +228,12 @@ Napi::Value BlenoMac::CleanUp(const Napi::CallbackInfo& info) {
|
|
|
228
228
|
return Napi::Value();
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
Napi::Value BlenoMac::Stop(const Napi::CallbackInfo& info) {
|
|
232
|
+
CHECK_MANAGER()
|
|
233
|
+
CleanUp(info);
|
|
234
|
+
return Napi::Value();
|
|
235
|
+
}
|
|
236
|
+
|
|
231
237
|
Napi::Function BlenoMac::GetClass(Napi::Env env) {
|
|
232
238
|
return DefineClass(env, "BlenoMac", {
|
|
233
239
|
BlenoMac::InstanceMethod("init", &BlenoMac::Init),
|
|
@@ -248,6 +254,7 @@ Napi::Function BlenoMac::GetClass(Napi::Env env) {
|
|
|
248
254
|
BlenoMac::InstanceMethod("readHandle", &BlenoMac::ReadValue),
|
|
249
255
|
BlenoMac::InstanceMethod("writeHandle", &BlenoMac::WriteValue),
|
|
250
256
|
BlenoMac::InstanceMethod("cleanUp", &BlenoMac::CleanUp),
|
|
257
|
+
BlenoMac::InstanceMethod("stop", &BlenoMac::Stop),
|
|
251
258
|
});
|
|
252
259
|
}
|
|
253
260
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoprocent/bleno",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"node-gyp-build": "^4.8.1"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
|
-
"@stoprocent/bluetooth-hci-socket": "^1.4.
|
|
73
|
+
"@stoprocent/bluetooth-hci-socket": "^1.4.5",
|
|
74
74
|
"bplist-parser": "0.3.2",
|
|
75
75
|
"xpc-connect": "^3.0.0"
|
|
76
76
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|