react-native-gizwits-sdk-v5 1.4.85-light → 1.4.89-light
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 +4 -4
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt +90 -0
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizParamsChecker.kt +0 -1
- package/ios/RNGizDeviceManagerModule.swift +18 -10
- package/package.json +1 -1
- package/react-native-gizwits-sdk-v5.podspec +1 -1
package/android/build.gradle
CHANGED
|
@@ -65,10 +65,10 @@ dependencies {
|
|
|
65
65
|
|
|
66
66
|
implementation 'com.github.wendykierp:JTransforms:3.1'
|
|
67
67
|
|
|
68
|
-
implementation("io.github.gizwits:sdk:1.4.
|
|
69
|
-
implementation("io.github.gizwits:sdk-bluetooth:1.4.
|
|
70
|
-
implementation("io.github.gizwits:sdk-lan:1.4.
|
|
71
|
-
implementation("io.github.gizwits:sdk-mqtt:1.4.
|
|
68
|
+
implementation("io.github.gizwits:sdk:1.4.6-light")
|
|
69
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.4.6-light")
|
|
70
|
+
implementation("io.github.gizwits:sdk-lan:1.4.6-light")
|
|
71
|
+
implementation("io.github.gizwits:sdk-mqtt:1.4.6-light")
|
|
72
72
|
// implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
|
|
73
73
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version")
|
|
74
74
|
// retrofit
|
package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt
CHANGED
|
@@ -13,6 +13,7 @@ import com.gizwits.smart.sdk.bluetooth.bleCapability
|
|
|
13
13
|
import com.gizwits.smart.sdk.common.GizConfiguration
|
|
14
14
|
import com.gizwits.smart.sdk.common.ProvideWiFiCredentialsEvent
|
|
15
15
|
import com.gizwits.smart.sdk.core.capacity.CapacityTypes
|
|
16
|
+
import com.gizwits.smart.sdk.core.network.model.GizDeviceLocalTimerParams
|
|
16
17
|
import com.gizwits.smart.sdk.exception.GizException
|
|
17
18
|
import com.gizwits.smart.sdk.lan.lanCapability
|
|
18
19
|
import com.gizwits.smart.sdk.mqtt.mqttCapability
|
|
@@ -76,6 +77,33 @@ data class StopMusicalRhythmParams(
|
|
|
76
77
|
override val id: String,
|
|
77
78
|
): DeviceParams
|
|
78
79
|
|
|
80
|
+
data class QueryTimerParams(
|
|
81
|
+
@SerializedName("id")
|
|
82
|
+
override val id: String,
|
|
83
|
+
@SerializedName("type")
|
|
84
|
+
val type: CapacityTypes,
|
|
85
|
+
): DeviceParams
|
|
86
|
+
|
|
87
|
+
data class DeleteTimerParams(
|
|
88
|
+
@SerializedName("id")
|
|
89
|
+
override val id: String,
|
|
90
|
+
@SerializedName("type")
|
|
91
|
+
val type: CapacityTypes,
|
|
92
|
+
@SerializedName("timerId")
|
|
93
|
+
val timerId: Int,
|
|
94
|
+
): DeviceParams
|
|
95
|
+
|
|
96
|
+
data class CreateTimerParams(
|
|
97
|
+
@SerializedName("id")
|
|
98
|
+
override val id: String,
|
|
99
|
+
@SerializedName("type")
|
|
100
|
+
val type: CapacityTypes,
|
|
101
|
+
@SerializedName("data")
|
|
102
|
+
val data: GizDeviceLocalTimerParams,
|
|
103
|
+
): DeviceParams
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
79
107
|
data class StartMusicalRhythmParams(
|
|
80
108
|
@SerializedName("id")
|
|
81
109
|
override val id: String,
|
|
@@ -472,6 +500,68 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
472
500
|
}
|
|
473
501
|
}
|
|
474
502
|
|
|
503
|
+
@ReactMethod
|
|
504
|
+
fun queryTimer(options: ReadableMap, result: Callback) {
|
|
505
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, QueryTimerParams::class.java)
|
|
506
|
+
if (config !=null && device !=null) {
|
|
507
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
508
|
+
val res = when(config.type) {
|
|
509
|
+
CapacityTypes.BLE -> device.bleCapability.queryTimer()
|
|
510
|
+
CapacityTypes.LAN -> device.lanCapability.queryTimer()
|
|
511
|
+
CapacityTypes.MQTT -> device.mqttCapability.queryTimer()
|
|
512
|
+
}
|
|
513
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
@ReactMethod
|
|
519
|
+
fun deleteTimer(options: ReadableMap, result: Callback) {
|
|
520
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, DeleteTimerParams::class.java)
|
|
521
|
+
if (config !=null && device !=null) {
|
|
522
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
523
|
+
val res = when(config.type) {
|
|
524
|
+
CapacityTypes.BLE -> device.bleCapability.deleteTimer(config.timerId)
|
|
525
|
+
CapacityTypes.LAN -> device.lanCapability.deleteTimer(config.timerId)
|
|
526
|
+
CapacityTypes.MQTT -> device.mqttCapability.deleteTimer(config.timerId)
|
|
527
|
+
}
|
|
528
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
@ReactMethod
|
|
534
|
+
fun createTimer(options: ReadableMap, result: Callback) {
|
|
535
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, CreateTimerParams::class.java)
|
|
536
|
+
if (config !=null && device !=null) {
|
|
537
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
538
|
+
val res = when(config.type) {
|
|
539
|
+
CapacityTypes.BLE -> device.bleCapability.createTimer(config.data)
|
|
540
|
+
CapacityTypes.LAN -> device.lanCapability.createTimer(config.data)
|
|
541
|
+
CapacityTypes.MQTT -> device.mqttCapability.createTimer(config.data)
|
|
542
|
+
}
|
|
543
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
@ReactMethod
|
|
550
|
+
fun editTimer(options: ReadableMap, result: Callback) {
|
|
551
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, CreateTimerParams::class.java)
|
|
552
|
+
if (config !=null && device !=null) {
|
|
553
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
554
|
+
val res = when(config.type) {
|
|
555
|
+
CapacityTypes.BLE -> device.bleCapability.editTimer(config.data)
|
|
556
|
+
CapacityTypes.LAN -> device.lanCapability.editTimer(config.data)
|
|
557
|
+
CapacityTypes.MQTT -> device.mqttCapability.editTimer(config.data)
|
|
558
|
+
}
|
|
559
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
|
|
475
565
|
fun sendEvent(name:String, data: WritableMap?) {
|
|
476
566
|
reactApplicationContext
|
|
477
567
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
@@ -5,7 +5,6 @@ import com.facebook.react.bridge.ReadableNativeMap
|
|
|
5
5
|
import com.gizwits.smart.sdk.GizDevice
|
|
6
6
|
import com.gizwits.smart.sdk.GizSDKManager
|
|
7
7
|
import com.gizwits.smart.sdk.exception.GizException
|
|
8
|
-
import com.gizwits.smart.sdk.exception.GizParseException
|
|
9
8
|
import com.google.gson.Gson
|
|
10
9
|
import com.google.gson.JsonSyntaxException
|
|
11
10
|
import com.google.gson.annotations.SerializedName
|
|
@@ -502,28 +502,36 @@ class RNGizDeviceManagerModule: RCTEventEmitter {
|
|
|
502
502
|
// 开始音乐律动
|
|
503
503
|
@objc
|
|
504
504
|
public func startMusicalRhythm(_ options: NSDictionary, result: @escaping RCTResponseSenderBlock) {
|
|
505
|
-
|
|
506
505
|
if let params = RNGizParamsChecker.check(options: options, result: result, paramsType: StartMusicalRhythmParams.self) {
|
|
507
506
|
// 先找到设备
|
|
508
507
|
|
|
509
508
|
if let device = self.findDevice(id: params.id) {
|
|
509
|
+
var lastExecutionTime: Date? = nil
|
|
510
|
+
|
|
510
511
|
let res = device.startMusicalRhythm(sensitivity: params.sensitivity, mode: params.mode) { [params] data in
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
512
|
+
let now = Date()
|
|
513
|
+
let isBeat = data.isBeat ?? false
|
|
514
|
+
|
|
515
|
+
if isBeat || lastExecutionTime == nil || now.timeIntervalSince(lastExecutionTime!) >= 0.03 {
|
|
516
|
+
lastExecutionTime = now
|
|
517
|
+
|
|
518
|
+
if params.needMonitor {
|
|
519
|
+
var data = [
|
|
520
|
+
"deviceID": params.id,
|
|
521
|
+
"data": GizRNCallbackManager.convertToDictionary(object: data) as Any
|
|
522
|
+
] as [String : Any]?
|
|
523
|
+
self.sendEvent(withName: "GizMusicalRhythmEvnet", body: data)
|
|
524
|
+
data = nil
|
|
525
|
+
}
|
|
517
526
|
}
|
|
518
527
|
}
|
|
519
|
-
|
|
528
|
+
|
|
529
|
+
GizRNCallbackManager.callbackWithResult(callback: result, result: GizResult<Int?, GizAPIException?>(successMessage: "", data: nil))
|
|
520
530
|
} else {
|
|
521
531
|
// 提示设备不存在
|
|
522
532
|
GizRNCallbackManager.callbackWithResult(callback: result, result: GizResult<Int?, GizAPIException?>(error: GizAPIException.GIZ_OPENAPI_DEVICE_NOT_FOUND))
|
|
523
533
|
}
|
|
524
|
-
|
|
525
534
|
}
|
|
526
|
-
|
|
527
535
|
}
|
|
528
536
|
@objc
|
|
529
537
|
public func stopMusicalRhythm(_ options: NSDictionary, result: @escaping RCTResponseSenderBlock) {
|
package/package.json
CHANGED