@stoprocent/noble 1.15.0 → 1.15.2

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
@@ -3,14 +3,39 @@
3
3
  [![npm version](https://badgen.net/npm/v/@stoprocent/noble)](https://www.npmjs.com/package/@stoprocent/noble)
4
4
  [![npm downloads](https://badgen.net/npm/dt/@stoprocent/noble)](https://www.npmjs.com/package/@stoprocent/noble)
5
5
  [![Build Status](https://travis-ci.org/stoprocent/noble.svg?branch=master)](https://travis-ci.org/stoprocent/noble)
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)
7
- [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#sponsors)
8
6
 
9
7
  A Node.js BLE (Bluetooth Low Energy) central module.
10
8
 
11
- Want to implement a peripheral? Check out [bleno](https://github.com/stoprocent/bleno).
9
+ Want to implement a peripheral? Check out [@stoprocent/bleno](https://github.com/stoprocent/bleno).
12
10
 
13
- __Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes.
11
+ ## About This Fork
12
+
13
+ This fork of `noble` was created to introduce several key improvements and new features:
14
+
15
+ 1. **HCI UART Support**: This version enables HCI UART communication through the `@stoprocent/node-bluetooth-hci-socket` dependency, allowing more flexible use of Bluetooth devices across platforms.
16
+
17
+ 2. **macOS Native Bindings Fix**: I have fixed the native bindings for macOS, ensuring better compatibility and performance on Apple devices.
18
+
19
+ 3. **New Features**:
20
+ - A `setAddress` function has been added, allowing users to set the MAC address of the central device.
21
+ - A `connect(...)/connectAsync(...)` function has been added, allowing users to connect directly to specific device by address/identifier without a need to prior scan.
22
+ - Additionally, I plan to add raw L2CAP channel support, enhancing low-level Bluetooth communication capabilities.
23
+
24
+ If you appreciate these enhancements and the continued development of this project, please consider supporting my work.
25
+
26
+ [![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/stoprocent)
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ npm install @stoprocent/noble
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```javascript
37
+ const noble = require('@stoprocent/noble');
38
+ ```
14
39
 
15
40
  ## Documentation
16
41
 
@@ -824,90 +849,8 @@ Intel Dual Band Wireless-AC 7260 (Intel Corporation Wireless 7260 (rev 73)): `Er
824
849
 
825
850
  You need to stop scanning before trying to connect in order to solve this issue.
826
851
 
827
- ## Backers
828
-
829
- Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/noble#backer)]
830
-
831
- <a href="https://opencollective.com/noble/backer/0/website" target="_blank"><img src="https://opencollective.com/noble/backer/0/avatar.svg"></a>
832
- <a href="https://opencollective.com/noble/backer/1/website" target="_blank"><img src="https://opencollective.com/noble/backer/1/avatar.svg"></a>
833
- <a href="https://opencollective.com/noble/backer/2/website" target="_blank"><img src="https://opencollective.com/noble/backer/2/avatar.svg"></a>
834
- <a href="https://opencollective.com/noble/backer/3/website" target="_blank"><img src="https://opencollective.com/noble/backer/3/avatar.svg"></a>
835
- <a href="https://opencollective.com/noble/backer/4/website" target="_blank"><img src="https://opencollective.com/noble/backer/4/avatar.svg"></a>
836
- <a href="https://opencollective.com/noble/backer/5/website" target="_blank"><img src="https://opencollective.com/noble/backer/5/avatar.svg"></a>
837
- <a href="https://opencollective.com/noble/backer/6/website" target="_blank"><img src="https://opencollective.com/noble/backer/6/avatar.svg"></a>
838
- <a href="https://opencollective.com/noble/backer/7/website" target="_blank"><img src="https://opencollective.com/noble/backer/7/avatar.svg"></a>
839
- <a href="https://opencollective.com/noble/backer/8/website" target="_blank"><img src="https://opencollective.com/noble/backer/8/avatar.svg"></a>
840
- <a href="https://opencollective.com/noble/backer/9/website" target="_blank"><img src="https://opencollective.com/noble/backer/9/avatar.svg"></a>
841
- <a href="https://opencollective.com/noble/backer/10/website" target="_blank"><img src="https://opencollective.com/noble/backer/10/avatar.svg"></a>
842
- <a href="https://opencollective.com/noble/backer/11/website" target="_blank"><img src="https://opencollective.com/noble/backer/11/avatar.svg"></a>
843
- <a href="https://opencollective.com/noble/backer/12/website" target="_blank"><img src="https://opencollective.com/noble/backer/12/avatar.svg"></a>
844
- <a href="https://opencollective.com/noble/backer/13/website" target="_blank"><img src="https://opencollective.com/noble/backer/13/avatar.svg"></a>
845
- <a href="https://opencollective.com/noble/backer/14/website" target="_blank"><img src="https://opencollective.com/noble/backer/14/avatar.svg"></a>
846
- <a href="https://opencollective.com/noble/backer/15/website" target="_blank"><img src="https://opencollective.com/noble/backer/15/avatar.svg"></a>
847
- <a href="https://opencollective.com/noble/backer/16/website" target="_blank"><img src="https://opencollective.com/noble/backer/16/avatar.svg"></a>
848
- <a href="https://opencollective.com/noble/backer/17/website" target="_blank"><img src="https://opencollective.com/noble/backer/17/avatar.svg"></a>
849
- <a href="https://opencollective.com/noble/backer/18/website" target="_blank"><img src="https://opencollective.com/noble/backer/18/avatar.svg"></a>
850
- <a href="https://opencollective.com/noble/backer/19/website" target="_blank"><img src="https://opencollective.com/noble/backer/19/avatar.svg"></a>
851
- <a href="https://opencollective.com/noble/backer/20/website" target="_blank"><img src="https://opencollective.com/noble/backer/20/avatar.svg"></a>
852
- <a href="https://opencollective.com/noble/backer/21/website" target="_blank"><img src="https://opencollective.com/noble/backer/21/avatar.svg"></a>
853
- <a href="https://opencollective.com/noble/backer/22/website" target="_blank"><img src="https://opencollective.com/noble/backer/22/avatar.svg"></a>
854
- <a href="https://opencollective.com/noble/backer/23/website" target="_blank"><img src="https://opencollective.com/noble/backer/23/avatar.svg"></a>
855
- <a href="https://opencollective.com/noble/backer/24/website" target="_blank"><img src="https://opencollective.com/noble/backer/24/avatar.svg"></a>
856
- <a href="https://opencollective.com/noble/backer/25/website" target="_blank"><img src="https://opencollective.com/noble/backer/25/avatar.svg"></a>
857
- <a href="https://opencollective.com/noble/backer/26/website" target="_blank"><img src="https://opencollective.com/noble/backer/26/avatar.svg"></a>
858
- <a href="https://opencollective.com/noble/backer/27/website" target="_blank"><img src="https://opencollective.com/noble/backer/27/avatar.svg"></a>
859
- <a href="https://opencollective.com/noble/backer/28/website" target="_blank"><img src="https://opencollective.com/noble/backer/28/avatar.svg"></a>
860
- <a href="https://opencollective.com/noble/backer/29/website" target="_blank"><img src="https://opencollective.com/noble/backer/29/avatar.svg"></a>
861
-
862
- ## Sponsors
863
-
864
- Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/noble#sponsor)]
865
-
866
- <a href="https://opencollective.com/noble/sponsor/0/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/0/avatar.svg"></a>
867
- <a href="https://opencollective.com/noble/sponsor/1/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/1/avatar.svg"></a>
868
- <a href="https://opencollective.com/noble/sponsor/2/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/2/avatar.svg"></a>
869
- <a href="https://opencollective.com/noble/sponsor/3/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/3/avatar.svg"></a>
870
- <a href="https://opencollective.com/noble/sponsor/4/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/4/avatar.svg"></a>
871
- <a href="https://opencollective.com/noble/sponsor/5/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/5/avatar.svg"></a>
872
- <a href="https://opencollective.com/noble/sponsor/6/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/6/avatar.svg"></a>
873
- <a href="https://opencollective.com/noble/sponsor/7/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/7/avatar.svg"></a>
874
- <a href="https://opencollective.com/noble/sponsor/8/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/8/avatar.svg"></a>
875
- <a href="https://opencollective.com/noble/sponsor/9/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/9/avatar.svg"></a>
876
- <a href="https://opencollective.com/noble/sponsor/10/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/10/avatar.svg"></a>
877
- <a href="https://opencollective.com/noble/sponsor/11/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/11/avatar.svg"></a>
878
- <a href="https://opencollective.com/noble/sponsor/12/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/12/avatar.svg"></a>
879
- <a href="https://opencollective.com/noble/sponsor/13/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/13/avatar.svg"></a>
880
- <a href="https://opencollective.com/noble/sponsor/14/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/14/avatar.svg"></a>
881
- <a href="https://opencollective.com/noble/sponsor/15/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/15/avatar.svg"></a>
882
- <a href="https://opencollective.com/noble/sponsor/16/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/16/avatar.svg"></a>
883
- <a href="https://opencollective.com/noble/sponsor/17/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/17/avatar.svg"></a>
884
- <a href="https://opencollective.com/noble/sponsor/18/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/18/avatar.svg"></a>
885
- <a href="https://opencollective.com/noble/sponsor/19/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/19/avatar.svg"></a>
886
- <a href="https://opencollective.com/noble/sponsor/20/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/20/avatar.svg"></a>
887
- <a href="https://opencollective.com/noble/sponsor/21/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/21/avatar.svg"></a>
888
- <a href="https://opencollective.com/noble/sponsor/22/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/22/avatar.svg"></a>
889
- <a href="https://opencollective.com/noble/sponsor/23/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/23/avatar.svg"></a>
890
- <a href="https://opencollective.com/noble/sponsor/24/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/24/avatar.svg"></a>
891
- <a href="https://opencollective.com/noble/sponsor/25/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/25/avatar.svg"></a>
892
- <a href="https://opencollective.com/noble/sponsor/26/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/26/avatar.svg"></a>
893
- <a href="https://opencollective.com/noble/sponsor/27/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/27/avatar.svg"></a>
894
- <a href="https://opencollective.com/noble/sponsor/28/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/28/avatar.svg"></a>
895
- <a href="https://opencollective.com/noble/sponsor/29/website" target="_blank"><img src="https://opencollective.com/noble/sponsor/29/avatar.svg"></a>
896
-
897
852
  ## Useful links
898
853
 
899
854
  * [Bluetooth Development Portal](http://developer.bluetooth.org)
900
855
  * [GATT Specifications](https://www.bluetooth.com/specifications/gatt/)
901
856
  * [Bluetooth: ATT and GATT](http://epx.com.br/artigos/bluetooth_gatt.php)
902
-
903
- ## License
904
-
905
- Copyright (C) 2015 Sandeep Mistry <sandeep.mistry@gmail.com>
906
-
907
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
908
-
909
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
910
-
911
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
912
-
913
- [![Analytics](https://ga-beacon.appspot.com/UA-56089547-1/sandeepmistry/noble?pixel)](https://github.com/igrigorik/ga-beacon)
@@ -1,4 +1,4 @@
1
- const noble = require('./with-custom-binding')({ extended: true });
1
+ const noble = require('../../with-custom-binding')({ extended: true });
2
2
 
3
3
  console.log('noble');
4
4
 
package/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export declare function connect(peripheralUuid: string, options?: object, callba
29
29
  export declare function connectAsync(peripheralUuid: string, options?: object): Promise<Peripheral>;
30
30
  export declare function cancelConnect(peripheralUuid: string, options?: object): void;
31
31
  export declare function reset(): void;
32
+ export declare function stop(): void;
32
33
 
33
34
  export declare function setAddress(address: string): void;
34
35
 
@@ -113,7 +113,7 @@ NobleBindings.prototype.init = function () {
113
113
  is present it can throw an exception - in which case we don't
114
114
  want to try and clear up afterwards (issue #502) */
115
115
  process.on('SIGINT', this.onSigIntBinded);
116
- process.on('exit', this.onExit.bind(this));
116
+ process.on('exit', this.stop.bind(this));
117
117
  };
118
118
 
119
119
  NobleBindings.prototype.onSigInt = function () {
@@ -126,12 +126,13 @@ NobleBindings.prototype.onSigInt = function () {
126
126
  }
127
127
  };
128
128
 
129
- NobleBindings.prototype.onExit = function () {
129
+ NobleBindings.prototype.stop = function () {
130
130
  this.stopScanning();
131
-
132
131
  for (const handle in this._aclStreams) {
133
132
  this._hci.disconnect(handle);
134
133
  }
134
+ this._hci.reset();
135
+ this._hci.stop();
135
136
  };
136
137
 
137
138
  NobleBindings.prototype.onStateChange = function (state) {
@@ -290,6 +290,10 @@ Hci.prototype.reset = function () {
290
290
  this._socket.write(cmd);
291
291
  };
292
292
 
293
+ Hci.prototype.stop = function () {
294
+ this._socket.stop();
295
+ };
296
+
293
297
  Hci.prototype.readSupportedCommands = function () {
294
298
  const cmd = Buffer.alloc(4);
295
299
 
package/lib/noble.js CHANGED
@@ -190,7 +190,15 @@ Noble.prototype.onScanStop = function () {
190
190
  };
191
191
 
192
192
  Noble.prototype.reset = function () {
193
- this._bindings.reset();
193
+ if (this._bindings.reset) {
194
+ this._bindings.reset();
195
+ }
196
+ };
197
+
198
+ Noble.prototype.stop = function () {
199
+ if (this._bindings.stop) {
200
+ this._bindings.stop();
201
+ }
194
202
  };
195
203
 
196
204
  Noble.prototype.onDiscover = function (uuid, address, addressType, connectable, advertisement, rssi, scannable) {
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.15.0",
9
+ "version": "1.15.2",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/stoprocent/noble.git"
@@ -25,7 +25,7 @@
25
25
  "types": "./index.d.ts",
26
26
  "gypfile": true,
27
27
  "engines": {
28
- "node": ">=6"
28
+ "node": ">=14"
29
29
  },
30
30
  "dependencies": {
31
31
  "debug": "^4.3.7",
@@ -34,7 +34,7 @@
34
34
  "node-gyp-build": "^4.8.1"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@stoprocent/bluetooth-hci-socket": "^1.4.0"
37
+ "@stoprocent/bluetooth-hci-socket": "^1.4.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@commitlint/cli": "^19.3.0",
@@ -268,22 +268,28 @@ describe('hci-socket bindings', () => {
268
268
  assert.calledTwice(process.on);
269
269
  });
270
270
 
271
- describe('onExit', () => {
271
+ describe('stop', () => {
272
272
  it('no handles', () => {
273
273
  bindings._gap.stopScanning = fake.resolves(null);
274
+ bindings._hci.reset = fake.resolves(null);
275
+ bindings._hci.stop = fake.resolves(null);
274
276
 
275
- bindings.onExit();
277
+ bindings.stop();
276
278
 
277
279
  assert.calledOnce(bindings._gap.stopScanning);
280
+ assert.calledOnce(bindings._hci.reset);
281
+ assert.calledOnce(bindings._hci.stop);
278
282
  });
279
283
 
280
284
  it('with handles', () => {
281
285
  bindings._gap.stopScanning = fake.resolves(null);
282
286
  bindings._hci.disconnect = fake.resolves(null);
287
+ bindings._hci.reset = fake.resolves(null);
288
+ bindings._hci.stop = fake.resolves(null);
283
289
 
284
290
  bindings._aclStreams = [1, 2, 3];
285
291
 
286
- bindings.onExit();
292
+ bindings.stop();
287
293
 
288
294
  assert.calledOnce(bindings._gap.stopScanning);
289
295
  assert.calledThrice(bindings._hci.disconnect);