react-native-gizwits-sdk-v5 1.4.55 → 1.4.57
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.2.
|
|
67
|
-
implementation("io.github.gizwits:sdk-bluetooth:1.2.
|
|
68
|
-
implementation("io.github.gizwits:sdk-lan:1.2.
|
|
69
|
-
implementation("io.github.gizwits:sdk-mqtt:1.2.
|
|
66
|
+
implementation("io.github.gizwits:sdk:1.2.9")
|
|
67
|
+
implementation("io.github.gizwits:sdk-bluetooth:1.2.9")
|
|
68
|
+
implementation("io.github.gizwits:sdk-lan:1.2.9")
|
|
69
|
+
implementation("io.github.gizwits:sdk-mqtt:1.2.9")
|
|
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
|
package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt
CHANGED
|
@@ -16,6 +16,7 @@ import com.gizwits.smart.sdk.core.capacity.CapacityTypes
|
|
|
16
16
|
import com.gizwits.smart.sdk.exception.GizException
|
|
17
17
|
import com.gizwits.smart.sdk.lan.lanCapability
|
|
18
18
|
import com.gizwits.smart.sdk.mqtt.mqttCapability
|
|
19
|
+
import com.gizwits.smart.sdk.light.MusicalRhythmParseMode
|
|
19
20
|
import com.gizwits.smart.sdk.mqtt.queryBoundDevices
|
|
20
21
|
import com.gizwits.smart.sdk.ota.GizOTAFirmwareType
|
|
21
22
|
import com.gizwits.smart.sdk.ota.OTAProgressData
|
|
@@ -69,6 +70,22 @@ data class GizUnBindParams(
|
|
|
69
70
|
override val id: String,
|
|
70
71
|
): DeviceParams
|
|
71
72
|
|
|
73
|
+
data class StopMusicalRhythmParams(
|
|
74
|
+
@SerializedName("id")
|
|
75
|
+
override val id: String,
|
|
76
|
+
): DeviceParams
|
|
77
|
+
|
|
78
|
+
data class StartMusicalRhythmParams(
|
|
79
|
+
@SerializedName("id")
|
|
80
|
+
override val id: String,
|
|
81
|
+
@SerializedName("needMonitor")
|
|
82
|
+
val needMonitor: Boolean,
|
|
83
|
+
@SerializedName("sensitivity")
|
|
84
|
+
val sensitivity: Int,
|
|
85
|
+
@SerializedName("mode")
|
|
86
|
+
val mode: MusicalRhythmParseMode,
|
|
87
|
+
): DeviceParams
|
|
88
|
+
|
|
72
89
|
data class GizConnectParams(
|
|
73
90
|
@SerializedName("id")
|
|
74
91
|
override val id: String,
|
|
@@ -132,6 +149,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
132
149
|
enum class EventName(val value: String) {
|
|
133
150
|
GizOTAProgressEvent("GizOTAProgressEvent"),
|
|
134
151
|
GizProvideWiFiCredentialsEvent("GizProvideWiFiCredentialsEvent"),
|
|
152
|
+
GizMusicalRhythmEvnet("GizMusicalRhythmEvnet")
|
|
135
153
|
}
|
|
136
154
|
|
|
137
155
|
fun jsonObjectToPairs(jsonObject: JsonObject): Array<Pair<String, Any>> {
|
|
@@ -406,6 +424,38 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
406
424
|
}
|
|
407
425
|
}
|
|
408
426
|
}
|
|
427
|
+
@ReactMethod
|
|
428
|
+
fun startMusicalRhythm(options: ReadableMap, result: Callback) {
|
|
429
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StartMusicalRhythmParams::class.java)
|
|
430
|
+
print("startMusicalRhythm ${config}")
|
|
431
|
+
if (config !=null && device !=null) {
|
|
432
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
433
|
+
val res = device.startMusicalRhythm(config.sensitivity, config.mode) {
|
|
434
|
+
if (config.needMonitor) {
|
|
435
|
+
val jsonObject = JSONObject()
|
|
436
|
+
val gson = Gson()
|
|
437
|
+
val dataString = gson.toJson(it)
|
|
438
|
+
jsonObject.put("data", dataString)
|
|
439
|
+
jsonObject.put("deviceID", config.id)
|
|
440
|
+
sendEvent(EventName.GizMusicalRhythmEvnet.name, GizRNCallbackManager.jsonObject2WriteableMap(jsonObject))
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success(Unit))
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
@ReactMethod
|
|
448
|
+
fun stopMusicalRhythm(options: ReadableMap, result: Callback) {
|
|
449
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StopMusicalRhythmParams::class.java)
|
|
450
|
+
if (config !=null && device !=null) {
|
|
451
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
452
|
+
val res = device.stopMusicalRhythm();
|
|
453
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success(Unit))
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
|
|
409
459
|
|
|
410
460
|
fun sendEvent(name:String, data: WritableMap?) {
|
|
411
461
|
reactApplicationContext
|