From 907f9314657fd0554fecda06e919b98768b0aeea Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 11 十月 2023 18:00:56 +0800
Subject: [PATCH] 2023年10月11日18:00:50

---
 HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java
index 6e8ef74..6c5a295 100644
--- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java
+++ b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java
@@ -30,6 +30,7 @@
 import org.greenrobot.eventbus.EventBus;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -152,12 +153,12 @@
             connOpts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
             sampleClient.setCallback(new MqttCallbackExtended() {
                 public void connectComplete(boolean reconnect, String serverURI) {
-                    LogUtils.d(TAG, "connect success");
+                    LogUtils.d(TAG, "mqtt杩炴帴鎴愬姛");
                     checkAndsubscribeAllTopics("");
                 }
 
                 public void connectionLost(Throwable throwable) {
-                    LogUtils.d(TAG, "杩炴帴鏂紑");
+                    LogUtils.d(TAG, "mqtt杩炴帴鏂紑");
                     lastTopicFilters.clear();
                 }
 
@@ -224,7 +225,7 @@
         if (cloudsGatewayId.equals(HDLLinkConfig.getInstance().getHomeId())) {
             aes = getHomeAES();
         } else if (gatewayBean != null && HDLConnectHelper.getGatewayTypeList().contains(gatewayBean.getGatewayType())) {
-            //姣背娉qtt涓撶敤绉橀挜
+            //閫嗗彉鍣╩qtt涓撶敤绉橀挜
             aes = gatewayBean.getAesKey();
         } else {
             aes = HDLLinkConfig.getInstance().getAesKey();
@@ -239,7 +240,11 @@
             return;
         }
         String bodyStr = new String(bytes);
-        LogUtils.d(TAG, "\r\n" + "mqtt->杩滅▼鍥炲鏁版嵁" + bodyStr);
+        if (HDLConnectHelper.isInverterTopic(topic)) {
+            LogUtils.d(TAG, "\r\n" + "mqtt->杩滅▼鍥炲鏁版嵁" + Arrays.toString(HDLConnectHelper.byteArrayConvertIntArray(bytes)));
+        } else {
+            LogUtils.d(TAG, "\r\n" + "mqtt->杩滅▼鍥炲鏁版嵁" + bodyStr);
+        }
         /**
          * 绾㈠瀹濊澶囬�氳繃/thing/topo/found涓婚  涓婃姤绾㈠瀹濊澶囧凡缁忓叆缃戜簡  鐒跺悗鐩存帴return  涓嶉渶瑕佸啀涓嬭浜�
          */
@@ -278,7 +283,7 @@
      * @param sendTopic 璇锋眰涓婚
      */
     public synchronized void checkAndsubscribeAllTopics(String sendTopic) {
-        if (null != sampleClient && sampleClient.isConnected() == false) {
+        if (null != sampleClient && !sampleClient.isConnected()) {
             return;
         }
         try {
@@ -401,6 +406,7 @@
                     mqttRecvClient.sampleClient.disconnect();
                     mqttRecvClient.sampleClient.close();
                     mqttRecvClient = null;
+                    lastTopicFilters.clear();
                 }
             } catch (MqttException e) {
                 e.printStackTrace();

--
Gitblit v1.8.0