react-native-gizwits-sdk-v5 1.3.67 → 1.3.69
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.54")
|
|
67
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.0.54")
|
|
68
|
+
implementation("io.github.gizwits:sdk-lan:1.0.54")
|
|
69
|
+
implementation("io.github.gizwits:sdk-mqtt:1.0.54")
|
|
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
|
|
|
@@ -113,7 +113,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
113
113
|
override fun initialize() {
|
|
114
114
|
super.initialize()
|
|
115
115
|
CoroutineScope(Dispatchers.IO).launch {
|
|
116
|
-
GizSDKManager.subscribeBindEvent().collect {
|
|
116
|
+
GizSDKManager.subscribeBindEvent().collect {
|
|
117
117
|
val data = JSONObject()
|
|
118
118
|
data.put("did", it.first)
|
|
119
119
|
data.put("isBind", it.second)
|
|
@@ -131,12 +131,14 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
131
131
|
// 被移除的设备携程会自动销毁
|
|
132
132
|
scope.launch {
|
|
133
133
|
combineLatest(
|
|
134
|
-
dev.bleCapacity.subscribeStatus()
|
|
135
|
-
dev.bleCapacity.subscribeIsLogin()
|
|
134
|
+
dev.bleCapacity.subscribeStatus(),
|
|
135
|
+
dev.bleCapacity.subscribeIsLogin(),
|
|
136
136
|
) { status, isLogin ->
|
|
137
|
+
Pair(status, isLogin)
|
|
138
|
+
}.collectLatest {
|
|
137
139
|
val data = JSONObject()
|
|
138
|
-
data.put("state",
|
|
139
|
-
data.put("isLogin",
|
|
140
|
+
data.put("state", it.first.toInt())
|
|
141
|
+
data.put("isLogin", it.second)
|
|
140
142
|
data.put("type", "BLE")
|
|
141
143
|
data.put("device", dev.toJsonObject())
|
|
142
144
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -162,15 +164,17 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
162
164
|
|
|
163
165
|
scope.launch {
|
|
164
166
|
combineLatest(
|
|
165
|
-
dev.lanCapacity.subscribeStatus()
|
|
166
|
-
dev.lanCapacity.subscribeIsLogin()
|
|
167
|
+
dev.lanCapacity.subscribeStatus(),
|
|
168
|
+
dev.lanCapacity.subscribeIsLogin(),
|
|
167
169
|
) { status, isLogin ->
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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))
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
scope.launch {
|
|
@@ -193,12 +197,14 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
193
197
|
|
|
194
198
|
scope.launch {
|
|
195
199
|
combineLatest(
|
|
196
|
-
dev.mqttCapacity.subscribeStatus()
|
|
197
|
-
dev.mqttCapacity.subscribeIsLogin()
|
|
200
|
+
dev.mqttCapacity.subscribeStatus(),
|
|
201
|
+
dev.mqttCapacity.subscribeIsLogin(),
|
|
198
202
|
) { status, isLogin ->
|
|
203
|
+
Pair(status, isLogin)
|
|
204
|
+
}.collectLatest {
|
|
199
205
|
val data = JSONObject()
|
|
200
|
-
data.put("state",
|
|
201
|
-
data.put("isLogin",
|
|
206
|
+
data.put("state", it.first.toInt())
|
|
207
|
+
data.put("isLogin", it.second)
|
|
202
208
|
data.put("type", "MQTT")
|
|
203
209
|
data.put("device", dev.toJsonObject())
|
|
204
210
|
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
@@ -255,13 +261,15 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
255
261
|
fun initSDK(options: ReadableMap, result: Callback) {
|
|
256
262
|
var config = RNGizParamsChecker.check(options, result, GizConfiguration::class.java)
|
|
257
263
|
config?.let {
|
|
264
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
258
265
|
try {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
266
|
+
GizSDKManager.setDebug(true)
|
|
267
|
+
GizSDKManager.initSDK(config)
|
|
268
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success<Number>(0))
|
|
262
269
|
} catch (e: GizException) {
|
|
263
|
-
|
|
270
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.failure<Number>(e))
|
|
264
271
|
}
|
|
272
|
+
}
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
275
|
@ReactMethod
|