| | |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Bundle; |
| | | import android.os.Process; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | |
| | | import com.google.gson.Gson; |
| | |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | | import com.hdl.sdk.link.common.event.EventListener; |
| | | import com.hdl.sdk.link.core.bean.ModbusResponse; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("监听到的数据==="+new Gson().toJson(response),false); |
| | | HdlLogLogic.print("监听到的数据===" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败==="+e.getMessage(), e.getCode(),true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败===" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onEventMessage(EventNotifyRefreshGatewayAesKeyInfo event) { |
| | | public void onEventMessage(BaseEventBus event) { |
| | | //网关更新mqtt秘钥更新通知 |
| | | if (event == null) { |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(event.getTopic())) { |
| | | return; |
| | | } |
| | | String[] topics = event.getTopic().split("/"); |
| | | //主题不符合规则不处理 |
| | | if (topics.length < 3) { |
| | | return; |
| | | } |
| | | int index = -1; |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getGatewayId().equals(event.getGatewayId())) { |
| | | if (gatewayBean.getGatewayId().equals(topics[2])) { |
| | | index = i; |
| | | break; |
| | | } |