From dcb7088c2dca789074f8f48597dca3c55f3ab6f1 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 01 二月 2024 19:37:09 +0800 Subject: [PATCH] 2024年02月01日19:37:00 --- HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLConnectHelper.java | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 42 insertions(+), 3 deletions(-) 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 9fc5d40..e3c80dc 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 @@ -21,6 +21,8 @@ import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -112,7 +114,7 @@ /** * 鍙兘杩斿洖code灞炴�у彲鑳芥病鏈� 娌℃湁鐨勮瘽鐩存帴鎴愬姛 鏈夌殑璇濆彧鏈�200鎵嶄細鎴愬姛 */ - if (code == null || code.intValue() == 200 || code.intValue() == 0) { + if (code == null || code == 200 || code == 0) { notifySucceed(msg); } else { notifyFailure(ErrorUtils.getByCode(code)); @@ -331,13 +333,22 @@ } if (MqttRecvClient.getInstance() != null) { MqttRecvClient.getInstance().send(requestTopic, encryBytes); + if (HDLConnectHelper.isInverterTopic(linkRequest.getCloudTopic())) { + LogUtils.i("杩滅▼鍙戦�佹暟鎹細" + linkRequest.getCloudTopic() + "\r\n" + Arrays.toString(byteArrayConvertIntArray(linkRequest.getCloudSendBytes()))); + } else { + LogUtils.i("杩滅▼鍙戦�佹暟鎹細" + linkRequest.getCloudTopic() + "\r\n" + new String(linkRequest.getCloudSendBytes())); + } } - LogUtils.i("杩滅▼鍙戦�佹暟鎹細" + linkRequest.getCloudTopic() + "\r\n" + new String(linkRequest.getCloudSendBytes())); } //鏈湴TCP else { + linkRequest.setEncrypt(false);// 2024骞�01鏈�31鏃�16:34:22 榛樿鏄庢枃閫氳,鍥犱负鍒涘缓鐢电珯,缁戝畾閫嗗彉鍣ㄦ椂锛岄渶瑕佽缃弬鏁扮粰閫嗗彉鍣�,杩欐椂鍊欒繕娌℃湁绉橀挜; if (!linkRequest.getTopic().endsWith("heartbeat")) {//蹇冭烦涓婚鏁版嵁杩囧锛岃繃婊や笅 - LogUtils.i("鏈湴鍙戦�佹暟鎹細\r\n" + new String(linkRequest.getSendBytes())); + if (HDLConnectHelper.isInverterTopic(linkRequest.getTopic())) { + LogUtils.i("鏈湴鍙戦�佹暟鎹細\r\n" + Arrays.toString(byteArrayConvertIntArray(linkRequest.getSendBytes()))); + } else { + LogUtils.i("鏈湴鍙戦�佹暟鎹細\r\n" + new String(linkRequest.getSendBytes())); + } } HDLTcpConnect.getTcpSocketBoot(ipAddress).sendMsg(EncryptUtil.getEncryBytes(linkRequest)); } @@ -408,6 +419,7 @@ } } + /** * 鏀寔姣背绫诲瀷 * @@ -433,4 +445,31 @@ listener = null; } } + + + public static boolean isInverterTopic(String topic) { + if (TextUtils.isEmpty(topic)) { + return false; + } + return topic.endsWith("custom/native/inverter/down_reply") + || topic.endsWith("custom/native/inverter/down") + || topic.endsWith("custom/native/inverter/up"); + } + + /** + * byte鏁扮粍杞崲鎴恑nt鏁扮粍(涓轰簡鎵撳嵃鍑烘棤绗﹀彿鐨刡tye鏁扮粍鏁版嵁) + * + * @param bytes 鏁扮粍 + * @return + */ + public static Integer[] byteArrayConvertIntArray(byte[] bytes) { + if (bytes == null || bytes.length == 0) { + return new Integer[]{}; + } + Integer[] arr = new Integer[bytes.length]; + for (int i = 0; i < bytes.length; i++) { + arr[i] = bytes[i] & 0xff; + } + return arr; + } } -- Gitblit v1.8.0