mac
2023-10-11 907f9314657fd0554fecda06e919b98768b0aeea
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())) {
            //毫米波mqtt专用秘钥
            //逆变器mqtt专用秘钥
            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();