react-native-gizwits-sdk-v5 1.5.6-light → 1.5.6-thirdbluetooth

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.
Files changed (146) hide show
  1. package/android/build.gradle +7 -5
  2. package/android/libs/sdk-bluetooth-release.aar +0 -0
  3. package/android/libs/sdk-lan-release.aar +0 -0
  4. package/android/libs/sdk-mqtt-release.aar +0 -0
  5. package/android/libs/sdk-release.aar +0 -0
  6. package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/GizRNCallbackManager.kt +6 -5
  7. package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt +123 -85
  8. package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizParamsChecker.kt +1 -0
  9. package/ios/GizwitsiOSSDK.framework/GizwitsiOSSDK +0 -0
  10. package/ios/GizwitsiOSSDK.framework/Headers/CocoaAsyncSocket.h +18 -0
  11. package/ios/GizwitsiOSSDK.framework/Headers/DDASLLogger.h +41 -0
  12. package/ios/GizwitsiOSSDK.framework/Headers/DDAbstractDatabaseLogger.h +102 -0
  13. package/ios/GizwitsiOSSDK.framework/Headers/DDContextFilterLogFormatter.h +63 -0
  14. package/ios/GizwitsiOSSDK.framework/Headers/DDDispatchQueueLogFormatter.h +128 -0
  15. package/ios/GizwitsiOSSDK.framework/Headers/DDFileLogger.h +340 -0
  16. package/ios/GizwitsiOSSDK.framework/Headers/DDLog+LOGV.h +99 -0
  17. package/ios/GizwitsiOSSDK.framework/Headers/DDLog.h +632 -0
  18. package/ios/GizwitsiOSSDK.framework/Headers/DDMultiFormatter.h +30 -0
  19. package/ios/GizwitsiOSSDK.framework/Headers/DDTTYLogger.h +171 -0
  20. package/ios/GizwitsiOSSDK.framework/Headers/ESPAES.h +19 -0
  21. package/ios/GizwitsiOSSDK.framework/Headers/ESPDataCode.h +44 -0
  22. package/ios/GizwitsiOSSDK.framework/Headers/ESPDatumCode.h +38 -0
  23. package/ios/GizwitsiOSSDK.framework/Headers/ESPGuideCode.h +15 -0
  24. package/ios/GizwitsiOSSDK.framework/Headers/ESPTools.h +22 -0
  25. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouch.h +36 -0
  26. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchDelegate.h +24 -0
  27. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchGenerator.h +46 -0
  28. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchResult.h +36 -0
  29. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchTask.h +124 -0
  30. package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchTaskParameter.h +173 -0
  31. package/ios/GizwitsiOSSDK.framework/Headers/ESPUDPSocketClient.h +50 -0
  32. package/ios/GizwitsiOSSDK.framework/Headers/ESPUDPSocketServer.h +49 -0
  33. package/ios/GizwitsiOSSDK.framework/Headers/ESP_ByteUtil.h +128 -0
  34. package/ios/GizwitsiOSSDK.framework/Headers/ESP_CRC8.h +61 -0
  35. package/ios/GizwitsiOSSDK.framework/Headers/ESP_NetUtil.h +82 -0
  36. package/ios/GizwitsiOSSDK.framework/Headers/ESP_WifiUtil.h +33 -0
  37. package/ios/GizwitsiOSSDK.framework/Headers/ForegroundReconnection.h +23 -0
  38. package/ios/GizwitsiOSSDK.framework/Headers/GCDTimer.h +19 -0
  39. package/ios/GizwitsiOSSDK.framework/Headers/GizwitsiOSSDK-Swift.h +338 -0
  40. package/ios/GizwitsiOSSDK.framework/Headers/GizwitsiOSSDK.h +24 -0
  41. package/ios/GizwitsiOSSDK.framework/Headers/MQTTClient.h +39 -0
  42. package/ios/GizwitsiOSSDK.framework/Headers/MQTTInMemoryPersistence.h +16 -0
  43. package/ios/GizwitsiOSSDK.framework/Headers/MQTTSSLSecurityPolicyDecoder.h +19 -0
  44. package/ios/GizwitsiOSSDK.framework/Headers/MQTTSSLSecurityPolicyEncoder.h +18 -0
  45. package/ios/GizwitsiOSSDK.framework/Headers/MQTTSessionLegacy.h +112 -0
  46. package/ios/GizwitsiOSSDK.framework/Headers/MQTTSessionSynchron.h +194 -0
  47. package/ios/GizwitsiOSSDK.framework/Headers/MQTTStrict.h +33 -0
  48. package/ios/GizwitsiOSSDK.framework/Headers/MQTTUntil.h +14 -0
  49. package/ios/GizwitsiOSSDK.framework/Headers/ReconnectTimer.h +21 -0
  50. package/ios/GizwitsiOSSDK.framework/Headers/_GCDAsyncSocket.h +1226 -0
  51. package/ios/GizwitsiOSSDK.framework/Headers/_GCDAsyncUdpSocket.h +1036 -0
  52. package/ios/GizwitsiOSSDK.framework/Headers/_GizwitsParser.h +61 -0
  53. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketDecoder.h +39 -0
  54. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketEncoder.h +38 -0
  55. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketTransport.h +79 -0
  56. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCoreDataPersistence.h +21 -0
  57. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTDecoder.h +66 -0
  58. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTLog.h +123 -0
  59. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTMessage.h +233 -0
  60. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTPersistence.h +124 -0
  61. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTProperties.h +76 -0
  62. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSSLSecurityPolicy.h +158 -0
  63. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSSLSecurityPolicyTransport.h +30 -0
  64. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSession.h +886 -0
  65. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSessionManager.h +237 -0
  66. package/ios/GizwitsiOSSDK.framework/Headers/_MQTTTransport.h +114 -0
  67. package/ios/GizwitsiOSSDK.framework/Headers/_SSZipArchive.h +178 -0
  68. package/ios/GizwitsiOSSDK.framework/Headers/_SSZipCommon.h +71 -0
  69. package/ios/GizwitsiOSSDK.framework/Headers/_ZipArchive.h +26 -0
  70. package/ios/GizwitsiOSSDK.framework/Headers/a_weighting.h +88 -0
  71. package/ios/GizwitsiOSSDK.framework/Headers/aubio.h +231 -0
  72. package/ios/GizwitsiOSSDK.framework/Headers/audio_unit.h +61 -0
  73. package/ios/GizwitsiOSSDK.framework/Headers/awhitening.h +125 -0
  74. package/ios/GizwitsiOSSDK.framework/Headers/beattracking.h +121 -0
  75. package/ios/GizwitsiOSSDK.framework/Headers/biquad.h +75 -0
  76. package/ios/GizwitsiOSSDK.framework/Headers/c_weighting.h +88 -0
  77. package/ios/GizwitsiOSSDK.framework/Headers/common.h +104 -0
  78. package/ios/GizwitsiOSSDK.framework/Headers/cvec.h +247 -0
  79. package/ios/GizwitsiOSSDK.framework/Headers/dct.h +85 -0
  80. package/ios/GizwitsiOSSDK.framework/Headers/fft.h +144 -0
  81. package/ios/GizwitsiOSSDK.framework/Headers/filter.h +176 -0
  82. package/ios/GizwitsiOSSDK.framework/Headers/filterbank.h +90 -0
  83. package/ios/GizwitsiOSSDK.framework/Headers/filterbank_mel.h +72 -0
  84. package/ios/GizwitsiOSSDK.framework/Headers/fmat.h +172 -0
  85. package/ios/GizwitsiOSSDK.framework/Headers/fvec.h +178 -0
  86. package/ios/GizwitsiOSSDK.framework/Headers/hist.h +63 -0
  87. package/ios/GizwitsiOSSDK.framework/Headers/ioutils.h +60 -0
  88. package/ios/GizwitsiOSSDK.framework/Headers/log.h +99 -0
  89. package/ios/GizwitsiOSSDK.framework/Headers/lvec.h +118 -0
  90. package/ios/GizwitsiOSSDK.framework/Headers/mathutils.h +330 -0
  91. package/ios/GizwitsiOSSDK.framework/Headers/mfcc.h +79 -0
  92. package/ios/GizwitsiOSSDK.framework/Headers/musicutils.h +171 -0
  93. package/ios/GizwitsiOSSDK.framework/Headers/notes.h +113 -0
  94. package/ios/GizwitsiOSSDK.framework/Headers/onset.h +347 -0
  95. package/ios/GizwitsiOSSDK.framework/Headers/parameter.h +159 -0
  96. package/ios/GizwitsiOSSDK.framework/Headers/peakpicker.h +57 -0
  97. package/ios/GizwitsiOSSDK.framework/Headers/phasevoc.h +112 -0
  98. package/ios/GizwitsiOSSDK.framework/Headers/pitch.h +197 -0
  99. package/ios/GizwitsiOSSDK.framework/Headers/pitchfcomb.h +76 -0
  100. package/ios/GizwitsiOSSDK.framework/Headers/pitchmcomb.h +77 -0
  101. package/ios/GizwitsiOSSDK.framework/Headers/pitchschmitt.h +75 -0
  102. package/ios/GizwitsiOSSDK.framework/Headers/pitchspecacf.h +103 -0
  103. package/ios/GizwitsiOSSDK.framework/Headers/pitchyin.h +100 -0
  104. package/ios/GizwitsiOSSDK.framework/Headers/pitchyinfast.h +102 -0
  105. package/ios/GizwitsiOSSDK.framework/Headers/pitchyinfft.h +99 -0
  106. package/ios/GizwitsiOSSDK.framework/Headers/resampler.h +65 -0
  107. package/ios/GizwitsiOSSDK.framework/Headers/sampler.h +140 -0
  108. package/ios/GizwitsiOSSDK.framework/Headers/scale.h +80 -0
  109. package/ios/GizwitsiOSSDK.framework/Headers/sink.h +181 -0
  110. package/ios/GizwitsiOSSDK.framework/Headers/sink_apple_audio.h +163 -0
  111. package/ios/GizwitsiOSSDK.framework/Headers/sink_sndfile.h +162 -0
  112. package/ios/GizwitsiOSSDK.framework/Headers/sink_wavwrite.h +162 -0
  113. package/ios/GizwitsiOSSDK.framework/Headers/source.h +184 -0
  114. package/ios/GizwitsiOSSDK.framework/Headers/source_apple_audio.h +156 -0
  115. package/ios/GizwitsiOSSDK.framework/Headers/source_avcodec.h +155 -0
  116. package/ios/GizwitsiOSSDK.framework/Headers/source_sndfile.h +155 -0
  117. package/ios/GizwitsiOSSDK.framework/Headers/source_wavread.h +160 -0
  118. package/ios/GizwitsiOSSDK.framework/Headers/specdesc.h +204 -0
  119. package/ios/GizwitsiOSSDK.framework/Headers/tempo.h +255 -0
  120. package/ios/GizwitsiOSSDK.framework/Headers/tss.h +103 -0
  121. package/ios/GizwitsiOSSDK.framework/Headers/types.h +70 -0
  122. package/ios/GizwitsiOSSDK.framework/Headers/vecutils.h +116 -0
  123. package/ios/GizwitsiOSSDK.framework/Headers/wavetable.h +178 -0
  124. package/ios/GizwitsiOSSDK.framework/Info.plist +0 -0
  125. package/ios/GizwitsiOSSDK.framework/LICENSE +17 -0
  126. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  127. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.abi.json +57489 -0
  128. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +1752 -0
  129. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  130. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftinterface +1752 -0
  131. package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
  132. package/ios/GizwitsiOSSDK.framework/Modules/module.modulemap +11 -0
  133. package/ios/GizwitsiOSSDK.framework/PrivacyInfo.xcprivacy +23 -0
  134. package/ios/GizwitsiOSSDK.framework/README.md +31 -0
  135. package/ios/RNGizDeviceManagerModule.m +2 -5
  136. package/ios/RNGizDeviceManagerModule.swift +43 -155
  137. package/ios/RNGizSDKManagerModule.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  138. package/ios/RNGizSDKManagerModule.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  139. package/lib/device.d.ts +3 -5
  140. package/lib/device.js +6 -28
  141. package/lib/device.js.map +1 -1
  142. package/lib/index.js +0 -42
  143. package/lib/index.js.map +1 -1
  144. package/lib/types.d.ts +0 -22
  145. package/package.json +1 -1
  146. package/react-native-gizwits-sdk-v5.podspec +2 -2
