@stoprocent/bleno 0.11.2 → 0.11.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/lib/hci-socket/acl-stream.js +3 -1
- package/lib/hci-socket/hci.js +11 -4
- package/lib/hci-socket/mgmt.js +2 -4
- package/lib/hci-socket/smp.js +3 -3
- package/package.json +2 -2
- package/prebuilds/darwin-x64+arm64/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-ia32/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-x64/@stoprocent+bleno.node +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { EventEmitter } = require('events');
|
|
2
2
|
const Smp = require('./smp');
|
|
3
|
+
const Mgmt = require('./mgmt');
|
|
3
4
|
|
|
4
5
|
class AclStream extends EventEmitter {
|
|
5
6
|
constructor (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) {
|
|
@@ -8,7 +9,8 @@ class AclStream extends EventEmitter {
|
|
|
8
9
|
this._handle = handle;
|
|
9
10
|
this.encypted = false;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
const mgmt = new Mgmt(hci.BluetoothHciSocket);
|
|
13
|
+
this._smp = new Smp(this, mgmt, localAddressType, localAddress, remoteAddressType, remoteAddress);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
close () {
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -80,6 +80,8 @@ class Hci extends EventEmitter {
|
|
|
80
80
|
options = options || {};
|
|
81
81
|
|
|
82
82
|
const BluetoothHciSocket = loadDriver(options.hciDriver || 'default');
|
|
83
|
+
this.BluetoothHciSocket = BluetoothHciSocket;
|
|
84
|
+
|
|
83
85
|
this._socket = new BluetoothHciSocket();
|
|
84
86
|
|
|
85
87
|
this._manufacturer = null;
|
|
@@ -653,11 +655,16 @@ class Hci extends EventEmitter {
|
|
|
653
655
|
}
|
|
654
656
|
|
|
655
657
|
onSocketError (error) {
|
|
656
|
-
debug(
|
|
657
|
-
|
|
658
|
-
if (error
|
|
658
|
+
debug(`onSocketError: ${error.message}`);
|
|
659
|
+
// Handle Socket Error
|
|
660
|
+
if ('syscall' in error && error['syscall'] === 'socket creation failed') {
|
|
661
|
+
this.emit('stateChange', 'unsupported');
|
|
662
|
+
}
|
|
663
|
+
// Permisions
|
|
664
|
+
else if (error.code === 'EPERM') {
|
|
659
665
|
this.emit('stateChange', 'unauthorized');
|
|
660
|
-
}
|
|
666
|
+
}
|
|
667
|
+
else if (error.message === 'Network is down') {
|
|
661
668
|
// no-op
|
|
662
669
|
}
|
|
663
670
|
}
|
package/lib/hci-socket/mgmt.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
const debug = require('debug')('mgmt');
|
|
2
2
|
|
|
3
|
-
const BluetoothHciSocket = require('@stoprocent/bluetooth-hci-socket');
|
|
4
|
-
|
|
5
3
|
const LTK_INFO_SIZE = 36;
|
|
6
4
|
|
|
7
5
|
const MGMT_OP_LOAD_LONG_TERM_KEYS = 0x0013;
|
|
8
6
|
|
|
9
7
|
class Mgmt {
|
|
10
|
-
constructor () {
|
|
11
|
-
this._socket = new
|
|
8
|
+
constructor (socketClass) {
|
|
9
|
+
this._socket = new socketClass();
|
|
12
10
|
this._ltkInfos = [];
|
|
13
11
|
|
|
14
12
|
this._socket.on('data', this.onSocketData.bind(this));
|
package/lib/hci-socket/smp.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { EventEmitter } = require('events');
|
|
2
2
|
const crypto = require('./crypto');
|
|
3
|
-
const Mgmt = require('./mgmt');
|
|
4
3
|
|
|
5
4
|
const SMP_CID = 0x0006;
|
|
6
5
|
|
|
@@ -15,11 +14,12 @@ const SMP_MASTER_IDENT = 0x07;
|
|
|
15
14
|
const SMP_UNSPECIFIED = 0x08;
|
|
16
15
|
|
|
17
16
|
class Smp extends EventEmitter {
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
constructor (aclStream, mgmt, localAddressType, localAddress, remoteAddressType, remoteAddress) {
|
|
19
19
|
super();
|
|
20
20
|
|
|
21
21
|
this._aclStream = aclStream;
|
|
22
|
-
this._mgmt =
|
|
22
|
+
this._mgmt = mgmt;
|
|
23
23
|
|
|
24
24
|
this._iat = Buffer.from([(remoteAddressType === 'random') ? 0x01 : 0x00]);
|
|
25
25
|
this._ia = Buffer.from(remoteAddress.split(':').reverse().join(''), 'hex');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoprocent/bleno",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"node-gyp-build": "^4.8.4"
|
|
70
70
|
},
|
|
71
71
|
"optionalDependencies": {
|
|
72
|
-
"@stoprocent/bluetooth-hci-socket": "^2.2.
|
|
72
|
+
"@stoprocent/bluetooth-hci-socket": "^2.2.3"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|