react-native-gizwits-sdk-v5 1.4.19 → 1.4.21
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.84")
|
|
67
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.0.84")
|
|
68
|
+
implementation("io.github.gizwits:sdk-lan:1.0.84")
|
|
69
|
+
implementation("io.github.gizwits:sdk-mqtt:1.0.84")
|
|
70
70
|
// implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
|
|
71
71
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version")
|
|
72
72
|
// retrofit
|
|
@@ -63,6 +63,8 @@ data class GizFeedback(
|
|
|
63
63
|
class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
64
64
|
|
|
65
65
|
private var mReactContext: ReactContext? = null
|
|
66
|
+
|
|
67
|
+
private var isSubscriptDevices: List<String> = listOf();
|
|
66
68
|
init {
|
|
67
69
|
mReactContext = reactContext
|
|
68
70
|
}
|
|
@@ -132,108 +134,119 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
132
134
|
.debounce(500)
|
|
133
135
|
.flatMapConcat { deviceList ->
|
|
134
136
|
deviceList.map { dev ->
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
|
|
138
|
+
if (!isSubscriptDevices.contains(dev.mac)) {
|
|
139
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
140
|
+
async {
|
|
141
|
+
dev.bleCapability.subscribeModuleProfile().debounce(500).collect {
|
|
142
|
+
if (it != null) {
|
|
143
|
+
emitDeviceListChange()
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
async {
|
|
148
|
+
combine(
|
|
149
|
+
dev.bleCapability.subscribeStatus(),
|
|
150
|
+
dev.bleCapability.subscribeIsLogin(),
|
|
151
|
+
) { status, isLogin ->
|
|
152
|
+
Pair(status, isLogin)
|
|
153
|
+
}.collect {
|
|
154
|
+
val data = JSONObject()
|
|
155
|
+
data.put("state", it.first.toInt())
|
|
156
|
+
data.put("isLogin", it.second)
|
|
157
|
+
data.put("type", "BLE")
|
|
158
|
+
data.put("device", dev.toJsonObject())
|
|
159
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
160
|
+
}
|
|
156
161
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
async {
|
|
163
|
+
dev.bleCapability.subscribeDp().collect{
|
|
164
|
+
val data = JSONObject()
|
|
165
|
+
data.put("data", JSONObject(it.toString()))
|
|
166
|
+
data.put("type", "BLE")
|
|
167
|
+
data.put("device", dev.toJsonObject())
|
|
168
|
+
sendEvent(EventName.DeviceDataListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
169
|
+
}
|
|
165
170
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
async {
|
|
172
|
+
dev.lanCapability.subscribeModuleProfile().debounce(500).collectLatest{
|
|
173
|
+
if (it != null) {
|
|
174
|
+
emitDeviceListChange()
|
|
175
|
+
}
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
|
-
}
|
|
174
178
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
async {
|
|
180
|
+
combineLatest(
|
|
181
|
+
dev.lanCapability.subscribeStatus(),
|
|
182
|
+
dev.lanCapability.subscribeIsLogin(),
|
|
183
|
+
) { status, isLogin ->
|
|
184
|
+
Pair(status, isLogin)
|
|
185
|
+
}.collectLatest {
|
|
186
|
+
val data = JSONObject()
|
|
187
|
+
data.put("state", it.first.toInt())
|
|
188
|
+
data.put("isLogin", it.second)
|
|
189
|
+
data.put("type", "LAN")
|
|
190
|
+
data.put("device", dev.toJsonObject())
|
|
191
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
192
|
+
}
|
|
188
193
|
}
|
|
189
|
-
}
|
|
190
194
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
async {
|
|
196
|
+
dev.lanCapability.subscribeDp().collect{
|
|
197
|
+
val data = JSONObject()
|
|
198
|
+
data.put("data", JSONObject(it.toString()))
|
|
199
|
+
data.put("type", "LAN")
|
|
200
|
+
data.put("device", dev.toJsonObject())
|
|
201
|
+
sendEvent(EventName.DeviceDataListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
202
|
+
}
|
|
198
203
|
}
|
|
199
|
-
}
|
|
200
204
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
async {
|
|
206
|
+
combineLatest(
|
|
207
|
+
dev.mqttCapability.subscribeStatus(),
|
|
208
|
+
dev.mqttCapability.subscribeIsLogin(),
|
|
209
|
+
) { status, isLogin ->
|
|
210
|
+
Pair(status, isLogin)
|
|
211
|
+
}.collectLatest {
|
|
212
|
+
val data = JSONObject()
|
|
213
|
+
data.put("state", it.first.toInt())
|
|
214
|
+
data.put("isLogin", it.second)
|
|
215
|
+
data.put("type", "MQTT")
|
|
216
|
+
data.put("device", dev.toJsonObject())
|
|
217
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
218
|
+
}
|
|
214
219
|
}
|
|
215
|
-
}
|
|
216
220
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
// 不会主动发生改表
|
|
222
|
+
// async {
|
|
223
|
+
// dev.mqttCapability.subscribeModuleProfile().debounce(500).collectLatest{
|
|
224
|
+
// if (it != null) {
|
|
225
|
+
// emitDeviceListChange()
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
|
|
230
|
+
async {
|
|
231
|
+
dev.mqttCapability.subscribeDp().collect{
|
|
232
|
+
val data = JSONObject()
|
|
233
|
+
data.put("data", JSONObject(it.toString()))
|
|
234
|
+
data.put("type", "MQTT")
|
|
235
|
+
data.put("device", dev.toJsonObject())
|
|
236
|
+
sendEvent(EventName.DeviceDataListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
237
|
+
}
|
|
224
238
|
}
|
|
225
239
|
}
|
|
226
240
|
}
|
|
227
241
|
}
|
|
228
242
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// }
|
|
243
|
+
/*
|
|
244
|
+
更新当前已经订阅的设备
|
|
245
|
+
如果设备消失,又出现,就可以正常的重新订阅
|
|
246
|
+
*/
|
|
247
|
+
isSubscriptDevices = deviceList.map{
|
|
248
|
+
dev.mac
|
|
249
|
+
}
|
|
237
250
|
|
|
238
251
|
emptyFlow<Unit>()
|
|
239
252
|
}
|
package/package.json
CHANGED