hxb
2023-12-15 3b47201d878ba8ff973b84baf15942475688e964
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/MqttRecvClient.java
@@ -7,6 +7,7 @@
import com.hdl.sdk.link.common.utils.LogUtils;
import com.hdl.sdk.link.core.bean.LinkPacket;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import com.hdl.sdk.link.core.bean.eventbus.EventBindMiniRemoteSuccessInfo;
import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
@@ -30,6 +31,7 @@
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -148,7 +150,7 @@
            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) {
@@ -207,6 +209,11 @@
                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);
@@ -223,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())) {
            //毫米波mqtt专用秘钥
        }
        else if (gatewayBean != null && HDLConnectHelper.getGatewayTypeList().contains(gatewayBean.getGatewayType())) {
            //毫米波mqtt专用秘钥、逆变器mqtt专用秘钥
            aes = gatewayBean.getAesKey();
        } else {
            aes = HDLLinkConfig.getInstance().getAesKey();
@@ -239,7 +247,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,6 +290,9 @@
     * @param sendTopic 请求主题
     */
    public synchronized void checkAndsubscribeAllTopics(String sendTopic) {
        if (null == sampleClient) {
            return;
        }
        if (null != sampleClient && sampleClient.isConnected() == false) {
            return;
        }
@@ -379,6 +394,9 @@
     * 切换住宅的时候订阅要全部取消
     */
    public void removeAllTopic() {
        if (null == sampleClient) {
            return;
        }
        if (null != sampleClient && sampleClient.isConnected() == false) {
            return;
        }
@@ -401,6 +419,7 @@
                    mqttRecvClient.sampleClient.disconnect();
                    mqttRecvClient.sampleClient.close();
                    mqttRecvClient = null;
                    lastTopicFilters.clear();
                }
            } catch (MqttException e) {
                e.printStackTrace();