@stoprocent/bleno 0.12.1 → 0.12.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/examples/pizza/pizza.js +2 -2
- package/lib/bleno-event-emitter.js +27 -0
- package/lib/bleno.js +8 -8
- package/lib/characteristic.js +2 -2
- package/lib/hci-socket/acl-stream.js +2 -2
- package/lib/hci-socket/bindings.js +2 -2
- package/lib/hci-socket/gap.js +2 -2
- package/lib/hci-socket/gatt.js +2 -2
- package/lib/hci-socket/hci.js +2 -2
- package/lib/hci-socket/smp.js +2 -2
- package/lib/mac/bindings.js +2 -2
- package/lib/primary-service.js +2 -2
- package/package.json +4 -3
- package/patches/@thegecko+docker-run+3.1.0.patch +13 -0
- package/patches/@vweevers+docker-pull+1.1.1.patch +13 -0
- package/patches/prebuildify-cross+5.1.1.patch +30 -0
- 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
package/examples/pizza/pizza.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { EventEmitter } = require('events');
|
|
2
|
+
|
|
3
|
+
class BlenoEventEmitter extends EventEmitter {
|
|
4
|
+
/**
|
|
5
|
+
* Like once(), but ensures at most one listener exists for the given event.
|
|
6
|
+
* If a previous exclusive listener was registered for the same event, it is
|
|
7
|
+
* removed before the new one is added. This prevents listener accumulation
|
|
8
|
+
* when a method is called repeatedly before the event fires.
|
|
9
|
+
*/
|
|
10
|
+
onceExclusive (event, callback) {
|
|
11
|
+
if (!this._exclusiveCallbacks) {
|
|
12
|
+
this._exclusiveCallbacks = new Map();
|
|
13
|
+
}
|
|
14
|
+
const prev = this._exclusiveCallbacks.get(event);
|
|
15
|
+
if (prev) {
|
|
16
|
+
this.removeListener(event, prev);
|
|
17
|
+
}
|
|
18
|
+
const wrappedCallback = (...args) => {
|
|
19
|
+
this._exclusiveCallbacks.delete(event);
|
|
20
|
+
callback(...args);
|
|
21
|
+
};
|
|
22
|
+
this._exclusiveCallbacks.set(event, wrappedCallback);
|
|
23
|
+
this.once(event, wrappedCallback);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = BlenoEventEmitter;
|
package/lib/bleno.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const debug = require('debug')('bleno');
|
|
2
2
|
const UuidUtil = require('./uuid-util');
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const BlenoEventEmitter = require('./bleno-event-emitter');
|
|
5
5
|
|
|
6
6
|
const PrimaryService = require('./primary-service');
|
|
7
7
|
const Characteristic = require('./characteristic');
|
|
8
8
|
const Descriptor = require('./descriptor');
|
|
9
9
|
|
|
10
|
-
class Bleno extends
|
|
10
|
+
class Bleno extends BlenoEventEmitter {
|
|
11
11
|
constructor (bindings) {
|
|
12
12
|
super();
|
|
13
13
|
this.initialized = false;
|
|
@@ -138,7 +138,7 @@ class Bleno extends EventEmitter {
|
|
|
138
138
|
}
|
|
139
139
|
} else {
|
|
140
140
|
if (typeof callback === 'function') {
|
|
141
|
-
this.
|
|
141
|
+
this.onceExclusive('advertisingStart', callback);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const undashedServiceUuids = [];
|
|
@@ -186,7 +186,7 @@ class Bleno extends EventEmitter {
|
|
|
186
186
|
iBeaconData.writeInt8(measuredPower, uuidDataLength + 4);
|
|
187
187
|
|
|
188
188
|
if (typeof callback === 'function') {
|
|
189
|
-
this.
|
|
189
|
+
this.onceExclusive('advertisingStart', callback);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
debug('iBeacon data = ' + iBeaconData.toString('hex'));
|
|
@@ -225,7 +225,7 @@ class Bleno extends EventEmitter {
|
|
|
225
225
|
}
|
|
226
226
|
} else {
|
|
227
227
|
if (typeof callback === 'function') {
|
|
228
|
-
this.
|
|
228
|
+
this.onceExclusive('advertisingStart', callback);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
this._bindings.startAdvertisingWithEIRData(advertisementData, scanData);
|
|
@@ -243,7 +243,7 @@ class Bleno extends EventEmitter {
|
|
|
243
243
|
|
|
244
244
|
stopAdvertising (callback) {
|
|
245
245
|
if (typeof callback === 'function') {
|
|
246
|
-
this.
|
|
246
|
+
this.onceExclusive('advertisingStop', callback);
|
|
247
247
|
}
|
|
248
248
|
this._bindings.stopAdvertising();
|
|
249
249
|
}
|
|
@@ -264,7 +264,7 @@ class Bleno extends EventEmitter {
|
|
|
264
264
|
|
|
265
265
|
setServices (services, callback) {
|
|
266
266
|
if (typeof callback === 'function') {
|
|
267
|
-
this.
|
|
267
|
+
this.onceExclusive('servicesSet', callback);
|
|
268
268
|
}
|
|
269
269
|
this._bindings.setServices(services);
|
|
270
270
|
}
|
|
@@ -303,7 +303,7 @@ class Bleno extends EventEmitter {
|
|
|
303
303
|
|
|
304
304
|
updateRssi (callback) {
|
|
305
305
|
if (typeof callback === 'function') {
|
|
306
|
-
this.
|
|
306
|
+
this.onceExclusive('rssiUpdate', (rssi) => callback(null, rssi));
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
this._bindings.updateRssi();
|
package/lib/characteristic.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BlenoEventEmitter = require('./bleno-event-emitter');
|
|
2
2
|
const UuidUtil = require('./uuid-util');
|
|
3
3
|
|
|
4
|
-
class Characteristic extends
|
|
4
|
+
class Characteristic extends BlenoEventEmitter {
|
|
5
5
|
constructor (options) {
|
|
6
6
|
super();
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
2
2
|
const Smp = require('./smp');
|
|
3
3
|
const Mgmt = require('./mgmt');
|
|
4
4
|
|
|
5
|
-
class AclStream extends
|
|
5
|
+
class AclStream extends BlenoEventEmitter {
|
|
6
6
|
constructor (hci, handle, localAddressType, localAddress, remoteAddressType, remoteAddress) {
|
|
7
7
|
super();
|
|
8
8
|
this._hci = hci;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const debug = require('debug')('bindings');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
4
4
|
const os = require('os');
|
|
5
5
|
|
|
6
6
|
const AclStream = require('./acl-stream');
|
|
@@ -8,7 +8,7 @@ const Hci = require('./hci');
|
|
|
8
8
|
const Gap = require('./gap');
|
|
9
9
|
const Gatt = require('./gatt');
|
|
10
10
|
|
|
11
|
-
class BlenoBindings extends
|
|
11
|
+
class BlenoBindings extends BlenoEventEmitter {
|
|
12
12
|
constructor (options) {
|
|
13
13
|
super();
|
|
14
14
|
|
package/lib/hci-socket/gap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const debug = require('debug')('gap');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
4
4
|
const os = require('os');
|
|
5
5
|
|
|
6
6
|
const Hci = require('./hci');
|
|
@@ -9,7 +9,7 @@ const isLinux = (os.platform() === 'linux');
|
|
|
9
9
|
const isIntelEdison = isLinux && (os.release().includes('edison'));
|
|
10
10
|
const isYocto = isLinux && (os.release().includes('yocto'));
|
|
11
11
|
|
|
12
|
-
class Gap extends
|
|
12
|
+
class Gap extends BlenoEventEmitter {
|
|
13
13
|
constructor (hci) {
|
|
14
14
|
super();
|
|
15
15
|
|
package/lib/hci-socket/gatt.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const debug = require('debug')('gatt');
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const Characteristic = require('../characteristic');
|
|
9
9
|
|
|
@@ -64,7 +64,7 @@ const ATT_ECODE_INSUFF_RESOURCES = 0x11;
|
|
|
64
64
|
|
|
65
65
|
const ATT_CID = 0x0004;
|
|
66
66
|
|
|
67
|
-
class Gatt extends
|
|
67
|
+
class Gatt extends BlenoEventEmitter {
|
|
68
68
|
constructor () {
|
|
69
69
|
super();
|
|
70
70
|
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const debug = require('debug')('hci');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
4
4
|
const { loadDriver } = require('@stoprocent/bluetooth-hci-socket');
|
|
5
5
|
|
|
6
6
|
const vendorSpecific = require('./vs');
|
|
@@ -74,7 +74,7 @@ const HCI_OE_USER_ENDED_CONNECTION = 0x13;
|
|
|
74
74
|
|
|
75
75
|
const STATUS_MAPPER = require('./hci-status');
|
|
76
76
|
|
|
77
|
-
class Hci extends
|
|
77
|
+
class Hci extends BlenoEventEmitter {
|
|
78
78
|
constructor (options) {
|
|
79
79
|
super();
|
|
80
80
|
options = options || {};
|
package/lib/hci-socket/smp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
2
2
|
const crypto = require('./crypto');
|
|
3
3
|
|
|
4
4
|
const SMP_CID = 0x0006;
|
|
@@ -13,7 +13,7 @@ const SMP_MASTER_IDENT = 0x07;
|
|
|
13
13
|
|
|
14
14
|
const SMP_UNSPECIFIED = 0x08;
|
|
15
15
|
|
|
16
|
-
class Smp extends
|
|
16
|
+
class Smp extends BlenoEventEmitter {
|
|
17
17
|
|
|
18
18
|
constructor (aclStream, mgmt, localAddressType, localAddress, remoteAddressType, remoteAddress) {
|
|
19
19
|
super();
|
package/lib/mac/bindings.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BlenoEventEmitter = require('../bleno-event-emitter');
|
|
2
2
|
|
|
3
3
|
const { resolve } = require('path');
|
|
4
4
|
const dir = resolve(__dirname, '..', '..');
|
|
@@ -6,6 +6,6 @@ const binding = require('node-gyp-build')(dir);
|
|
|
6
6
|
|
|
7
7
|
const { BlenoMac } = binding;
|
|
8
8
|
|
|
9
|
-
Object.setPrototypeOf(BlenoMac.prototype,
|
|
9
|
+
Object.setPrototypeOf(BlenoMac.prototype, BlenoEventEmitter.prototype);
|
|
10
10
|
|
|
11
11
|
module.exports = BlenoMac;
|
package/lib/primary-service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BlenoEventEmitter = require('./bleno-event-emitter');
|
|
2
2
|
const UuidUtil = require('./uuid-util');
|
|
3
3
|
|
|
4
|
-
class PrimaryService extends
|
|
4
|
+
class PrimaryService extends BlenoEventEmitter {
|
|
5
5
|
constructor (options) {
|
|
6
6
|
super();
|
|
7
7
|
this.uuid = UuidUtil.removeDashes(options.uuid);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoprocent/bleno",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"lint": "eslint \"**/*.js\"",
|
|
20
20
|
"lint-fix": "eslint \"**/*.js\" --fix",
|
|
21
21
|
"prebuildify": "prebuildify --napi --target 14.0.0 --force --strip --verbose",
|
|
22
|
-
"prebuildify-cross": "prebuildify-cross --napi --target 14.0.0 --force --strip --verbose",
|
|
22
|
+
"prebuildify-cross": "patch-package && prebuildify-cross --napi --target 14.0.0 --force --strip --verbose",
|
|
23
23
|
"semantic-release": "semantic-release",
|
|
24
24
|
"pretest": "npm run rebuild",
|
|
25
25
|
"rebuild": "node-gyp rebuild",
|
|
@@ -65,11 +65,12 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"debug": "^4.4.0",
|
|
68
|
+
"patch-package": "^8.0.0",
|
|
68
69
|
"node-addon-api": "^8.3.1",
|
|
69
70
|
"node-gyp-build": "^4.8.4"
|
|
70
71
|
},
|
|
71
72
|
"optionalDependencies": {
|
|
72
|
-
"@stoprocent/bluetooth-hci-socket": "^2.2.
|
|
73
|
+
"@stoprocent/bluetooth-hci-socket": "^2.2.5"
|
|
73
74
|
},
|
|
74
75
|
"publishConfig": {
|
|
75
76
|
"access": "public"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/node_modules/@thegecko/docker-run/index.js b/node_modules/@thegecko/docker-run/index.js
|
|
2
|
+
index 5299bee..4de15b3 100644
|
|
3
|
+
--- a/node_modules/@thegecko/docker-run/index.js
|
|
4
|
+
+++ b/node_modules/@thegecko/docker-run/index.js
|
|
5
|
+
@@ -14,7 +14,7 @@ var endsWith = function(str, suffix) {
|
|
6
|
+
var run = function(image, opts) {
|
|
7
|
+
if (!opts) opts = {}
|
|
8
|
+
|
|
9
|
+
- var request = docker({host: opts.host, version: opts.version || 'v1.21'})
|
|
10
|
+
+ var request = docker({host: opts.host, version: opts.version || 'v1.44'})
|
|
11
|
+
var that = new events.EventEmitter()
|
|
12
|
+
var tty = !!opts.tty
|
|
13
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/node_modules/@vweevers/docker-pull/index.js b/node_modules/@vweevers/docker-pull/index.js
|
|
2
|
+
index 67b3e73..5fcb567 100644
|
|
3
|
+
--- a/node_modules/@vweevers/docker-pull/index.js
|
|
4
|
+
+++ b/node_modules/@vweevers/docker-pull/index.js
|
|
5
|
+
@@ -12,7 +12,7 @@ var pull = function (image, opts, cb) {
|
|
6
|
+
image = parse(image)
|
|
7
|
+
if (!image) throw new Error('Invalid image')
|
|
8
|
+
|
|
9
|
+
- var request = docker({host: opts.host, version: opts.version || 'v1.21'})
|
|
10
|
+
+ var request = docker({host: opts.host, version: opts.version || 'v1.44'})
|
|
11
|
+
var that = new events.EventEmitter()
|
|
12
|
+
var layers = {}
|
|
13
|
+
var progress = {}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
diff --git a/node_modules/prebuildify-cross/guest.js b/node_modules/prebuildify-cross/guest.js
|
|
2
|
+
index dfd9eb7..6d284fb 100644
|
|
3
|
+
--- a/node_modules/prebuildify-cross/guest.js
|
|
4
|
+
+++ b/node_modules/prebuildify-cross/guest.js
|
|
5
|
+
@@ -9,19 +9,15 @@ const cwd = '/home/node/app'
|
|
6
|
+
const files = JSON.parse(process.env.PREBUILDIFY_CROSS_FILES)
|
|
7
|
+
const argv = process.argv.slice(2)
|
|
8
|
+
|
|
9
|
+
-// Copy host files to working directory
|
|
10
|
+
-for (const file of files) {
|
|
11
|
+
- const a = path.join('/input', file)
|
|
12
|
+
- const b = path.join(cwd, file)
|
|
13
|
+
+// Recursively copy all input files to working directory
|
|
14
|
+
+fs.cpSync('/input', cwd, { recursive: true })
|
|
15
|
+
|
|
16
|
+
- fs.mkdirSync(path.dirname(b), { recursive: true })
|
|
17
|
+
- fs.copyFileSync(a, b, fs.constants.COPYFILE_EXCL)
|
|
18
|
+
- fs.chmodSync(b, 0o644)
|
|
19
|
+
+// Clean build directory if it exists to ensure fresh build
|
|
20
|
+
+const buildDir = path.join(cwd, 'build')
|
|
21
|
+
+if (fs.existsSync(buildDir)) {
|
|
22
|
+
+ fs.rmSync(buildDir, { recursive: true, force: true })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
-// Use node_modules of host to avoid a second install step
|
|
26
|
+
-fs.symlinkSync('/input/node_modules', path.join(cwd, 'node_modules'))
|
|
27
|
+
-
|
|
28
|
+
const stdio = ['ignore', 2, 2]
|
|
29
|
+
const res = cp.spawnSync('npx', ['--no-install', 'prebuildify', ...argv], { cwd, stdio })
|
|
30
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|