node-switchbot 1.8.1-beta.9 → 1.8.2-beta.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/lib/switchbot.js +16 -14
- package/package.json +3 -3
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
|
-
|
|
203
|
-
|
|
204
|
-
"
|
|
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.
|
|
3
|
+
"version": "1.8.2-beta.0",
|
|
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-
|
|
38
|
+
"@abandonware/noble": "1.9.2-20"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"npm-check-updates": "^16.7
|
|
41
|
+
"npm-check-updates": "^16.10.7"
|
|
42
42
|
}
|
|
43
43
|
}
|