react-native-gizwits-sdk-v5 1.3.65 → 1.3.67
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/android/build.gradle
CHANGED
|
@@ -63,10 +63,10 @@ dependencies {
|
|
|
63
63
|
|
|
64
64
|
implementation "androidx.startup:startup-runtime:$startup_version"
|
|
65
65
|
|
|
66
|
-
implementation("io.github.gizwits:sdk:1.0.
|
|
67
|
-
implementation("io.github.gizwits:sdk-bluetooth:1.0.
|
|
68
|
-
implementation("io.github.gizwits:sdk-lan:1.0.
|
|
69
|
-
implementation("io.github.gizwits:sdk-mqtt:1.0.
|
|
66
|
+
implementation("io.github.gizwits:sdk:1.0.52")
|
|
67
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.0.52")
|
|
68
|
+
implementation("io.github.gizwits:sdk-lan:1.0.52")
|
|
69
|
+
implementation("io.github.gizwits:sdk-mqtt:1.0.52")
|
|
70
70
|
|
|
71
71
|
// implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
|
|
72
72
|
|
|
@@ -23,6 +23,7 @@ import com.gizwits.smart.sdk.lan.subscribeLanDeviceList
|
|
|
23
23
|
import com.gizwits.smart.sdk.mqtt.mqttCapacity
|
|
24
24
|
import com.gizwits.smart.sdk.mqtt.queryBoundDevices
|
|
25
25
|
import com.gizwits.smart.sdk.mqtt.subscribeBoundDeviceList
|
|
26
|
+
import com.gizwits.smart.sdk.mqtt.subscribeBindEvent
|
|
26
27
|
import com.google.gson.annotations.SerializedName
|
|
27
28
|
import kotlinx.coroutines.CoroutineScope
|
|
28
29
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -65,7 +66,8 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
65
66
|
enum class EventName(val value: String) {
|
|
66
67
|
DeviceDataListener("DeviceDataListener"),
|
|
67
68
|
DeviceListListener("DeviceListListener"),
|
|
68
|
-
DeviceStateListener("DeviceStateListener")
|
|
69
|
+
DeviceStateListener("DeviceStateListener"),
|
|
70
|
+
DeviceBindStateListener("DeviceBindStateListener"),
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/** @hide */
|
|
@@ -82,6 +84,19 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
82
84
|
transform(it.first, it.second, it.third)
|
|
83
85
|
}
|
|
84
86
|
}
|
|
87
|
+
/** @hide */
|
|
88
|
+
@OptIn(ExperimentalCoroutinesApi::class)
|
|
89
|
+
fun <T1, T2, R> combineLatest(
|
|
90
|
+
flow1: Flow<T1>,
|
|
91
|
+
flow2: Flow<T2>,
|
|
92
|
+
transform: suspend (a: T1, b: T2) -> R
|
|
93
|
+
): Flow<R> {
|
|
94
|
+
return combine(flow1, flow2) { value1, value2 ->
|
|
95
|
+
Pair(value1, value2)
|
|
96
|
+
}.mapLatest {
|
|
97
|
+
transform(it.first, it.second)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
85
100
|
|
|
86
101
|
override fun getName() = "RNGizSDKManagerModule"
|
|
87
102
|
private val deviceListState: Flow<List<GizDevice>> =
|
|
@@ -97,6 +112,14 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
97
112
|
|
|
98
113
|
override fun initialize() {
|
|
99
114
|
super.initialize()
|
|
115
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
116
|
+
GizSDKManager.subscribeBindEvent().collect {
|
|
117
|
+
val data = JSONObject()
|
|
118
|
+
data.put("did", it.first)
|
|
119
|
+
data.put("isBind", it.second)
|
|
120
|
+
sendEvent(EventName.DeviceBindStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
121
|
+
}
|
|
122
|
+
}
|
|
100
123
|
CoroutineScope(Dispatchers.IO).launch {
|
|
101
124
|
deviceListState.debounce(500).collect { deviceList ->
|
|
102
125
|
val newDevices = deviceList - devices
|
|
@@ -107,9 +130,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
107
130
|
// 新增的设备挂监听
|
|
108
131
|
// 被移除的设备携程会自动销毁
|
|
109
132
|
scope.launch {
|
|
110
|
-
|
|
133
|
+
combineLatest(
|
|
134
|
+
dev.bleCapacity.subscribeStatus().debounce(500),
|
|
135
|
+
dev.bleCapacity.subscribeIsLogin().debounce(500),
|
|
136
|
+
) { status, isLogin ->
|
|
111
137
|
val data = JSONObject()
|
|
112
|
-
data.put("state",
|
|
138
|
+
data.put("state", status.toInt())
|
|
139
|
+
data.put("isLogin", isLogin)
|
|
113
140
|
data.put("type", "BLE")
|
|
114
141
|
data.put("device", dev.toJsonObject())
|
|
115
142
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -134,9 +161,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
134
161
|
|
|
135
162
|
|
|
136
163
|
scope.launch {
|
|
137
|
-
|
|
164
|
+
combineLatest(
|
|
165
|
+
dev.lanCapacity.subscribeStatus().debounce(500),
|
|
166
|
+
dev.lanCapacity.subscribeIsLogin().debounce(500),
|
|
167
|
+
) { status, isLogin ->
|
|
138
168
|
val data = JSONObject()
|
|
139
|
-
data.put("state",
|
|
169
|
+
data.put("state", status.toInt())
|
|
170
|
+
data.put("isLogin", isLogin)
|
|
140
171
|
data.put("type", "LAN")
|
|
141
172
|
data.put("device", dev.toJsonObject())
|
|
142
173
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -161,9 +192,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
161
192
|
|
|
162
193
|
|
|
163
194
|
scope.launch {
|
|
164
|
-
|
|
195
|
+
combineLatest(
|
|
196
|
+
dev.mqttCapacity.subscribeStatus().debounce(500),
|
|
197
|
+
dev.mqttCapacity.subscribeIsLogin().debounce(500),
|
|
198
|
+
) { status, isLogin ->
|
|
165
199
|
val data = JSONObject()
|
|
166
|
-
data.put("state",
|
|
200
|
+
data.put("state", status.toInt())
|
|
201
|
+
data.put("isLogin", isLogin)
|
|
167
202
|
data.put("type", "MQTT")
|
|
168
203
|
data.put("device", dev.toJsonObject())
|
|
169
204
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -58,12 +58,11 @@ class RNGizSDKManagerModule: RCTEventEmitter, GizSdkEventHandlerDelegate {
|
|
|
58
58
|
sendEvent(withName: "DeviceDataListener", body: data)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
func onDeviceState(device: GizwitsiOSSDK.GizDevice, state: GizwitsiOSSDK.GizWifiDeviceNetStatus,
|
|
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
65
|
"type": type.rawValue,
|
|
66
|
-
"isOnline": isOnline,
|
|
67
66
|
"isLogin": isLogin
|
|
68
67
|
] as [String : Any]
|
|
69
68
|
sendEvent(withName: "DeviceStateListener", body: data)
|
package/lib/types.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare type AuthenticationMethod = 0 | 1;
|
|
|
2
2
|
export interface GizBaseCapability {
|
|
3
3
|
name: string;
|
|
4
4
|
isActive: boolean;
|
|
5
|
-
isOnline: boolean;
|
|
6
5
|
isLogin: boolean;
|
|
7
6
|
netStatus: NetStatus;
|
|
8
7
|
connect: () => Promise<GizResult<any, any>>;
|
|
@@ -119,7 +118,6 @@ export interface DeviceDataRes {
|
|
|
119
118
|
export interface DeviceStateRes {
|
|
120
119
|
device: IDevice;
|
|
121
120
|
state: GizDeviceNetStatus;
|
|
122
|
-
isOnline: boolean;
|
|
123
121
|
isLogin: boolean;
|
|
124
122
|
type: GizCapability;
|
|
125
123
|
}
|
package/package.json
CHANGED