| | |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.callback.GatewayCallBack; |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | */ |
| | | public void switchHouse(HouseIdBean houseIdBean) { |
| | | String oidHomeId = UserConfigManage.getInstance().getHomeId(); |
| | | // if (houseIdBean.getHomeId().equals(oidHomeId)) { |
| | | // return; |
| | | // } |
| | | if (houseIdBean.getHomeId().equals(oidHomeId)) { |
| | | HdlLogLogic.print("点击同一个住宅"); |
| | | return; |
| | | } |
| | | //订阅要全部取消 |
| | | if (MqttRecvClient.getInstance() != null) { |
| | | MqttRecvClient.getInstance().removeAllTopic(); |
| | | } |
| | | //要清空之前tcp连接缓存 |
| | | //TODO: 10/10/23 |
| | | //删除旧的住宅文件夹 |
| | | HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath()); |
| | | //重新设置住宅id |
| | | UserConfigManage.getInstance().setHomeId(houseIdBean.getHomeId()); |
| | | //重新设置本地通讯秘钥 |
| | | UserConfigManage.getInstance().setLocalSecret(houseIdBean.getLocalSecret()); |
| | | //重新创建住宅文件夹 |
| | | HdlFileLogic.getInstance().createDirectory(); |
| | | //配置本地通信的信息 |
| | | initLocalLinkSdk(); |
| | | HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 配置本地通信的信息(tcp通信用到) |
| | | */ |
| | | private void initLocalLinkSdk() { |
| | | HDLLinkConfig.getInstance().setHomeId(UserConfigManage.getInstance().getHomeId()); |
| | | HDLLinkConfig.getInstance().setLocalSecret(UserConfigManage.getInstance().getLocalSecret()); |
| | | |
| | | |
| | | //重新创建住宅文件夹 |
| | | HdlFileLogic.getInstance().createDirectory(); |
| | | //进去住宅详情搜索一下逆变器列表,目的是建立通讯通道; |
| | | HdlDeviceLogic.getInstance().searchGateway(null); |
| | | } |
| | | |
| | | |
| | | static class HouseBeanClass { |
| | | |