From d451118d4be05f180cfe1f99bc5904f74db8cc3f Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期四, 22 二月 2024 15:40:58 +0800
Subject: [PATCH] 引用线上库

---
 HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 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 d6a0d1a..d2a9673 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
@@ -150,16 +150,16 @@
             connOpts.setCleanSession(true);
             connOpts.setKeepAliveInterval(10);
             connOpts.setAutomaticReconnect(true);
-            connOpts.setConnectionTimeout(10);
+            connOpts.setConnectionTimeout(60);
             connOpts.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
             sampleClient.setCallback(new MqttCallbackExtended() {
                 public void connectComplete(boolean reconnect, String serverURI) {
-                    LogUtils.d(TAG, "mqtt杩炴帴鎴愬姛");
+                    LogUtils.d(TAG, "connect success");
                     checkAndsubscribeAllTopics("");
                 }
 
                 public void connectionLost(Throwable throwable) {
-                    LogUtils.d(TAG, "mqtt杩炴帴鏂紑");
+                    LogUtils.d(TAG, "杩炴帴鏂紑");
                     lastTopicFilters.clear();
                 }
 
@@ -209,13 +209,14 @@
                 return;
             }
             LogUtils.d(TAG, "缃戝叧閲嶈繛mqtt绉橀挜鏇存柊閫氱煡->" + topic);
+
             BaseEventBus baseEventBus=new BaseEventBus();
             baseEventBus.setTopic(topic);
             EventBus.getDefault().post(baseEventBus);
 
-//            EventNotifyRefreshGatewayAesKeyInfo eventNotifyRefreshGatewayAesKeyInfo = new EventNotifyRefreshGatewayAesKeyInfo();
-//            eventNotifyRefreshGatewayAesKeyInfo.setGatewayId(topics[2]);
-//            EventBus.getDefault().post(eventNotifyRefreshGatewayAesKeyInfo);
+            EventNotifyRefreshGatewayAesKeyInfo eventNotifyRefreshGatewayAesKeyInfo = new EventNotifyRefreshGatewayAesKeyInfo();
+            eventNotifyRefreshGatewayAesKeyInfo.setGatewayId(topics[2]);
+            EventBus.getDefault().post(eventNotifyRefreshGatewayAesKeyInfo);
             return;
         }
 
@@ -229,8 +230,9 @@
         GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(cloudsGatewayId);
         if (cloudsGatewayId.equals(HDLLinkConfig.getInstance().getHomeId())) {
             aes = getHomeAES();
-        } else if (gatewayBean != null && HDLConnectHelper.getGatewayTypeList().contains(gatewayBean.getGatewayType())) {
-            //閫嗗彉鍣╩qtt涓撶敤绉橀挜
+        }
+        else if (gatewayBean != null && HDLConnectHelper.getNotGatewayTypeList().contains(gatewayBean.getGatewayType())) {
+            //姣背娉qtt涓撶敤绉橀挜銆侀�嗗彉鍣╩qtt涓撶敤绉橀挜
             aes = gatewayBean.getAesKey();
         } else {
             aes = HDLLinkConfig.getInstance().getAesKey();
@@ -288,7 +290,10 @@
      * @param sendTopic 璇锋眰涓婚
      */
     public synchronized void checkAndsubscribeAllTopics(String sendTopic) {
-        if (null != sampleClient && !sampleClient.isConnected()) {
+        if (null == sampleClient) {
+            return;
+        }
+        if (null != sampleClient && sampleClient.isConnected() == false) {
             return;
         }
         try {
@@ -389,6 +394,9 @@
      * 鍒囨崲浣忓畢鐨勬椂鍊欒闃呰鍏ㄩ儴鍙栨秷
      */
     public void removeAllTopic() {
+        if (null == sampleClient) {
+            return;
+        }
         if (null != sampleClient && sampleClient.isConnected() == false) {
             return;
         }

--
Gitblit v1.8.0