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.
- package/android/build.gradle +7 -5
- package/android/libs/sdk-bluetooth-release.aar +0 -0
- package/android/libs/sdk-lan-release.aar +0 -0
- package/android/libs/sdk-mqtt-release.aar +0 -0
- package/android/libs/sdk-release.aar +0 -0
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/GizRNCallbackManager.kt +6 -5
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt +123 -85
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizParamsChecker.kt +1 -0
- package/ios/GizwitsiOSSDK.framework/GizwitsiOSSDK +0 -0
- package/ios/GizwitsiOSSDK.framework/Headers/CocoaAsyncSocket.h +18 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDASLLogger.h +41 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDAbstractDatabaseLogger.h +102 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDContextFilterLogFormatter.h +63 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDDispatchQueueLogFormatter.h +128 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDFileLogger.h +340 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDLog+LOGV.h +99 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDLog.h +632 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDMultiFormatter.h +30 -0
- package/ios/GizwitsiOSSDK.framework/Headers/DDTTYLogger.h +171 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPAES.h +19 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPDataCode.h +44 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPDatumCode.h +38 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPGuideCode.h +15 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTools.h +22 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouch.h +36 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchDelegate.h +24 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchGenerator.h +46 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchResult.h +36 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchTask.h +124 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPTouchTaskParameter.h +173 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPUDPSocketClient.h +50 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESPUDPSocketServer.h +49 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESP_ByteUtil.h +128 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESP_CRC8.h +61 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESP_NetUtil.h +82 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ESP_WifiUtil.h +33 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ForegroundReconnection.h +23 -0
- package/ios/GizwitsiOSSDK.framework/Headers/GCDTimer.h +19 -0
- package/ios/GizwitsiOSSDK.framework/Headers/GizwitsiOSSDK-Swift.h +338 -0
- package/ios/GizwitsiOSSDK.framework/Headers/GizwitsiOSSDK.h +24 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTClient.h +39 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTInMemoryPersistence.h +16 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTSSLSecurityPolicyDecoder.h +19 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTSSLSecurityPolicyEncoder.h +18 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTSessionLegacy.h +112 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTSessionSynchron.h +194 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTStrict.h +33 -0
- package/ios/GizwitsiOSSDK.framework/Headers/MQTTUntil.h +14 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ReconnectTimer.h +21 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_GCDAsyncSocket.h +1226 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_GCDAsyncUdpSocket.h +1036 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_GizwitsParser.h +61 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketDecoder.h +39 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketEncoder.h +38 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCFSocketTransport.h +79 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTCoreDataPersistence.h +21 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTDecoder.h +66 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTLog.h +123 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTMessage.h +233 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTPersistence.h +124 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTProperties.h +76 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSSLSecurityPolicy.h +158 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSSLSecurityPolicyTransport.h +30 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSession.h +886 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTSessionManager.h +237 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_MQTTTransport.h +114 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_SSZipArchive.h +178 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_SSZipCommon.h +71 -0
- package/ios/GizwitsiOSSDK.framework/Headers/_ZipArchive.h +26 -0
- package/ios/GizwitsiOSSDK.framework/Headers/a_weighting.h +88 -0
- package/ios/GizwitsiOSSDK.framework/Headers/aubio.h +231 -0
- package/ios/GizwitsiOSSDK.framework/Headers/audio_unit.h +61 -0
- package/ios/GizwitsiOSSDK.framework/Headers/awhitening.h +125 -0
- package/ios/GizwitsiOSSDK.framework/Headers/beattracking.h +121 -0
- package/ios/GizwitsiOSSDK.framework/Headers/biquad.h +75 -0
- package/ios/GizwitsiOSSDK.framework/Headers/c_weighting.h +88 -0
- package/ios/GizwitsiOSSDK.framework/Headers/common.h +104 -0
- package/ios/GizwitsiOSSDK.framework/Headers/cvec.h +247 -0
- package/ios/GizwitsiOSSDK.framework/Headers/dct.h +85 -0
- package/ios/GizwitsiOSSDK.framework/Headers/fft.h +144 -0
- package/ios/GizwitsiOSSDK.framework/Headers/filter.h +176 -0
- package/ios/GizwitsiOSSDK.framework/Headers/filterbank.h +90 -0
- package/ios/GizwitsiOSSDK.framework/Headers/filterbank_mel.h +72 -0
- package/ios/GizwitsiOSSDK.framework/Headers/fmat.h +172 -0
- package/ios/GizwitsiOSSDK.framework/Headers/fvec.h +178 -0
- package/ios/GizwitsiOSSDK.framework/Headers/hist.h +63 -0
- package/ios/GizwitsiOSSDK.framework/Headers/ioutils.h +60 -0
- package/ios/GizwitsiOSSDK.framework/Headers/log.h +99 -0
- package/ios/GizwitsiOSSDK.framework/Headers/lvec.h +118 -0
- package/ios/GizwitsiOSSDK.framework/Headers/mathutils.h +330 -0
- package/ios/GizwitsiOSSDK.framework/Headers/mfcc.h +79 -0
- package/ios/GizwitsiOSSDK.framework/Headers/musicutils.h +171 -0
- package/ios/GizwitsiOSSDK.framework/Headers/notes.h +113 -0
- package/ios/GizwitsiOSSDK.framework/Headers/onset.h +347 -0
- package/ios/GizwitsiOSSDK.framework/Headers/parameter.h +159 -0
- package/ios/GizwitsiOSSDK.framework/Headers/peakpicker.h +57 -0
- package/ios/GizwitsiOSSDK.framework/Headers/phasevoc.h +112 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitch.h +197 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchfcomb.h +76 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchmcomb.h +77 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchschmitt.h +75 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchspecacf.h +103 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchyin.h +100 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchyinfast.h +102 -0
- package/ios/GizwitsiOSSDK.framework/Headers/pitchyinfft.h +99 -0
- package/ios/GizwitsiOSSDK.framework/Headers/resampler.h +65 -0
- package/ios/GizwitsiOSSDK.framework/Headers/sampler.h +140 -0
- package/ios/GizwitsiOSSDK.framework/Headers/scale.h +80 -0
- package/ios/GizwitsiOSSDK.framework/Headers/sink.h +181 -0
- package/ios/GizwitsiOSSDK.framework/Headers/sink_apple_audio.h +163 -0
- package/ios/GizwitsiOSSDK.framework/Headers/sink_sndfile.h +162 -0
- package/ios/GizwitsiOSSDK.framework/Headers/sink_wavwrite.h +162 -0
- package/ios/GizwitsiOSSDK.framework/Headers/source.h +184 -0
- package/ios/GizwitsiOSSDK.framework/Headers/source_apple_audio.h +156 -0
- package/ios/GizwitsiOSSDK.framework/Headers/source_avcodec.h +155 -0
- package/ios/GizwitsiOSSDK.framework/Headers/source_sndfile.h +155 -0
- package/ios/GizwitsiOSSDK.framework/Headers/source_wavread.h +160 -0
- package/ios/GizwitsiOSSDK.framework/Headers/specdesc.h +204 -0
- package/ios/GizwitsiOSSDK.framework/Headers/tempo.h +255 -0
- package/ios/GizwitsiOSSDK.framework/Headers/tss.h +103 -0
- package/ios/GizwitsiOSSDK.framework/Headers/types.h +70 -0
- package/ios/GizwitsiOSSDK.framework/Headers/vecutils.h +116 -0
- package/ios/GizwitsiOSSDK.framework/Headers/wavetable.h +178 -0
- package/ios/GizwitsiOSSDK.framework/Info.plist +0 -0
- package/ios/GizwitsiOSSDK.framework/LICENSE +17 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.abi.json +57489 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +1752 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftinterface +1752 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
- package/ios/GizwitsiOSSDK.framework/Modules/module.modulemap +11 -0
- package/ios/GizwitsiOSSDK.framework/PrivacyInfo.xcprivacy +23 -0
- package/ios/GizwitsiOSSDK.framework/README.md +31 -0
- package/ios/RNGizDeviceManagerModule.m +2 -5
- package/ios/RNGizDeviceManagerModule.swift +43 -155
- package/ios/RNGizSDKManagerModule.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RNGizSDKManagerModule.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/lib/device.d.ts +3 -5
- package/lib/device.js +6 -28
- package/lib/device.js.map +1 -1
- package/lib/index.js +0 -42
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +0 -22
- package/package.json +1 -1
- package/react-native-gizwits-sdk-v5.podspec +2 -2
package/android/build.gradle
CHANGED
|
@@ -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(
|
|
69
|
-
implementation("io.github.gizwits:sdk
|
|
70
|
-
implementation("io.github.gizwits:sdk-
|
|
71
|
-
implementation("io.github.gizwits:sdk-
|
|
72
|
-
//
|
|
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
|
|
Binary file
|
|
Binary file
|
|
@@ -33,11 +33,12 @@ object GizRNCallbackManager {
|
|
|
33
33
|
} else {
|
|
34
34
|
data.success = false
|
|
35
35
|
result.exceptionOrNull()?.let {
|
|
36
|
-
|
|
37
|
-
data.error =
|
|
38
|
-
data.message =
|
|
39
|
-
}
|
|
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
|
}
|
package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt
CHANGED
|
@@ -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.
|
|
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
|
|
83
|
+
data class SetDeviceMtuParams(
|
|
81
84
|
@SerializedName("id")
|
|
82
85
|
override val id: String,
|
|
83
|
-
@SerializedName("
|
|
84
|
-
val
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
505
|
-
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result,
|
|
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
|
-
|
|
538
|
-
val res =
|
|
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
|
|
551
|
-
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result,
|
|
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
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
|
Binary file
|
|
@@ -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
|