| | |
| | | import android.os.Process; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationTipDialog; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | | import com.hdl.sdk.link.common.event.EventListener; |
| | | import com.hdl.sdk.link.core.bean.LinkResponse; |
| | |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.connect.HDLUdpConnect; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | |
| | | // AppManagerUtils.getAppManager().finishActivity(StartActivity.class); |
| | | // this.portConflictDialog(); |
| | | } |
| | | |
| | | public void startAppAutomaticallyOpenUni() { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | if (TextUtils.isEmpty(event.getTopic())) { |
| | | return; |
| | | } |
| | | //网关更新mqtt秘钥更新通知 |
| | | //网关mqtt秘钥更新通知 |
| | | if (event.getTopic().contains("/custom/mqtt/secret/change")) { |
| | | String[] topics = event.getTopic().split("/"); |
| | | //主题不符合规则不处理 |
| | |
| | | HdlThreadLogic.runSubThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //防止app启动的时候没有网络(app也登录不了),导致获取不了mqtt远程连接信息; |
| | | initMqttClient(); |
| | | |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> obj) { |
| | |
| | | */ |
| | | private void startAppAutomaticallyOpenUni(boolean delay) { |
| | | |
| | | if(delay) { |
| | | if (delay) { |
| | | SystemClock.sleep(2000); |
| | | } |
| | | List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); |
| | | if (HouseIdList.size() == 0) { |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | if(delay){ |
| | | HdlUniLogic.getInstance().openUniMPDelay(path, null); |
| | | }else { |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | } else { |
| | | int select_home = 0; |
| | | for (int i = 0; i < HouseIdList.size(); i++) { |
| | |
| | | HouseIdBean houseIdBean = HouseIdList.get(select_home); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | if(delay) { |
| | | HdlUniLogic.getInstance().openUniMPDelay(path, null); |
| | | }else { |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * 初始化mqtt客户端 |
| | | */ |
| | | public void initMqttClient() { |
| | | //检查断开状态 |
| | | if (!MqttRecvClient.getInstance().isConnected()) { |
| | | MqttRecvClient.getInstance().reConnect(); |
| | | } |
| | | if (!MqttRecvClient.getInstance().isInit()) { |
| | | HdlMqttLogic.getInstance().getMqttRemoteInfo(HomeType.A, new CloudCallBeak<MqttInfo>() { |
| | | @Override |
| | | public void onSuccess(MqttInfo info) { |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord(),null); |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | } |
| | | } |