| | |
| | | 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();
|
| | | }
|
| | |
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | 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();
|
| | |
| | | * @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 {
|
| | |
| | | * 切换住宅的时候订阅要全部取消
|
| | | */
|
| | | public void removeAllTopic() {
|
| | | if (null == sampleClient) {
|
| | | return;
|
| | | }
|
| | | if (null != sampleClient && sampleClient.isConnected() == false) {
|
| | | return;
|
| | | }
|