@stoprocent/bleno 0.10.5 → 0.11.0

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/index.d.ts CHANGED
@@ -179,8 +179,14 @@ declare module '@stoprocent/bleno' {
179
179
  }
180
180
 
181
181
  export interface HciBindingsOptions extends BaseBindingsOptions {
182
+ /** Driver Type ('default' | 'uart' | 'usb' | 'native') */
182
183
  hciDriver?: import('@stoprocent/bluetooth-hci-socket').DriverType;
184
+ /** Bind Params (for USB and UART Hci Drivers only) */
183
185
  bindParams?: import('@stoprocent/bluetooth-hci-socket').BindParams;
186
+ /** HCI Device ID (Linux Only), Default is 0 */
187
+ deviceId?: number;
188
+ /** Uses User channel instead of Raw HCI Channel */
189
+ userChannel?: boolean;
184
190
  }
185
191
 
186
192
  export interface MacBindingsOptions extends BaseBindingsOptions {
@@ -85,7 +85,17 @@ class Hci extends EventEmitter {
85
85
  this._manufacturer = null;
86
86
  this._isDevUp = null;
87
87
  this._state = null;
88
- this._deviceId = null;
88
+
89
+ this._deviceId = options.deviceId != null
90
+ ? parseInt(options.deviceId, 10)
91
+ : process.env.BLENO_HCI_DEVICE_ID
92
+ ? parseInt(process.env.BLENO_HCI_DEVICE_ID, 10)
93
+ : undefined;
94
+
95
+ this._userChannel =
96
+ (typeof options.userChannel === 'undefined' && options.userChannel) ||
97
+ process.env.HCI_CHANNEL_USER;
98
+
89
99
  // le-u min payload size + l2cap header size
90
100
  // see Bluetooth spec 4.2 [Vol 3, Part A, Chapter 4]
91
101
  this._aclMtu = 23 + 4;
@@ -102,16 +112,13 @@ class Hci extends EventEmitter {
102
112
  this._socket.on('error', this.onSocketError.bind(this));
103
113
  this._socket.on('state', this.pollIsDevUp.bind(this));
104
114
 
105
- const deviceId = process.env.BLENO_HCI_DEVICE_ID ? parseInt(process.env.BLENO_HCI_DEVICE_ID) : undefined;
106
-
107
- if (process.env.HCI_CHANNEL_USER) {
108
- this._deviceId = this._socket.bindUser(deviceId, this._bindParams);
109
-
115
+ if (this._userChannel) {
116
+ this._deviceId = this._socket.bindUser(this._deviceId, this._bindParams);
110
117
  this._socket.start();
111
118
 
112
119
  this.reset();
113
120
  } else {
114
- this._deviceId = this._socket.bindRaw(deviceId, this._bindParams);
121
+ this._deviceId = this._socket.bindRaw(this._deviceId, this._bindParams);
115
122
  this._socket.start();
116
123
 
117
124
  this.pollIsDevUp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoprocent/bleno",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "description": "A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",