react-native-gizwits-sdk-v5 1.3.64 → 1.3.66
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.
|
@@ -97,6 +97,14 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
97
97
|
|
|
98
98
|
override fun initialize() {
|
|
99
99
|
super.initialize()
|
|
100
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
101
|
+
GizSDKManager.subscribeBindEvent().collect { data ->
|
|
102
|
+
val data = JSONObject()
|
|
103
|
+
data.put("did", data.first)
|
|
104
|
+
data.put("isBind", data.second)
|
|
105
|
+
sendEvent(EventName.DeviceBindStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
106
|
+
}
|
|
107
|
+
}
|
|
100
108
|
CoroutineScope(Dispatchers.IO).launch {
|
|
101
109
|
deviceListState.debounce(500).collect { deviceList ->
|
|
102
110
|
val newDevices = deviceList - devices
|
|
@@ -107,9 +115,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
107
115
|
// 新增的设备挂监听
|
|
108
116
|
// 被移除的设备携程会自动销毁
|
|
109
117
|
scope.launch {
|
|
110
|
-
|
|
118
|
+
combineLatest(
|
|
119
|
+
dev.bleCapacity.subscribeStatus(),
|
|
120
|
+
dev.bleCapacity.subscribeIsLogin(),
|
|
121
|
+
).debounce(500).collectLatest { status, isLogin ->
|
|
111
122
|
val data = JSONObject()
|
|
112
|
-
data.put("state",
|
|
123
|
+
data.put("state", status.toInt())
|
|
124
|
+
data.put("isLogin", isLogin)
|
|
113
125
|
data.put("type", "BLE")
|
|
114
126
|
data.put("device", dev.toJsonObject())
|
|
115
127
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -134,9 +146,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
134
146
|
|
|
135
147
|
|
|
136
148
|
scope.launch {
|
|
137
|
-
|
|
149
|
+
combineLatest(
|
|
150
|
+
dev.lanCapacity.subscribeStatus(),
|
|
151
|
+
dev.lanCapacity.subscribeIsLogin(),
|
|
152
|
+
).debounce(500).collectLatest { status, isLogin ->
|
|
138
153
|
val data = JSONObject()
|
|
139
|
-
data.put("state",
|
|
154
|
+
data.put("state", status.toInt())
|
|
155
|
+
data.put("isLogin", isLogin)
|
|
140
156
|
data.put("type", "LAN")
|
|
141
157
|
data.put("device", dev.toJsonObject())
|
|
142
158
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -161,9 +177,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
161
177
|
|
|
162
178
|
|
|
163
179
|
scope.launch {
|
|
164
|
-
|
|
180
|
+
combineLatest(
|
|
181
|
+
dev.mqttCapacity.subscribeStatus(),
|
|
182
|
+
dev.mqttCapacity.subscribeIsLogin(),
|
|
183
|
+
).debounce(500).collectLatest { status, isLogin ->
|
|
165
184
|
val data = JSONObject()
|
|
166
|
-
data.put("state",
|
|
185
|
+
data.put("state", status.toInt())
|
|
186
|
+
data.put("isLogin", isLogin)
|
|
167
187
|
data.put("type", "MQTT")
|
|
168
188
|
data.put("device", dev.toJsonObject())
|
|
169
189
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -58,11 +58,12 @@ class RNGizSDKManagerModule: RCTEventEmitter, GizSdkEventHandlerDelegate {
|
|
|
58
58
|
sendEvent(withName: "DeviceDataListener", body: data)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
func onDeviceState(device: GizwitsiOSSDK.GizDevice, state: GizwitsiOSSDK.GizWifiDeviceNetStatus, type: GizwitsiOSSDK.GizCapability) {
|
|
61
|
+
func onDeviceState(device: GizwitsiOSSDK.GizDevice, state: GizwitsiOSSDK.GizWifiDeviceNetStatus, isLogin: Bool, type: GizwitsiOSSDK.GizCapability) {
|
|
62
62
|
let data = [
|
|
63
63
|
"device": GizRNCallbackManager.convertToDictionary(object: device) ?? [:],
|
|
64
64
|
"state": state.rawValue,
|
|
65
|
-
"type": type.rawValue
|
|
65
|
+
"type": type.rawValue,
|
|
66
|
+
"isLogin": isLogin
|
|
66
67
|
] as [String : Any]
|
|
67
68
|
sendEvent(withName: "DeviceStateListener", body: data)
|
|
68
69
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare type AuthenticationMethod = 0 | 1;
|
|
|
2
2
|
export interface GizBaseCapability {
|
|
3
3
|
name: string;
|
|
4
4
|
isActive: boolean;
|
|
5
|
+
isLogin: boolean;
|
|
5
6
|
netStatus: NetStatus;
|
|
6
7
|
connect: () => Promise<GizResult<any, any>>;
|
|
7
8
|
getDeviceInfo: () => Promise<GizResult<GizDeviceInfoProfile, any>>;
|
|
@@ -117,6 +118,7 @@ export interface DeviceDataRes {
|
|
|
117
118
|
export interface DeviceStateRes {
|
|
118
119
|
device: IDevice;
|
|
119
120
|
state: GizDeviceNetStatus;
|
|
121
|
+
isLogin: boolean;
|
|
120
122
|
type: GizCapability;
|
|
121
123
|
}
|
|
122
124
|
export interface DeviceBindRes {
|