mac
2023-12-19 56f20167290570fd27998ba9816a8f63d199f152
app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java
@@ -16,6 +16,7 @@
import com.hdl.linkpm.sdk.ota.bean.DeviceFirmwareBean;
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;
@@ -30,7 +31,9 @@
import com.hdl.photovoltaic.utils.Md5Utils;
import com.hdl.sdk.link.common.exception.HDLLinkException;
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;
@@ -378,13 +381,13 @@
    //endregion
    /**
     * 设置终止下载文件指令
     * 取消终止下载文件指令
     */
    public void setStopDriversDownload() {
    public void stopDownloadUpgradeFile() {
        this.stopDownload = true;
    }
    /**
     * 向云端获取【设备升级文件(驱动,固件)下载】升级文件
     *
@@ -451,6 +454,43 @@
        });
    }
    /**
     * 取消升级驱动,固件文件指令
     *
     * @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);
//                }
//            }
//        });
    }
    /**
     * 启动本地服务