@stoprocent/noble 1.10.3 → 1.10.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/.github/workflows/build.yml +77 -0
- package/.github/workflows/nodepackage.yml +6 -15
- package/README.md +13 -23
- package/binding.gyp +22 -0
- package/examples/advertisement-discovery.js +1 -1
- package/examples/cache-gatt-discovery.js +1 -1
- package/examples/cache-gatt-reconnect.js +1 -1
- package/examples/echo.js +1 -1
- package/examples/enter-exit.js +2 -2
- package/examples/ext-advertisement-discovery.js +65 -0
- package/examples/peripheral-explorer-async.js +1 -1
- package/examples/peripheral-explorer.js +1 -1
- package/examples/pizza/central.js +1 -1
- package/index.d.ts +187 -196
- package/index.js +1 -6
- package/lib/distributed/bindings.js +33 -33
- package/lib/hci-socket/bindings.js +1 -3
- package/lib/hci-socket/crypto.js +4 -4
- package/lib/hci-socket/gap.js +22 -18
- package/lib/hci-socket/gatt.js +4 -4
- package/lib/hci-socket/hci.js +3 -3
- package/lib/mac/binding.gyp +23 -11
- package/lib/noble.js +10 -6
- package/lib/peripheral.js +0 -7
- package/lib/resolve-bindings.js +39 -3
- package/lib/webbluetooth/bindings.js +2 -2
- package/lib/websocket/bindings.js +32 -32
- package/lib/win/binding.gyp +25 -5
- package/lib/win/src/ble_manager.cc +4 -1
- package/lib/win/src/ble_manager.h +1 -1
- package/lib/win/src/peripheral_winrt.cc +2 -0
- package/lib/win/src/radio_watcher.cc +1 -0
- package/lib/win/src/winrt_cpp.cc +1 -0
- package/package.json +31 -37
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/test/lib/distributed/bindings.test.js +15 -15
- package/test/lib/hci-socket/gap.test.js +39 -0
- package/test/lib/hci-socket/hci.test.js +1 -1
- package/test/lib/resolve-bindings.test.js +102 -0
- package/test/lib/webbluetooth/bindings.test.js +2 -2
- package/test/lib/websocket/bindings.test.js +2 -2
- package/test/mocha.setup.js +0 -0
- package/test/noble.test.js +12 -11
- package/test.custom.js +131 -0
- package/test.js +1 -1
- package/with-custom-binding.js +6 -0
- package/ws-slave.js +10 -10
- package/.github/workflows/npm-publish.yml +0 -26
- package/lib/hci-uart/bindings.js +0 -569
- package/lib/hci-uart/hci-serial-parser.js +0 -70
- package/lib/hci-uart/hci.js +0 -1360
- package/lib/manufacture.js +0 -46
- package/misc/0001-hci-uart-on-usb-cdc.patch +0 -161
- package/misc/nrf52840-usb-cdc.hex +0 -8907
- package/misc/nrf52840dk.hex +0 -6921
- package/misc/prj.conf +0 -43
- package/test/lib/manufacture.test.js +0 -77
package/lib/hci-socket/gatt.js
CHANGED
|
@@ -199,9 +199,9 @@ Gatt.prototype.errorResponse = function (opcode, handle, status) {
|
|
|
199
199
|
|
|
200
200
|
Gatt.prototype._queueCommand = function (buffer, callback, writeCallback) {
|
|
201
201
|
this._commandQueue.push({
|
|
202
|
-
buffer
|
|
203
|
-
callback
|
|
204
|
-
writeCallback
|
|
202
|
+
buffer,
|
|
203
|
+
callback,
|
|
204
|
+
writeCallback
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
if (this._currentCommand === null) {
|
|
@@ -375,7 +375,7 @@ Gatt.prototype.discoverServices = function (uuids) {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
if (
|
|
378
|
+
if (opcode !== ATT_OP_READ_BY_GROUP_RESP || services[services.length - 1].endHandle === 0xffff) {
|
|
379
379
|
const serviceUuids = [];
|
|
380
380
|
for (i = 0; i < services.length; i++) {
|
|
381
381
|
const uuid = services[i].uuid.trim();
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -3,7 +3,7 @@ const debug = require('debug')('hci');
|
|
|
3
3
|
const events = require('events');
|
|
4
4
|
const util = require('util');
|
|
5
5
|
|
|
6
|
-
const BluetoothHciSocket = require('@
|
|
6
|
+
const BluetoothHciSocket = require('@stoprocent/bluetooth-hci-socket');
|
|
7
7
|
|
|
8
8
|
const HCI_COMMAND_PKT = 0x01;
|
|
9
9
|
const HCI_ACLDATA_PKT = 0x02;
|
|
@@ -845,8 +845,8 @@ Hci.prototype.onSocketData = function (data) {
|
|
|
845
845
|
this.emit('aclDataPkt', handle, cid, pktData);
|
|
846
846
|
} else {
|
|
847
847
|
this._handleBuffers[handle] = {
|
|
848
|
-
length
|
|
849
|
-
cid
|
|
848
|
+
length,
|
|
849
|
+
cid,
|
|
850
850
|
data: pktData
|
|
851
851
|
};
|
|
852
852
|
}
|
package/lib/mac/binding.gyp
CHANGED
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
+
'variables': {
|
|
3
|
+
'openssl_fips' : ''
|
|
4
|
+
},
|
|
2
5
|
'targets': [
|
|
3
6
|
{
|
|
4
7
|
'target_name': 'binding',
|
|
5
|
-
'sources': [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
'sources': [
|
|
9
|
+
'src/noble_mac.mm',
|
|
10
|
+
'src/napi_objc.mm',
|
|
11
|
+
'src/ble_manager.mm',
|
|
12
|
+
'src/objc_cpp.mm',
|
|
13
|
+
'src/callbacks.cc'
|
|
14
|
+
],
|
|
15
|
+
'include_dirs': [
|
|
16
|
+
"<!(node -p \"require('node-addon-api').include_dir\")"
|
|
17
|
+
],
|
|
8
18
|
'cflags!': [ '-fno-exceptions' ],
|
|
9
19
|
'cflags_cc!': [ '-fno-exceptions' ],
|
|
20
|
+
"defines": ["NAPI_CPP_EXCEPTIONS"],
|
|
10
21
|
'xcode_settings': {
|
|
11
22
|
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
|
23
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.9',
|
|
12
24
|
'CLANG_CXX_LIBRARY': 'libc++',
|
|
13
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
|
14
25
|
'OTHER_CFLAGS': [
|
|
15
|
-
|
|
26
|
+
'-fobjc-arc',
|
|
27
|
+
'-arch x86_64',
|
|
28
|
+
'-arch arm64'
|
|
16
29
|
],
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'
|
|
30
|
+
'OTHER_LDFLAGS': [
|
|
31
|
+
'-framework CoreBluetooth',
|
|
32
|
+
'-arch x86_64',
|
|
33
|
+
'-arch arm64'
|
|
21
34
|
]
|
|
22
|
-
}
|
|
23
|
-
'product_dir': '../lib/mac/native',
|
|
35
|
+
}
|
|
24
36
|
}
|
|
25
37
|
]
|
|
26
38
|
}
|
package/lib/noble.js
CHANGED
|
@@ -18,7 +18,7 @@ function Noble (bindings) {
|
|
|
18
18
|
this._services = {};
|
|
19
19
|
this._characteristics = {};
|
|
20
20
|
this._descriptors = {};
|
|
21
|
-
this._discoveredPeripheralUUids =
|
|
21
|
+
this._discoveredPeripheralUUids = {};
|
|
22
22
|
|
|
23
23
|
this._bindings.on('stateChange', this.onStateChange.bind(this));
|
|
24
24
|
this._bindings.on('addressChange', this.onAddressChange.bind(this));
|
|
@@ -58,7 +58,11 @@ function Noble (bindings) {
|
|
|
58
58
|
this.initialized = true;
|
|
59
59
|
|
|
60
60
|
process.nextTick(() => {
|
|
61
|
-
|
|
61
|
+
try {
|
|
62
|
+
this._bindings.init();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
this.emit('warning', 'Initialization of USB device failed: ' + error.message);
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
});
|
|
@@ -131,7 +135,7 @@ const startScanning = function (serviceUuids, allowDuplicates, callback) {
|
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
this._discoveredPeripheralUUids =
|
|
138
|
+
this._discoveredPeripheralUUids = {};
|
|
135
139
|
this._allowDuplicates = allowDuplicates;
|
|
136
140
|
|
|
137
141
|
this._bindings.startScanning(serviceUuids, allowDuplicates);
|
|
@@ -204,10 +208,10 @@ Noble.prototype.onDiscover = function (uuid, address, addressType, connectable,
|
|
|
204
208
|
peripheral.rssi = rssi;
|
|
205
209
|
}
|
|
206
210
|
|
|
207
|
-
const previouslyDiscoverd =
|
|
211
|
+
const previouslyDiscoverd = this._discoveredPeripheralUUids[uuid] === true;
|
|
208
212
|
|
|
209
213
|
if (!previouslyDiscoverd) {
|
|
210
|
-
this._discoveredPeripheralUUids
|
|
214
|
+
this._discoveredPeripheralUUids[uuid] = true;
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
if (this._allowDuplicates || !previouslyDiscoverd || (!scannable && !connectable)) {
|
|
@@ -587,7 +591,7 @@ Noble.prototype.onHandleNotify = function (peripheralUuid, handle, data) {
|
|
|
587
591
|
|
|
588
592
|
Noble.prototype.onMtu = function (peripheralUuid, mtu) {
|
|
589
593
|
const peripheral = this._peripherals[peripheralUuid];
|
|
590
|
-
if (peripheral &&
|
|
594
|
+
if (peripheral && mtu) peripheral.mtu = mtu;
|
|
591
595
|
};
|
|
592
596
|
|
|
593
597
|
module.exports = Noble;
|
package/lib/peripheral.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const events = require('events');
|
|
2
2
|
const util = require('util');
|
|
3
3
|
|
|
4
|
-
const Manufacturer = require('./manufacture');
|
|
5
|
-
|
|
6
4
|
function Peripheral (noble, id, address, addressType, connectable, advertisement, rssi, scannable) {
|
|
7
5
|
this._noble = noble;
|
|
8
6
|
|
|
@@ -17,11 +15,6 @@ function Peripheral (noble, id, address, addressType, connectable, advertisement
|
|
|
17
15
|
this.services = null;
|
|
18
16
|
this.mtu = null;
|
|
19
17
|
this.state = 'disconnected';
|
|
20
|
-
this.manufacturer = null;
|
|
21
|
-
|
|
22
|
-
if (typeof this.advertisement !== 'undefined' && typeof this.advertisement.manufacturerData !== 'undefined') {
|
|
23
|
-
this.manufacturer = new Manufacturer(noble, this.advertisement.manufacturerData);
|
|
24
|
-
}
|
|
25
18
|
}
|
|
26
19
|
|
|
27
20
|
util.inherits(Peripheral, events.EventEmitter);
|
package/lib/resolve-bindings.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
const os = require('os');
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
function getWindowsBindings () {
|
|
4
|
+
const ver = os
|
|
5
|
+
.release()
|
|
6
|
+
.split('.')
|
|
7
|
+
.map((str) => parseInt(str, 10));
|
|
8
|
+
if (
|
|
9
|
+
!(
|
|
10
|
+
ver[0] > 10 ||
|
|
11
|
+
(ver[0] === 10 && ver[1] > 0) ||
|
|
12
|
+
(ver[0] === 10 && ver[1] === 0 && ver[2] >= 15063)
|
|
13
|
+
)
|
|
14
|
+
) {
|
|
15
|
+
return require('./hci-socket/bindings');
|
|
16
|
+
} else {
|
|
17
|
+
return require('./win/bindings');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = function (options = {}) {
|
|
22
|
+
const platform = os.platform();
|
|
23
|
+
|
|
24
|
+
if (process.env.NOBLE_WEBSOCKET) {
|
|
25
|
+
return new (require('./websocket/bindings'))(options);
|
|
26
|
+
} else if (process.env.NOBLE_DISTRIBUTED) {
|
|
27
|
+
return new (require('./distributed/bindings'))(options);
|
|
28
|
+
} else if (
|
|
29
|
+
platform === 'linux' ||
|
|
30
|
+
platform === 'freebsd' ||
|
|
31
|
+
(process.env.BLUETOOTH_HCI_SOCKET_UART_PORT ||
|
|
32
|
+
process.env.BLUETOOTH_HCI_SOCKET_FORCE_UART) ||
|
|
33
|
+
(process.env.BLUETOOTH_HCI_SOCKET_USB_VID &&
|
|
34
|
+
process.env.BLUETOOTH_HCI_SOCKET_USB_PID)
|
|
35
|
+
) {
|
|
36
|
+
return new (require('./hci-socket/bindings'))(options);
|
|
37
|
+
} else if (platform === 'darwin') {
|
|
38
|
+
return new (require('./mac/bindings'))(options);
|
|
39
|
+
} else if (platform === 'win32') {
|
|
40
|
+
return new (getWindowsBindings())(options);
|
|
5
41
|
} else {
|
|
6
42
|
throw new Error('Unsupported platform');
|
|
7
43
|
}
|
|
@@ -109,9 +109,9 @@ NobleBindings.prototype.startScanning = function (options, allowDuplicates) {
|
|
|
109
109
|
|
|
110
110
|
self._peripherals[address] = {
|
|
111
111
|
uuid: address,
|
|
112
|
-
address
|
|
112
|
+
address,
|
|
113
113
|
advertisement: { localName: device.name }, // advertisement,
|
|
114
|
-
device
|
|
114
|
+
device,
|
|
115
115
|
cachedServices: {},
|
|
116
116
|
localName: device.name,
|
|
117
117
|
serviceUuids: options.services
|
|
@@ -79,9 +79,9 @@ NobleBindings.prototype._onMessage = function (event) {
|
|
|
79
79
|
|
|
80
80
|
this._peripherals[peripheralUuid] = {
|
|
81
81
|
uuid: peripheralUuid,
|
|
82
|
-
address
|
|
83
|
-
advertisement
|
|
84
|
-
rssi
|
|
82
|
+
address,
|
|
83
|
+
advertisement,
|
|
84
|
+
rssi
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
this.emit('discover', peripheralUuid, address, addressType, connectable, advertisement, rssi);
|
|
@@ -135,8 +135,8 @@ NobleBindings.prototype._sendCommand = function (command, errorCallback) {
|
|
|
135
135
|
NobleBindings.prototype.startScanning = function (serviceUuids, allowDuplicates) {
|
|
136
136
|
this._startScanCommand = {
|
|
137
137
|
action: 'startScanning',
|
|
138
|
-
serviceUuids
|
|
139
|
-
allowDuplicates
|
|
138
|
+
serviceUuids,
|
|
139
|
+
allowDuplicates
|
|
140
140
|
};
|
|
141
141
|
this._sendCommand(this._startScanCommand);
|
|
142
142
|
|
|
@@ -186,7 +186,7 @@ NobleBindings.prototype.discoverServices = function (deviceUuid, uuids) {
|
|
|
186
186
|
this._sendCommand({
|
|
187
187
|
action: 'discoverServices',
|
|
188
188
|
peripheralUuid: peripheral.uuid,
|
|
189
|
-
uuids
|
|
189
|
+
uuids
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
192
|
|
|
@@ -196,8 +196,8 @@ NobleBindings.prototype.discoverIncludedServices = function (deviceUuid, service
|
|
|
196
196
|
this._sendCommand({
|
|
197
197
|
action: 'discoverIncludedServices',
|
|
198
198
|
peripheralUuid: peripheral.uuid,
|
|
199
|
-
serviceUuid
|
|
200
|
-
serviceUuids
|
|
199
|
+
serviceUuid,
|
|
200
|
+
serviceUuids
|
|
201
201
|
});
|
|
202
202
|
};
|
|
203
203
|
|
|
@@ -207,8 +207,8 @@ NobleBindings.prototype.discoverCharacteristics = function (deviceUuid, serviceU
|
|
|
207
207
|
this._sendCommand({
|
|
208
208
|
action: 'discoverCharacteristics',
|
|
209
209
|
peripheralUuid: peripheral.uuid,
|
|
210
|
-
serviceUuid
|
|
211
|
-
characteristicUuids
|
|
210
|
+
serviceUuid,
|
|
211
|
+
characteristicUuids
|
|
212
212
|
});
|
|
213
213
|
};
|
|
214
214
|
|
|
@@ -218,8 +218,8 @@ NobleBindings.prototype.read = function (deviceUuid, serviceUuid, characteristic
|
|
|
218
218
|
this._sendCommand({
|
|
219
219
|
action: 'read',
|
|
220
220
|
peripheralUuid: peripheral.uuid,
|
|
221
|
-
serviceUuid
|
|
222
|
-
characteristicUuid
|
|
221
|
+
serviceUuid,
|
|
222
|
+
characteristicUuid
|
|
223
223
|
});
|
|
224
224
|
};
|
|
225
225
|
|
|
@@ -229,10 +229,10 @@ NobleBindings.prototype.write = function (deviceUuid, serviceUuid, characteristi
|
|
|
229
229
|
this._sendCommand({
|
|
230
230
|
action: 'write',
|
|
231
231
|
peripheralUuid: peripheral.uuid,
|
|
232
|
-
serviceUuid
|
|
233
|
-
characteristicUuid
|
|
232
|
+
serviceUuid,
|
|
233
|
+
characteristicUuid,
|
|
234
234
|
data: data.toString('hex'),
|
|
235
|
-
withoutResponse
|
|
235
|
+
withoutResponse
|
|
236
236
|
});
|
|
237
237
|
};
|
|
238
238
|
|
|
@@ -242,9 +242,9 @@ NobleBindings.prototype.broadcast = function (deviceUuid, serviceUuid, character
|
|
|
242
242
|
this._sendCommand({
|
|
243
243
|
action: 'broadcast',
|
|
244
244
|
peripheralUuid: peripheral.uuid,
|
|
245
|
-
serviceUuid
|
|
246
|
-
characteristicUuid
|
|
247
|
-
broadcast
|
|
245
|
+
serviceUuid,
|
|
246
|
+
characteristicUuid,
|
|
247
|
+
broadcast
|
|
248
248
|
});
|
|
249
249
|
};
|
|
250
250
|
|
|
@@ -254,9 +254,9 @@ NobleBindings.prototype.notify = function (deviceUuid, serviceUuid, characterist
|
|
|
254
254
|
this._sendCommand({
|
|
255
255
|
action: 'notify',
|
|
256
256
|
peripheralUuid: peripheral.uuid,
|
|
257
|
-
serviceUuid
|
|
258
|
-
characteristicUuid
|
|
259
|
-
notify
|
|
257
|
+
serviceUuid,
|
|
258
|
+
characteristicUuid,
|
|
259
|
+
notify
|
|
260
260
|
});
|
|
261
261
|
};
|
|
262
262
|
|
|
@@ -266,8 +266,8 @@ NobleBindings.prototype.discoverDescriptors = function (deviceUuid, serviceUuid,
|
|
|
266
266
|
this._sendCommand({
|
|
267
267
|
action: 'discoverDescriptors',
|
|
268
268
|
peripheralUuid: peripheral.uuid,
|
|
269
|
-
serviceUuid
|
|
270
|
-
characteristicUuid
|
|
269
|
+
serviceUuid,
|
|
270
|
+
characteristicUuid
|
|
271
271
|
});
|
|
272
272
|
};
|
|
273
273
|
|
|
@@ -277,9 +277,9 @@ NobleBindings.prototype.readValue = function (deviceUuid, serviceUuid, character
|
|
|
277
277
|
this._sendCommand({
|
|
278
278
|
action: 'readValue',
|
|
279
279
|
peripheralUuid: peripheral.uuid,
|
|
280
|
-
serviceUuid
|
|
281
|
-
characteristicUuid
|
|
282
|
-
descriptorUuid
|
|
280
|
+
serviceUuid,
|
|
281
|
+
characteristicUuid,
|
|
282
|
+
descriptorUuid
|
|
283
283
|
});
|
|
284
284
|
};
|
|
285
285
|
|
|
@@ -289,9 +289,9 @@ NobleBindings.prototype.writeValue = function (deviceUuid, serviceUuid, characte
|
|
|
289
289
|
this._sendCommand({
|
|
290
290
|
action: 'writeValue',
|
|
291
291
|
peripheralUuid: peripheral.uuid,
|
|
292
|
-
serviceUuid
|
|
293
|
-
characteristicUuid
|
|
294
|
-
descriptorUuid
|
|
292
|
+
serviceUuid,
|
|
293
|
+
characteristicUuid,
|
|
294
|
+
descriptorUuid,
|
|
295
295
|
data: data.toString('hex')
|
|
296
296
|
});
|
|
297
297
|
};
|
|
@@ -302,7 +302,7 @@ NobleBindings.prototype.readHandle = function (deviceUuid, handle) {
|
|
|
302
302
|
this._sendCommand({
|
|
303
303
|
action: 'readHandle',
|
|
304
304
|
peripheralUuid: peripheral.uuid,
|
|
305
|
-
handle
|
|
305
|
+
handle
|
|
306
306
|
});
|
|
307
307
|
};
|
|
308
308
|
|
|
@@ -312,9 +312,9 @@ NobleBindings.prototype.writeHandle = function (deviceUuid, handle, data, withou
|
|
|
312
312
|
this._sendCommand({
|
|
313
313
|
action: 'writeHandle',
|
|
314
314
|
peripheralUuid: peripheral.uuid,
|
|
315
|
-
handle
|
|
315
|
+
handle,
|
|
316
316
|
data: data.toString('hex'),
|
|
317
|
-
withoutResponse
|
|
317
|
+
withoutResponse
|
|
318
318
|
});
|
|
319
319
|
};
|
|
320
320
|
|
package/lib/win/binding.gyp
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
+
'variables': {
|
|
3
|
+
'openssl_fips' : ''
|
|
4
|
+
},
|
|
2
5
|
'targets': [
|
|
3
6
|
{
|
|
4
7
|
'target_name': 'binding',
|
|
5
|
-
'sources': [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
'sources': [
|
|
9
|
+
'src/noble_winrt.cc',
|
|
10
|
+
'src/napi_winrt.cc',
|
|
11
|
+
'src/peripheral_winrt.cc',
|
|
12
|
+
'src/radio_watcher.cc',
|
|
13
|
+
'src/notify_map.cc',
|
|
14
|
+
'src/ble_manager.cc',
|
|
15
|
+
'src/winrt_cpp.cc',
|
|
16
|
+
'src/winrt_guid.cc',
|
|
17
|
+
'src/callbacks.cc'
|
|
18
|
+
],
|
|
19
|
+
'include_dirs': [
|
|
20
|
+
"<!(node -p \"require('node-addon-api').include_dir\")",
|
|
21
|
+
"<!@(node -p \"require('napi-thread-safe-callback').include\")"
|
|
22
|
+
],
|
|
8
23
|
'cflags!': [ '-fno-exceptions' ],
|
|
9
24
|
'cflags_cc!': [ '-fno-exceptions' ],
|
|
10
25
|
'msvs_settings': {
|
|
11
26
|
'VCCLCompilerTool': {
|
|
12
27
|
'ExceptionHandling': 1,
|
|
13
|
-
'AdditionalOptions': [
|
|
28
|
+
'AdditionalOptions': [
|
|
29
|
+
'/await',
|
|
30
|
+
'/std:c++latest'
|
|
31
|
+
],
|
|
14
32
|
},
|
|
15
33
|
},
|
|
16
34
|
'msvs_target_platform_version':'10.0.18362.0',
|
|
17
35
|
'msvs_target_platform_minversion':'10.0.18362.0',
|
|
18
36
|
'conditions': [
|
|
19
|
-
['OS=="win"', {
|
|
37
|
+
['OS=="win"', {
|
|
38
|
+
'defines': [ '_HAS_EXCEPTIONS=1' ]
|
|
39
|
+
}]
|
|
20
40
|
],
|
|
21
41
|
}
|
|
22
42
|
]
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
#include <winrt/Windows.Storage.Streams.h>
|
|
13
13
|
using winrt::Windows::Devices::Bluetooth::BluetoothCacheMode;
|
|
14
14
|
using winrt::Windows::Devices::Bluetooth::BluetoothConnectionStatus;
|
|
15
|
+
using winrt::Windows::Devices::Bluetooth::BluetoothLEDevice;
|
|
15
16
|
using winrt::Windows::Storage::Streams::DataReader;
|
|
16
17
|
using winrt::Windows::Storage::Streams::DataWriter;
|
|
18
|
+
using winrt::Windows::Storage::Streams::IBuffer;
|
|
17
19
|
|
|
18
20
|
template <typename T> auto inFilter(std::vector<T> filter, T object)
|
|
19
21
|
{
|
|
@@ -190,7 +192,7 @@ bool BLEManager::Connect(const std::string& uuid)
|
|
|
190
192
|
return true;
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
void BLEManager::OnConnected(IAsyncOperation<BluetoothLEDevice> asyncOp, AsyncStatus
|
|
195
|
+
void BLEManager::OnConnected(IAsyncOperation<BluetoothLEDevice> asyncOp, AsyncStatus status,
|
|
194
196
|
const std::string uuid)
|
|
195
197
|
{
|
|
196
198
|
if (status == AsyncStatus::Completed)
|
|
@@ -375,6 +377,7 @@ void BLEManager::OnCharacteristicsDiscovered(IAsyncOperation<GattCharacteristics
|
|
|
375
377
|
auto result = asyncOp.GetResults();
|
|
376
378
|
CHECK_RESULT(result);
|
|
377
379
|
std::vector<std::pair<std::string, std::vector<std::string>>> characteristicsUuids;
|
|
380
|
+
|
|
378
381
|
FOR(characteristic, result.Characteristics())
|
|
379
382
|
{
|
|
380
383
|
auto id = characteristic.Uuid();
|
|
@@ -47,7 +47,7 @@ private:
|
|
|
47
47
|
void OnRadio(Radio& radio);
|
|
48
48
|
void OnScanResult(BluetoothLEAdvertisementWatcher watcher, const BluetoothLEAdvertisementReceivedEventArgs& args);
|
|
49
49
|
void OnScanStopped(BluetoothLEAdvertisementWatcher watcher, const BluetoothLEAdvertisementWatcherStoppedEventArgs& args);
|
|
50
|
-
void OnConnected(IAsyncOperation<BluetoothLEDevice> asyncOp, AsyncStatus
|
|
50
|
+
void OnConnected(IAsyncOperation<BluetoothLEDevice> asyncOp, AsyncStatus status, std::string uuid);
|
|
51
51
|
void OnConnectionStatusChanged(BluetoothLEDevice device, winrt::Windows::Foundation::IInspectable inspectable);
|
|
52
52
|
void OnServicesDiscovered(IAsyncOperation<GattDeviceServicesResult> asyncOp, AsyncStatus status, std::string uuid, std::vector<winrt::guid> serviceUUIDs);
|
|
53
53
|
void OnIncludedServicesDiscovered(IAsyncOperation<GattDeviceServicesResult> asyncOp, AsyncStatus status, std::string uuid, std::string serviceId, std::vector<winrt::guid> serviceUUIDs);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "winrt_cpp.h"
|
|
3
3
|
|
|
4
4
|
#include <winrt/Windows.Storage.Streams.h>
|
|
5
|
+
#include <winrt/Windows.Foundation.Collections.h>
|
|
5
6
|
using namespace winrt::Windows::Storage::Streams;
|
|
6
7
|
|
|
7
8
|
using winrt::Windows::Devices::Bluetooth::BluetoothCacheMode;
|
|
@@ -43,6 +44,7 @@ void PeripheralWinrt::Update(const int rssiValue, const BluetoothLEAdvertisement
|
|
|
43
44
|
advertismentType == BluetoothLEAdvertisementType::ConnectableDirected;
|
|
44
45
|
|
|
45
46
|
manufacturerData.clear();
|
|
47
|
+
|
|
46
48
|
for (auto ds : advertisment.DataSections())
|
|
47
49
|
{
|
|
48
50
|
if (ds.DataType() == BluetoothLEAdvertisementDataTypes::TxPowerLevel())
|
package/lib/win/src/winrt_cpp.cc
CHANGED
package/package.json
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
"author": "Sandeep Mistry",
|
|
3
3
|
"maintainers": [
|
|
4
4
|
"Jacob Rosenthal",
|
|
5
|
-
"Luis Montes"
|
|
5
|
+
"Luis Montes",
|
|
6
|
+
"Marek Serafin"
|
|
6
7
|
],
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"name": "@stoprocent/noble",
|
|
9
10
|
"description": "A Node.js BLE (Bluetooth Low Energy) central library.",
|
|
10
|
-
"version": "1.10.
|
|
11
|
+
"version": "1.10.4",
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
13
|
-
"url": "
|
|
14
|
+
"url": "https://github.com/stoprocent/noble.git"
|
|
14
15
|
},
|
|
15
16
|
"bugs": {
|
|
16
17
|
"url": "https://github.com/stoprocent/noble/issues"
|
|
@@ -28,57 +29,50 @@
|
|
|
28
29
|
"engines": {
|
|
29
30
|
"node": ">=6"
|
|
30
31
|
},
|
|
31
|
-
"os": [
|
|
32
|
-
"darwin",
|
|
33
|
-
"linux",
|
|
34
|
-
"freebsd",
|
|
35
|
-
"win32"
|
|
36
|
-
],
|
|
37
32
|
"dependencies": {
|
|
38
|
-
"debug": "^4.3.
|
|
33
|
+
"debug": "^4.3.4",
|
|
34
|
+
"napi-thread-safe-callback": "^0.0.6",
|
|
35
|
+
"node-addon-api": "^4.3.0",
|
|
36
|
+
"node-gyp-build": "^4.5.0"
|
|
39
37
|
},
|
|
40
38
|
"optionalDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"serialport": "^10.4.0"
|
|
39
|
+
"@stoprocent/bluetooth-hci-socket": "^0.6.4"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
|
-
"
|
|
42
|
+
"@semantic-release/exec": "6.0.3",
|
|
43
|
+
"async": "^3.2.4",
|
|
46
44
|
"cross-env": "^7.0.3",
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-config-semistandard": "^
|
|
49
|
-
"eslint-config-standard": "^
|
|
50
|
-
"eslint-plugin-import": "^2.
|
|
51
|
-
"eslint-plugin-
|
|
52
|
-
"eslint-plugin-promise": "^
|
|
53
|
-
"mocha": "^
|
|
54
|
-
"node-gyp": "^
|
|
45
|
+
"eslint": "^8.31.0",
|
|
46
|
+
"eslint-config-semistandard": "^17.0.0",
|
|
47
|
+
"eslint-config-standard": "^17.0.0",
|
|
48
|
+
"eslint-plugin-import": "^2.26.0",
|
|
49
|
+
"eslint-plugin-n": "^15.6.0",
|
|
50
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
51
|
+
"mocha": "^10.2.0",
|
|
52
|
+
"node-gyp": "^9.4.0",
|
|
55
53
|
"nyc": "^15.1.0",
|
|
56
|
-
"prebuildify": "^5.0.
|
|
57
|
-
"prebuildify-
|
|
58
|
-
"prettier": "^2.
|
|
54
|
+
"prebuildify": "^5.0.1",
|
|
55
|
+
"prebuildify-cross": "5.0.0",
|
|
56
|
+
"prettier": "^2.8.1",
|
|
59
57
|
"proxyquire": "^2.1.3",
|
|
58
|
+
"semantic-release": "21.1.0",
|
|
60
59
|
"should": "~13.2.3",
|
|
61
|
-
"sinon": "^
|
|
62
|
-
"ws": "^8.
|
|
60
|
+
"sinon": "^15.0.1",
|
|
61
|
+
"ws": "^8.11.0"
|
|
63
62
|
},
|
|
64
63
|
"scripts": {
|
|
64
|
+
"install": "node-gyp-build",
|
|
65
65
|
"lint": "eslint \"**/*.js\"",
|
|
66
66
|
"lint-fix": "eslint \"**/*.js\" --fix",
|
|
67
|
+
"prebuildify": "prebuildify --napi --target 14.0.0 --force --strip --verbose",
|
|
68
|
+
"prebuildify-cross": "prebuildify-cross --napi --target 14.0.0 --force --strip --verbose",
|
|
69
|
+
"semantic-release": "semantic-release",
|
|
70
|
+
"pretest": "npm run rebuild",
|
|
71
|
+
"rebuild": "node-gyp rebuild",
|
|
67
72
|
"coverage": "nyc npm test && nyc report --reporter=text-lcov > .nyc_output/lcov.info",
|
|
68
73
|
"test": "cross-env NODE_ENV=test mocha --recursive \"test/*.test.js\" \"test/**/*.test.js\" --exit"
|
|
69
74
|
},
|
|
70
75
|
"browser": {
|
|
71
76
|
"./lib/resolve-bindings.js": "./lib/resolve-bindings-web.js"
|
|
72
|
-
},
|
|
73
|
-
"binary": {
|
|
74
|
-
"napi_versions": [
|
|
75
|
-
4
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
"homepage": "https://github.com/stoprocent/noble#readme",
|
|
79
|
-
"directories": {
|
|
80
|
-
"example": "examples",
|
|
81
|
-
"lib": "lib",
|
|
82
|
-
"test": "test"
|
|
83
77
|
}
|
|
84
78
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|