@ray-js/lock-sdk 1.1.1-beta.1 → 1.1.1-beta.2
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/state.js +18 -9
- package/package.json +1 -1
package/lib/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import config, { hasCapability } from "./config";
|
|
1
|
+
import config, { hasCapability, hasDp } from "./config";
|
|
2
2
|
import { onDpDataChange, onDeviceInfoUpdated, offDeviceInfoUpdated, offDpDataChange, registerDevice, getDeviceOnlineType, onOnlineChange, offOnlineChange, onBleChange, offBleChange, registerBleStatus, getDeviceInfo, onMqttMessage, registerMQTTDeviceListener, registerMQTTProtocolListener, offMqttMessage, onAppShow, onAppHide, } from "./utils/device";
|
|
3
3
|
import { getDeviceProperties } from "./api/setting";
|
|
4
4
|
import { parseCapabilities } from "./parse";
|
|
@@ -51,21 +51,30 @@ export const getDeviceStatus = () => {
|
|
|
51
51
|
const supportWifi = hasCapability(ProductCommunicationType.WIFI);
|
|
52
52
|
const supportBle = hasCapability(ProductCommunicationType.BLUETOOTH);
|
|
53
53
|
const supportThread = hasCapability(ProductCommunicationType.THREAD);
|
|
54
|
-
const hasWirelessAwakeDp =
|
|
54
|
+
const hasWirelessAwakeDp = hasDp(dpCodes.wirelessAwake);
|
|
55
55
|
const wirelessAwake = getDpValue(dpCodes.wirelessAwake);
|
|
56
|
-
const isDeviceOnline = hasWirelessAwakeDp
|
|
57
|
-
? wirelessAwake && isCloudOnline
|
|
58
|
-
: isCloudOnline;
|
|
59
56
|
status.connectEnable = isSupportBleControl() && !isOnline;
|
|
60
57
|
if (supportWifi) {
|
|
61
58
|
if (!status.connectEnable) {
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
if (isCloudOnline) {
|
|
60
|
+
status.connectEnable =
|
|
61
|
+
hasWirelessAwakeDp && wirelessAwake === false && !isBleOnline;
|
|
62
|
+
}
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
if (isOnline) {
|
|
67
|
-
if (
|
|
68
|
-
|
|
66
|
+
if (isCloudOnline) {
|
|
67
|
+
if (hasWirelessAwakeDp) {
|
|
68
|
+
if (wirelessAwake) {
|
|
69
|
+
status.onlineTypes.push("cloud");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
status.type = "offline";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
status.onlineTypes.push("cloud");
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
79
|
else if (isLocalOnline) {
|
|
71
80
|
status.onlineTypes.push("local");
|