@stoprocent/noble 1.9.2-16

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 (112) hide show
  1. package/.editorconfig +11 -0
  2. package/.eslintrc.js +25 -0
  3. package/.github/FUNDING.yml +2 -0
  4. package/.github/workflows/fediverse-action.yml +16 -0
  5. package/.github/workflows/nodepackage.yml +77 -0
  6. package/.github/workflows/npm-publish.yml +26 -0
  7. package/.github/workflows/prebuild.yml +65 -0
  8. package/.nycrc.json +4 -0
  9. package/CHANGELOG.md +119 -0
  10. package/LICENSE +20 -0
  11. package/MAINTAINERS.md +1 -0
  12. package/README.md +833 -0
  13. package/assets/noble-logo.png +0 -0
  14. package/assets/noble-logo.svg +13 -0
  15. package/binding.gyp +19 -0
  16. package/codecov.yml +5 -0
  17. package/examples/advertisement-discovery.js +65 -0
  18. package/examples/cache-gatt-discovery.js +198 -0
  19. package/examples/cache-gatt-reconnect.js +164 -0
  20. package/examples/echo.js +104 -0
  21. package/examples/enter-exit.js +78 -0
  22. package/examples/peripheral-explorer-async.js +133 -0
  23. package/examples/peripheral-explorer.js +225 -0
  24. package/examples/pizza/README.md +15 -0
  25. package/examples/pizza/central.js +194 -0
  26. package/examples/pizza/pizza.js +60 -0
  27. package/index.d.ts +203 -0
  28. package/index.js +6 -0
  29. package/lib/characteristic.js +161 -0
  30. package/lib/characteristics.json +449 -0
  31. package/lib/descriptor.js +72 -0
  32. package/lib/descriptors.json +47 -0
  33. package/lib/distributed/bindings.js +326 -0
  34. package/lib/hci-socket/acl-stream.js +60 -0
  35. package/lib/hci-socket/bindings.js +788 -0
  36. package/lib/hci-socket/crypto.js +74 -0
  37. package/lib/hci-socket/gap.js +432 -0
  38. package/lib/hci-socket/gatt.js +809 -0
  39. package/lib/hci-socket/hci-status.json +71 -0
  40. package/lib/hci-socket/hci.js +1264 -0
  41. package/lib/hci-socket/signaling.js +76 -0
  42. package/lib/hci-socket/smp.js +140 -0
  43. package/lib/hci-uart/bindings.js +569 -0
  44. package/lib/hci-uart/hci-serial-parser.js +70 -0
  45. package/lib/hci-uart/hci.js +1336 -0
  46. package/lib/mac/binding.gyp +26 -0
  47. package/lib/mac/bindings.js +11 -0
  48. package/lib/mac/src/ble_manager.h +41 -0
  49. package/lib/mac/src/ble_manager.mm +435 -0
  50. package/lib/mac/src/callbacks.cc +222 -0
  51. package/lib/mac/src/callbacks.h +84 -0
  52. package/lib/mac/src/napi_objc.h +12 -0
  53. package/lib/mac/src/napi_objc.mm +50 -0
  54. package/lib/mac/src/noble_mac.h +34 -0
  55. package/lib/mac/src/noble_mac.mm +264 -0
  56. package/lib/mac/src/objc_cpp.h +26 -0
  57. package/lib/mac/src/objc_cpp.mm +126 -0
  58. package/lib/mac/src/peripheral.h +23 -0
  59. package/lib/manufacture.js +48 -0
  60. package/lib/noble.js +593 -0
  61. package/lib/peripheral.js +219 -0
  62. package/lib/resolve-bindings-web.js +9 -0
  63. package/lib/resolve-bindings.js +44 -0
  64. package/lib/service.js +72 -0
  65. package/lib/services.json +92 -0
  66. package/lib/webbluetooth/bindings.js +368 -0
  67. package/lib/websocket/bindings.js +321 -0
  68. package/lib/win/binding.gyp +23 -0
  69. package/lib/win/bindings.js +11 -0
  70. package/lib/win/src/ble_manager.cc +802 -0
  71. package/lib/win/src/ble_manager.h +77 -0
  72. package/lib/win/src/callbacks.cc +274 -0
  73. package/lib/win/src/callbacks.h +33 -0
  74. package/lib/win/src/napi_winrt.cc +76 -0
  75. package/lib/win/src/napi_winrt.h +12 -0
  76. package/lib/win/src/noble_winrt.cc +308 -0
  77. package/lib/win/src/noble_winrt.h +34 -0
  78. package/lib/win/src/notify_map.cc +62 -0
  79. package/lib/win/src/notify_map.h +50 -0
  80. package/lib/win/src/peripheral.h +23 -0
  81. package/lib/win/src/peripheral_winrt.cc +296 -0
  82. package/lib/win/src/peripheral_winrt.h +82 -0
  83. package/lib/win/src/radio_watcher.cc +125 -0
  84. package/lib/win/src/radio_watcher.h +61 -0
  85. package/lib/win/src/winrt_cpp.cc +82 -0
  86. package/lib/win/src/winrt_cpp.h +11 -0
  87. package/lib/win/src/winrt_guid.cc +12 -0
  88. package/lib/win/src/winrt_guid.h +13 -0
  89. package/misc/nrf52840dk.hex +6921 -0
  90. package/misc/prj.conf +43 -0
  91. package/package.json +96 -0
  92. package/test/lib/characteristic.test.js +791 -0
  93. package/test/lib/descriptor.test.js +249 -0
  94. package/test/lib/distributed/bindings.test.js +918 -0
  95. package/test/lib/hci-socket/acl-stream.test.js +188 -0
  96. package/test/lib/hci-socket/bindings.test.js +1756 -0
  97. package/test/lib/hci-socket/crypto.test.js +55 -0
  98. package/test/lib/hci-socket/gap.test.js +1089 -0
  99. package/test/lib/hci-socket/gatt.test.js +2392 -0
  100. package/test/lib/hci-socket/hci.test.js +1891 -0
  101. package/test/lib/hci-socket/signaling.test.js +94 -0
  102. package/test/lib/hci-socket/smp.test.js +268 -0
  103. package/test/lib/manufacture.test.js +77 -0
  104. package/test/lib/peripheral.test.js +623 -0
  105. package/test/lib/resolve-bindings.test.js +102 -0
  106. package/test/lib/service.test.js +195 -0
  107. package/test/lib/webbluetooth/bindings.test.js +190 -0
  108. package/test/lib/websocket/bindings.test.js +456 -0
  109. package/test/noble.test.js +1565 -0
  110. package/test.js +131 -0
  111. package/with-bindings.js +5 -0
  112. package/ws-slave.js +404 -0
