@stoprocent/noble 1.10.3 → 1.11.1
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/fediverse-action.yml +16 -0
- package/.github/workflows/nodepackage.yml +6 -15
- package/.github/workflows/npm-publish.yml +2 -2
- package/.github/workflows/prebuild.yml +65 -0
- package/README.md +11 -3
- package/binding.gyp +19 -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 +2 -2
- 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/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 +28 -24
- package/test/lib/distributed/bindings.test.js +15 -15
- package/test/lib/hci-socket/gap.test.js +39 -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/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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# YAML
|
|
2
|
+
---
|
|
3
|
+
name: fediverse-action
|
|
4
|
+
on: [push]
|
|
5
|
+
jobs:
|
|
6
|
+
post:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v3
|
|
10
|
+
- id: log
|
|
11
|
+
run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)"
|
|
12
|
+
- if: "contains(steps.log.outputs.message, 'Release ')"
|
|
13
|
+
uses: rzr/fediverse-action@master
|
|
14
|
+
with:
|
|
15
|
+
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
|
|
16
|
+
message: "https://github.com/${{ github.repository }}/commit/${{ steps.log.outputs.message }} ~ #FediVerseAction"
|
|
@@ -13,23 +13,14 @@ jobs:
|
|
|
13
13
|
runs-on: ${{ matrix.os }}
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
|
-
os: [ubuntu-
|
|
17
|
-
node: [12, 14]
|
|
16
|
+
os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-2019]
|
|
17
|
+
node: [12, 14, 16, 18]
|
|
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
|
|
@@ -14,10 +14,10 @@ jobs:
|
|
|
14
14
|
- if: "contains(steps.log.outputs.message, 'Release ')"
|
|
15
15
|
uses: actions/setup-node@master
|
|
16
16
|
with:
|
|
17
|
-
node-version:
|
|
17
|
+
node-version: 16.0.0
|
|
18
18
|
- if: "contains(steps.log.outputs.message, 'Release ')"
|
|
19
19
|
uses: pascalgn/npm-publish-action@1.3.9
|
|
20
|
-
with: # All of
|
|
20
|
+
with: # All of these inputs are optional
|
|
21
21
|
tag_name: "v%s"
|
|
22
22
|
tag_message: "v%s"
|
|
23
23
|
commit_pattern: "^Release (\\S+)"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: prebuild
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
tags:
|
|
8
|
+
- '*'
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- master
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
prebuild:
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
include:
|
|
19
|
+
- name: darwin
|
|
20
|
+
os: macos-11
|
|
21
|
+
node: x64
|
|
22
|
+
- name: linux
|
|
23
|
+
os: ubuntu-latest
|
|
24
|
+
- name: win32
|
|
25
|
+
os: windows-2019
|
|
26
|
+
name: Build ${{ matrix.name }}
|
|
27
|
+
runs-on: ${{ matrix.os }}
|
|
28
|
+
steps:
|
|
29
|
+
- if: matrix.node
|
|
30
|
+
uses: actions/setup-node@v3
|
|
31
|
+
with:
|
|
32
|
+
node-version: 14.x
|
|
33
|
+
architecture: ${{ matrix.node }}
|
|
34
|
+
- uses: actions/checkout@v3
|
|
35
|
+
- name: Install dependencies (ubuntu-latest)
|
|
36
|
+
# Use g++-9 only on versions after 'ubuntu-18.04'
|
|
37
|
+
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
38
|
+
run: |
|
|
39
|
+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
40
|
+
sudo apt -qq update
|
|
41
|
+
sudo apt install -y g++-9
|
|
42
|
+
export CC="g++-9"
|
|
43
|
+
- run: npm install --ignore-scripts
|
|
44
|
+
- run: npm run prebuild-${{ matrix.name }}
|
|
45
|
+
- run: tar -zcvf ${{ matrix.name }}.tar.gz -C prebuilds .
|
|
46
|
+
- uses: actions/upload-artifact@v2
|
|
47
|
+
with:
|
|
48
|
+
name: ${{ matrix.name }}
|
|
49
|
+
path: ${{ matrix.name }}.tar.gz
|
|
50
|
+
retention-days: 1
|
|
51
|
+
release:
|
|
52
|
+
needs: prebuild
|
|
53
|
+
name: Release
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v3
|
|
58
|
+
- uses: actions/download-artifact@v2
|
|
59
|
+
with:
|
|
60
|
+
path: artifacts
|
|
61
|
+
- uses: docker://antonyurchenko/git-release:v4
|
|
62
|
+
env:
|
|
63
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
64
|
+
with:
|
|
65
|
+
args: artifacts/*/*.tar.gz
|
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
|
|
@@ -181,7 +189,7 @@ set BLUETOOTH_HCI_SOCKET_USB_PID=xxx
|
|
|
181
189
|
```
|
|
182
190
|
|
|
183
191
|
```javascript
|
|
184
|
-
const noble = require('@abandonware/noble')
|
|
192
|
+
const noble = require('@abandonware/noble');
|
|
185
193
|
```
|
|
186
194
|
|
|
187
195
|
## API docs
|
|
@@ -693,7 +701,7 @@ const Noble = require('@abandonware/noble/lib/noble');
|
|
|
693
701
|
const params = {
|
|
694
702
|
deviceId: 0,
|
|
695
703
|
userChannel: true,
|
|
696
|
-
extended: false
|
|
704
|
+
extended: false //ble5 extended features
|
|
697
705
|
};
|
|
698
706
|
|
|
699
707
|
const noble = new Noble(new HCIBindings(params));
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
'targets': [
|
|
3
|
+
{
|
|
4
|
+
'target_name': 'noble',
|
|
5
|
+
'conditions': [
|
|
6
|
+
['OS=="mac"', {
|
|
7
|
+
'dependencies': [
|
|
8
|
+
'lib/mac/binding.gyp:binding',
|
|
9
|
+
],
|
|
10
|
+
}],
|
|
11
|
+
['OS=="win"', {
|
|
12
|
+
'dependencies': [
|
|
13
|
+
'lib/win/binding.gyp:binding',
|
|
14
|
+
],
|
|
15
|
+
}],
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
}
|
|
@@ -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
|
+
});
|