react-native-gizwits-sdk-v5 1.3.66 → 1.3.68
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.53")
|
|
67
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.0.53")
|
|
68
|
+
implementation("io.github.gizwits:sdk-lan:1.0.53")
|
|
69
|
+
implementation("io.github.gizwits:sdk-mqtt:1.0.53")
|
|
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>> =
|
|
@@ -98,10 +113,10 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
98
113
|
override fun initialize() {
|
|
99
114
|
super.initialize()
|
|
100
115
|
CoroutineScope(Dispatchers.IO).launch {
|
|
101
|
-
GizSDKManager.subscribeBindEvent().collect {
|
|
116
|
+
GizSDKManager.subscribeBindEvent().collect {
|
|
102
117
|
val data = JSONObject()
|
|
103
|
-
data.put("did",
|
|
104
|
-
data.put("isBind",
|
|
118
|
+
data.put("did", it.first)
|
|
119
|
+
data.put("isBind", it.second)
|
|
105
120
|
sendEvent(EventName.DeviceBindStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
106
121
|
}
|
|
107
122
|
}
|
|
@@ -118,10 +133,12 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
118
133
|
combineLatest(
|
|
119
134
|
dev.bleCapacity.subscribeStatus(),
|
|
120
135
|
dev.bleCapacity.subscribeIsLogin(),
|
|
121
|
-
)
|
|
136
|
+
) { status, isLogin ->
|
|
137
|
+
Pair(status, isLogin)
|
|
138
|
+
}.collectLatest {
|
|
122
139
|
val data = JSONObject()
|
|
123
|
-
data.put("state",
|
|
124
|
-
data.put("isLogin",
|
|
140
|
+
data.put("state", it.first.toInt())
|
|
141
|
+
data.put("isLogin", it.second)
|
|
125
142
|
data.put("type", "BLE")
|
|
126
143
|
data.put("device", dev.toJsonObject())
|
|
127
144
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -149,13 +166,15 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
149
166
|
combineLatest(
|
|
150
167
|
dev.lanCapacity.subscribeStatus(),
|
|
151
168
|
dev.lanCapacity.subscribeIsLogin(),
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
169
|
+
) { status, isLogin ->
|
|
170
|
+
Pair(status, isLogin)
|
|
171
|
+
}.collectLatest {
|
|
172
|
+
val data = JSONObject()
|
|
173
|
+
data.put("state", it.first.toInt())
|
|
174
|
+
data.put("isLogin", it.second)
|
|
175
|
+
data.put("type", "LAN")
|
|
176
|
+
data.put("device", dev.toJsonObject())
|
|
177
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
159
178
|
}
|
|
160
179
|
}
|
|
161
180
|
scope.launch {
|
|
@@ -180,10 +199,12 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
180
199
|
combineLatest(
|
|
181
200
|
dev.mqttCapacity.subscribeStatus(),
|
|
182
201
|
dev.mqttCapacity.subscribeIsLogin(),
|
|
183
|
-
)
|
|
202
|
+
) { status, isLogin ->
|
|
203
|
+
Pair(status, isLogin)
|
|
204
|
+
}.collectLatest {
|
|
184
205
|
val data = JSONObject()
|
|
185
|
-
data.put("state",
|
|
186
|
-
data.put("isLogin",
|
|
206
|
+
data.put("state", it.first.toInt())
|
|
207
|
+
data.put("isLogin", it.second)
|
|
187
208
|
data.put("type", "MQTT")
|
|
188
209
|
data.put("device", dev.toJsonObject())
|
|
189
210
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
package/package.json
CHANGED