@@ -64,12 +64,14 @@ dependencies {
64
64
  implementation "androidx.startup:startup-runtime:$startup_version"
65
65
 
66
66
  implementation 'com.github.wendykierp:JTransforms:3.1'
67
+ // ESPTouch
68
+ implementation 'com.github.EspressifApp:lib-esptouch-android:1.1.1'
67
69
 
68
- implementation("io.github.gizwits:sdk:1.6.1-light")
69
- implementation("io.github.gizwits:sdk-bluetooth:1.6.1-light")
70
- implementation("io.github.gizwits:sdk-lan:1.6.1-light")
71
- implementation("io.github.gizwits:sdk-mqtt:1.6.1-light")
72
- // implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
70
+ implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
71
+ // implementation("io.github.gizwits:sdk:1.4.2")
72
+ // implementation("io.github.gizwits:sdk-bluetooth:1.4.2")
73
+ // implementation("io.github.gizwits:sdk-lan:1.4.2")
74
+ // implementation("io.github.gizwits:sdk-mqtt:1.4.2")
73
75
  implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version")
74
76
  // retrofit
75
77
  implementation("com.squareup.retrofit2:retrofit:$retrofit_version")
Binary file
Binary file
@@ -33,11 +33,12 @@ object GizRNCallbackManager {
33
33
  } else {
34
34
  data.success = false
35
35
  result.exceptionOrNull()?.let {
36
- try {
37
- data.error = (it as GizException).errorCode
38
- data.message = (it as GizException).localizedMessage
39
- } catch (e: Exception) {
40
-
36
+ if (it is GizException) {
37
+ data.error = it.errorCode
38
+ data.message = it.localizedMessage ?: it.message ?: ""
39
+ } else {
40
+ // 对于非 GizException 的异常(如 IllegalArgumentException),使用异常的消息
41
+ data.message = it.message ?: it.localizedMessage ?: it.toString()
41
42
  }
42
43
  }
43
44
  }
@@ -8,13 +8,14 @@ import com.facebook.react.bridge.ReadableMap
8
8
  import com.facebook.react.bridge.WritableMap
9
9
  import com.facebook.react.modules.core.DeviceEventManagerModule
10
10
  import com.gizwits.smart.sdk.GizDevice
11
+ import com.gizwits.smart.sdk.esptouch.GizESPTouchSmartConfig
11
12
  import com.gizwits.smart.sdk.GizSDKManager
12
13
  import com.gizwits.smart.sdk.bluetooth.bleCapability
13
14
  import com.gizwits.smart.sdk.common.GizConfiguration
14
- import com.gizwits.smart.sdk.common.ProvideWiFiCredentialsEvent
15
+ import com.gizwits.smart.sdk.common.GizWiFiActivatorEvent
15
16
  import com.gizwits.smart.sdk.core.capacity.CapacityTypes
16
- import com.gizwits.smart.sdk.core.network.model.GizDeviceLocalTimerParams
17
17
  import com.gizwits.smart.sdk.exception.GizException
18
+ import com.gizwits.smart.sdk.extend.hexToByteArray
18
19
  import com.gizwits.smart.sdk.lan.lanCapability
19
20
  import com.gizwits.smart.sdk.mqtt.mqttCapability
20
21
  import com.gizwits.smart.sdk.light.MusicalRhythmParseMode
@@ -27,6 +28,8 @@ import com.google.gson.JsonObject
27
28
  import com.google.gson.annotations.SerializedName
28
29
  import kotlinx.coroutines.CoroutineScope
29
30
  import kotlinx.coroutines.Dispatchers
31
+ import kotlinx.coroutines.SupervisorJob
32
+ import kotlinx.coroutines.cancel
30
33
  import kotlinx.coroutines.launch
31
34
  import org.json.JSONArray
32
35
  import org.json.JSONObject
@@ -77,33 +80,22 @@ data class StopMusicalRhythmParams(
77
80
  override val id: String,
78
81
  ): DeviceParams
79
82
 
80
- data class QueryTimerParams(
83
+ data class SetDeviceMtuParams(
81
84
  @SerializedName("id")
82
85
  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,
86
+ @SerializedName("mtu")
87
+ val mtu: Int,
94
88
  ): DeviceParams
95
89
 
96
- data class CreateTimerParams(
90
+ data class SendThirdDeviceDpParams(
97
91
  @SerializedName("id")
98
92
  override val id: String,
99
- @SerializedName("type")
100
- val type: CapacityTypes,
101
93
  @SerializedName("data")
102
- val data: GizDeviceLocalTimerParams,
94
+ val data: String,
95
+ @SerializedName("characteristicUuid")
96
+ val characteristicUuid: String? = null,
103
97
  ): DeviceParams
104
98
 
105
-
106
-
107
99
  data class StartMusicalRhythmParams(
108
100
  @SerializedName("id")
109
101
  override val id: String,
@@ -145,6 +137,20 @@ data class GizProvideWiFiCredentialsParams(
145
137
  @SerializedName("timeout")
146
138
  val timeout: Long,
147
139
  ): DeviceParams
140
+
141
+ data class GizProvideWiFiCredentialsWithAirLinkParams(
142
+ @SerializedName("ssid")
143
+ val ssid: String,
144
+ @SerializedName("password")
145
+ val password: String,
146
+ @SerializedName("timeout")
147
+ val timeout: Long,
148
+ @SerializedName("productKeys")
149
+ val productKeys: List<String>,
150
+ ): DeviceParams {
151
+ override val id: String = "airlink" // AirLink 配网不需要设备ID
152
+ }
153
+
148
154
  data class GizStopProvideWiFiCredentialsParams(
149
155
  @SerializedName("id")
150
156
  override val id: String,
@@ -175,6 +181,8 @@ data class StopUpgradeParams(
175
181
 
176
182
 
177
183
  class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
184
+ private val moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
185
+
178
186
  enum class EventName(val value: String) {
179
187
  GizOTAProgressEvent("GizOTAProgressEvent"),
180
188
  GizProvideWiFiCredentialsEvent("GizProvideWiFiCredentialsEvent"),
@@ -191,11 +199,17 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
191
199
  }
192
200
 
193
201
  override fun getName() = "RNGizDeviceManagerModule"
202
+
203
+ override fun onCatalystInstanceDestroy() {
204
+ super.onCatalystInstanceDestroy()
205
+ moduleScope.cancel() // 取消所有协程
206
+ }
207
+
194
208
  @ReactMethod
195
209
  fun sendDp(options: ReadableMap, result: Callback) {
196
210
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizSendDPParams::class.java)
197
211
  if (config !=null && device !=null) {
198
- CoroutineScope(Dispatchers.IO).launch {
212
+ moduleScope.launch {
199
213
  try {
200
214
  val gson = Gson()
201
215
  val jsonObject = gson.fromJson(config.data, JsonObject::class.java)
@@ -216,7 +230,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
216
230
  fun getDp(options: ReadableMap, result: Callback) {
217
231
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizGetDPParams::class.java)
218
232
  if (config !=null && device !=null) {
219
- CoroutineScope(Dispatchers.IO).launch {
233
+ moduleScope.launch {
220
234
  var res = when(config.type) {
221
235
  CapacityTypes.BLE -> device.bleCapability.getDp(config.attrs)
222
236
  CapacityTypes.LAN -> device.lanCapability.getDp(config.attrs)
@@ -238,7 +252,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
238
252
  fun getDeviceInfo(options: ReadableMap, result: Callback) {
239
253
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizGetDeviceInfoParams::class.java)
240
254
  if (config !=null && device !=null) {
241
- CoroutineScope(Dispatchers.IO).launch {
255
+ moduleScope.launch {
242
256
  val res = when(config.type) {
243
257
  CapacityTypes.BLE -> device.bleCapability.getDeviceInfo()
244
258
  CapacityTypes.LAN -> device.lanCapability.getDeviceInfo()
@@ -253,7 +267,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
253
267
  fun updateDeviceInfo(options: ReadableMap, result: Callback) {
254
268
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, UpdateDeviceInfoParams::class.java)
255
269
  if (config !=null && device !=null) {
256
- CoroutineScope(Dispatchers.IO).launch {
270
+ moduleScope.launch {
257
271
  val res = device.updateDeviceInfo(config.alias, config.remark)
258
272
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
259
273
  // if (res.isSuccess) {
@@ -267,7 +281,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
267
281
  fun bind(options: ReadableMap, result: Callback) {
268
282
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizBindParams::class.java)
269
283
  if (config !=null && device !=null) {
270
- CoroutineScope(Dispatchers.IO).launch {
284
+ moduleScope.launch {
271
285
  val res = device.bind(config.alias, config.remark)
272
286
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
273
287
  // if (res.isSuccess) {
@@ -281,7 +295,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
281
295
  fun unBind(options: ReadableMap, result: Callback) {
282
296
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizUnBindParams::class.java)
283
297
  if (config !=null && device !=null) {
284
- CoroutineScope(Dispatchers.IO).launch {
298
+ moduleScope.launch {
285
299
  val res = device.unBind()
286
300
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
287
301
  if (res.isSuccess) {
@@ -294,7 +308,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
294
308
  fun stopProvideWiFiCredentials(options: ReadableMap, result: Callback) {
295
309
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizStopProvideWiFiCredentialsParams::class.java)
296
310
  if (config !=null && device !=null) {
297
- CoroutineScope(Dispatchers.IO).launch {
311
+ moduleScope.launch {
298
312
  val res = when(config.type) {
299
313
  CapacityTypes.BLE -> device.bleCapability.stopProvideWiFiCredentials()
300
314
  CapacityTypes.LAN -> device.lanCapability.stopProvideWiFiCredentials()
@@ -305,7 +319,15 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
305
319
  }
306
320
  }
307
321
 
308
- fun wiFiCredentialsEventHandler(event: ProvideWiFiCredentialsEvent, device: GizDevice) {
322
+ @ReactMethod
323
+ fun stopProvideWiFiCredentialsWithAirLink(result: Callback) {
324
+ moduleScope.launch {
325
+ val res = GizESPTouchSmartConfig.stopProvideWiFiCredentialsWithAirLink()
326
+ GizRNCallbackManager.callbackWithResult(callback = result, result = res)
327
+ }
328
+ }
329
+
330
+ fun wiFiCredentialsEventHandler(event: GizWiFiActivatorEvent, device: GizDevice) {
309
331
  val jsonObject = JSONObject()
310
332
  jsonObject.put("data", event.toString())
311
333
  jsonObject.put("device", device.toJsonObject())
@@ -314,11 +336,21 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
314
336
  GizRNCallbackManager.jsonObject2WriteableMap(jsonObject)
315
337
  )
316
338
  }
339
+
340
+ fun wiFiCredentialsWithAirLinkEventHandler(event: GizWiFiActivatorEvent) {
341
+ val jsonObject = JSONObject()
342
+ jsonObject.put("data", event.toString())
343
+ sendEvent(
344
+ EventName.GizProvideWiFiCredentialsEvent.name,
345
+ GizRNCallbackManager.jsonObject2WriteableMap(jsonObject)
346
+ )
347
+ }
348
+
317
349
  @ReactMethod
318
350
  fun provideWiFiCredentials(options: ReadableMap, result: Callback) {
319
351
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizProvideWiFiCredentialsParams::class.java)
320
352
  if (config !=null && device !=null) {
321
- CoroutineScope(Dispatchers.IO).launch {
353
+ moduleScope.launch {
322
354
  val res = when(config.type) {
323
355
  CapacityTypes.BLE -> device.bleCapability.provideWiFiCredentials(
324
356
  config.ssid,
@@ -350,11 +382,31 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
350
382
  }
351
383
  }
352
384
 
385
+ @ReactMethod
386
+ fun provideWiFiCredentialsWithAirLink(options: ReadableMap, result: Callback) {
387
+ val config = RNGizParamsChecker.check(options, result, GizProvideWiFiCredentialsWithAirLinkParams::class.java)
388
+ config?.let {
389
+ moduleScope.launch {
390
+ val res = GizESPTouchSmartConfig.provideWiFiCredentialsWithAirLink(
391
+ reactApplicationContext,
392
+ config.ssid,
393
+ config.password,
394
+ config.timeout,
395
+ config.productKeys,
396
+ processHandler = {
397
+ wiFiCredentialsWithAirLinkEventHandler(it)
398
+ }
399
+ )
400
+ GizRNCallbackManager.callbackWithResult(callback = result, result = res)
401
+ }
402
+ }
403
+ }
404
+
353
405
  @ReactMethod
354
406
  fun register(options: ReadableMap, result: Callback) {
355
407
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizRegisterDeviceParams::class.java)
356
408
  if (config !=null && device !=null) {
357
- CoroutineScope(Dispatchers.IO).launch {
409
+ moduleScope.launch {
358
410
  val res = device.register()
359
411
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
360
412
  }
@@ -365,7 +417,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
365
417
  fun connect(options: ReadableMap, result: Callback) {
366
418
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizConnectParams::class.java)
367
419
  if (config !=null && device !=null) {
368
- CoroutineScope(Dispatchers.IO).launch {
420
+ moduleScope.launch {
369
421
  val res = when(config.type) {
370
422
  CapacityTypes.BLE -> device.bleCapability.connect()
371
423
  CapacityTypes.LAN -> device.lanCapability.connect()
@@ -379,7 +431,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
379
431
  fun disConnect(options: ReadableMap, result: Callback) {
380
432
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizDisConnectParams::class.java)
381
433
  if (config !=null && device !=null) {
382
- CoroutineScope(Dispatchers.IO).launch {
434
+ moduleScope.launch {
383
435
  val res = when(config.type) {
384
436
  CapacityTypes.BLE -> device.bleCapability.disConnect()
385
437
  CapacityTypes.LAN -> device.lanCapability.disConnect()
@@ -394,7 +446,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
394
446
  fun checkUpdate(options: ReadableMap, result: Callback) {
395
447
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizCheckUpdateParams::class.java)
396
448
  if (config !=null && device !=null) {
397
- CoroutineScope(Dispatchers.IO).launch {
449
+ moduleScope.launch {
398
450
  val res = when(config.type) {
399
451
  CapacityTypes.BLE -> device.bleCapability.checkUpdate(config.firmwareType)
400
452
  CapacityTypes.LAN -> device.lanCapability.checkUpdate(config.firmwareType)
@@ -421,7 +473,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
421
473
  fun startUpgrade(options: ReadableMap, result: Callback) {
422
474
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizCheckUpdateParams::class.java)
423
475
  if (config !=null && device !=null) {
424
- CoroutineScope(Dispatchers.IO).launch {
476
+ moduleScope.launch {
425
477
  val res = when(config.type) {
426
478
  CapacityTypes.BLE -> {
427
479
  device.bleCapability.startUpgrade(config.firmwareType, processHandler = {
@@ -443,7 +495,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
443
495
  fun cancelUpgrade(options: ReadableMap, result: Callback) {
444
496
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StopUpgradeParams::class.java)
445
497
  if (config !=null && device !=null) {
446
- CoroutineScope(Dispatchers.IO).launch {
498
+ moduleScope.launch {
447
499
  val res = when(config.type) {
448
500
  CapacityTypes.BLE -> device.bleCapability.cancelUpgrade()
449
501
  CapacityTypes.LAN -> device.lanCapability.cancelUpgrade()
@@ -458,7 +510,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
458
510
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StartMusicalRhythmParams::class.java)
459
511
  print("startMusicalRhythm ${config}")
460
512
  if (config !=null && device !=null) {
461
- CoroutineScope(Dispatchers.IO).launch {
513
+ moduleScope.launch {
462
514
  val res = device.startMusicalRhythm(config.sensitivity, config.mode) { data ->
463
515
  if (config.needMonitor) {
464
516
  val jsonObject = JSONObject()
@@ -493,7 +545,7 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
493
545
  fun stopMusicalRhythm(options: ReadableMap, result: Callback) {
494
546
  val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, StopMusicalRhythmParams::class.java)
495
547
  if (config !=null && device !=null) {
496
- CoroutineScope(Dispatchers.IO).launch {
548
+ moduleScope.launch {
497
549
  val res = device.stopMusicalRhythm();
498
550
  GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success(Unit))
499
551
  }
@@ -501,67 +553,53 @@ class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactCon
501
553
  }
502
554
 
503
555
  @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)
556
+ fun setDeviceMtu(options: ReadableMap, result: Callback) {
557
+ val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, SetDeviceMtuParams::class.java)
536
558
  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
- }
559
+ moduleScope.launch {
560
+ val res = device.setDeviceMtu(config.mtu);
543
561
  GizRNCallbackManager.callbackWithResult(callback = result, result = res)
544
562
  }
545
563
  }
546
564
  }
547
565
 
548
-
549
566
  @ReactMethod
550
- fun editTimer(options: ReadableMap, result: Callback) {
551
- val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, CreateTimerParams::class.java)
567
+ fun sendThirdDeviceDp(options: ReadableMap, result: Callback) {
568
+ val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, SendThirdDeviceDpParams::class.java)
552
569
  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)
570
+ moduleScope.launch {
571
+ try {
572
+ // 第三方设备直接透传原始数据,使用特殊键 "rawData" 标识原始数据
573
+ // 只支持十六进制字符串格式(只包含 0-9A-Fa-f,且长度为偶数)
574
+ if (!config.data.matches(Regex("^[0-9A-Fa-f]+$"))) {
575
+ GizRNCallbackManager.callbackWithResult(
576
+ callback = result,
577
+ result = Result.failure<Unit>(IllegalArgumentException("Data must be a valid hexadecimal string (0-9A-Fa-f only)"))
578
+ )
579
+ return@launch
580
+ }
581
+
582
+ if (config.data.length % 2 != 0) {
583
+ GizRNCallbackManager.callbackWithResult(
584
+ callback = result,
585
+ result = Result.failure<Unit>(IllegalArgumentException("Hex string length must be even"))
586
+ )
587
+ return@launch
588
+ }
589
+
590
+ // 使用十六进制解码
591
+ val rawData: ByteArray = config.data.hexToByteArray()
592
+
593
+ // 使用特殊键 "rawData" 传递原始数据,sendThirdDeviceDp 会识别并直接透传
594
+ val res = device.sendThirdDeviceDp("rawData" to rawData, characteristicUuid = config.characteristicUuid)
595
+ GizRNCallbackManager.callbackWithResult(callback = result, result = res)
596
+ } catch (e: Exception) {
597
+ GizRNCallbackManager.callbackWithResult(callback = result, result = Result.failure<Unit>(e))
558
598
  }
559
- GizRNCallbackManager.callbackWithResult(callback = result, result = res)
560
599
  }
561
600
  }
562
601
  }
563
602
 
564
-
565
603
  fun sendEvent(name:String, data: WritableMap?) {
566
604
  reactApplicationContext
567
605
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -5,6 +5,7 @@ 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
8
9
  import com.google.gson.Gson
9
10
  import com.google.gson.JsonSyntaxException
10
11
  import com.google.gson.annotations.SerializedName
@@ -0,0 +1,18 @@
1
+ //
2
+ // CocoaAsyncSocket.h
3
+ // CocoaAsyncSocket
4
+ //
5
+ // Created by Derek Clarkson on 10/08/2015.
6
+ // CocoaAsyncSocket project is in the public domain.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ //! Project version number for CocoaAsyncSocket.
12
+ FOUNDATION_EXPORT double _cocoaAsyncSocketVersionNumber;
13
+
14
+ //! Project version string for CocoaAsyncSocket.
15
+ FOUNDATION_EXPORT const unsigned char _cocoaAsyncSocketVersionString[];
16
+
17
+ #import "_GCDAsyncSocket.h"
18
+ #import "_GCDAsyncUdpSocket.h"
@@ -0,0 +1,41 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <asl.h>
3
+
4
+ #import "DDLog.h"
5
+
6
+ /**
7
+ * Welcome to Cocoa Lumberjack!
8
+ *
9
+ * The project page has a wealth of documentation if you have any questions.
10
+ * https://github.com/CocoaLumberjack/CocoaLumberjack
11
+ *
12
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
13
+ * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14
+ *
15
+ *
16
+ * This class provides a logger for the Apple System Log facility.
17
+ *
18
+ * As described in the "Getting Started" page,
19
+ * the traditional NSLog() function directs it's output to two places:
20
+ *
21
+ * - Apple System Log
22
+ * - StdErr (if stderr is a TTY) so log statements show up in Xcode console
23
+ *
24
+ * To duplicate NSLog() functionality you can simply add this logger and a tty logger.
25
+ * However, if you instead choose to use file logging (for faster performance),
26
+ * you may choose to use a file logger and a tty logger.
27
+ **/
28
+
29
+ @interface DDASLLogger : DDAbstractLogger <DDLogger>
30
+ {
31
+ aslclient client;
32
+ }
33
+
34
+ + (instancetype)sharedInstance;
35
+
36
+ // Inherited from DDAbstractLogger
37
+
38
+ // - (id <DDLogFormatter>)logFormatter;
39
+ // - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
40
+
41
+ @end
@@ -0,0 +1,102 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ #import "DDLog.h"
4
+
5
+ /**
6
+ * Welcome to Cocoa Lumberjack!
7
+ *
8
+ * The project page has a wealth of documentation if you have any questions.
9
+ * https://github.com/CocoaLumberjack/CocoaLumberjack
10
+ *
11
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
12
+ * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
13
+ *
14
+ *
15
+ * This class provides an abstract implementation of a database logger.
16
+ *
17
+ * That is, it provides the base implementation for a database logger to build atop of.
18
+ * All that is needed for a concrete database logger is to extend this class
19
+ * and override the methods in the implementation file that are prefixed with "db_".
20
+ **/
21
+
22
+ @interface DDAbstractDatabaseLogger : DDAbstractLogger {
23
+ @protected
24
+ NSUInteger saveThreshold;
25
+ NSTimeInterval saveInterval;
26
+ NSTimeInterval maxAge;
27
+ NSTimeInterval deleteInterval;
28
+ BOOL deleteOnEverySave;
29
+
30
+ BOOL saveTimerSuspended;
31
+ NSUInteger unsavedCount;
32
+ dispatch_time_t unsavedTime;
33
+ dispatch_source_t saveTimer;
34
+ dispatch_time_t lastDeleteTime;
35
+ dispatch_source_t deleteTimer;
36
+ }
37
+
38
+ /**
39
+ * Specifies how often to save the data to disk.
40
+ * Since saving is an expensive operation (disk io) it is not done after every log statement.
41
+ * These properties allow you to configure how/when the logger saves to disk.
42
+ *
43
+ * A save is done when either (whichever happens first):
44
+ *
45
+ * - The number of unsaved log entries reaches saveThreshold
46
+ * - The amount of time since the oldest unsaved log entry was created reaches saveInterval
47
+ *
48
+ * You can optionally disable the saveThreshold by setting it to zero.
49
+ * If you disable the saveThreshold you are entirely dependent on the saveInterval.
50
+ *
51
+ * You can optionally disable the saveInterval by setting it to zero (or a negative value).
52
+ * If you disable the saveInterval you are entirely dependent on the saveThreshold.
53
+ *
54
+ * It's not wise to disable both saveThreshold and saveInterval.
55
+ *
56
+ * The default saveThreshold is 500.
57
+ * The default saveInterval is 60 seconds.
58
+ **/
59
+ @property (assign, readwrite) NSUInteger saveThreshold;
60
+ @property (assign, readwrite) NSTimeInterval saveInterval;
61
+
62
+ /**
63
+ * It is likely you don't want the log entries to persist forever.
64
+ * Doing so would allow the database to grow infinitely large over time.
65
+ *
66
+ * The maxAge property provides a way to specify how old a log statement can get
67
+ * before it should get deleted from the database.
68
+ *
69
+ * The deleteInterval specifies how often to sweep for old log entries.
70
+ * Since deleting is an expensive operation (disk io) is is done on a fixed interval.
71
+ *
72
+ * An alternative to the deleteInterval is the deleteOnEverySave option.
73
+ * This specifies that old log entries should be deleted during every save operation.
74
+ *
75
+ * You can optionally disable the maxAge by setting it to zero (or a negative value).
76
+ * If you disable the maxAge then old log statements are not deleted.
77
+ *
78
+ * You can optionally disable the deleteInterval by setting it to zero (or a negative value).
79
+ *
80
+ * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted.
81
+ *
82
+ * It's not wise to enable both deleteInterval and deleteOnEverySave.
83
+ *
84
+ * The default maxAge is 7 days.
85
+ * The default deleteInterval is 5 minutes.
86
+ * The default deleteOnEverySave is NO.
87
+ **/
88
+ @property (assign, readwrite) NSTimeInterval maxAge;
89
+ @property (assign, readwrite) NSTimeInterval deleteInterval;
90
+ @property (assign, readwrite) BOOL deleteOnEverySave;
91
+
92
+ /**
93
+ * Forces a save of any pending log entries (flushes log entries to disk).
94
+ **/
95
+ - (void)savePendingLogEntries;
96
+
97
+ /**
98
+ * Removes any log entries that are older than maxAge.
99
+ **/
100
+ - (void)deleteOldLogEntries;
101
+
102
+ @end