react-native-gizwits-sdk-v5 1.3.62 → 1.3.63

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.
@@ -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.50")
67
- implementation("io.github.gizwits:sdk-bluetooth:1.0.50")
68
- implementation("io.github.gizwits:sdk-lan:1.0.50")
69
- implementation("io.github.gizwits:sdk-mqtt:1.0.50")
66
+ implementation("io.github.gizwits:sdk:1.0.51")
67
+ implementation("io.github.gizwits:sdk-bluetooth:1.0.51")
68
+ implementation("io.github.gizwits:sdk-lan:1.0.51")
69
+ implementation("io.github.gizwits:sdk-mqtt:1.0.51")
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
 
@@ -139,7 +139,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
139
139
  fun sendDp(options: ReadableMap, result: Callback) {
140
140
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizSendDPParams::class.java)
141
141
  if (config !=null && device !=null) {
142
- CoroutineScope(Dispatchers.Main).launch {
142
+ CoroutineScope(Dispatchers.IO).launch {
143
143
  try {
144
144
  val gson = Gson()
145
145
  val jsonObject = gson.fromJson(config.data, JsonObject::class.java)
@@ -160,7 +160,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
160
160
  fun getDp(options: ReadableMap, result: Callback) {
161
161
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizGetDPParams::class.java)
162
162
  if (config !=null && device !=null) {
163
- CoroutineScope(Dispatchers.Main).launch {
163
+ CoroutineScope(Dispatchers.IO).launch {
164
164
  var res = when(config.type) {
165
165
  CapacityTypes.BLE -> device.bleCapacity.getDp(config.attrs)
166
166
  CapacityTypes.LAN -> device.lanCapacity.getDp(config.attrs)
@@ -182,7 +182,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
182
182
  fun getDeviceInfo(options: ReadableMap, result: Callback) {
183
183
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizGetDeviceInfoParams::class.java)
184
184
  if (config !=null && device !=null) {
185
- CoroutineScope(Dispatchers.Main).launch {
185
+ CoroutineScope(Dispatchers.IO).launch {
186
186
  val res = when(config.type) {
187
187
  CapacityTypes.BLE -> device.bleCapacity.getDeviceInfo()
188
188
  CapacityTypes.LAN -> device.lanCapacity.getDeviceInfo()
@@ -197,7 +197,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
197
197
  fun bind(options: ReadableMap, result: Callback) {
198
198
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizBindParams::class.java)
199
199
  if (config !=null && device !=null) {
200
- CoroutineScope(Dispatchers.Main).launch {
200
+ CoroutineScope(Dispatchers.IO).launch {
201
201
  val res = device.bindDevice(config.alias, config.remark)
202
202
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
203
203
  if (res.isSuccess) {
@@ -211,7 +211,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
211
211
  fun unBind(options: ReadableMap, result: Callback) {
212
212
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizUnBindParams::class.java)
213
213
  if (config !=null && device !=null) {
214
- CoroutineScope(Dispatchers.Main).launch {
214
+ CoroutineScope(Dispatchers.IO).launch {
215
215
  val res = device.unbindDevice()
216
216
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
217
217
  if (res.isSuccess) {
@@ -224,7 +224,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
224
224
  fun stopProvideWiFiCredentials(options: ReadableMap, result: Callback) {
225
225
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizStopProvideWiFiCredentialsParams::class.java)
226
226
  if (config !=null && device !=null) {
227
- CoroutineScope(Dispatchers.Main).launch {
227
+ CoroutineScope(Dispatchers.IO).launch {
228
228
  val res = when(config.type) {
229
229
  CapacityTypes.BLE -> device.bleCapacity.stopProvideWiFiCredentials()
230
230
  CapacityTypes.LAN -> device.lanCapacity.stopProvideWiFiCredentials()
@@ -248,7 +248,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
248
248
  fun provideWiFiCredentials(options: ReadableMap, result: Callback) {
249
249
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizProvideWiFiCredentialsParams::class.java)
250
250
  if (config !=null && device !=null) {
251
- CoroutineScope(Dispatchers.Main).launch {
251
+ CoroutineScope(Dispatchers.IO).launch {
252
252
  val res = when(config.type) {
253
253
  CapacityTypes.BLE -> device.bleCapacity.provideWiFiCredentials(
254
254
  config.ssid,
@@ -284,7 +284,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
284
284
  fun register(options: ReadableMap, result: Callback) {
285
285
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizRegisterDeviceParams::class.java)
286
286
  if (config !=null && device !=null) {
287
- CoroutineScope(Dispatchers.Main).launch {
287
+ CoroutineScope(Dispatchers.IO).launch {
288
288
  val res = device.register()
289
289
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
290
290
  }
@@ -295,7 +295,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
295
295
  fun connect(options: ReadableMap, result: Callback) {
296
296
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizConnectParams::class.java)
297
297
  if (config !=null && device !=null) {
298
- CoroutineScope(Dispatchers.Main).launch {
298
+ CoroutineScope(Dispatchers.IO).launch {
299
299
  val res = when(config.type) {
300
300
  CapacityTypes.BLE -> device.bleCapacity.connect()
301
301
  CapacityTypes.LAN -> device.lanCapacity.connect()
@@ -309,7 +309,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
309
309
  fun disConnect(options: ReadableMap, result: Callback) {
310
310
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizDisConnectParams::class.java)
311
311
  if (config !=null && device !=null) {
312
- CoroutineScope(Dispatchers.Main).launch {
312
+ CoroutineScope(Dispatchers.IO).launch {
313
313
  val res = when(config.type) {
314
314
  CapacityTypes.BLE -> device.bleCapacity.disconnect()
315
315
  CapacityTypes.LAN -> device.lanCapacity.disconnect()
@@ -324,7 +324,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
324
324
  fun checkUpdate(options: ReadableMap, result: Callback) {
325
325
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizCheckUpdateParams::class.java)
326
326
  if (config !=null && device !=null) {
327
- CoroutineScope(Dispatchers.Main).launch {
327
+ CoroutineScope(Dispatchers.IO).launch {
328
328
  val res = when(config.type) {
329
329
  CapacityTypes.BLE -> device.bleCapacity.checkUpdate(config.firmwareType)
330
330
  CapacityTypes.LAN -> device.lanCapacity.checkUpdate(config.firmwareType)
@@ -351,7 +351,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
351
351
  fun startUpgrade(options: ReadableMap, result: Callback) {
352
352
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizCheckUpdateParams::class.java)
353
353
  if (config !=null && device !=null) {
354
- CoroutineScope(Dispatchers.Main).launch {
354
+ CoroutineScope(Dispatchers.IO).launch {
355
355
  val res = when(config.type) {
356
356
  CapacityTypes.BLE -> {
357
357
  device.bleCapacity.startUpgrade(config.firmwareType, processHandler = {
@@ -373,7 +373,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
373
373
  fun cancelUpgrade(options: ReadableMap, result: Callback) {
374
374
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StopUpgradeParams::class.java)
375
375
  if (config !=null && device !=null) {
376
- CoroutineScope(Dispatchers.Main).launch {
376
+ CoroutineScope(Dispatchers.IO).launch {
377
377
  val res = when(config.type) {
378
378
  CapacityTypes.BLE -> device.bleCapacity.cancelUpgrade()
379
379
  CapacityTypes.LAN -> device.lanCapacity.cancelUpgrade()
@@ -97,7 +97,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
97
97
 
98
98
  override fun initialize() {
99
99
  super.initialize()
100
- CoroutineScope(Dispatchers.Main).launch {
100
+ CoroutineScope(Dispatchers.IO).launch {
101
101
  deviceListState.debounce(500).collect { deviceList ->
102
102
  val newDevices = deviceList - devices
103
103
  devices = deviceList
@@ -233,7 +233,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
233
233
  fun getProductDataPointConfig(options: ReadableMap, result: Callback) {
234
234
  var config = RNGizParamsChecker.check(options, result, GizGetProductConfig::class.java)
235
235
  config?.let {
236
- CoroutineScope(Dispatchers.Main).launch {
236
+ CoroutineScope(Dispatchers.IO).launch {
237
237
  try {
238
238
  val config = GizSDKManager.getProductDataPointConfig(config.productKey)
239
239
  if (config != null) {
@@ -250,7 +250,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
250
250
  }
251
251
  @ReactMethod
252
252
  fun getDevices(options: ReadableMap, result: Callback) {
253
- CoroutineScope(Dispatchers.Main).launch {
253
+ CoroutineScope(Dispatchers.IO).launch {
254
254
  // 查询 绑定设备 返回设备列表
255
255
  GizSDKManager.queryBoundDevices()
256
256
  deviceListState.take(1).collect {
@@ -283,7 +283,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
283
283
 
284
284
  @ReactMethod
285
285
  fun cleanCache(options: ReadableMap, result: Callback) {
286
- CoroutineScope(Dispatchers.Main).launch {
286
+ CoroutineScope(Dispatchers.IO).launch {
287
287
  GizSDKManager.cleanCache()
288
288
  GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success<Number>(0))
289
289
  }
@@ -293,7 +293,7 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
293
293
  fun feedback(options: ReadableMap, result: Callback) {
294
294
  var config = RNGizParamsChecker.check(options, result, GizFeedback::class.java)
295
295
  config?.let {
296
- CoroutineScope(Dispatchers.Main).launch {
296
+ CoroutineScope(Dispatchers.IO).launch {
297
297
  GizSDKManager.feedback(config.uploadLog,config.contact,config.content)
298
298
  GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success<Number>(0))
299
299
  }
@@ -41,14 +41,14 @@ class RNGizUserManagerModule(reactContext: ReactApplicationContext) : ReactConte
41
41
  }
42
42
  @ReactMethod
43
43
  fun loginByAnonymous(options: ReadableMap, result: Callback) {
44
- CoroutineScope(Dispatchers.Main).launch {
44
+ CoroutineScope(Dispatchers.IO).launch {
45
45
  val res = GizSDKManager.getUserManager().loginByAnonymous()
46
46
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
47
47
  }
48
48
  }
49
49
  @ReactMethod
50
50
  fun logout(options: ReadableMap, result: Callback) {
51
- CoroutineScope(Dispatchers.Main).launch {
51
+ CoroutineScope(Dispatchers.IO).launch {
52
52
  val res = GizSDKManager.getUserManager().logout()
53
53
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gizwits-sdk-v5",
3
- "version": "1.3.62",
3
+ "version": "1.3.63",
4
4
  "description": "Gizwits",
5
5
  "homepage": "https://github.com/demchenkoalex/react-native-gizwits-sdk-v5#readme",
6
6
  "main": "lib/index.js",