From 1844a2a29c68d9f9f6aa620d6f05623eede34a57 Mon Sep 17 00:00:00 2001
From: 刘卫锦 <lwj@hdlchina.com.cn>
Date: 星期四, 29 六月 2023 15:37:22 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.23:6688/r/~wjc/HDLPhotovoltaicDebugAPP
---
app/src/main/java/com/hdl/photovoltaic/bean/ModBusBean.java | 28 ++
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java | 9
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkResponse.java | 4
app/src/main/assets/data/dcloud_control.xml | 4
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java | 308 +++++++++++++++++++++++++
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | 6
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 66 ++++-
app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java | 22 +
HDLLinkLocalSdk/src/main/res/values/strings_code.xml | 1
HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml | 1
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java | 98 +++----
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java | 17
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java | 1
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/QueueUtils.java | 7
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java | 2
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java | 88 +++++++
16 files changed, 578 insertions(+), 84 deletions(-)
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java
index a041d71..fbdfecd 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java
@@ -38,6 +38,7 @@
public static final HDLLinkCode HDL_TOPIC_NOT_RIGHT=new HDLLinkCode(-2110,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_TOPIC_NOT_RIGHT));
public static final HDLLinkCode HDL_OBJECT_NOT_SUPPORT=new HDLLinkCode(-2111,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_OBJECT_NOT_SUPPORT));
public static final HDLLinkCode HDL_GATEWAY_REMOTE_NOT_RESPONSE=new HDLLinkCode(-2112,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GATEWAY_REMOTE_NOT_RESPONSE));
+ public static final HDLLinkCode HDL_SUCCESS=new HDLLinkCode(0,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.SUCCESS));
private String msg;
private int code;
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkResponse.java
index ad2f655..5a58a0d 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkResponse.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkResponse.java
@@ -34,7 +34,7 @@
public void setByteData(byte []data) {
this.byteData = data;
- this.data = new String(data);
+// this.data = new String(data);
this.length=data.length;
}
@@ -45,7 +45,7 @@
public void setData(String data) {
this.data = data;
if (!TextUtils.isEmpty(data)) {
- this.byteData = data.getBytes();
+// this.byteData = data.getBytes();
setLength(data.length());
} else {
setLength(0);
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java
new file mode 100644
index 0000000..cc54c11
--- /dev/null
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java
@@ -0,0 +1,88 @@
+package com.hdl.sdk.link.core.bean;
+
+import androidx.annotation.NonNull;
+
+import com.hdl.sdk.link.common.utils.gson.GsonConvert;
+
+import java.io.Serializable;
+
+/**
+ * Created by hxb on 2021/12/19.
+ */
+public class ModbusResponse implements Serializable {
+
+ /**
+ * 鍘熺敓涓婚
+ */
+ private String topic;
+ /**
+ * 鍘熺敓鏁版嵁
+ */
+ private byte []data;
+
+ /**
+ * 缃戝叧Oid
+ */
+ private String oid;
+
+
+ /**
+ * 鑾峰彇鍘熺敓涓婚
+ *
+ * @return
+ */
+ public String getTopic() {
+ return topic;
+ }
+
+ /**
+ * 璁剧疆鍘熺敓涓婚
+ *
+ * @param topic
+ */
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ /**
+ * 鑾峰彇鍘熺敓鏁版嵁
+ *
+ * @return
+ */
+ public byte []getData() {
+ return data;
+ }
+
+ /**
+ * 璁剧疆鍘熺敓鏁版嵁
+ *
+ * @param data
+ */
+ public void setData(byte []data) {
+ this.data = data;
+ }
+
+ /**
+ * 鑾峰彇缃戝叧涓昏淇℃伅锛屽彲鑳芥槸oid锛屽彲鑳芥槸缃戝叧Id锛屽彲鑳芥槸mac
+ *
+ * @return
+ */
+ public String getOid() {
+ return oid;
+ }
+
+ /**
+ * 璁剧疆Oid
+ *
+ * @param
+ */
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+
+ @NonNull
+ @Override
+ public String toString() {
+ return GsonConvert.getGson().toJson(this);
+ }
+}
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java
index 7e58147..bfff2ff 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java
@@ -8,5 +8,5 @@
* Created by hxb on 2021/12/15.
*/
public interface ModbusCallBack extends BaseCallBack {
- void onSuccess(String msg);
+ void onSuccess(byte []data);
}
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java
index 18967d5..47e5363 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java
@@ -12,6 +12,7 @@
import com.hdl.sdk.link.common.utils.ThreadToolUtils;
import com.hdl.sdk.link.core.bean.LinkRequest;
import com.hdl.sdk.link.core.bean.LinkResponse;
+import com.hdl.sdk.link.core.bean.ModbusResponse;
import com.hdl.sdk.link.core.bean.ZigbeeResponse;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
@@ -126,6 +127,14 @@
else{
notifyFailure(HDLLinkCode.HDL_TOPIC_NOT_RIGHT);
}
+ }else if(msg instanceof ModbusResponse){
+ ModbusResponse response = (ModbusResponse) msg;
+ if (replyTopic.equals(response.getTopic())) {
+ notifySucceed(response.getData());
+ }
+ else{
+ notifyFailure(HDLLinkCode.HDL_TOPIC_NOT_RIGHT);
+ }
}
else{
notifyFailure(new HDLLinkCode(HDLLinkCode.HDL_OBJECT_NOT_SUPPORT.getCode(), "Object Name:" + msg));
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java
index e38c3ad..241fee5 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java
@@ -11,9 +11,9 @@
import com.hdl.sdk.link.common.utils.LogUtils;
import com.hdl.sdk.link.core.bean.LinkRequest;
import com.hdl.sdk.link.core.bean.LinkResponse;
+import com.hdl.sdk.link.core.bean.ModbusResponse;
import com.hdl.sdk.link.core.bean.ZigbeeResponse;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
-import com.hdl.sdk.link.core.callback.BaseCallBack;
import com.hdl.sdk.link.core.callback.ModbusCallBack;
import com.hdl.sdk.link.core.callback.ZigbeeCallBack;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
@@ -28,9 +28,9 @@
private static final String TAG="HDLModbusConnect";
private static HDLModBusConnect instance;
/**
- * 鍐呴儴鐢紝涓昏鏄鐞嗗鐞嗘帀閫忎紶涓婚鍙妉ink涓婚鍚庯紝杩樺師Zigbee鍘熺敓鏁版嵁鍙婁富棰樼敤
+ * 鍐呴儴鐢紝涓昏鏄鐞嗗鐞嗘帀閫忎紶涓婚鍙妉ink涓婚鍚庯紝杩樺師modbus鍘熺敓鏁版嵁鍙婁富棰樼敤
*/
- private final String zigbeeAllTopic = "/Modbus";
+ private final String allTopic = "/Modbus";
/**
* 杩斿洖褰撳墠瀹炰緥锛屼笉瀛樺湪灏卞垱寤哄苟鍚屾椂娉ㄥ唽鐩戝惉浜嬩欢
@@ -54,7 +54,7 @@
if(null==eventListener){
return;
}
- EventDispatcher.getInstance().register(zigbeeAllTopic, eventListener);
+ EventDispatcher.getInstance().register(allTopic, eventListener);
}
/**
@@ -66,7 +66,7 @@
if(null==eventListener){
return;
}
- EventDispatcher.getInstance().remove(zigbeeAllTopic, eventListener);
+ EventDispatcher.getInstance().remove(allTopic, eventListener);
}
/**
@@ -76,44 +76,39 @@
final EventListener eventListener = new EventListener() {
@Override
public void onMessage(Object msg) {
-// try {
-// if (msg instanceof LinkResponse) {
-// LinkResponse linkResponse = (LinkResponse) msg;
-// String body = linkResponse.getData();
-// int index = body.indexOf("{");
-// //zigbee鍥炲鐨勬暟鎹墠鏈変富棰橈紝鍚庨潰鎵嶆槸鏁版嵁
-// if (index <= 0)
-// return;
-//
-// String zigbeeTopic = body.substring(0, index).trim();
-// //zigbee鐨勮礋杞芥暟鎹�
-// String bodyData = body.substring(index);
-//
-// ZigbeeResponse zigbeeResponse = new ZigbeeResponse();
-// zigbeeResponse.setTopic(zigbeeTopic);
-// zigbeeResponse.setData(bodyData);
-// String oid = null;
-// //鏄惁鏄�氳繃涓荤綉鍏抽�忎紶涓婚
-// if (linkResponse.getTopic().contains("/slaveoid/")) {
-// oid = linkResponse.getTopic().split("/")[8];
-// } else {
-// oid = linkResponse.getTopic().split("/")[2];
-// }
-// zigbeeResponse.setOid(oid);
-// for (GatewayBean gatewayBean : HDLLinkLocalGateway.getInstance().getGatewayList()) {
-// if (oid.equals(gatewayBean.getGatewayId()) || oid.equals(gatewayBean.getDevice_mac()) || oid.equals(gatewayBean.getOid())) {
-// //涓婇潰鐨刼id鍙兘鏄綉鍏砳d鎴栬�卪ac鎴栬�呮槸oid锛屼笉绠℃槸鍝釜缁熶竴浣跨敤oid琛ㄧず鏂瑰紡
-// zigbeeResponse.setOid(gatewayBean.getOid());
-// break;
-// }
-// }
-// EventDispatcher.getInstance().post(zigbeeTopic, zigbeeResponse);
-// //鍙戝竷Zigbee鍘熺敓涓婚鍙婃暟鎹�
-// EventDispatcher.getInstance().post(zigbeeAllTopic, zigbeeResponse);
-// }
-// } catch (Exception e) {
-// LogUtils.e(TAG,"LinkResponse杞琙igbeeResponse寮傚父:"+ e.getMessage());
-// }
+ try {
+ if (msg instanceof LinkResponse) {
+ LinkResponse linkResponse = (LinkResponse) msg;
+ if(linkResponse.getTopic()==null||!linkResponse.getTopic().contains("custom/native/inverter/"))
+ {
+ return;
+ }
+ byte []data = linkResponse.getByteData();
+ ModbusResponse modbusResponse= new ModbusResponse();
+ modbusResponse.setTopic("Modbus"+data[0]+data[1]);
+ modbusResponse.setData(data);
+ String oid = null;
+ //鏄惁鏄�氳繃涓荤綉鍏抽�忎紶涓婚
+ if (linkResponse.getTopic().contains("/slaveoid/")) {
+ oid = linkResponse.getTopic().split("/")[8];
+ } else {
+ oid = linkResponse.getTopic().split("/")[2];
+ }
+ modbusResponse.setOid(oid);
+ for (GatewayBean gatewayBean : HDLLinkLocalGateway.getInstance().getGatewayList()) {
+ if (oid.equals(gatewayBean.getGatewayId()) || oid.equals(gatewayBean.getDevice_mac()) || oid.equals(gatewayBean.getOid())) {
+ //涓婇潰鐨刼id鍙兘鏄綉鍏砳d鎴栬�卪ac鎴栬�呮槸oid锛屼笉绠℃槸鍝釜缁熶竴浣跨敤oid琛ㄧず鏂瑰紡
+ modbusResponse.setOid(gatewayBean.getOid());
+ break;
+ }
+ }
+ EventDispatcher.getInstance().post(allTopic, modbusResponse);
+ //鍙戝竷Zigbee鍘熺敓涓婚鍙婃暟鎹�
+// EventDispatcher.getInstance().post(allTopic, zigbeeResponse);
+ }
+ } catch (Exception e) {
+ LogUtils.e(TAG,"LinkResponse杞琈odbusResponse寮傚父:"+ e.getMessage());
+ }
}
};
//娉ㄥ唽鐩存帴閫氳鐨勪富棰橈紝鍖呮嫭鐩存帴鍜屼富缃戝叧閫氳鎴栬�呯洿鎺ュ拰浠庣綉鍏抽�氳
@@ -127,11 +122,10 @@
* 鍙戦�佸師鐢熸暟鎹�
*
* @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d
- * @param responeTopic 鍥炲涓婚
* @param payload 鍙戦�佹暟鎹�
* @param baseCallBack 缁撴灉鍥炶皟
*/
- public void Send(String gatewayOidOrGatewayId,String responeTopic, String payload, final ModbusCallBack baseCallBack) {
+ public void Send(String gatewayOidOrGatewayId, byte []payload, final ModbusCallBack baseCallBack) {
//濡傛灉鏈湴鏈夐摼鎺ヨ繖涓綉鍏�,鍒欑敤鏈湴杩炴帴
GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId);
if (null == gatewayBean) {
@@ -150,17 +144,19 @@
} else {
request.setCloudTopic(String.format(TopicConstant.NATIVE_MODBUS_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId));
}
- request.setReplyTopic(responeTopic);
+ request.setReplyTopic("Modbus"+payload[0]+payload[1]);
long timeout = 2 * 1000;
new HDLConnectHelper(timeout, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() {
@Override
public void onSucceed(Object msg) {
-// if (msg instanceof String) {
-// if (null != baseCallBack) {
-// baseCallBack.onSuccess(msg+"");
-// }
-// }
+ if (msg instanceof Byte[]) {
+ if (null != baseCallBack) {
+ baseCallBack.onSuccess((byte[])msg);
+ }
+ }else{
+ LogUtils.e("鍙戦�丮odbus鍥炶皟瀵硅薄绫诲瀷闈炴暟缁勭被鍨嬶紝绫诲瀷鏄�"+msg.getClass());
+ }
}
@Override
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/QueueUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/QueueUtils.java
index dcc7ffc..2d0e0ea 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/QueueUtils.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/QueueUtils.java
@@ -117,9 +117,10 @@
} else {
response.setData(new String(linkPacket.getBody(), "utf-8"));
}
-// if (HDLConnectHelper.isLocal()) {
- LogUtils.i("鏈湴鎺ユ敹鍒版暟鎹�:\r\n" + response.getTopic() + "\r\n" + response.getData());
-// }
+ response.setByteData(linkPacket.getBody());
+ // if (HDLConnectHelper.isLocal()) {
+ LogUtils.i("鏈湴鎺ユ敹鍒版暟鎹�:\r\n" + response.getTopic() + "\r\n" + response.getData());
+ // }
//瑙f瀽瀹屾垚,topic鍙戦�佷竴娆�
EventDispatcher.getInstance().post(response.getTopic(), response);
}
diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java
index d7b6668..1f50858 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java
@@ -716,25 +716,26 @@
/**
* 鍙戦�佹暟鎹埌Link缃戝叧
*
- * @param ip 缃戝叧IP
* @param mac 缃戝叧mac
* @param isEncrypt 鏄惁鍔犲瘑
* @param topic 璇锋眰涓婚
* @param jObject 璐熻浇鏁版嵁<娌℃湁濉玭ull></>
* @param sendPath 鍙戦�佽矾寰�<绫诲悕+鏂规硶鍚�>class->methodName</>
*/
- public void sendDataToLinkGateway(String ip, String mac, boolean isEncrypt,
+ public void sendDataToLinkGateway(String mac, boolean isEncrypt,
String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
- String topicSend = topic.replace("%s", mac);
+ GatewayBean gatewayBean = this.getLocalGateway(mac);
+ if (gatewayBean == null) {
+ callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode));
+ return;
+ }
+ String topicSend = topic.replace("%s", gatewayBean.getOid());
//缁勮闇�瑕佸彂閫佺殑鏁版嵁
String sendStr = createSendData(jObject);
// LogUtils.i("sendDataToLinkGateway->" + sendPath + "->鏈湴鍙戦�乗r\n" + topicSend + "\r\n" + sendStr);
LinkRequest message = new LinkRequest(topicSend, sendStr, isEncrypt);
- GatewayBean gatewayBean = this.getLocalGateway(mac);
- if (gatewayBean != null) {
- message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId()));
- }
- new HDLConnectHelper(ip, message, new HDLConnectHelper.HdlSocketListener() {
+ message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId()));
+ new HDLConnectHelper(gatewayBean.getIp_address(), message, new HDLConnectHelper.HdlSocketListener() {
@Override
public void onSucceed(Object msg) {
if (callBack == null) return;
diff --git a/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml b/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml
index 25f17da..d842ea7 100644
--- a/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml
+++ b/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml
@@ -24,4 +24,5 @@
<string name="HDL_TOPIC_NOT_RIGHT">涓婚娌℃湁鍖归厤</string>
<string name="HDL_OBJECT_NOT_SUPPORT">瀵硅薄涓嶆敮鎸�</string>
<string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">缃戝叧鏈湴杩炴帴澶辫触锛岄�氳繃杩滅▼閫氳涓嶅洖澶�</string>
+ <string name="SUCCESS">鎴愬姛</string>
</resources>
\ No newline at end of file
diff --git a/HDLLinkLocalSdk/src/main/res/values/strings_code.xml b/HDLLinkLocalSdk/src/main/res/values/strings_code.xml
index ca99860..8cc9e3e 100644
--- a/HDLLinkLocalSdk/src/main/res/values/strings_code.xml
+++ b/HDLLinkLocalSdk/src/main/res/values/strings_code.xml
@@ -24,4 +24,5 @@
<string name="HDL_TOPIC_NOT_RIGHT">Theme does not match</string>
<string name="HDL_OBJECT_NOT_SUPPORT">Object not supported</string>
<string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">Gateway local connection failed, unable to reply through remote communication</string>
+<string name="SUCCESS">success</string>
</resources>
\ No newline at end of file
diff --git a/app/src/main/assets/data/dcloud_control.xml b/app/src/main/assets/data/dcloud_control.xml
index 727b81a..acfad40 100644
--- a/app/src/main/assets/data/dcloud_control.xml
+++ b/app/src/main/assets/data/dcloud_control.xml
@@ -1,6 +1,6 @@
-<hbuilder version="1.9.9.80110" debug="false" syncDebug ="false">
+<hbuilder debug="true" syncDebug="false" version="1.9.9.80110">
<apps>
- <app appid="unimp" appver="1.0"/>
+ <app appid="unimp" appver="1.0" />
</apps>
</hbuilder>
diff --git a/app/src/main/java/com/hdl/photovoltaic/bean/ModBusBean.java b/app/src/main/java/com/hdl/photovoltaic/bean/ModBusBean.java
new file mode 100644
index 0000000..fed6b01
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/bean/ModBusBean.java
@@ -0,0 +1,28 @@
+package com.hdl.photovoltaic.bean;
+
+import java.io.Serializable;
+
+/**
+ * Created by hxb on 2023/6/28.
+ */
+public class ModBusBean implements Serializable {
+
+ private String oid;//缃戝叧oid
+ private byte []data;//鎺у埗鍛戒护
+
+ public String getOid() {
+ return oid;
+ }
+
+ public void setOid(String oid) {
+ this.oid = oid;
+ }
+
+ public byte []getData() {
+ return data;
+ }
+
+ public void setData(byte []data) {
+ this.data = data;
+ }
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java b/app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java
index 9afc648..47e9e8b 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java
@@ -1,4 +1,26 @@
package com.hdl.photovoltaic.internet;
+
+import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
+import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
+
+/**
+ * 瀹㈡埛绔搷浣滈�昏緫
+ */
public class TcpClient {
+
+ /**
+ * 鍙戦�佹暟鎹埌Link缃戝叧
+ *
+ * @param mac 缃戝叧mac
+ * @param isEncrypt 鏄惁鍔犲瘑
+ * @param topic 璇锋眰涓婚
+ * @param jObject 璐熻浇鏁版嵁<娌℃湁濉玭ull></>
+ * @param sendPath 鍙戦�佽矾寰�<绫诲悕+鏂规硶鍚�>class->methodName</>
+ */
+ public void sendDataToLinkGateway(String mac, boolean isEncrypt,
+ String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
+ HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, isEncrypt, topic, jObject, sendPath, callBack);
+
+ }
}
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java b/app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
index d814fe7..1b70139 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
@@ -1,4 +1,312 @@
package com.hdl.photovoltaic.internet.api;
public class TopicApi {
+ /*
+ *閫氱煡鍒犻櫎骞堕��缃戝瓙璁惧鎷撴墤鍏崇郴
+ *鍒犻櫎浠庣綉鍏�
+ * */
+ public static final String DELETING_GATEWAY_SLAVE = "/base/%s/thing/topo/delete/notify";
+
+ /*
+ *缃戝叧鐗╃悊閫�缃戝悗涓婃姤鍒犻櫎(閫�缃�)瀛愯澶�
+ * */
+ public static final String DELETING_GATEWAY_SLAVE_RESULT = "/base/%s/thing/topo/delete/up";
+
+
+ /*
+ 缃戝叧鏁版嵁澶囦唤杩樺師
+ * */
+ public static final String GATEWAY_BACKUP_RESTORE_DOWN = "/base/%s/device/backup/restore/down";
+
+ /*
+ 璋冭瘯浜哄憳涓诲姩閫氱煡缃戝叧澶囦唤鏁版嵁
+ * */
+ public static final String GATEWAY_BACKUP_NOTICE_DOWN = "/base/%s/device/backup/notice/down";
+ /*
+ 澶囦唤杩樺師杩涘害鑾峰彇
+ * */
+ public static final String GATEWAY_BACKUP_PROGRESS_GET = "/base/%s/device/backup/restore/progress/get";
+
+ /*
+ * 缃戝叧缂栬緫鍛戒护
+ * 鍐欒繙绋嬩俊鎭殑锛屼緥濡傛湇鍔″櫒鍦板潃銆丠omeId銆佸瘑閽ヤ箣绫�
+ * 涓庢湇鍔″櫒鐩稿叧鐨�
+ * */
+ public static final String GATEWAY_EDIT_REMOTE = "/user/%s/custom/gateway/remote/edit";
+
+ /*
+ * 缃戝叧鎭㈠鍑哄満璁剧疆鍛戒护
+ * */
+ public static final String GATEWAY_INITIALIZE_REMOTE = "/user/%s/custom/gateway/initialize";
+ public static final String GATEWAY_FIND_REMOTE = "/base/%s/thing/service/mmv_device_find/down";
+
+ /**
+ * 绾㈠瀹濈殑瀹氫綅
+ */
+ public static final String IR_FIND_REMOTE = "/base/%s/thing/service/irDeviceFind/down";
+ /**
+ * 绾㈠瀹濊瘯鐮�
+ */
+ public static final String IR_CODE_TEST = "/base/%s/thing/service/irCodeTest/down";
+ /**
+ * 绾㈠瀹濋仴鎺у櫒娣诲姞
+ */
+ public static final String IR_DEVICE_ADD = "/base/%s/thing/service/irDeviceAdd/down";
+ /**
+ * 绾㈠瀹濋仴鎺у櫒鍒楄〃鑾峰彇
+ */
+ public static final String IR_DEVICE_LIST = "/base/%s/thing/service/irDeviceListGet/down";
+ /**
+ * 绾㈠瀹濊嚜瀛︾爜
+ */
+ public static final String IR_CODE_STUDY = "/base/%s/thing/service/irCodeStudy/down";
+ /**
+ * 绾㈠瀹濊嚜瀛︾爜鍒犻櫎
+ */
+ public static final String IR_CODE_REMOVE = "/base/%s/thing/service/irCodeRemove/down";
+
+
+ /*
+ * 缃戝叧缂栬緫鍛戒护
+ * 涓庢湇鍔″櫒鏃犲叧鐨�
+ * */
+ public static final String GATEWAY_SEND_EDIT = "/user/%s/custom/gateway/edit";
+
+ /**
+ * 璁剧疆缃戝叧鍏ョ綉妯″紡
+ * 鍏ョ綉浠庢満璁惧浣跨敤
+ * 浠庣綉鍏炽�佺孩澶栧疂绛夌綉缁滆澶�
+ */
+ public static final String GATEWAY_AUTH = "/user/%s/custom/device/auth_gateway";
+ //鑾峰彇缃戝叧淇℃伅
+ public static final String GATEWAY_GET = "/user/%s/custom/gateway/remote/get";
+
+ //缃戝叧骞挎挱鍏ョ綉鎸囦护
+ public static final String GATEWAY_AUTH_BROADCAST = "/user/all/custom/device/network_access/broadcast";
+
+ //璁惧鍏ョ綉鍜岃璇�
+ public static final String DEIVCE_AUTH_REQUEST = "/user/all/custom/device/network_access/request";
+
+ //璁惧鍏ョ綉鍜岃璇佸搷搴�
+ public static final String DEIVCE_AUTH_REQUEST_REPLY = "/user/all/custom/device/network_access/request_reply";
+
+ /**
+ * 鎼滅储缃戝叧
+ */
+ public static final String GATEWAY_SEARCH = "/user/all/custom/gateway/search";
+
+ /**
+ * 鎼滅储缃戝叧鍝嶅簲
+ */
+ public static final String GATEWAY_SEARCH_REPLY = "/user/all/custom/gateway/search_reply";
+
+ //缃戝叧璇︾粏淇℃伅鑾峰彇s=gw_id
+ public static final String GATEWAY_INFO = "/user/%s/custom/gateway/get";
+
+ //鑾峰彇鐗╃悊璁惧鍒楄〃
+ public static final String GET_DEVICE_LIST = "/user/%s/custom/device/list/get";
+
+ //鑾峰彇鐗╃悊璁惧鍒楄〃鍝嶅簲
+ public static final String GET_DEVICE_LIST_REPLY = "/user/%s/custom/device/list/get_reply";
+
+ //鑾峰彇鍔熻兘鍒楄〃
+ public static final String GET_FUNCTION_LIST = "/user/%s/custom/function/list/get";
+
+ //妯℃嫙浜戠ota
+ public static final String OTA_UPGRADE_DOWN = "/base/%s/ota/device/upgrade/down";
+
+ /**
+ * 缂栬緫sid
+ */
+ public static final String EDIT_FUNCTION = "/user/%s/custom/function/attribute/edit";
+
+ //鑾峰彇鍔熻兘鍝嶅簲
+ public static final String GET_FUNCTION_LIST_REPLY = "/user/%s/custom/function/list/get_reply";
+
+ //鍔熻兘灞炴�ц鍙�
+ public static final String GET_FUNCTION_ATTRIBUTE = "/user/%s/custom/function/attribute/get";
+ //鍔熻兘灞炴�х紪杈�
+ public static final String EDIT_FUNCTION_ATTRIBUTE = "/user/%s/custom/function/attribute/edit";
+
+ //鍔熻兘灞炴�у搷搴�
+ public static final String GET_FUNCTION_ATTRIBUTE_REPLY = "/user/%s/custom/function/attribute/get_reply";
+
+ //鎺у埗
+ public static final String PROPERTY_DOWN = "/base/%s/thing/property/down";
+
+ //鎺у埗鍝嶅簲
+ public static final String PROPERTY_DOWN_REPLY = "/base/%s/thing/property/down_reply";
+
+ //鐘舵�佷笂鎶�
+ public static final String PROPERTY_UP = "/base/%s/thing/property/up";
+
+ //鐘舵�佷笂鎶ュ搷搴�
+ public static final String PROPERTY_UP_REPLY = "/base/%s/thing/property/up_reply";
+
+ //璇诲彇鐘舵��
+ public static final String PROPERTY_READ = "/base/%s/thing/property/read";
+
+ //璇诲彇鐘舵�佸搷搴�
+ public static final String PROPERTY_READ_REPLY = "/base/%s/thing/property/read_reply";
+
+ //鏇存敼缃戝叧澶囨敞鍚�
+ public static final String GATEWAY_RENAME = "/user/%s/custom/gateway/edit";
+
+ //8.1鑾峰彇鍦烘櫙鍒楄〃
+ public static final String SCENE_LIST_GET = "/user/%s/custom/scene/list/get";
+
+ //8.2鑾峰彇鍦烘櫙
+ public static final String SCENE_GET = "/user/%s/custom/scene/get";
+
+ //8.3鎵ц鍦烘櫙
+ public static final String SCENE_CONTROL = "/user/%s/custom/scene/execute";
+
+ //8.4鍦烘櫙澧炲姞
+ public static final String CREATE_SCENE = "/user/%s/custom/scene/add";
+
+ //8.5鍦烘櫙缂栬緫
+ public static final String SCENE_EDIT = "/user/%s/custom/scene/edit";
+
+ //8.6鍦烘櫙鍒犻櫎
+ public static final String SCENE_DELETE = "/user/%s/custom/scene/delete";
+
+ //9.1 鎴块棿淇℃伅鍒楄〃鑾峰彇
+ public static final String ROOM_LIST_GET = "/user/%s/custom/room/list/get";
+
+ //9.2 鎴块棿淇℃伅娣诲姞锛堝閲忥級
+ public static final String ROOM_ADD = "/user/%s/custom/room/add";
+
+ //9.2.1 鎴块棿淇℃伅娣诲姞锛堝叏閲忥級
+ public static final String ROOM_COVER_ADD = "/user/%s/custom/room/cover/add";
+
+ //9.3 鎴块棿淇℃伅缂栬緫
+ public static final String ROOM_EDIT = "/user/%s/custom/room/edit";
+
+ //9.4 鎴块棿淇℃伅鍒犻櫎
+ public static final String ROOM_DELETE = "/user/%s/custom/room/delete";
+
+ //9.5 鎴块棿缁戝畾鍏崇郴鍒楄〃鑾峰彇
+ public static final String ROOM_BIND_LIST_GET = "/user/%s/custom/room/bind/list/get";
+
+ //9.6 鎴块棿缁戝畾鍏崇郴娣诲姞锛堝閲忥級
+ public static final String ROOM_BIND_ADD = "/user/%s/custom/room/bind/add";
+
+ //9.6.1 鎴块棿缁戝畾鍏崇郴娣诲姞(鍏ㄩ噺)
+ public static final String ROOM_BIND_COVER_ADD = "/user/%s/custom/room/bind/cover/add";
+
+ //9.7 鎴块棿缁戝畾鍏崇郴鍒犻櫎
+ public static final String ROOM_BIND_DELETE = "/user/%s/custom/room/bind/delete";
+
+ //10.1 鑷姩鍖栧垪琛ㄨ幏鍙�
+ public static final String LOGIC_LIST_GET = "/user/%s/custom/logic/list/get";
+
+ //10.2 鑷姩鍖栨墜鍔ㄦ墽琛�
+ public static final String LOGIC_execute = "/user/%s/custom/logic/execute";
+
+ //10.3 鑷姩鍖栬幏鍙� 鍒楄〃涓�娆℃�ц鍏�
+ public static final String LOGIC_GET = "/user/%s/custom/logic/get";
+
+ //10.4 鑷姩鍖栨柊澧�/缂栬緫
+ public static final String LOGIC_EDIT = "/user/%s/custom/logic/edit";
+
+ //10.5 鑷姩鍖栧垹闄�
+ public static final String LOGIC_DELETE = "/user/%s/custom/logic/delete";
+
+ //10.6 鑷姩鍖栧惎鐢ㄧ鐢�
+ public static final String LOGIC_ENABLE_EDIT = "/user/%s/custom/logic/enable/edit";
+
+ //10.7 鑷姩鍖栫姸鎬佷笂鎶� 鎵ц缁撴灉銆佹湰鍦板惎鐢ㄧ鐢ㄧ姸鎬佷笂鎶�
+ public static final String LOGIC_STATUS_UP = "/user/%s/custom/logic/status/up";
+
+ //11.1 瀹夐槻鍒楄〃鑾峰彇
+ public static final String SECURITY_LIST_GET = "/user/%s/custom/security/list/get";
+
+ //11.2 瀹夐槻鑾峰彇
+ public static final String SECURITY_GET = "/user/%s/custom/security/get";
+
+ //11.3 瀹夐槻鏂板/缂栬緫
+ public static final String SECURITY_EDIT = "/user/%s/custom/security/edit";
+
+ //11.4 瀹夐槻鍒犻櫎
+ public static final String SECURITY_DELETE = "/user/%s/custom/security/delete";
+
+ //11.5 甯冮槻璁剧疆
+ public static final String SECURITY_STATUS_SET = "/user/%s/custom/security/status/set";
+
+ //11.6 瀹夐槻闃插尯鐘舵�佽鍙�
+ public static final String SECURITY_STATUS_GET = "/user/%s/custom/security/status/get";
+
+ //11.7 瀹夐槻闃插尯鎶ヨ鐘舵�佷笂鎶�
+ public static final String SECURITY_STATUS_UP = "/user/%s/custom/security/status/up";
+
+ //11.8 瀹夐槻Bypass璇诲彇
+ public static final String SECURITY_BYPASS_GET = "/user/%s/custom/security/bypass/get";
+
+ //11.9 瀹夐槻Bypass璁剧疆
+ public static final String SECURITY_BYPASS_SET = "/user/%s/custom/security/bypass/set";
+
+ /**
+ * 璁惧杩炴帴TCP涔嬪墠骞挎挱
+ */
+ public static final String BROADCAST = "/user/all/custom/gateway/broadcast";
+
+ /**
+ * 涓荤綉鍏冲洖澶�
+ */
+ public static final String BROADCAST_REPLY = "/user/all/custom/gateway/broadcast_reply";
+
+ /**
+ * sid缁戝畾鎴块棿
+ */
+ public static final String SID_BIND_ROOM = "/user/%s/custom/room/bind/add";
+
+ /**
+ * sid瑙g粦鎴块棿
+ */
+ public static final String SID_DELETE_ROOM = "/user/%s/custom/room/bind/delete";
+
+ /**
+ * 蹇冭烦妫�娴�
+ */
+ public static final String HEARTBEAT = "/user/%s/custom/gateway/heartbeat";
+// public static final String HEARTBEAT="/user/%s/custom/gateway1/qqheartbeat";
+ /**
+ * 蹇冭烦妫�娴嬪洖澶�
+ */
+ public static final String HEARTBEAT_REPLY = "/user/%s/custom/gateway/heartbeat_reply";
+
+ public static final String NATIVE_ZIGBEE_DOWN = "/user/%s/custom/native/zigbee/down";
+
+ public static final String NATIVE_ZIGBEE_DOWN_REPLY = "/user/%s/custom/native/zigbee/down_reply";
+
+ public static final String NATIVE_ZIGBEE_UP = "/user/%s/custom/native/zigbee/up";
+
+ public static final String NATIVE_ZIGBEE_DOWN_SLAVE = "/user/%s/custom/native/zigbee/down/slaveoid/%s";
+
+ public static final String NATIVE_ZIGBEE_DOWN_SLAVE_REPLY = "/user/%s/custom/native/zigbee/down_reply/slaveoid/%s";
+
+ public static final String NATIVE_ZIGBEE_UP_SLAVE = "/user/%s/custom/native/zigbee/up/slaveoid/%s";
+
+ public static final String NATIVE_LINK_DOWN = "/user/%s/custom/native/a/down";
+
+ public static final String NATIVE_LINK_DOWN_REPLY = "/user/%s/custom/native/a/down_reply";
+
+ public static final String NATIVE_LINK_UP = "/user/%s/custom/native/a/up";
+
+ public static final String NATIVE_LINK_DOWN_SLAVE = "/user/%s/custom/native/a/down/slaveoid/%s";
+
+ public static final String NATIVE_LINK_DOWN_SLAVE_REPLY = "/user/%s/custom/native/a/down_reply/slaveoid/%s";
+
+ public static final String NATIVE_LINK_UP_SLAVE = "/user/%s/custom/native/a/up/slaveoid/%s";
+
+ public static final String GATEWAY_LOCATION_EDIT = "/user/%s/custom/gateway/location/edit";
+
+ public static final String GATEWAY_LOCATION_GET = "/user/%s/custom/gateway/location/get";
+
+ public static final String NATIVE_MODBUS_DOWN = "/user/%s/custom/native/inverter/down";
+ public static final String NATIVE_MODBUS_UP = "/user/%s/custom/native/inverter/up";
+ public static final String NATIVE_MODBUS_DOWN_REPLY = "/user/%s/custom/native/inverter/down_reply";
+
+ public static final String NATIVE_MODBUS_DOWN_SLAVE = "/user/%s/custom/native/inverter/down/slaveoid/%s";
+ public static final String NATIVE_MODBUS_DOWN_SLAVE_REPLY = "/user/%s/custom/native/inverter/down_reply/slaveoid/%s";
}
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
index 6f7334a..73039a7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -511,9 +511,9 @@
*/
public void switchHouse(HouseIdBean houseIdBean) {
String oidHomeId = UserConfigManage.getInstance().getHomeId();
- if (houseIdBean.getHomeId().equals(oidHomeId)) {
- return;
- }
+// if (houseIdBean.getHomeId().equals(oidHomeId)) {
+// return;
+// }
//鍒犻櫎鏃х殑浣忓畢鏂囦欢澶�
HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath());
//閲嶆柊璁剧疆浣忓畢id
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index 063f4ab..fa50ef7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -8,6 +8,7 @@
import com.google.gson.Gson;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.bean.BaseEventBus;
+import com.hdl.photovoltaic.bean.ModBusBean;
import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.listener.CloudCallBeak;
@@ -16,9 +17,12 @@
import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
import com.hdl.photovoltaic.uni.UniToAndroidBean;
import com.hdl.photovoltaic.utils.WifiUtils;
+import com.hdl.sdk.link.common.exception.HDLLinkCode;
import com.hdl.sdk.link.common.exception.HDLLinkException;
+import com.hdl.sdk.link.common.utils.LogUtils;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.callback.GatewayCallBack;
+import com.hdl.sdk.link.core.callback.ModbusCallBack;
import com.hdl.sdk.link.core.connect.HDLModBusConnect;
import org.greenrobot.eventbus.EventBus;
@@ -51,6 +55,8 @@
}
return sHdlUniLogic;
}
+
+ //region ******銆愬師鐢熴�戝拰銆愬皬绋嬪簭銆戦�氳鐨勬柟娉� onOtherUniMPEventReceive();openUniMP();sendUni();******
/**
* 鍘熺敓鎺ユ敹鍒皍ni鍙戞潵鐨勬暟鎹�
@@ -99,28 +105,19 @@
HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
@Override
public void onSuccess(List<GatewayBean> gatewayBeanList) {
- HDLUniMP.UniCallBackBaseBean callBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
- callBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_LIST);
- callBackBaseBean.setData(gatewayBeanList);
- sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, callBackBaseBean);
+ uniCallbackData(gatewayBeanList, callback);
}
@Override
public void onError(HDLLinkException e) {
//鍙戦�佸け璐�
- HDLUniMP.UniCallBackBaseBean callBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
- callBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_LIST);
- callBackBaseBean.setCode(e.getCode() + "");
- callBackBaseBean.setCode(e.getMsg());
- sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, callBackBaseBean);
+ uniCallbackData(null, e.getCode() + "", "", callback);
}
});
}
break;
case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: {
-
- //鍙戦�乵odbus鍗忚
-// HDLModBusConnect.getInstance().Send(uniToAndroidBean.getGatewayOid(), null, );
+ sendModBus(data, callback);
}
}
@@ -131,14 +128,14 @@
case HDLUniMP.UNI_EVENT_REPLY_WIFI_LIST: {
//鑾峰彇wifi鍒楄〃
if (callback != null) {
- uniCallbackData(wifiUtils.getScanResult(), "0", "", callback);
+ uniCallbackData(wifiUtils.getScanResult(), callback);
}
}
break;
case HDLUniMP.UNI_EVENT_REPLY_WIFI_INFO: {
//褰撳墠wifi璇︽儏
if (callback != null) {
- uniCallbackData(wifiUtils.getCurrentConnectWifiInfo(), "0", "", callback);
+ uniCallbackData(wifiUtils.getCurrentConnectWifiInfo(), callback);
}
}
break;
@@ -154,6 +151,38 @@
HdlLogLogic.print("uni===鍘熺敓鎺ユ敹uni鍙戞潵鐨勬暟鎹�", e.getMessage());
}
+ }
+
+ /**
+ * 鍙戦�乵odbus鍗忚鏁版嵁
+ *
+ * @param data modbus鏁版嵁
+ * @param callback 鍥炶皟
+ */
+ void sendModBus(Object data, DCUniMPJSCallback callback) {
+ String tempData = getKeyValue("data", data);
+ if (tempData == null) {
+ LogUtils.i("data鍐呭涓虹┖");
+ return;
+ }
+ ModBusBean modBusBean = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(tempData), ModBusBean.class);
+ if (modBusBean.getOid() == null || modBusBean.getData() == null) {
+ LogUtils.i("鍐呭涓虹┖,oid=" + modBusBean.getOid() + " data=" + modBusBean.getData());
+ return;
+ }
+
+ //鍙戦�乵odbus鍗忚
+ HDLModBusConnect.getInstance().Send(modBusBean.getOid(), modBusBean.getData(), new ModbusCallBack() {
+ @Override
+ public void onSuccess(byte[] data) {
+ uniCallbackData(data, callback);
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ uniCallbackData(null, e.getCode() + "", "澶辫触", callback);
+ }
+ });
}
/**
@@ -190,6 +219,10 @@
public void checkRemoveOtherUniMPEventCallBack() {
HDLUniMPSDKManager.getInstance().checkRemoveOtherUniMPEventCallBack(this);
}
+ //endregion
+
+
+ //region ******涓�鑸柟娉�******
/**
* 缁勮uni鍙戦�佹暟鎹牸寮�
@@ -242,6 +275,10 @@
}
+ private void uniCallbackData(Object obj, DCUniMPJSCallback callback) {
+ uniCallbackData(obj, HDLLinkCode.HDL_SUCCESS + "", HDLLinkCode.HDL_SUCCESS.getMsg(), callback);
+ }
+
/**
* 褰撳墠瀵硅薄杞� JSONObject
*
@@ -284,6 +321,7 @@
return "";
}
}
+ //endregion
}
--
Gitblit v1.8.0