| | |
| | | try { |
| | | String hardwareModel = getKeyValue("hardwareModel", getKeyValue("data", data));//硬件型号 |
| | | String osImageId = getKeyValue("osImageId", getKeyValue("data", data));//系统镜像id |
| | | String firmwareVersionId = getKeyValue("firmwareVersionId", getKeyValue("data", data));//系统镜像id |
| | | String firmwareVersionId = getKeyValue("firmwareVersionId", getKeyValue("data", data));//固件版本id |
| | | List<DeviceFirmwareBean> list = new ArrayList<>(); |
| | | String driverFileList = HdlFileLogic.getInstance().getFirmwareRootPath(); |
| | | File file = new File(driverFileList); |
| | |
| | | String[] ary = path.split("/"); |
| | | String[] driverInfoAry = ary[ary.length - 1].split("_"); |
| | | DeviceFirmwareBean deviceFirmwareBean = new DeviceFirmwareBean(); |
| | | deviceFirmwareBean.setVersion(driverInfoAry[0]); |
| | | deviceFirmwareBean.setImageId(driverInfoAry[1].replace(".zip", "")); |
| | | deviceFirmwareBean.setOid(driverInfoAry[0]); |
| | | deviceFirmwareBean.setVersion(driverInfoAry[1].replace(".zip", "")); |
| | | deviceFirmwareBean.setLocalUrl(HdlFileLogic.getInstance().getFirmwarePathFileName(deviceFirmwareBean.getOid(), deviceFirmwareBean.getVersion())); |
| | | list.add(deviceFirmwareBean); |
| | | } |
| | | } |
| | |
| | | private void uniDeviceFirmwareDownload(Object data, DCUniMPJSCallback callback) { |
| | | String deviceOidId = getKeyValue("deviceOidId", getKeyValue("data", data));//云端上设备id |
| | | String oid = getKeyValue("oid", getKeyValue("data", data));//设备oid |
| | | String imageId = getKeyValue("imageId", getKeyValue("data", data));//驱动镜像id |
| | | String version = getKeyValue("version", getKeyValue("data", data));//驱动版本 |
| | | String localUrl = getKeyValue("localUrl", getKeyValue("data", data));//储存在本地驱动文件路径 |
| | | String imageId = getKeyValue("imageId", getKeyValue("data", data));//固件镜像id |
| | | String version = getKeyValue("version", getKeyValue("data", data));//固件版本 |
| | | String localUrl = getKeyValue("localUrl", getKeyValue("data", data));//储存在本地固件文件路径 |
| | | String url = getKeyValue("url", getKeyValue("data", data));//云端上文件地址 |
| | | String md5 = getKeyValue("md5", getKeyValue("data", data));//云端上文件MD5 |
| | | HdlOtaLogic.getInstance().getDeviceUpgradeDownloadFile(url, new CloudCallBeak<ResponseBody>() { |
| | |
| | | String firmwarePathFileName = HdlFileLogic.getInstance().getFirmwarePathFileName(oid, version); |
| | | boolean isBoolean = HdlOtaLogic.getInstance().disposeDownLoadFile(firmwarePathFileName, responseBody, md5, HdlOtaLogic.firmware_type); |
| | | if (isBoolean) { |
| | | HdlFileLogic.getInstance().deleteFile(localUrl);//下载成功,删除旧文件; |
| | | HdlFileLogic.getInstance().deleteFile(localUrl);//下载成功,删除旧固件文件; |
| | | } else { |
| | | HdlFileLogic.getInstance().deleteFile(firmwarePathFileName);//下载失败删除不完成数据; |
| | | HdlFileLogic.getInstance().deleteFile(firmwarePathFileName);//下载失败,删除不完整固件文件; |
| | | } |
| | | HdlLogLogic.print("写入新固件文件到内存成功.", false); |
| | | } |
| | |
| | | String deviceOidId = getKeyValue("deviceOidId", getKeyValue("data", data));//云端上设备id |
| | | String oid = getKeyValue("oid", getKeyValue("data", data));//设备id |
| | | String firmwareVersionId = getKeyValue("firmwareVersionId", getKeyValue("data", data));//固件版本id |
| | | String version = getKeyValue("version", getKeyValue("data", data));//驱动版本 |
| | | String version = getKeyValue("version", getKeyValue("data", data));//固件版本 |
| | | String hardwareModel = getKeyValue("hardwareModel", getKeyValue("data", data));//云端上文件MD5 |
| | | |
| | | //升级本地优先->云端升级 |
| | |
| | | public void onSuccess(CloudInverterDeviceBean cloudInverterDeviceBean) { |
| | | //1:连接中,2:故障,3:运行,4:离线,6:逆变器连不上云(自定义) |
| | | if (cloudInverterDeviceBean == null) { |
| | | uniCallbackData(null, 6, HDLApp.getInstance().getString(R.string.ota_not_cloud_upgrade_fails), callback); |
| | | uniCallbackData(null, 6, HDLApp.getInstance().getString(R.string.ota_binding_cloud_upgrade_fails), callback); |
| | | return; |
| | | } |
| | | if (cloudInverterDeviceBean.getDeviceStatus() != 3) { |
| | | uniCallbackData(null, cloudInverterDeviceBean.getDeviceStatus(), getDeviceStatusString(cloudInverterDeviceBean.getDeviceStatus()), callback); |
| | | uniCallbackData(null, cloudInverterDeviceBean.getDeviceStatus(), HDLApp.getInstance().getString(R.string.ota_not_cloud_upgrade_fails), callback); |
| | | return; |
| | | } |
| | | //4:运行 |
| | |
| | | String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName(driverCode, version); |
| | | boolean isBoolean = HdlOtaLogic.getInstance().disposeDownLoadFile(drivePathFileName, responseBody, md5, HdlOtaLogic.driver_type); |
| | | if (isBoolean) { |
| | | HdlFileLogic.getInstance().deleteFile(localUrl);//下载成功,删除旧文件; |
| | | HdlFileLogic.getInstance().deleteFile(localUrl);//下载成功,删除旧驱动文件; |
| | | } else { |
| | | HdlFileLogic.getInstance().deleteFile(drivePathFileName);//下载失败删除不完成数据; |
| | | HdlFileLogic.getInstance().deleteFile(drivePathFileName);//下载失败,删除不完整驱动文件; |
| | | } |
| | | HdlLogLogic.print("写入新驱动文件到内存成功.", false); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * @param deviceStatus 逆变器连接云端状态值( 1:待机,2:连接中,3:故障,4:运行,5:离线) |
| | | * @param deviceStatus 逆变器连接云端状态值( 1:连接中,2:故障,3:运行,4:离线) |
| | | * @return 返回文本 |
| | | */ |
| | | public String getDeviceStatusString(int deviceStatus) { |
| | | switch (deviceStatus) { |
| | | case 1: { |
| | | return HDLApp.getInstance().getString(R.string.my_power_station_await); |
| | | } |
| | | case 2: { |
| | | return HDLApp.getInstance().getString(R.string.my_power_station_connecting); |
| | | } |
| | | case 3: { |
| | | case 2: { |
| | | return HDLApp.getInstance().getString(R.string.my_power_station_malfunction); |
| | | } |
| | | case 5: { |
| | | case 4: { |
| | | return HDLApp.getInstance().getString(R.string.my_power_station_off_line); |
| | | } |
| | | default: |