react-native-gizwits-sdk-v5 1.2.3 → 1.2.5
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 +3 -0
- package/android/libs/sdk-bluetooth-debug.aar +0 -0
- package/android/libs/sdk-bluetooth-release.aar +0 -0
- package/android/libs/sdk-debug.aar +0 -0
- package/android/libs/sdk-lan-debug.aar +0 -0
- package/android/libs/sdk-lan-release.aar +0 -0
- package/android/libs/sdk-mqtt-debug.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 +5 -0
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizDeviceManagerModule.kt +107 -0
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizParamsChecker.kt +23 -0
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizSDKManagerModule.kt +67 -2
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizSDKManagerPackage.kt +2 -1
- package/android/src/main/java/com/gizwits/reactnativegizwitssdkv5/RNGizUserManagerModule.kt +42 -6
- package/ios/GizwitsiOSSDK.framework/GizwitsiOSSDK +0 -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.swiftdoc +0 -0
- package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
- package/ios/RNGizSDKManagerModule.swift +12 -0
- package/lib/types.d.ts +3 -3
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -7,6 +7,7 @@ buildscript {
|
|
|
7
7
|
kotlin_coroutine_version = '1.6.4'
|
|
8
8
|
retrofit_version = '2.9.0'
|
|
9
9
|
room_version = '2.5.0'
|
|
10
|
+
mqtt_version = '1.2.5'
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
repositories {
|
|
@@ -58,6 +59,8 @@ dependencies {
|
|
|
58
59
|
implementation 'io.sentry:sentry-android-timber:6.29.0'
|
|
59
60
|
implementation 'com.jakewharton.timber:timber:5.0.1'
|
|
60
61
|
implementation 'io.sentry:sentry-android:6.29.0'
|
|
62
|
+
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:$mqtt_version"
|
|
63
|
+
|
|
61
64
|
|
|
62
65
|
implementation files('libs/sdk-debug.aar', 'libs/sdk-bluetooth-debug.aar', 'libs/sdk-lan-debug.aar', 'libs/sdk-mqtt-debug.aar')
|
|
63
66
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version")
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,15 +6,20 @@ import com.facebook.react.bridge.WritableArray
|
|
|
6
6
|
import com.facebook.react.bridge.WritableMap
|
|
7
7
|
import com.gizwits.smart.sdk.exception.GizException
|
|
8
8
|
import com.google.gson.Gson
|
|
9
|
+
import com.google.gson.annotations.SerializedName
|
|
9
10
|
import com.google.gson.reflect.TypeToken
|
|
10
11
|
import org.json.JSONArray
|
|
11
12
|
import org.json.JSONException
|
|
12
13
|
import org.json.JSONObject
|
|
13
14
|
|
|
14
15
|
class GizResult<T> {
|
|
16
|
+
@SerializedName("success")
|
|
15
17
|
var success = false;
|
|
18
|
+
@SerializedName("data")
|
|
16
19
|
var data: T? = null
|
|
20
|
+
@SerializedName("error")
|
|
17
21
|
var error: Number? = null
|
|
22
|
+
@SerializedName("message")
|
|
18
23
|
var message: String = ""
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package com.gizwits.reactnativegizwitssdkv5
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Callback
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
import com.gizwits.smart.sdk.GizDevice
|
|
9
|
+
import com.gizwits.smart.sdk.GizSDKManager
|
|
10
|
+
import com.gizwits.smart.sdk.bluetooth.bleCapacity
|
|
11
|
+
import com.gizwits.smart.sdk.common.GizConfiguration
|
|
12
|
+
import com.gizwits.smart.sdk.core.capacity.CapacityTypes
|
|
13
|
+
import com.gizwits.smart.sdk.exception.GizException
|
|
14
|
+
import com.gizwits.smart.sdk.lan.lanCapacity
|
|
15
|
+
import com.gizwits.smart.sdk.mqtt.mqttCapacity
|
|
16
|
+
import com.gizwits.smart.sdk.mqtt.queryBoundDevices
|
|
17
|
+
import com.google.gson.annotations.SerializedName
|
|
18
|
+
import kotlinx.coroutines.CoroutineScope
|
|
19
|
+
import kotlinx.coroutines.Dispatchers
|
|
20
|
+
import kotlinx.coroutines.launch
|
|
21
|
+
|
|
22
|
+
data class GizBindParams(
|
|
23
|
+
@SerializedName("id")
|
|
24
|
+
override val id: Int,
|
|
25
|
+
@SerializedName("alias")
|
|
26
|
+
val alias: String,
|
|
27
|
+
@SerializedName("remark")
|
|
28
|
+
val remark: String,
|
|
29
|
+
) : DeviceParams
|
|
30
|
+
|
|
31
|
+
data class GizUnBindParams(
|
|
32
|
+
@SerializedName("id")
|
|
33
|
+
override val id: Int,
|
|
34
|
+
): DeviceParams
|
|
35
|
+
|
|
36
|
+
data class GizConnectParams(
|
|
37
|
+
@SerializedName("id")
|
|
38
|
+
override val id: Int,
|
|
39
|
+
@SerializedName("type")
|
|
40
|
+
val type: CapacityTypes
|
|
41
|
+
): DeviceParams
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class RNGizDeviceManagerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
45
|
+
enum class EventName(val value: String) {
|
|
46
|
+
GizOTAProgressEvent("GizOTAProgressEvent"),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun getName() = "RNGizDeviceManagerModule"
|
|
50
|
+
@ReactMethod
|
|
51
|
+
fun sendDp(options: ReadableMap, result: Callback) {}
|
|
52
|
+
@ReactMethod
|
|
53
|
+
fun getDp(options: ReadableMap, result: Callback) {}
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun getDeviceInfo(options: ReadableMap, result: Callback) {}
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
fun bind(options: ReadableMap, result: Callback) {
|
|
59
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizBindParams::class.java)
|
|
60
|
+
if (config !=null && device !=null) {
|
|
61
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
62
|
+
val res = device.bindDevice(config.alias, config.remark)
|
|
63
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
64
|
+
if (res.isSuccess) {
|
|
65
|
+
GizSDKManager.queryBoundDevices()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactMethod
|
|
72
|
+
fun unBind(options: ReadableMap, result: Callback) {
|
|
73
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizUnBindParams::class.java)
|
|
74
|
+
if (config !=null && device !=null) {
|
|
75
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
76
|
+
val res = device.unbindDevice()
|
|
77
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
78
|
+
if (res.isSuccess) {
|
|
79
|
+
GizSDKManager.queryBoundDevices()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
@ReactMethod
|
|
85
|
+
fun checkUpdate(options: ReadableMap, result: Callback) {}
|
|
86
|
+
@ReactMethod
|
|
87
|
+
fun startUpgrade(options: ReadableMap, result: Callback) {}
|
|
88
|
+
@ReactMethod
|
|
89
|
+
fun register(options: ReadableMap, result: Callback) {}
|
|
90
|
+
|
|
91
|
+
@ReactMethod
|
|
92
|
+
fun connect(options: ReadableMap, result: Callback) {
|
|
93
|
+
val (config, device) = RNGizParamsChecker.checkDeviceAndParams(options, result, GizConnectParams::class.java)
|
|
94
|
+
if (config !=null && device !=null) {
|
|
95
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
96
|
+
val res = when(config.type) {
|
|
97
|
+
CapacityTypes.BLE -> device.bleCapacity.connect()
|
|
98
|
+
CapacityTypes.LAN -> device.lanCapacity.connect()
|
|
99
|
+
CapacityTypes.MQTT -> device.mqttCapacity.connect()
|
|
100
|
+
}
|
|
101
|
+
// GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
@ReactMethod
|
|
106
|
+
fun disConnect(options: ReadableMap, result: Callback) {}
|
|
107
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
package com.gizwits.reactnativegizwitssdkv5
|
|
2
2
|
import com.facebook.react.bridge.Callback
|
|
3
3
|
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.gizwits.smart.sdk.GizDevice
|
|
5
|
+
import com.gizwits.smart.sdk.GizSDKManager
|
|
4
6
|
import com.gizwits.smart.sdk.exception.GizException
|
|
5
7
|
import com.gizwits.smart.sdk.exception.GizParseException
|
|
6
8
|
import com.google.gson.Gson
|
|
7
9
|
import com.google.gson.JsonSyntaxException
|
|
10
|
+
import com.google.gson.annotations.SerializedName
|
|
8
11
|
|
|
12
|
+
interface DeviceParams{
|
|
13
|
+
val id: Int
|
|
14
|
+
}
|
|
9
15
|
class RNGizParamsChecker {
|
|
10
16
|
companion object {
|
|
11
17
|
fun <T : Any> check(options: ReadableMap, result: Callback, paramsType: Class<T>): T? {
|
|
@@ -22,5 +28,22 @@ class RNGizParamsChecker {
|
|
|
22
28
|
return null
|
|
23
29
|
}
|
|
24
30
|
}
|
|
31
|
+
|
|
32
|
+
fun <T : DeviceParams> checkDeviceAndParams(options: ReadableMap, result: Callback, paramsType: Class<T>): Pair<T?, GizDevice?> {
|
|
33
|
+
val config = check(options, result, paramsType)
|
|
34
|
+
var dev: GizDevice? = null
|
|
35
|
+
config?.let {
|
|
36
|
+
dev = GizSDKManager.getRegisteredDevice(config.id)
|
|
37
|
+
if (dev == null) {
|
|
38
|
+
GizRNCallbackManager.callbackWithResult(
|
|
39
|
+
callback = result,
|
|
40
|
+
result = Result.failure<Number>(GizException.GIZ_OPENAPI_DEVICE_NOT_FOUND)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return Pair(config, dev)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
25
48
|
}
|
|
26
49
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.gizwits.reactnativegizwitssdkv5
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.Callback
|
|
4
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
@@ -10,22 +11,36 @@ import com.facebook.react.bridge.WritableMap
|
|
|
10
11
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
11
12
|
import com.gizwits.smart.sdk.GizDevice
|
|
12
13
|
import com.gizwits.smart.sdk.GizSDKManager
|
|
14
|
+
import com.gizwits.smart.sdk.GizUserManager
|
|
15
|
+
import com.gizwits.smart.sdk.bluetooth.bleCapacity
|
|
13
16
|
import com.gizwits.smart.sdk.bluetooth.startScan
|
|
14
17
|
import com.gizwits.smart.sdk.bluetooth.stopScan
|
|
15
18
|
import com.gizwits.smart.sdk.bluetooth.subscribeBluetoothDeviceList
|
|
16
19
|
import com.gizwits.smart.sdk.common.GizConfiguration
|
|
17
20
|
import com.gizwits.smart.sdk.common.combineLatest
|
|
18
21
|
import com.gizwits.smart.sdk.exception.GizException
|
|
22
|
+
import com.gizwits.smart.sdk.lan.lanCapacity
|
|
19
23
|
import com.gizwits.smart.sdk.lan.subscribeLanDeviceList
|
|
24
|
+
import com.gizwits.smart.sdk.mqtt.mqttCapacity
|
|
25
|
+
import com.gizwits.smart.sdk.mqtt.queryBoundDevices
|
|
20
26
|
import com.gizwits.smart.sdk.mqtt.subscribeBoundDeviceList
|
|
21
27
|
import kotlinx.coroutines.CoroutineScope
|
|
22
28
|
import kotlinx.coroutines.Dispatchers
|
|
23
29
|
import kotlinx.coroutines.flow.Flow
|
|
30
|
+
import kotlinx.coroutines.flow.collect
|
|
31
|
+
import kotlinx.coroutines.flow.collectLatest
|
|
32
|
+
import kotlinx.coroutines.flow.last
|
|
33
|
+
import kotlinx.coroutines.flow.take
|
|
34
|
+
import kotlinx.coroutines.flow.toList
|
|
24
35
|
import kotlinx.coroutines.launch
|
|
25
36
|
import org.json.JSONArray
|
|
37
|
+
import org.json.JSONObject
|
|
26
38
|
|
|
27
39
|
class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
28
40
|
|
|
41
|
+
companion object {
|
|
42
|
+
internal var devices = listOf<GizDevice>()
|
|
43
|
+
}
|
|
29
44
|
enum class EventName(val value: String) {
|
|
30
45
|
DeviceDataListener("DeviceDataListener"),
|
|
31
46
|
DeviceListListener("DeviceListListener"),
|
|
@@ -48,11 +63,45 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
48
63
|
super.initialize()
|
|
49
64
|
CoroutineScope(Dispatchers.Main).launch {
|
|
50
65
|
deviceListState.collect { deviceList ->
|
|
66
|
+
// 保存一份缓存
|
|
67
|
+
val newDevices = deviceList - devices
|
|
68
|
+
newDevices.forEach{dev ->
|
|
69
|
+
val devJob = dev.getDeviceJob()
|
|
70
|
+
val scope = CoroutineScope(devJob)
|
|
71
|
+
scope.launch {
|
|
72
|
+
dev.bleCapacity.subscribeStatus().collect{
|
|
73
|
+
val data = JSONObject()
|
|
74
|
+
data.put("state", it.toInt())
|
|
75
|
+
data.put("type", "BLE")
|
|
76
|
+
data.put("device", dev.toJsonObject())
|
|
77
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
scope.launch {
|
|
81
|
+
dev.lanCapacity.subscribeStatus().collect{
|
|
82
|
+
val data = JSONObject()
|
|
83
|
+
data.put("state", it.toInt())
|
|
84
|
+
data.put("type", "LAN")
|
|
85
|
+
data.put("device", dev.toJsonObject())
|
|
86
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
scope.launch {
|
|
90
|
+
dev.mqttCapacity.subscribeStatus().collect{
|
|
91
|
+
val data = JSONObject()
|
|
92
|
+
data.put("state", it.toInt())
|
|
93
|
+
data.put("type", "MQTT")
|
|
94
|
+
data.put("device", dev.toJsonObject())
|
|
95
|
+
sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
devices = deviceList
|
|
51
100
|
val deviceListJson = JSONArray()
|
|
52
101
|
deviceList.forEach{ item ->
|
|
53
102
|
deviceListJson.put(item.toJsonObject())
|
|
54
103
|
}
|
|
55
|
-
sendEvent(EventName.
|
|
104
|
+
sendEvent(EventName.DeviceListListener.name, GizRNCallbackManager.jsonArray2WriteableArray(deviceListJson))
|
|
56
105
|
}
|
|
57
106
|
}
|
|
58
107
|
}
|
|
@@ -82,7 +131,23 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
|
|
|
82
131
|
}
|
|
83
132
|
@ReactMethod
|
|
84
133
|
fun getDevices(options: ReadableMap, result: Callback) {
|
|
85
|
-
|
|
134
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
135
|
+
// 查询 绑定设备 返回设备列表
|
|
136
|
+
GizSDKManager.queryBoundDevices()
|
|
137
|
+
deviceListState.take(1).collect {
|
|
138
|
+
val jsonData = JSONArray()
|
|
139
|
+
it.forEach{device ->
|
|
140
|
+
jsonData.put(device.toJsonObject())
|
|
141
|
+
}
|
|
142
|
+
// 设备列表比较特殊,手动回调
|
|
143
|
+
val writableMap = Arguments.createMap()
|
|
144
|
+
writableMap.putArray("data", GizRNCallbackManager.jsonArray2WriteableArray(jsonData))
|
|
145
|
+
writableMap.putBoolean("success", true)
|
|
146
|
+
writableMap.putInt("error", 0)
|
|
147
|
+
writableMap.putString("message", "")
|
|
148
|
+
result.invoke(null, writableMap)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
86
151
|
}
|
|
87
152
|
|
|
88
153
|
@ReactMethod
|
|
@@ -17,7 +17,8 @@ class RNGizSDKManagerPackage : ReactPackage {
|
|
|
17
17
|
MutableList<NativeModule> {
|
|
18
18
|
return mutableListOf(
|
|
19
19
|
RNGizSDKManagerModule(reactContext),
|
|
20
|
-
RNGizUserManagerModule(reactContext)
|
|
20
|
+
RNGizUserManagerModule(reactContext),
|
|
21
|
+
RNGizDeviceManagerModule(reactContext)
|
|
21
22
|
)
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -5,17 +5,53 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
5
5
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.gizwits.smart.sdk.
|
|
9
|
-
import com.gizwits.smart.sdk.
|
|
10
|
-
import com.gizwits.smart.sdk.
|
|
8
|
+
import com.gizwits.smart.sdk.GizUserManagerImpl
|
|
9
|
+
import com.gizwits.smart.sdk.common.GizConfiguration
|
|
10
|
+
import com.gizwits.smart.sdk.core.data.model.UserToken
|
|
11
|
+
import com.google.gson.annotations.SerializedName
|
|
12
|
+
import kotlinx.coroutines.CoroutineScope
|
|
13
|
+
import kotlinx.coroutines.Dispatchers
|
|
14
|
+
import kotlinx.coroutines.launch
|
|
15
|
+
import java.util.Date
|
|
16
|
+
|
|
17
|
+
data class UpdateAuthorizeDataParams(
|
|
18
|
+
@SerializedName("token")
|
|
19
|
+
val token: String,
|
|
20
|
+
@SerializedName("uid")
|
|
21
|
+
val uid: String
|
|
22
|
+
)
|
|
11
23
|
|
|
12
24
|
class RNGizUserManagerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
13
25
|
override fun getName() = "RNGizUserManagerModule"
|
|
14
|
-
private val userManager: GizUserManager = GizSDKManager.getUserManager()
|
|
15
26
|
|
|
16
27
|
@ReactMethod
|
|
17
28
|
fun getAuthorizeData(options: ReadableMap, result: Callback) {
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
val tokenInfo = GizUserManagerImpl.getUserTokenStream().value
|
|
30
|
+
val authData = UpdateAuthorizeDataParams(tokenInfo?.token ?: "", tokenInfo?.userId ?: "")
|
|
31
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success(authData))
|
|
32
|
+
}
|
|
33
|
+
@ReactMethod
|
|
34
|
+
fun updateAuthorizeData(options: ReadableMap, result: Callback) {
|
|
35
|
+
var config = RNGizParamsChecker.check(options, result, UpdateAuthorizeDataParams::class.java)
|
|
36
|
+
config?.let {
|
|
37
|
+
// Date 暂时没有用到
|
|
38
|
+
GizUserManagerImpl.updateAuthorizeData(UserToken(config.token, config.uid, Date()))
|
|
39
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = Result.success(0))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
@ReactMethod
|
|
44
|
+
fun loginByAnonymous(options: ReadableMap, result: Callback) {
|
|
45
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
46
|
+
val res = GizUserManagerImpl.loginByAnonymous()
|
|
47
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
@ReactMethod
|
|
51
|
+
fun logout(options: ReadableMap, result: Callback) {
|
|
52
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
53
|
+
val res = GizUserManagerImpl.logout()
|
|
54
|
+
GizRNCallbackManager.callbackWithResult(callback = result, result = res)
|
|
55
|
+
}
|
|
20
56
|
}
|
|
21
57
|
}
|
|
Binary file
|
|
Binary file
|
package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftdoc
CHANGED
|
Binary file
|
package/ios/GizwitsiOSSDK.framework/Modules/GizwitsiOSSDK.swiftmodule/arm64-apple-ios.swiftmodule
CHANGED
|
Binary file
|
|
@@ -68,6 +68,18 @@ class RNGizSDKManagerModule: RCTEventEmitter, GizSdkEventHandlerDelegate {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
@objc
|
|
72
|
+
public func startBleScan(_ options: NSDictionary, result: @escaping RCTResponseSenderBlock) {
|
|
73
|
+
GizSDKManager.sharedInstance.startBleScan()
|
|
74
|
+
GizRNCallbackManager.callbackWithResult(callback: result, result: GizResult<Int?, GizAPIException?>(data: nil, success: true))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@objc
|
|
78
|
+
public func stopBleScan(_ options: NSDictionary, result: @escaping RCTResponseSenderBlock) {
|
|
79
|
+
GizSDKManager.sharedInstance.stopBleScan()
|
|
80
|
+
GizRNCallbackManager.callbackWithResult(callback: result, result: GizResult<Int?, GizAPIException?>(data: nil, success: true))
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
@objc
|
|
72
84
|
override static func requiresMainQueueSetup() -> Bool {
|
|
73
85
|
return true
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type AuthenticationMethod = 0 | 1;
|
|
2
2
|
export interface GizBaseCapability {
|
|
3
3
|
name: string;
|
|
4
|
-
|
|
4
|
+
isActive: boolean;
|
|
5
5
|
netStatus: NetStatus;
|
|
6
6
|
connect: () => Promise<GizResult<any, any>>;
|
|
7
7
|
getDeviceInfo: () => Promise<GizResult<GizDeviceInfoProfile, any>>;
|
|
@@ -101,7 +101,7 @@ export interface GizConfigStruct {
|
|
|
101
101
|
productInfos: ProductInfoStruct[];
|
|
102
102
|
serverInfo?: ServerInfoStruct;
|
|
103
103
|
}
|
|
104
|
-
export declare type
|
|
104
|
+
export declare type GizDeviceNetStatus = 0 | 1 | 2;
|
|
105
105
|
export declare type GizCapability = 'BLE' | 'LAN' | 'MQTT';
|
|
106
106
|
export declare type GizOTAFirmwareType = 'Module' | 'MCU';
|
|
107
107
|
export interface DeviceDataRes {
|
|
@@ -111,7 +111,7 @@ export interface DeviceDataRes {
|
|
|
111
111
|
}
|
|
112
112
|
export interface DeviceStateRes {
|
|
113
113
|
device: IDevice;
|
|
114
|
-
state:
|
|
114
|
+
state: GizDeviceNetStatus;
|
|
115
115
|
type: GizCapability;
|
|
116
116
|
}
|
|
117
117
|
export declare type DeviceDataCallback = (data: DeviceDataRes) => void;
|