@stoprocent/bleno 0.10.4 → 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
|
@@ -51,12 +51,12 @@ declare module '@stoprocent/bleno' {
|
|
|
51
51
|
|
|
52
52
|
constructor(options: CharacteristicOptions);
|
|
53
53
|
|
|
54
|
-
onIndicate:
|
|
55
|
-
onNotify:
|
|
56
|
-
onReadRequest:
|
|
57
|
-
onSubscribe:
|
|
58
|
-
onUnsubscribe:
|
|
59
|
-
onWriteRequest:
|
|
54
|
+
onIndicate(handle: ConnectionHandle): void;
|
|
55
|
+
onNotify(handle: ConnectionHandle): void;
|
|
56
|
+
onReadRequest(handle: ConnectionHandle, offset: number, callback: ReadRequestCallback): void;
|
|
57
|
+
onSubscribe(handle: ConnectionHandle, maxValueSize: number, updateValueCallback: UpdateValueCallback): void;
|
|
58
|
+
onUnsubscribe(handle: ConnectionHandle): void;
|
|
59
|
+
onWriteRequest(handle: ConnectionHandle, data: Buffer, offset: number, withoutResponse: boolean, callback: WriteRequestCallback): void;
|
|
60
60
|
|
|
61
61
|
toString(): string;
|
|
62
62
|
|
|
@@ -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 {
|
package/lib/hci-socket/hci.js
CHANGED
|
@@ -85,7 +85,17 @@ class Hci extends EventEmitter {
|
|
|
85
85
|
this._manufacturer = null;
|
|
86
86
|
this._isDevUp = null;
|
|
87
87
|
this._state = null;
|
|
88
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
Binary file
|
|
Binary file
|
|
Binary file
|