@stoprocent/bleno 0.10.5 → 0.11.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/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();
@@ -8,7 +8,7 @@ class BlenoMac : public Napi::ObjectWrap<BlenoMac>
8
8
  public:
9
9
  BlenoMac(const Napi::CallbackInfo&);
10
10
  Napi::Value Init(const Napi::CallbackInfo&);
11
- Napi::Value CleanUp(const Napi::CallbackInfo&);
11
+ Napi::Value Stop(const Napi::CallbackInfo&);
12
12
 
13
13
  Napi::Value StartAdvertising(const Napi::CallbackInfo&);
14
14
  Napi::Value StartAdvertisingIBeacon(const Napi::CallbackInfo&);
@@ -52,9 +52,8 @@ Napi::Value BlenoMac::Init(const Napi::CallbackInfo& info) {
52
52
  return info.Env().Undefined();
53
53
  }
54
54
 
55
- Napi::Value BlenoMac::CleanUp(const Napi::CallbackInfo& info) {
55
+ Napi::Value BlenoMac::Stop(const Napi::CallbackInfo& info) {
56
56
  CHECK_MANAGER()
57
- CFRelease((__bridge CFTypeRef)peripheralManager);
58
57
  peripheralManager = nil;
59
58
  return info.Env().Undefined();
60
59
  }
@@ -135,7 +134,7 @@ Napi::Value BlenoMac::UpdateRssi(const Napi::CallbackInfo& info) {
135
134
  Napi::Function BlenoMac::GetClass(Napi::Env env) {
136
135
  return DefineClass(env, "BlenoMac", {
137
136
  BlenoMac::InstanceMethod("init", &BlenoMac::Init),
138
- BlenoMac::InstanceMethod("cleanUp", &BlenoMac::CleanUp),
137
+ BlenoMac::InstanceMethod("stop", &BlenoMac::Stop),
139
138
  BlenoMac::InstanceMethod("startAdvertising", &BlenoMac::StartAdvertising),
140
139
  BlenoMac::InstanceMethod("startAdvertisingIBeacon", &BlenoMac::StartAdvertisingIBeacon),
141
140
  BlenoMac::InstanceMethod("startAdvertisingWithEIRData", &BlenoMac::StartAdvertisingWithEIRData),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoprocent/bleno",
3
- "version": "0.10.5",
3
+ "version": "0.11.1",
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",