@stoprocent/noble 1.10.2 → 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 -194
- 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 -48
- 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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
- beta
|
|
7
|
+
concurrency:
|
|
8
|
+
group: build-${{ github.ref }}
|
|
9
|
+
cancel-in-progress: false
|
|
10
|
+
jobs:
|
|
11
|
+
prebuild:
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
include:
|
|
15
|
+
- name: darwin
|
|
16
|
+
os: macos-11
|
|
17
|
+
node: x64
|
|
18
|
+
command: prebuildify
|
|
19
|
+
args: --arch x64+arm64 --target 18.0.0
|
|
20
|
+
- name: win32-x86
|
|
21
|
+
os: windows-2019
|
|
22
|
+
node: x86
|
|
23
|
+
command: prebuildify
|
|
24
|
+
args: --target 14.0.0
|
|
25
|
+
- name: win32-x64
|
|
26
|
+
os: windows-2019
|
|
27
|
+
node: x64
|
|
28
|
+
command: prebuildify
|
|
29
|
+
args: --target 14.0.0
|
|
30
|
+
- name: linux-x64
|
|
31
|
+
os: ubuntu-latest
|
|
32
|
+
command: prebuildify-cross
|
|
33
|
+
args: -i centos7-devtoolset7 -i alpine
|
|
34
|
+
- name: linux-arm
|
|
35
|
+
os: ubuntu-latest
|
|
36
|
+
command: prebuildify-cross
|
|
37
|
+
args: -i linux-arm64-lts -i linux-armv7 -i linux-armv6
|
|
38
|
+
- name: android-arm
|
|
39
|
+
os: ubuntu-latest
|
|
40
|
+
command: prebuildify-cross
|
|
41
|
+
args: -i android-arm64 -i android-armv7
|
|
42
|
+
name: Build ${{ matrix.name }}
|
|
43
|
+
runs-on: ${{ matrix.os }}
|
|
44
|
+
steps:
|
|
45
|
+
- if: matrix.node
|
|
46
|
+
uses: actions/setup-node@v3
|
|
47
|
+
with:
|
|
48
|
+
node-version: 18.x
|
|
49
|
+
architecture: ${{ matrix.node }}
|
|
50
|
+
- uses: actions/checkout@v3
|
|
51
|
+
- run: npm ci
|
|
52
|
+
- run: npm run ${{ matrix.command }} -- ${{ matrix.args }}
|
|
53
|
+
- uses: actions/upload-artifact@v3
|
|
54
|
+
with:
|
|
55
|
+
name: build-artifacts
|
|
56
|
+
path: prebuilds/
|
|
57
|
+
if-no-files-found: error
|
|
58
|
+
- if: failure()
|
|
59
|
+
run: npx shx ls -lA
|
|
60
|
+
release:
|
|
61
|
+
needs: prebuild
|
|
62
|
+
name: Release
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
steps:
|
|
65
|
+
- uses: actions/checkout@v3
|
|
66
|
+
- uses: actions/download-artifact@v3
|
|
67
|
+
with:
|
|
68
|
+
name: build-artifacts
|
|
69
|
+
path: prebuilds
|
|
70
|
+
- uses: actions/setup-node@v3
|
|
71
|
+
with:
|
|
72
|
+
node-version: 18.x
|
|
73
|
+
- run: npm ci
|
|
74
|
+
- run: npm run semantic-release
|
|
75
|
+
env:
|
|
76
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
77
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -13,23 +13,14 @@ jobs:
|
|
|
13
13
|
runs-on: ${{ matrix.os }}
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
|
-
os: [ubuntu-
|
|
17
|
-
node: [
|
|
16
|
+
os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-2019]
|
|
17
|
+
node: [14, 16, 18, 20]
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
20
|
-
- uses: actions/setup-node@
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- uses: actions/setup-node@v3
|
|
21
21
|
with:
|
|
22
22
|
node-version: ${{ matrix.node }}
|
|
23
|
-
- name: Install dependencies (ubuntu-18.04)
|
|
24
|
-
# Use g++-4.8 only on 'ubuntu-18.04'
|
|
25
|
-
if: ${{ matrix.os == 'ubuntu-18.04' }}
|
|
26
|
-
run: |
|
|
27
|
-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
28
|
-
sudo apt -qq update
|
|
29
|
-
sudo apt install -y g++-4.8
|
|
30
|
-
export CC="g++-4.8"
|
|
31
23
|
- name: Install dependencies (ubuntu-latest)
|
|
32
|
-
# Use g++-9 only on versions after 'ubuntu-18.04'
|
|
33
24
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
34
25
|
run: |
|
|
35
26
|
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
@@ -51,9 +42,9 @@ jobs:
|
|
|
51
42
|
runs-on: ubuntu-latest
|
|
52
43
|
steps:
|
|
53
44
|
- name: ⬇️ Checkout code
|
|
54
|
-
uses: actions/checkout@
|
|
45
|
+
uses: actions/checkout@v3
|
|
55
46
|
- name: 💽 Setup nodejs
|
|
56
|
-
uses: actions/setup-node@
|
|
47
|
+
uses: actions/setup-node@v3
|
|
57
48
|
with:
|
|
58
49
|
node-version: '14'
|
|
59
50
|
- name: 📇 Use npm cache
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@abandonware/noble)
|
|
4
|
+
[](https://www.npmjs.com/package/@abandonware/noble)
|
|
3
5
|
[](https://travis-ci.org/abandonware/noble)
|
|
4
6
|
[](https://gitter.im/abandonware/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](#backers)
|
|
5
7
|
[](#sponsors)
|
|
@@ -23,7 +25,7 @@ __Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only su
|
|
|
23
25
|
```javascript
|
|
24
26
|
// Read the battery level of the first found peripheral exposing the Battery Level characteristic
|
|
25
27
|
|
|
26
|
-
const noble = require('@abandonware/noble')
|
|
28
|
+
const noble = require('@abandonware/noble');
|
|
27
29
|
|
|
28
30
|
noble.on('stateChange', async (state) => {
|
|
29
31
|
if (state === 'poweredOn') {
|
|
@@ -42,6 +44,12 @@ noble.on('discover', async (peripheral) => {
|
|
|
42
44
|
await peripheral.disconnectAsync();
|
|
43
45
|
process.exit(0);
|
|
44
46
|
});
|
|
47
|
+
```
|
|
48
|
+
## Use Noble With BLE5 Extended Features With HCI
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
const noble = require('@abandonware/noble/with-custom-binding')({extended: true});
|
|
52
|
+
|
|
45
53
|
```
|
|
46
54
|
|
|
47
55
|
## Installation
|
|
@@ -60,27 +68,9 @@ noble.on('discover', async (peripheral) => {
|
|
|
60
68
|
|
|
61
69
|
### Prerequisites
|
|
62
70
|
|
|
63
|
-
#### UART
|
|
64
|
-
|
|
65
|
-
The reason for this fork was to create more universal transport that can work across multiple operating systems.
|
|
66
|
-
Idea is to use Zephyr HCI over UART firmware and create noble driver to interface with HCI over UART.
|
|
67
|
-
|
|
68
|
-
##### Known Issues
|
|
69
|
-
What I have found so far that when using extended MTU and sending large amount of data Zephyr stops responding in rare cases. I have played with Zephyr configuration parameters in order to increase buffer sizes but with some luck. Sometimes when transfering fast, large payloads, with high MTU you can still hit the limit and Zephyr needs to be rebooted.
|
|
70
|
-
|
|
71
|
-
##### How to use this?
|
|
71
|
+
#### UART (Any OS)
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
2. If you have `nRF52840 PDK` you can in fact just use compiled HEX [misc/nrf52840dk.hex](misc/nrf52840dk.hex) (Buad Rate set to `1000000`)
|
|
75
|
-
3. If you want to compile it yourself:
|
|
76
|
-
1. You will need to install Zephyr ([https://docs.zephyrproject.org/latest/getting_started/index.html](https://docs.zephyrproject.org/latest/getting_started/index.html))
|
|
77
|
-
2. Compile HCI UART Example - `west build -p auto -b <your-board-name> zephyr/samples/bluetooth/hci_uart`
|
|
78
|
-
- e.g. When using `nRF52840 PDK` call `west build -p auto -b nrf52840dk_nrf52840 zephyr/samples/bluetooth/hci_uart`
|
|
79
|
-
4. Flash the firmware to Nordic Board e.g. using `nrfjprog`
|
|
80
|
-
- e.g. `nrfjprog -f NRF52 --program misc/nrf52840dk.hex –-chiperase --reset`
|
|
81
|
-
5. When you get a nordic board connected to the PC/Mac etc. with UART interface you are good to go.
|
|
82
|
-
6. In order to run any example from the examples folder or your own code you have to provide UART port by defining env variable: `NOBLE_HCI_UART_PORT`. Optionally if you use different Baud Rate you can change it by specifing `NOBLE_HCI_UART_BAUD_RATE`. Default value is `1000000`
|
|
83
|
-
7. e.g. `NOBLE_HCI_UART_PORT=/dev/tty.usbmodem0006837533091 node examples/peripheral-explorer.js b8:27:eb:83:9b:19`
|
|
73
|
+
Please refer to [https://github.com/stoprocent/node-bluetooth-hci-socket#uartserial-any-os](https://github.com/stoprocent/node-bluetooth-hci-socket#uartserial-any-os)
|
|
84
74
|
|
|
85
75
|
#### OS X
|
|
86
76
|
|
|
@@ -181,7 +171,7 @@ set BLUETOOTH_HCI_SOCKET_USB_PID=xxx
|
|
|
181
171
|
```
|
|
182
172
|
|
|
183
173
|
```javascript
|
|
184
|
-
const noble = require('@abandonware/noble')
|
|
174
|
+
const noble = require('@abandonware/noble');
|
|
185
175
|
```
|
|
186
176
|
|
|
187
177
|
## API docs
|
|
@@ -693,7 +683,7 @@ const Noble = require('@abandonware/noble/lib/noble');
|
|
|
693
683
|
const params = {
|
|
694
684
|
deviceId: 0,
|
|
695
685
|
userChannel: true,
|
|
696
|
-
extended: false
|
|
686
|
+
extended: false //ble5 extended features
|
|
697
687
|
};
|
|
698
688
|
|
|
699
689
|
const noble = new Noble(new HCIBindings(params));
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
'variables': {
|
|
3
|
+
'openssl_fips' : ''
|
|
4
|
+
},
|
|
5
|
+
'targets': [
|
|
6
|
+
{
|
|
7
|
+
'target_name': 'noble',
|
|
8
|
+
'conditions': [
|
|
9
|
+
['OS=="mac"', {
|
|
10
|
+
'dependencies': [
|
|
11
|
+
'lib/mac/binding.gyp:binding',
|
|
12
|
+
],
|
|
13
|
+
}],
|
|
14
|
+
['OS=="win"', {
|
|
15
|
+
'dependencies': [
|
|
16
|
+
'lib/win/binding.gyp:binding',
|
|
17
|
+
],
|
|
18
|
+
}],
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Prints timing information from discovered to connected to reading states.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
const noble = require('../index')
|
|
9
|
+
const noble = require('../index');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
|
|
12
12
|
// the sensor value to scan for, number of bits and factor for displaying it
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Prints timing information from discovered to connected to reading states.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
const noble = require('../index')
|
|
9
|
+
const noble = require('../index');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
|
|
12
12
|
// the sensor value to scan for, number of bits and factor for displaying it
|
package/examples/echo.js
CHANGED
package/examples/enter-exit.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
based on code provided by: Mattias Ask (http://www.dittlof.com)
|
|
9
9
|
*/
|
|
10
|
-
const noble = require('../index')
|
|
10
|
+
const noble = require('../index');
|
|
11
11
|
|
|
12
12
|
const RSSI_THRESHOLD = -90;
|
|
13
13
|
const EXIT_GRACE_PERIOD = 2000; // milliseconds
|
|
@@ -25,7 +25,7 @@ noble.on('discover', function (peripheral) {
|
|
|
25
25
|
|
|
26
26
|
if (entered) {
|
|
27
27
|
inRange[id] = {
|
|
28
|
-
peripheral
|
|
28
|
+
peripheral
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
console.log(
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const noble = require('../with-custom-binding')({ extended: true });
|
|
2
|
+
|
|
3
|
+
noble.on('stateChange', function (state) {
|
|
4
|
+
if (state === 'poweredOn') {
|
|
5
|
+
noble.startScanning([], false);
|
|
6
|
+
} else {
|
|
7
|
+
noble.stopScanning();
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
noble.on('discover', function (peripheral) {
|
|
12
|
+
console.log(`${new Date()}`);
|
|
13
|
+
console.log(
|
|
14
|
+
`Peripheral discovered (${peripheral.id} with address <${peripheral.address}, ${peripheral.addressType}>, connectable: ${peripheral.connectable}, scannable: ${peripheral.scannable}, RSSI ${peripheral.rssi}:`
|
|
15
|
+
);
|
|
16
|
+
console.log('\thello my local name is:');
|
|
17
|
+
console.log(`\t\t${peripheral.advertisement.localName}`);
|
|
18
|
+
console.log(
|
|
19
|
+
'\tcan I interest you in any of the following advertised services:'
|
|
20
|
+
);
|
|
21
|
+
console.log(`\t\t${JSON.stringify(peripheral.advertisement.serviceUuids)}`);
|
|
22
|
+
const serviceData = peripheral.advertisement.serviceData;
|
|
23
|
+
|
|
24
|
+
if (serviceData && serviceData.length) {
|
|
25
|
+
console.log('\there is my service data:');
|
|
26
|
+
for (const i in serviceData) {
|
|
27
|
+
console.log(
|
|
28
|
+
`\t\t${JSON.stringify(serviceData[i].uuid)}: ${JSON.stringify(
|
|
29
|
+
serviceData[i].data.toString('hex')
|
|
30
|
+
)}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (peripheral.advertisement.manufacturerData) {
|
|
36
|
+
console.log('\there is my manufacturer data:');
|
|
37
|
+
console.log(
|
|
38
|
+
`\t\t${JSON.stringify(
|
|
39
|
+
peripheral.advertisement.manufacturerData.toString('hex')
|
|
40
|
+
)}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (peripheral.advertisement.txPowerLevel !== undefined) {
|
|
45
|
+
console.log('\tmy TX power level is:');
|
|
46
|
+
console.log(`\t\t${peripheral.advertisement.txPowerLevel}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
process.on('SIGINT', function () {
|
|
53
|
+
console.log('Caught interrupt signal');
|
|
54
|
+
noble.stopScanning(() => process.exit());
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
process.on('SIGQUIT', function () {
|
|
58
|
+
console.log('Caught interrupt signal');
|
|
59
|
+
noble.stopScanning(() => process.exit());
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
process.on('SIGTERM', function () {
|
|
63
|
+
console.log('Caught interrupt signal');
|
|
64
|
+
noble.stopScanning(() => process.exit());
|
|
65
|
+
});
|