@stoprocent/noble 2.3.7 → 2.3.8

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.
@@ -158,20 +158,29 @@ Hci.prototype.init = function (options) {
158
158
  this._socket.on('error', this.onSocketError.bind(this));
159
159
  this._socket.on('state', this.pollIsDevUp.bind(this));
160
160
 
161
- if (this._userChannel) {
162
- this._socket.bindUser(this._deviceId, this._bindParams);
163
- this._socket.start();
164
-
165
- this.reset();
166
- } else {
167
- if (!this._bound) {
168
- this._socket.bindRaw(this._deviceId, this._bindParams);
169
- this._bound = true;
161
+ try {
162
+ // Bind first (either user channel or raw)
163
+ if (this._userChannel) {
164
+ this._socket.bindUser(this._deviceId, this._bindParams);
165
+ } else {
166
+ if (!this._bound) {
167
+ this._socket.bindRaw(this._deviceId, this._bindParams);
168
+ this._bound = true;
169
+ }
170
170
  }
171
+
172
+ // Start and reset (common to both paths)
171
173
  this._socket.start();
172
- this._isStarted = true;
173
174
  this.reset();
174
- this.pollIsDevUp();
175
+
176
+ // Set started flag and poll only for non-userChannel
177
+ if (!this._userChannel) {
178
+ this._isStarted = true;
179
+ this.pollIsDevUp();
180
+ }
181
+ } catch (error) {
182
+ debug(`init error: ${error.message}`);
183
+ this.emit('stateChange', 'unsupported');
175
184
  }
176
185
  };
177
186
 
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": "2.3.7",
9
+ "version": "2.3.8",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/stoprocent/noble.git"