@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.
Files changed (53) hide show
  1. package/.github/workflows/fediverse-action.yml +16 -0
  2. package/.github/workflows/nodepackage.yml +6 -15
  3. package/.github/workflows/npm-publish.yml +2 -2
  4. package/.github/workflows/prebuild.yml +65 -0
  5. package/README.md +11 -3
  6. package/binding.gyp +19 -0
  7. package/examples/advertisement-discovery.js +1 -1
  8. package/examples/cache-gatt-discovery.js +1 -1
  9. package/examples/cache-gatt-reconnect.js +1 -1
  10. package/examples/echo.js +1 -1
  11. package/examples/enter-exit.js +2 -2
  12. package/examples/ext-advertisement-discovery.js +65 -0
  13. package/examples/peripheral-explorer-async.js +1 -1
  14. package/examples/peripheral-explorer.js +1 -1
  15. package/examples/pizza/central.js +1 -1
  16. package/index.d.ts +187 -196
  17. package/index.js +1 -6
  18. package/lib/distributed/bindings.js +33 -33
  19. package/lib/hci-socket/bindings.js +1 -3
  20. package/lib/hci-socket/crypto.js +4 -4
  21. package/lib/hci-socket/gap.js +22 -18
  22. package/lib/hci-socket/gatt.js +4 -4
  23. package/lib/hci-socket/hci.js +2 -2
  24. package/lib/noble.js +10 -6
  25. package/lib/peripheral.js +0 -7
  26. package/lib/resolve-bindings.js +39 -3
  27. package/lib/webbluetooth/bindings.js +2 -2
  28. package/lib/websocket/bindings.js +32 -32
  29. package/lib/win/src/ble_manager.cc +4 -1
  30. package/lib/win/src/ble_manager.h +1 -1
  31. package/lib/win/src/peripheral_winrt.cc +2 -0
  32. package/lib/win/src/radio_watcher.cc +1 -0
  33. package/lib/win/src/winrt_cpp.cc +1 -0
  34. package/package.json +28 -24
  35. package/test/lib/distributed/bindings.test.js +15 -15
  36. package/test/lib/hci-socket/gap.test.js +39 -0
  37. package/test/lib/webbluetooth/bindings.test.js +2 -2
  38. package/test/lib/websocket/bindings.test.js +2 -2
  39. package/test/mocha.setup.js +0 -0
  40. package/test/noble.test.js +12 -11
  41. package/test.custom.js +131 -0
  42. package/test.js +1 -1
  43. package/with-custom-binding.js +6 -0
  44. package/ws-slave.js +10 -10
  45. package/lib/hci-uart/bindings.js +0 -569
  46. package/lib/hci-uart/hci-serial-parser.js +0 -70
  47. package/lib/hci-uart/hci.js +0 -1360
  48. package/lib/manufacture.js +0 -46
  49. package/misc/0001-hci-uart-on-usb-cdc.patch +0 -161
  50. package/misc/nrf52840-usb-cdc.hex +0 -8907
  51. package/misc/nrf52840dk.hex +0 -6921
  52. package/misc/prj.conf +0 -43
  53. 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-18.04, ubuntu-latest, macos-latest, windows-2016]
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@v2
20
- - uses: actions/setup-node@v1
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@v2
45
+ uses: actions/checkout@v3
55
46
  - name: 💽 Setup nodejs
56
- uses: actions/setup-node@v2
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: 10.0.0
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 theses inputs are optional
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
  # ![noble](assets/noble-logo.png)
2
2
 
3
+ [![npm version](https://badgen.net/npm/v/@abandonware/noble)](https://www.npmjs.com/package/@abandonware/noble)
4
+ [![npm downloads](https://badgen.net/npm/dt/@abandonware/noble)](https://www.npmjs.com/package/@abandonware/noble)
3
5
  [![Build Status](https://travis-ci.org/abandonware/noble.svg?branch=master)](https://travis-ci.org/abandonware/noble)
4
6
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/abandonware/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers)
5
7
  [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#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')({extended: false});
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')({extended: false});
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
+ }
@@ -1,4 +1,4 @@
1
- const noble = require('../index')({ extended: false });
1
+ const noble = require('../index');
2
2
 
3
3
  noble.on('stateChange', function (state) {
4
4
  if (state === 'poweredOn') {
@@ -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')({ extended: false });
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')({ extended: false });
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
@@ -6,7 +6,7 @@
6
6
  // start an interval to write data to the characteristic
7
7
 
8
8
  // const noble = require('noble');
9
- const noble = require('..')({ extended: false });
9
+ const noble = require('..');
10
10
 
11
11
  const ECHO_SERVICE_UUID = 'ec00';
12
12
  const ECHO_CHARACTERISTIC_UUID = 'ec0e';
@@ -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')({ extended: false });
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: 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
+ });
@@ -1,4 +1,4 @@
1
- const noble = require('../')({ extended: false });
1
+ const noble = require('../');
2
2
 
3
3
  const peripheralIdOrAddress = process.argv[2].toLowerCase();
4
4
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable handle-callback-err */
2
2
  const async = require('async');
3
- const noble = require('../index')({ extended: false });
3
+ const noble = require('../index');
4
4
 
5
5
  const peripheralIdOrAddress = process.argv[2].toLowerCase();
6
6
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable handle-callback-err */
2
- const noble = require('../..')({ extended: false });
2
+ const noble = require('../..');
3
3
  const pizza = require('./pizza');
4
4
 
5
5
  const pizzaServiceUuid = '13333333333333333333333333333337';