| | |
| | | import com.hdl.linkpm.sdk.ota.bean.CloudDeviceFirmwaresBean; |
| | | import com.hdl.linkpm.sdk.ota.bean.CloudGatewayDriversBean; |
| | | import com.hdl.linkpm.sdk.ota.bean.DeviceFirmwareBean; |
| | | import com.hdl.linkpm.sdk.ota.bean.DownloadUrlBean; |
| | | import com.hdl.linkpm.sdk.ota.bean.GatewayDriverBean; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.internet.HttpClient; |
| | | import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer; |
| | |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.Md5Utils; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.common.utils.ByteUtils; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | | import com.hdl.sdk.link.core.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | | |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | |
| | | //endregion |
| | | |
| | | |
| | | /** |
| | | * 设置终止下载文件指令 |
| | | * 取消终止下载文件指令 |
| | | */ |
| | | public void setStopDriversDownload() { |
| | | public void stopDownloadUpgradeFile() { |
| | | this.stopDownload = true; |
| | | } |
| | | |
| | | /** |
| | | * 向云端获取【设备升级文件(驱动,固件)下载】升级文件 |
| | | * |
| | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 取消升级驱动,固件文件指令 |
| | | * |
| | | * @param mac 设备mac |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void cancelUpgrade(String mac, LinkCallBack<Boolean> linkCallBack) { |
| | | String requestUrl = TopicApi.SET_GATEWAY_REMOTE_EDIT; |
| | | // JsonObject json = new JsonObject(); |
| | | // json.addProperty("homeId", UserConfigManage.getInstance().getHomeId()); |
| | | // json.addProperty("server_addr", AppConfigManage.getUserRegionUrl()); |
| | | // json.addProperty("local_secret", UserConfigManage.getInstance().getLocalSecret()); |
| | | // //解密负载数据(写密钥给网关一定是明文,因为那时网关还没有密钥) |
| | | // TcpClient.getInstance().sendDataToLinkGateway(mac, false, requestUrl, json, "", new HDLLinkCallBack() { |
| | | // @Override |
| | | // public void onSuccess(String msg) { |
| | | // GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(mac); |
| | | // if (gatewayBean != null) { |
| | | // if (!TextUtils.isEmpty(UserConfigManage.getInstance().getLocalSecret())) { |
| | | // gatewayBean.setLocalEncrypt(true); |
| | | // } |
| | | // } |
| | | // if (linkCallBack != null) { |
| | | // linkCallBack.onSuccess(true); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onError(HDLLinkException e) { |
| | | // if (linkCallBack != null) { |
| | | // linkCallBack.onError(e); |
| | | // } |
| | | // } |
| | | // }); |
| | | } |
| | | |
| | | |
| | |
| | | * @param describe 描述文本 |
| | | */ |
| | | public void eventBusPost(String fileFullPath, String type, int progressValue, String describe) { |
| | | HdlLogLogic.print("进度值====" + progressValue + ""); |
| | | |
| | | if (this.stopDownload) { |
| | | HdlFileLogic.getInstance().deleteFile(fileFullPath);//删除下载不完整数据; |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | |
| | | EventBus.getDefault().post(baseEventBus); |
| | | // } |
| | | // }); |
| | | |
| | | |
| | | } |
| | | |
| | | |