node-switchbot 1.8.1 → 1.8.2-beta.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.
Files changed (2) hide show
  1. package/lib/switchbot.js +16 -14
  2. package/package.json +4 -4
package/lib/switchbot.js CHANGED
@@ -195,27 +195,29 @@ class Switchbot {
195
195
 
196
196
  _init() {
197
197
  const promise = new Promise((resolve, reject) => {
198
+ let err;
198
199
  switch (this.noble.state) {
200
+ case ("unsupported", "unauthorized", "poweredOff"):
201
+ err = new Error(
202
+ "Failed to initialize the Noble object: " + this.noble.state
203
+ );
204
+ reject(err);
205
+ return;
206
+ case ("resetting", "unknown"):
207
+ err = new Error(
208
+ "Adapter is not ready: " + this.noble.state
209
+ );
210
+ reject(err);
211
+ return;
199
212
  case "poweredOn":
200
213
  resolve();
201
214
  return;
202
- case ("unsupported", "unauthorized", "poweredOff"):
203
- const err = new Error(
204
- "Failed to initialize the Noble object: " + this.noble.state
215
+ default:
216
+ err = new Error(
217
+ "Uknown state: " + this.noble.state
205
218
  );
206
219
  reject(err);
207
220
  return;
208
- default: // 'resetting', 'unknown'
209
- this.noble.once("stateChange", (state) => {
210
- if (state === "poweredOn") {
211
- resolve();
212
- } else {
213
- const err = new Error(
214
- "Failed to initialize the Noble object: " + state
215
- );
216
- reject(err);
217
- }
218
- });
219
221
  }
220
222
  });
221
223
  return promise;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.8.1",
3
+ "version": "1.8.2-beta.1",
4
4
  "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
5
5
  "main": "./lib/switchbot.js",
6
6
  "files": [
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "readmeFilename": "README.md",
37
37
  "dependencies": {
38
- "@abandonware/noble": "1.9.2-20"
38
+ "@abandonware/noble": "1.9.2-21"
39
39
  },
40
40
  "devDependencies": {
41
- "npm-check-updates": "^16.10.7"
41
+ "npm-check-updates": "^16.10.8"
42
42
  }
43
- }
43
+ }