@stoprocent/noble 1.13.0 → 1.13.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/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@stoprocent/noble)
|
|
4
|
+
[](https://www.npmjs.com/package/@stoprocent/noble)
|
|
5
|
+
[](https://travis-ci.org/stoprocent/noble)
|
|
6
6
|
[](https://gitter.im/abandonware/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](#backers)
|
|
7
7
|
[](#sponsors)
|
|
8
8
|
|
|
9
9
|
A Node.js BLE (Bluetooth Low Energy) central module.
|
|
10
10
|
|
|
11
|
-
Want to implement a peripheral? Check out [bleno](https://github.com/
|
|
11
|
+
Want to implement a peripheral? Check out [bleno](https://github.com/stoprocent/bleno).
|
|
12
12
|
|
|
13
13
|
__Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes.
|
|
14
14
|
|
|
@@ -25,7 +25,7 @@ __Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only su
|
|
|
25
25
|
```javascript
|
|
26
26
|
// Read the battery level of the first found peripheral exposing the Battery Level characteristic
|
|
27
27
|
|
|
28
|
-
const noble = require('@
|
|
28
|
+
const noble = require('@stoprocent/noble');
|
|
29
29
|
|
|
30
30
|
noble.on('stateChange', async (state) => {
|
|
31
31
|
if (state === 'poweredOn') {
|
|
@@ -48,7 +48,7 @@ noble.on('discover', async (peripheral) => {
|
|
|
48
48
|
## Use Noble With BLE5 Extended Features With HCI
|
|
49
49
|
|
|
50
50
|
```javascript
|
|
51
|
-
const noble = require('@
|
|
51
|
+
const noble = require('@stoprocent/noble/with-custom-binding')({extended: true});
|
|
52
52
|
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -72,6 +72,38 @@ const noble = require('@abandonware/noble/with-custom-binding')({extended: true}
|
|
|
72
72
|
|
|
73
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)
|
|
74
74
|
|
|
75
|
+
##### Example 1 (UART port spcified as enviromental variable)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
$ export BLUETOOTH_HCI_SOCKET_UART_PORT=/dev/tty...
|
|
79
|
+
$ export BLUETOOTH_HCI_SOCKET_UART_BAUDRATE=1000000
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
__NOTE:__ `BLUETOOTH_HCI_SOCKET_UART_BAUDRATE` defaults to `1000000` so only needed if different.
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const noble = require('@stoprocent/noble');
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
##### Example 2 (UART port spcified in `bindParams`)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
$ export BLUETOOTH_HCI_SOCKET_FORCE_UART=1
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
const noble = require('@stoprocent/noble/with-custom-binding') ( {
|
|
96
|
+
bindParams: {
|
|
97
|
+
uart: {
|
|
98
|
+
port: '/dev/tty...',
|
|
99
|
+
baudRate: 1000000
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} );
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
__NOTE:__ There is a [UART code example](examples/uart-bind-params.js) in the `/examples` directory.
|
|
106
|
+
|
|
75
107
|
#### OS X
|
|
76
108
|
|
|
77
109
|
* Install [Xcode](https://itunes.apple.com/ca/app/xcode/id497799835?mt=12)
|
|
@@ -161,7 +193,7 @@ Make sure your container runs with `--network=host` options and all specific env
|
|
|
161
193
|
### Installing and using the package
|
|
162
194
|
|
|
163
195
|
```sh
|
|
164
|
-
npm install @
|
|
196
|
+
npm install @stoprocent/noble
|
|
165
197
|
```
|
|
166
198
|
|
|
167
199
|
In Windows OS add your custom hci-usb dongle to the process env
|
|
@@ -171,7 +203,7 @@ set BLUETOOTH_HCI_SOCKET_USB_PID=xxx
|
|
|
171
203
|
```
|
|
172
204
|
|
|
173
205
|
```javascript
|
|
174
|
-
const noble = require('@
|
|
206
|
+
const noble = require('@stoprocent/noble');
|
|
175
207
|
```
|
|
176
208
|
|
|
177
209
|
## API docs
|
|
@@ -208,6 +240,7 @@ API structure:
|
|
|
208
240
|
|
|
209
241
|
* [Scanning and discovery](#scanning-and-discovery)
|
|
210
242
|
* [_Event: Adapter state changed_](#event-adapter-state-changed)
|
|
243
|
+
* [Set address](#set-address)
|
|
211
244
|
* [Start scanning](#start-scanning)
|
|
212
245
|
* [_Event: Scanning started_](#event-scanning-started)
|
|
213
246
|
* [Stop scanning](#stop-scanning)
|
|
@@ -270,6 +303,14 @@ noble.on('stateChange', callback(state));
|
|
|
270
303
|
* `poweredOff`
|
|
271
304
|
* `poweredOn`
|
|
272
305
|
|
|
306
|
+
#### Set address
|
|
307
|
+
|
|
308
|
+
```javascript
|
|
309
|
+
noble.setAddress('00:11:22:33:44:55'); // set adapter's mac address
|
|
310
|
+
```
|
|
311
|
+
__NOTE:__ Curently this feature is only supported on HCI as it's using vendor specific commands. Source of the commands is based on the [BlueZ bdaddr.c](https://github.com/pauloborges/bluez/blob/master/tools/bdaddr.c).
|
|
312
|
+
__NOTE:__ `noble.state` must be `poweredOn` before address can be set. `noble.on('stateChange', callback(state));` can be used to listen for state change events.
|
|
313
|
+
|
|
273
314
|
#### Start scanning
|
|
274
315
|
|
|
275
316
|
```javascript
|
|
@@ -643,7 +684,7 @@ descriptor.once('valueWrite');
|
|
|
643
684
|
By default, noble will select appropriate Bluetooth device bindings based on your platform. You can provide custom bindings using the `with-bindings` module.
|
|
644
685
|
|
|
645
686
|
```javascript
|
|
646
|
-
var noble = require('@
|
|
687
|
+
var noble = require('@stoprocent/noble/with-bindings')(require('./my-custom-bindings'));
|
|
647
688
|
```
|
|
648
689
|
|
|
649
690
|
### Running without root/sudo (Linux-specific)
|
|
@@ -677,8 +718,8 @@ sudo NOBLE_HCI_DEVICE_ID=1 node <your file>.js
|
|
|
677
718
|
If you are using multiple HCI devices in one setup you can run two instances of noble with different binding configurations by initializing them seperatly in code:
|
|
678
719
|
|
|
679
720
|
```
|
|
680
|
-
const HCIBindings = require('@
|
|
681
|
-
const Noble = require('@
|
|
721
|
+
const HCIBindings = require('@stoprocent/noble/lib/hci-socket/bindings');
|
|
722
|
+
const Noble = require('@stoprocent/noble/lib/noble');
|
|
682
723
|
|
|
683
724
|
const params = {
|
|
684
725
|
deviceId: 0,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"name": "@stoprocent/noble",
|
|
8
8
|
"description": "A Node.js BLE (Bluetooth Low Energy) central library.",
|
|
9
|
-
"version": "1.13.
|
|
9
|
+
"version": "1.13.1",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/stoprocent/noble.git"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node-gyp-build": "^4.5.0"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@stoprocent/bluetooth-hci-socket": "^1.1.
|
|
37
|
+
"@stoprocent/bluetooth-hci-socket": "^1.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@semantic-release/exec": "^6.0.3",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|