@quec/rn-device-module 1.9.13 → 2.16.1
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/.vscode/settings.json +3 -0
- package/QuecRNDeviceModule.podspec +54 -0
- package/README.md +1535 -1043
- package/android/build.gradle +119 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +23 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/old-info.properties +2 -0
- package/android/proguard-rules.pro +21 -0
- package/android/publishInfo.properties +4 -0
- package/android/settings.gradle +3 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/IQuecRNDeviceModuleSpec.java +1352 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/QuecRNDeviceModule.java +2423 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/QuecRNDeviceModulePackage.java +23 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/DataInfo.java +25 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/DataRes.java +31 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/DeviceDpsUpdateModel.java +18 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/ModelBridgeBasic.java +86 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/OtaUpgradePlanModel.java +292 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/ShareInfo.java +166 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/UserInfo.java +137 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/WriteCmdWithId.java +10 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/AnalysisChannelDataUtils.java +82 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/DataConvertUtils.kt +130 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ErrorCode.java +26 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ErrorUtils.java +11 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/IpcUtil.java +75 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/NetUtils.java +85 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/OnConnectListener.java +22 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ParamsValueUtils.java +79 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/QuecIotChannelMode.java +8 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ReactNativeJson.java +199 -0
- package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ResponseUtils.java +156 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/android/src/main/res/values-en/strings.xml +4 -0
- package/android/src/main/res/values-zh/strings.xml +4 -0
- package/android/src/test/java/com/quectel/smart/template/ExampleUnitTest.java +17 -0
- package/build.gradle +1 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/ios/Example/Podfile +17 -0
- package/ios/Example/QuecRNDeviceModule/AppDelegate.h +13 -0
- package/ios/Example/QuecRNDeviceModule/AppDelegate.m +46 -0
- package/ios/Example/QuecRNDeviceModule/Base.lproj/LaunchScreen.storyboard +31 -0
- package/ios/Example/QuecRNDeviceModule/Base.lproj/Main.storyboard +31 -0
- package/ios/Example/QuecRNDeviceModule/Images.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/ios/Example/QuecRNDeviceModule/QuecRNDeviceModule-Info.plist +40 -0
- package/ios/Example/QuecRNDeviceModule/QuecRNDeviceModule-Prefix.pch +16 -0
- package/ios/Example/QuecRNDeviceModule/ViewController.h +12 -0
- package/ios/Example/QuecRNDeviceModule/ViewController.m +29 -0
- package/ios/Example/QuecRNDeviceModule/en.lproj/InfoPlist.strings +2 -0
- package/ios/Example/QuecRNDeviceModule/main.m +15 -0
- package/ios/Example/QuecRNDeviceModule.xcodeproj/project.pbxproj +583 -0
- package/ios/Example/QuecRNDeviceModule.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Example/QuecRNDeviceModule.xcodeproj/xcshareddata/xcschemes/QuecRNDeviceModule-Example.xcscheme +101 -0
- package/ios/Example/QuecRNDeviceModule.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/Example/QuecRNDeviceModule.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/LICENSE +4 -0
- package/ios/QuecRNDeviceModule/Assets/.gitkeep +0 -0
- package/ios/QuecRNDeviceModule/Classes/QuecRNDeviceModule+Ext.h +27 -0
- package/ios/QuecRNDeviceModule/Classes/QuecRNDeviceModule+Impl.h +1137 -0
- package/ios/QuecRNDeviceModule/Classes/QuecRNDeviceModule+Impl.m +1524 -0
- package/ios/QuecRNDeviceModule/Classes/QuecRNDeviceModule.h +157 -0
- package/ios/QuecRNDeviceModule/Classes/QuecRNDeviceModule.m +721 -0
- package/ios/README.md +20 -0
- package/{.prettierrc.js → js/.prettierrc.js} +11 -11
- package/js/README.md +1535 -0
- package/js/package.json +25 -0
- package/{src → js/src}/index.ts +12 -12
- package/{src → js/src}/module.ts +1332 -939
- package/{src → js/src}/viewCommon.ts +3 -3
- package/js/tsconfig.json +26 -0
- package/js/yarn.lock +4 -0
- package/package.json +10 -26
- package/plugin.ts +1180 -0
- package/settings.gradle +2 -0
- package/tsconfig.json +9 -0
package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/bean/UserInfo.java
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.bean;
|
|
2
|
+
|
|
3
|
+
import java.io.Serializable;
|
|
4
|
+
|
|
5
|
+
public class UserInfo implements Serializable {
|
|
6
|
+
|
|
7
|
+
private String uid;
|
|
8
|
+
|
|
9
|
+
private String userDomain;
|
|
10
|
+
|
|
11
|
+
private String phone;
|
|
12
|
+
|
|
13
|
+
private String nikeName;
|
|
14
|
+
|
|
15
|
+
private String sex;
|
|
16
|
+
|
|
17
|
+
private String address;
|
|
18
|
+
|
|
19
|
+
private String email;
|
|
20
|
+
|
|
21
|
+
private String headimg;
|
|
22
|
+
|
|
23
|
+
private String wchartId;
|
|
24
|
+
|
|
25
|
+
private String wchartName;
|
|
26
|
+
|
|
27
|
+
private String registerTime;
|
|
28
|
+
|
|
29
|
+
private String lastLoginTime;
|
|
30
|
+
|
|
31
|
+
private String userType;
|
|
32
|
+
|
|
33
|
+
public void setUid(String uid) {
|
|
34
|
+
this.uid = uid;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public String getUid() {
|
|
38
|
+
return this.uid;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public void setUserDomain(String userDomain) {
|
|
42
|
+
this.userDomain = userDomain;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public String getUserDomain() {
|
|
46
|
+
return this.userDomain;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public void setPhone(String phone) {
|
|
50
|
+
this.phone = phone;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public String getPhone() {
|
|
54
|
+
return this.phone;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public void setNikeName(String nikeName) {
|
|
58
|
+
this.nikeName = nikeName;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public String getNikeName() {
|
|
62
|
+
return this.nikeName;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public void setSex(String sex) {
|
|
66
|
+
this.sex = sex;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public String getSex() {
|
|
70
|
+
return this.sex;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public void setAddress(String address) {
|
|
74
|
+
this.address = address;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public String getAddress() {
|
|
78
|
+
return this.address;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public void setEmail(String email) {
|
|
82
|
+
this.email = email;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public String getEmail() {
|
|
86
|
+
return this.email;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public void setHeadimg(String headimg) {
|
|
90
|
+
this.headimg = headimg;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public String getHeadimg() {
|
|
94
|
+
return this.headimg;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public void setWchartId(String wchartId) {
|
|
98
|
+
this.wchartId = wchartId;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public String getWchartId() {
|
|
102
|
+
return this.wchartId;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public void setWchartName(String wchartName) {
|
|
106
|
+
this.wchartName = wchartName;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public String getWchartName() {
|
|
110
|
+
return this.wchartName;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public void setRegisterTime(String registerTime) {
|
|
114
|
+
this.registerTime = registerTime;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public String getRegisterTime() {
|
|
118
|
+
return this.registerTime;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public void setLastLoginTime(String lastLoginTime) {
|
|
122
|
+
this.lastLoginTime = lastLoginTime;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public String getLastLoginTime() {
|
|
126
|
+
return this.lastLoginTime;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public void setUserType(String userType) {
|
|
130
|
+
this.userType = userType;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public String getUserType() {
|
|
134
|
+
return this.userType;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import android.util.Base64;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.bridge.WritableMap;
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
8
|
+
import com.google.gson.Gson;
|
|
9
|
+
import com.quectel.basic.queclog.QLog;
|
|
10
|
+
import com.quectel.sdk.iot.channel.kit.constaint.QuecIotChannelType;
|
|
11
|
+
import com.quectel.sdk.iot.channel.kit.model.QuecIotDataPointsModel;
|
|
12
|
+
import com.quectel.smart.rnplugin.quecrndevicemodule.bean.DeviceDpsUpdateModel;
|
|
13
|
+
|
|
14
|
+
import org.json.JSONException;
|
|
15
|
+
import org.json.JSONObject;
|
|
16
|
+
|
|
17
|
+
public class AnalysisChannelDataUtils {
|
|
18
|
+
|
|
19
|
+
public static void analysisChannelData(QuecIotDataPointsModel quecIotDataPointsModel, ReactApplicationContext context) {
|
|
20
|
+
if (context == null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
DeviceDpsUpdateModel model = new DeviceDpsUpdateModel();
|
|
25
|
+
model.dk = quecIotDataPointsModel.dk;
|
|
26
|
+
model.pk = quecIotDataPointsModel.pk;
|
|
27
|
+
model.dps = quecIotDataPointsModel.dps;
|
|
28
|
+
model.action = quecIotDataPointsModel.action.getVal();
|
|
29
|
+
if (quecIotDataPointsModel.transparentData != null) {
|
|
30
|
+
model.transparent = Base64.encodeToString(quecIotDataPointsModel.transparentData, Base64.DEFAULT);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (quecIotDataPointsModel.channelType == QuecIotChannelType.QuecIotChannelTypeWS) {
|
|
34
|
+
model.type = 1;
|
|
35
|
+
} else if (quecIotDataPointsModel.channelType == QuecIotChannelType.QuecIotChannelTypeWifi) {
|
|
36
|
+
model.type = 2;
|
|
37
|
+
} else if (quecIotDataPointsModel.channelType == QuecIotChannelType.QuecIotChannelTypeBLE) {
|
|
38
|
+
model.type = 3;
|
|
39
|
+
}
|
|
40
|
+
JSONObject jsonObject = new JSONObject(new Gson().toJson(model));
|
|
41
|
+
WritableMap allDataMap = ReactNativeJson.convertJsonToMap(jsonObject);
|
|
42
|
+
|
|
43
|
+
if (model.type == 1) {
|
|
44
|
+
//ws
|
|
45
|
+
JSONObject rawData = quecIotDataPointsModel.rawData;
|
|
46
|
+
JSONObject originData = quecIotDataPointsModel.originData;
|
|
47
|
+
WritableMap rawDataMap = ReactNativeJson.convertJsonToMap(rawData);
|
|
48
|
+
WritableMap originDataMap = ReactNativeJson.convertJsonToMap(originData);
|
|
49
|
+
allDataMap.putMap("rawData", rawDataMap);
|
|
50
|
+
allDataMap.putMap("originData", originDataMap);
|
|
51
|
+
}
|
|
52
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
53
|
+
.emit("onDeviceDpsUpdate", allDataMap);
|
|
54
|
+
} catch (JSONException e) {
|
|
55
|
+
QLog.e("AnalysisChannelDataUtils", e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 事件--更新在线状态
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
*
|
|
67
|
+
* @param context
|
|
68
|
+
* @param state
|
|
69
|
+
*
|
|
70
|
+
* see QuecRNDeviceModule onDeviceOnlineState
|
|
71
|
+
*/
|
|
72
|
+
@Deprecated
|
|
73
|
+
public static void updateOnlineState(ReactApplicationContext context, int state) {
|
|
74
|
+
// if (context != null) {
|
|
75
|
+
// WritableMap writableMap = Arguments.createMap();
|
|
76
|
+
// writableMap.putString("onlineState", state + "");
|
|
77
|
+
// QLog.e("QuecRNDeviceModule", "onlineState " + state);
|
|
78
|
+
// context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
79
|
+
// .emit("onDeviceOnlineState", writableMap);
|
|
80
|
+
// }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableArray
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.quectel.app.device.bean.*
|
|
7
|
+
import com.quectel.app.device.constant.ModelStyleConstant
|
|
8
|
+
|
|
9
|
+
object DataConvertUtils {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@JvmStatic
|
|
13
|
+
fun getRNArrayByModelBasicList(list: List<ModelBasic<*>>): WritableArray {
|
|
14
|
+
val writeArray = Arguments.createArray()
|
|
15
|
+
list.forEach {
|
|
16
|
+
val map = Arguments.createMap();
|
|
17
|
+
map.putInt("id", it.id)
|
|
18
|
+
map.putString("dataType", it.dataType)
|
|
19
|
+
map.putString("code", it.code)
|
|
20
|
+
map.putString("name", it.name);
|
|
21
|
+
map.putString("desc", it.desc)
|
|
22
|
+
map.putString("subType", it.subType)
|
|
23
|
+
val array = convertBasicToMap(it)
|
|
24
|
+
if (array.size() > 0) {
|
|
25
|
+
map.putArray("specs", array)
|
|
26
|
+
}
|
|
27
|
+
writeArray.pushMap(map);
|
|
28
|
+
}
|
|
29
|
+
return writeArray;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
fun convertBasicToMap(data: ModelBasic<*>): WritableArray {
|
|
34
|
+
var array = Arguments.createArray();
|
|
35
|
+
when (data.dataType) {
|
|
36
|
+
ModelStyleConstant.BOOL, ModelStyleConstant.ENUM -> {
|
|
37
|
+
val list = data.getSpecs() as List<BooleanSpecs>;
|
|
38
|
+
array = getWriteArrayForBooleanSpec(list);
|
|
39
|
+
}
|
|
40
|
+
ModelStyleConstant.INT, ModelStyleConstant.FLOAT, ModelStyleConstant.DOUBLE -> {
|
|
41
|
+
val numSpecs = data.getSpecs()[0] as NumSpecs
|
|
42
|
+
array = getWritableMapFromNumSpec(numSpecs);
|
|
43
|
+
}
|
|
44
|
+
ModelStyleConstant.TEXT -> {
|
|
45
|
+
val textSpecs = data.getSpecs()[0] as TextSpecs
|
|
46
|
+
array = getWriteArrayForTextSpecs(textSpecs);
|
|
47
|
+
}
|
|
48
|
+
ModelStyleConstant.ARRAY -> {
|
|
49
|
+
val spec = data.getSpecs()[0];
|
|
50
|
+
if (spec is ArraySpecs) {
|
|
51
|
+
val arraySpec = spec
|
|
52
|
+
array = getWriteArrayForArraySpec(arraySpec);
|
|
53
|
+
} else if (spec is ArrayStructSpecs<*>) {
|
|
54
|
+
val arraySpec = spec;
|
|
55
|
+
array = getWriteArrayForArrayStructSpec(arraySpec);
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
ModelStyleConstant.STRUCT -> {
|
|
60
|
+
val spec = data.getSpecs() as List<ModelBasic<*>>
|
|
61
|
+
array = getRNArrayByModelBasicList(spec)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return array
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fun getWriteArrayForArrayStructSpec(arraySpec: ArrayStructSpecs<*>): WritableArray {
|
|
68
|
+
var array = Arguments.createArray();
|
|
69
|
+
var map = Arguments.createMap();
|
|
70
|
+
map.putString("size", arraySpec.getSize())
|
|
71
|
+
map.putString("dataType", arraySpec.getDataType())
|
|
72
|
+
arraySpec.specs.forEach {
|
|
73
|
+
var map = Arguments.createMap();
|
|
74
|
+
map.putInt("id", it.id)
|
|
75
|
+
map.putString("dataType", it.dataType)
|
|
76
|
+
map.putString("code", it.code)
|
|
77
|
+
map.putString("name", it.name);
|
|
78
|
+
map.putString("desc", it.desc)
|
|
79
|
+
map.putString("subType", it.subType)
|
|
80
|
+
val array = convertBasicToMap(it)
|
|
81
|
+
if (array.size() > 0) {
|
|
82
|
+
map.putArray("specs", array)
|
|
83
|
+
}
|
|
84
|
+
array.pushMap(map);
|
|
85
|
+
}
|
|
86
|
+
return array
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun getWriteArrayForArraySpec(arraySpec: ArraySpecs): WritableArray {
|
|
90
|
+
var array = Arguments.createArray()
|
|
91
|
+
var map = Arguments.createMap()
|
|
92
|
+
map.putString("size", arraySpec.size)
|
|
93
|
+
map.putString("dataType", arraySpec.dataType)
|
|
94
|
+
array.pushMap(map)
|
|
95
|
+
return array
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private fun getWriteArrayForTextSpecs(textSpecs: TextSpecs): WritableArray {
|
|
99
|
+
var array = Arguments.createArray()
|
|
100
|
+
var map = Arguments.createMap()
|
|
101
|
+
map.putString("length", textSpecs.length);
|
|
102
|
+
array.pushMap(map);
|
|
103
|
+
return array
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
fun getWritableMapFromNumSpec(data: NumSpecs): WritableArray {
|
|
108
|
+
var array = Arguments.createArray();
|
|
109
|
+
var map: WritableMap = Arguments.createMap()
|
|
110
|
+
map.putString("unit", data.unit)
|
|
111
|
+
map.putString("min", data.min)
|
|
112
|
+
map.putString("max", data.max)
|
|
113
|
+
map.putString("step", data.step)
|
|
114
|
+
array.pushMap(map)
|
|
115
|
+
return array
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
fun getWriteArrayForBooleanSpec(list: List<BooleanSpecs>): WritableArray {
|
|
120
|
+
val array = Arguments.createArray();
|
|
121
|
+
list.forEach {
|
|
122
|
+
var map = Arguments.createMap();
|
|
123
|
+
map.putString("dataType", it.getDataType());
|
|
124
|
+
map.putString("name", it.getName());
|
|
125
|
+
map.putString("value", it.getValue());
|
|
126
|
+
array.pushMap(map)
|
|
127
|
+
}
|
|
128
|
+
return array;
|
|
129
|
+
}
|
|
130
|
+
}
|
package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ErrorCode.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 错误码定义类
|
|
5
|
+
*
|
|
6
|
+
* @author : king.pan
|
|
7
|
+
* @e-mail : king.pan@quectel.com
|
|
8
|
+
* @date : 2022/7/25 09:38
|
|
9
|
+
*/
|
|
10
|
+
public interface ErrorCode {
|
|
11
|
+
/**
|
|
12
|
+
* 错误码---网络异常
|
|
13
|
+
*/
|
|
14
|
+
String ERROR_CODE_NETWORK_ABNORMAL = "-1";
|
|
15
|
+
/**
|
|
16
|
+
* 错误码 -- json转换异常
|
|
17
|
+
*/
|
|
18
|
+
String ERROR_CODE_JSON_EXCEPTION = "-2";
|
|
19
|
+
/**
|
|
20
|
+
* 错误码 -- 请求失败
|
|
21
|
+
*/
|
|
22
|
+
String ERROR_CODE_REQUEST_FAIL = "-3";
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
}
|
package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/ErrorUtils.java
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise;
|
|
4
|
+
|
|
5
|
+
public class ErrorUtils {
|
|
6
|
+
|
|
7
|
+
public static void processJSONException(Promise promise, String code, String message) {
|
|
8
|
+
promise.reject(code, message);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
}
|
package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/IpcUtil.java
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import com.quectel.basic.common.base.QuecBaseApp;
|
|
4
|
+
import com.quectel.basic.queclog.QLog;
|
|
5
|
+
import com.quectel.basic.quecmmkv.MmkvManager;
|
|
6
|
+
|
|
7
|
+
import java.io.File;
|
|
8
|
+
import java.util.Arrays;
|
|
9
|
+
import java.util.Iterator;
|
|
10
|
+
|
|
11
|
+
public class IpcUtil {
|
|
12
|
+
|
|
13
|
+
public static void savePrivacyState(String pk, String dk, boolean isAgree) {
|
|
14
|
+
String key = "quec_ipc_privacy_" + pk + dk;
|
|
15
|
+
MmkvManager.getInstance().put(key, isAgree);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static boolean getPrivacyState(String pk, String dk){
|
|
19
|
+
String key = "quec_ipc_privacy_" + pk + dk;
|
|
20
|
+
return MmkvManager.getInstance().get(key,false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 清楚ipc视频图片缓存
|
|
25
|
+
* @param pk
|
|
26
|
+
* @param dk
|
|
27
|
+
*/
|
|
28
|
+
public static void clearIpcVideoPhotoMMKV(String pk,String dk){
|
|
29
|
+
try {
|
|
30
|
+
File filesDir = QuecBaseApp.getInstance().getFilesDir();
|
|
31
|
+
String capturePhotoPath = filesDir.getAbsolutePath() + "/ipc/photo";
|
|
32
|
+
String recordPath = filesDir.getAbsolutePath() + "/ipc/video";
|
|
33
|
+
String videoFolder = recordPath + "/" + pk + dk;
|
|
34
|
+
String photoFolder = capturePhotoPath + "/" + pk + dk;
|
|
35
|
+
clearFolderMMKV(videoFolder);
|
|
36
|
+
clearFolderMMKV(photoFolder);
|
|
37
|
+
}catch (Exception e){
|
|
38
|
+
QLog.e("清理ipc-video-photo文件缓存出错");
|
|
39
|
+
e.printStackTrace();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 清理文件夹mmkv缓存
|
|
45
|
+
* @param folderPath
|
|
46
|
+
*/
|
|
47
|
+
private static void clearFolderMMKV(String folderPath){
|
|
48
|
+
if (folderPath != null){
|
|
49
|
+
File folder = new File(folderPath);
|
|
50
|
+
if(folder.exists()){
|
|
51
|
+
File[] files = folder.listFiles();
|
|
52
|
+
if (files != null && files.length>0){
|
|
53
|
+
Iterator iterator = Arrays.asList(files).iterator();
|
|
54
|
+
while (iterator.hasNext()){
|
|
55
|
+
File file = (File) iterator.next();
|
|
56
|
+
String bean = MmkvManager.getInstance().get(file.getAbsolutePath(), null);
|
|
57
|
+
if (bean != null) {
|
|
58
|
+
MmkvManager.getInstance().remove(file.getAbsolutePath());
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
if(file.isFile()){
|
|
62
|
+
file.delete();
|
|
63
|
+
}else if(file.isDirectory()){
|
|
64
|
+
clearFolderMMKV(file.getAbsolutePath());
|
|
65
|
+
}
|
|
66
|
+
} catch (Exception e) {
|
|
67
|
+
e.printStackTrace();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
folder.delete();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
package/android/src/main/java/com/quectel/smart/rnplugin/quecrndevicemodule/utils/NetUtils.java
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.net.ConnectivityManager;
|
|
5
|
+
import android.net.NetworkInfo;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
public class NetUtils
|
|
9
|
+
{
|
|
10
|
+
private NetUtils()
|
|
11
|
+
{
|
|
12
|
+
/* cannot be instantiated */
|
|
13
|
+
throw new UnsupportedOperationException("cannot be instantiated");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public static enum NetType {
|
|
17
|
+
WIFI, CMNET, CMWAP, NONE
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 判断网络是否连接
|
|
22
|
+
*
|
|
23
|
+
* @param context
|
|
24
|
+
* @return
|
|
25
|
+
*/
|
|
26
|
+
public static boolean isConnected(Context context)
|
|
27
|
+
{
|
|
28
|
+
ConnectivityManager connectivity = (ConnectivityManager) context
|
|
29
|
+
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
30
|
+
if (null != connectivity)
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
NetworkInfo info = connectivity.getActiveNetworkInfo();
|
|
34
|
+
if (null != info && info.isConnected())
|
|
35
|
+
{
|
|
36
|
+
if (info.getState() == NetworkInfo.State.CONNECTED)
|
|
37
|
+
{
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 判断是否是wifi连接
|
|
47
|
+
*/
|
|
48
|
+
public static boolean isWifi(Context context)
|
|
49
|
+
{
|
|
50
|
+
ConnectivityManager cm = (ConnectivityManager) context
|
|
51
|
+
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
52
|
+
|
|
53
|
+
if (cm == null)
|
|
54
|
+
return false;
|
|
55
|
+
return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public static boolean isNetworkConnected(Context context) {
|
|
60
|
+
if (context != null) {
|
|
61
|
+
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
62
|
+
NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
|
|
63
|
+
if (mNetworkInfo != null) {
|
|
64
|
+
return mNetworkInfo.isAvailable();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static boolean isNetworkAvailable(Context context) {
|
|
71
|
+
ConnectivityManager mgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
72
|
+
NetworkInfo[] info = mgr.getAllNetworkInfo();
|
|
73
|
+
if (info != null) {
|
|
74
|
+
for (int i = 0; i < info.length; i++) {
|
|
75
|
+
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import com.quectel.sdk.iot.channel.kit.chanel.IQuecChannelManager;
|
|
4
|
+
import com.quectel.sdk.iot.channel.kit.constaint.QuecIotChannelType;
|
|
5
|
+
import com.quectel.sdk.iot.channel.kit.model.QuecIotDataPointsModel;
|
|
6
|
+
|
|
7
|
+
public abstract class OnConnectListener implements IQuecChannelManager.IQuecCallBackListener {
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@Override
|
|
11
|
+
public void onData(String channelId, QuecIotChannelType channelType, QuecIotDataPointsModel dataPointsModel) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
public void onBleClose(String channelId) {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public void onDisConnect(String channelId, QuecIotChannelType channelType) {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 获取参数值的方法类
|
|
9
|
+
*
|
|
10
|
+
* @author : king.pan
|
|
11
|
+
* @e-mail : king.pan@quectel.com
|
|
12
|
+
* @date : 2022/1/27 13:54
|
|
13
|
+
*/
|
|
14
|
+
public final class ParamsValueUtils {
|
|
15
|
+
/**
|
|
16
|
+
* 获取String 类型的参数值
|
|
17
|
+
*
|
|
18
|
+
* @param map 键值对集合
|
|
19
|
+
* @param key 关键字
|
|
20
|
+
* @param defaultValue 默认值
|
|
21
|
+
* @return String 类型的参数值
|
|
22
|
+
*/
|
|
23
|
+
public static String getString(@NonNull ReadableMap map, @NonNull String key, String defaultValue) {
|
|
24
|
+
if (map.hasKey(key)) {
|
|
25
|
+
return map.getString(key);
|
|
26
|
+
} else {
|
|
27
|
+
return defaultValue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 获取 int 类型的参数值
|
|
33
|
+
*
|
|
34
|
+
* @param map 键值对集合
|
|
35
|
+
* @param key 关键字
|
|
36
|
+
* @param defaultValue 默认值
|
|
37
|
+
* @return String 类型的参数值
|
|
38
|
+
*/
|
|
39
|
+
public static int getInt(@NonNull ReadableMap map, @NonNull String key, int defaultValue) {
|
|
40
|
+
if (map.hasKey(key)) {
|
|
41
|
+
return map.getInt(key);
|
|
42
|
+
} else {
|
|
43
|
+
return defaultValue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 获取 boolean 类型的参数值
|
|
50
|
+
*
|
|
51
|
+
* @param map 键值对集合
|
|
52
|
+
* @param key 关键字
|
|
53
|
+
* @param defaultValue 默认值
|
|
54
|
+
* @return String 类型的参数值
|
|
55
|
+
*/
|
|
56
|
+
public static boolean getBoolean(@NonNull ReadableMap map, @NonNull String key, boolean defaultValue) {
|
|
57
|
+
if (map.hasKey(key)) {
|
|
58
|
+
return map.getBoolean(key);
|
|
59
|
+
} else {
|
|
60
|
+
return defaultValue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 获取 Double 类型的参数值
|
|
66
|
+
*
|
|
67
|
+
* @param map 键值对集合
|
|
68
|
+
* @param key 关键字
|
|
69
|
+
* @param defaultValue 默认值
|
|
70
|
+
* @return String 类型的参数值
|
|
71
|
+
*/
|
|
72
|
+
public static Double getDouble(@NonNull ReadableMap map, @NonNull String key, double defaultValue) {
|
|
73
|
+
if (map.hasKey(key)) {
|
|
74
|
+
return map.getDouble(key);
|
|
75
|
+
} else {
|
|
76
|
+
return defaultValue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
package com.quectel.smart.rnplugin.quecrndevicemodule.utils;
|
|
2
|
+
|
|
3
|
+
public class QuecIotChannelMode {
|
|
4
|
+
public static final int QuecIotDataSendModeAuto = 0;
|
|
5
|
+
public static final int QuecIotDataSendModeWifi = 1;
|
|
6
|
+
public static final int QuecIotDataSendModeWS = 2;
|
|
7
|
+
public static final int QuecIotDataSendModeBLE = 3;
|
|
8
|
+
}
|