package/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ root = true
2
+ [*]
3
+ charset = utf-8
4
+ indent_size = 2
5
+ indent_style = space
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ trim_trailing_whitespace = true
9
+ quote_type = single
10
+ [*.{diff,md}]
11
+ trim_trailing_whitespace = false
package/.eslintrc.js ADDED
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['eslint:recommended', 'semistandard'],
4
+ parserOptions: {
5
+ ecmaVersion: 2017
6
+ },
7
+ env: {
8
+ browser: true,
9
+ mocha: true,
10
+ node: true
11
+ },
12
+ globals: {
13
+ Promise: true
14
+ },
15
+ rules: {
16
+ 'space-before-function-paren': ['error', 'always'],
17
+ 'no-unused-vars': [
18
+ 'error',
19
+ {
20
+ args: 'none'
21
+ }
22
+ ],
23
+ semi: 'error'
24
+ }
25
+ };
@@ -0,0 +1,2 @@
1
+ github: [rzr]
2
+ custom: ["https://www.paypal.me/rzrfreefr", www.rzr.online.fr]
@@ -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@v1
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"
@@ -0,0 +1,77 @@
1
+ name: Node.js package
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ matrix:
16
+ os: [ubuntu-18.04, ubuntu-latest, macos-latest, windows-2016]
17
+ node: [12, 14]
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: actions/setup-node@v1
21
+ with:
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
+ - name: Install dependencies (ubuntu-latest)
32
+ # Use g++-9 only on versions after 'ubuntu-18.04'
33
+ if: ${{ matrix.os == 'ubuntu-latest' }}
34
+ run: |
35
+ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
36
+ sudo apt -qq update
37
+ sudo apt install -y g++-9
38
+ export CC="g++-9"
39
+ - name: Install NPM packages
40
+ run: |
41
+ npm install
42
+ - name: Run tests
43
+ run: |
44
+ npm test
45
+ - name: Lint
46
+ run: |
47
+ npm run lint
48
+
49
+ quality:
50
+ name: Quality phase
51
+ runs-on: ubuntu-latest
52
+ steps:
53
+ - name: ⬇️ Checkout code
54
+ uses: actions/checkout@v2
55
+ - name: 💽 Setup nodejs
56
+ uses: actions/setup-node@v2
57
+ with:
58
+ node-version: '14'
59
+ - name: 📇 Use npm cache
60
+ uses: c-hive/gha-npm-cache@v1
61
+ - name: Install dependencies (ubuntu-latest)
62
+ run: |
63
+ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
64
+ sudo apt -qq update
65
+ sudo apt install -y g++-9
66
+ export CC="g++-9"
67
+ - name: 📦 Install NPM packages
68
+ run: |
69
+ npm install
70
+ - name: ✅ Test with coverage
71
+ run: |
72
+ npm run coverage
73
+ - name: 📄 Codecov report upload
74
+ uses: codecov/codecov-action@v2
75
+ with:
76
+ fail_ci_if_error: true
77
+ file: .nyc_output/lcov.info
@@ -0,0 +1,26 @@
1
+ name: npm-publish
2
+ on:
3
+ push:
4
+ branches:
5
+ - master # Change this to your default branch
6
+ jobs:
7
+ npm-publish:
8
+ name: npm-publish
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@master
12
+ - id: log
13
+ run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)"
14
+ - if: "contains(steps.log.outputs.message, 'Release ')"
15
+ uses: actions/setup-node@master
16
+ with:
17
+ node-version: 10.0.0
18
+ - if: "contains(steps.log.outputs.message, 'Release ')"
19
+ uses: pascalgn/npm-publish-action@1.3.9
20
+ with: # All of theses inputs are optional
21
+ tag_name: "v%s"
22
+ tag_message: "v%s"
23
+ commit_pattern: "^Release (\\S+)"
24
+ env: # More info about the environment variables in the README
25
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
26
+ NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
@@ -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-2016
26
+ name: Build ${{ matrix.name }}
27
+ runs-on: ${{ matrix.os }}
28
+ steps:
29
+ - if: matrix.node
30
+ uses: actions/setup-node@v2
31
+ with:
32
+ node-version: 14.x
33
+ architecture: ${{ matrix.node }}
34
+ - uses: actions/checkout@v2
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@v2
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/.nycrc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "all": true,
3
+ "exclude": ["examples/**", "test/**", "test.js", "ws-slave.js", ".eslintrc.js", "coverage/**"]
4
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ ## Version 1.9.1
2
+
3
+ * Don't forget previously discovered services and characteristics ([@elafargue](https://github.com/elafargue))
4
+ * Fixed peripheral-explorer example with newer async versions
5
+ * web socket binding: various fixes ([@hadrienk](https://github.com/hadrienk))
6
+ * Fix multiple init of bindings with multiple stateChange listeners added or noble.state is accessed
7
+
8
+ ## Version 1.9.0
9
+
10
+ * Don't initialize bindings until first state change listener added
11
+ * webble: hooked up disconnect event
12
+ * webble: clear cached services on reconnect
13
+ * hci-socket: Added upport 32-bit and 128-bit service data UUIDs ([@arekzelechowski](https://github.com/arekzelechowski))
14
+ * Update 'connectable' property upon discovery ([@dimitrisx](https://github.com/dimitrisx))
15
+ * macOS: Added support for High Sierra
16
+ * webble: remove subscribe listeners on disconnect
17
+
18
+ ## Version 1.8.1
19
+
20
+ * easier install instructions for Windows ([@don](https://github.com/don))
21
+ * hci-socket binding: more descriptive error outputs ([@mbifulco](https://github.com/mbifulco))
22
+ * hci-socket binding: report non-connectable advertisements without scan response
23
+ * Corrected deprecated `read` event for characteristics no emitting for notifications
24
+
25
+ ## Version 1.8.0
26
+
27
+ * hci-socket binding: always set scan parameters before scanning ([@Lahorde](https://github.com/Lahorde))
28
+ * hci-socket binding: add L2CAP signaling layer for non-Linux or Linux user channel mode
29
+ * hci-socket binding: Workarounds for scanning with N.T.C. C.H.I.P
30
+ * hci-socket binding: if `init()` fails we don't want to try and clear up ([@gfwilliams](https://github.com/gfwilliams))
31
+ * Fix read events firing for notifications ([@zkiiito](https://github.com/zkiiito))
32
+ * Add FreeBSD support ([@myfreeweb](https://github.com/myfreeweb))
33
+ * Fix startScanning callback calling setting error to try ([@MarSoft](https://github.com/MarSoft))
34
+ * New Web Bluetooth API shim ([@monteslu](https://github.com/monteslu))
35
+
36
+ ## Version 1.7.0
37
+
38
+ * hci-socket binding: now supports "long writes" ([@projectgus](https://github.com/projectgus))
39
+ * hci-socket binding: use latest bluetooth-hci-socket dependency (~0.5.1)
40
+ * hci-socket binding: add support to extract service solicitation UUID's from advertisement ([@smartyw](https://github.com/smartyw))
41
+ * web-socket binding: fixed write handle not working ([@christopherhex](https://github.com/christopherhex))
42
+ * hci-socket binding: initial bindUser support via HCI_CHANNEL_USER environment variable
43
+
44
+ ## Version 1.6.0
45
+
46
+ * hci-socket binding: use latest bluetooth-hci-socket dependency (~0.4.4)
47
+ * Added characteristic.subscribe and characteristic.unsubscribe API's (characteristic.notify is now deprecated)
48
+ * hci-socket binding: use OCF_LE_SET_EVENT_MASK for LE_SET_EVENT_MASK_CMD
49
+ * hci-socket binding: check READ_LE_HOST_SUPPORTED_CMD status before parsing result
50
+
51
+ ## Version 1.5.0
52
+
53
+ * hci-socket binding: add NOBLE_MULTI_ROLE flag for ignoring peripheral role commands ([@popasquat89](https://github.com/bradjc))
54
+ * Fix variable typo in ```with-bindings.js`` ([@rclai](https://github.com/rclai))
55
+
56
+ ## Version 1.4.0
57
+
58
+ * hci-socket binding: include service data UUID's when filtering discover
59
+ * hci-socket binding: emit scan start/stop when external app changes scanning start ([@bradjc](https://github.com/bradjc))
60
+ * Support for pluggable bindings ([@hgwood](https://github.com/hgwood))
61
+ * hci-socket binding: don't kill all descriptors when looking for new Characteristics ([@Neutrosider](https://github.com/Neutrosider))
62
+
63
+ ## Version 1.3.0
64
+
65
+ * Check and report LE Create Conn command status
66
+ * Correct parsing master clock accuracy value from LE Conn Complete event
67
+ * Added logic to reject rather than ignore unknown requests/commands. ([@george-hawkins](https://github.com/george-hawkins))
68
+ * Don't reset scan state on read local version response if state is powered on
69
+ * Expose local adapter address via ```noble.address```, available after ```poweredOn``` state change event
70
+ * Fix ```serviceUuids``` var check in ```peripheral-explorer.js``` ([@jrobeson](https://github.com/jrobeson))
71
+
72
+ ## Version 1.2.1
73
+
74
+ * Use latest v0.4.1 bluetooth-hci-socket dependency (for kernel 4.1.x disconnect workaround)
75
+ * Add read + write LE host supported commands (for kernel 4.1.x disconnect workaround)
76
+ * Fix a potential exception when accessing a non existent element ([@Loghorn](https://github.com/Loghorn))
77
+
78
+ ## Version 1.2.0
79
+
80
+ * Use v0.4.0 of bluetooth-hci-socket
81
+ * Ignore peripherals with only connectable flag on OS X 10.10
82
+ * Bindings no longer init themselves
83
+ * Fix this._discoveredPeripheralUUids = []; variable not initalized in constructor ([@jacobrosenthal](https://github.com/jacobrosenthal))
84
+ * New ```peripheral.connectable``` property
85
+ * Updates to Linux prerequisites in read me
86
+ * Throw error if scanning is started when state is not powered on
87
+
88
+ ## Version 1.1.0
89
+
90
+ * Introduce ```peripheral.id```, ```periheral.uuid``` is deprecated now
91
+ * Initial Windows support via WinUSB and bluetooth-hci-socket
92
+ * Rework Linux stack to use [bluetooth-hci-socket](https://github.com/sandeepmistry/node-bluetooth-hci-socket)
93
+ * Clarify notify related API's in read me ([@OJFord](https://github.com/OJFord))
94
+
95
+ ## Version 1.0.2
96
+
97
+ * Add mac dummy in binding.pyq ([@DomiR](https://github.com/DomiR))
98
+ * Fixes for distributed and websocket bindings ([@Loghorn](https://github.com/Loghorn))
99
+ * OS X Mavericks and legacy: manually emit write event for write without response requests
100
+ * Update README for packages needed for rpm-based systems ([@ppannuto](https://github.com/ppannuto))
101
+ * Linux: refresh serviceUuids for incoming advertisement ([@BBarash](https://github.com/BBarash))
102
+
103
+ ## Version 1.0.1
104
+
105
+ * correct peripherals not being created correctly
106
+
107
+ ## Version 1.0
108
+
109
+ * remove unneeded setTimeout's in OS X bindings
110
+ * added persistent peripherals between calls to .startScanning() on mavericks ([@andySigler](https://github.com/andySigler))
111
+ * report error or print warning if startScanning is called with state is not poweredOn
112
+ * emit events for warnings ([@voodootikigod ](https://github.com/voodootikigod))
113
+ * disable scanning flag on start on Linux to prevent unsupport adapter state in some cases
114
+ * update debug dependency version
115
+ * add address type to peripheral if known
116
+
117
+ ## Older
118
+
119
+ * Changes not recorded
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Sandeep Mistry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/MAINTAINERS.md ADDED
@@ -0,0 +1 @@
1
+ * Philippe Coval <mailto:p.coval@samsung.com> (https://www.npmjs.com/~rzr)