From 74d51db562aea6e2d8cb8f861a5eeeeb750696fb Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 19 十二月 2023 20:57:47 +0800
Subject: [PATCH] 2023年12月19日20:57:41

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java
index 51d3304..e1c7539 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlOtaLogic.java
@@ -7,6 +7,7 @@
 
 
 import com.google.gson.Gson;
+import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
@@ -14,9 +15,9 @@
 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;
@@ -30,9 +31,10 @@
 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;
@@ -91,7 +93,7 @@
     /**
      * 鏈嶅姟鏄惁寮�鍚� true=寮�鍚�
      */
-    public boolean mServiceStart = false;
+    public boolean mServiceStart= false;
 
     /**
      * true琛ㄧず缁堟涓嬭浇鍗囩骇鏂囦欢(鐢ㄦ埛琛屼负)
@@ -380,10 +382,11 @@
 
     //endregion
 
+
     /**
-     * 璁剧疆缁堟涓嬭浇鏂囦欢鎸囦护
+     * 鍙栨秷缁堟涓嬭浇鏂囦欢鎸囦护
      */
-    public void setStopDriversDownload() {
+    public void stopDownloadUpgradeFile() {
         this.stopDownload = true;
     }
 
@@ -427,6 +430,7 @@
      */
     public void pushUpgradePacketInfo(String mac, String oid, String module, String version, String size, String url, String sign_method, LinkCallBack<String> linkCallBack) {
         String requestUrl = TopicApi.SET_GATEWAY_UPGRADE_INFO;
+        JsonArray jsonArray = new JsonArray();
         JsonObject json = new JsonObject();
         json.addProperty("oid", oid);// 鐗╃悊璁惧oid
         json.addProperty("module", module);//妯″潡淇℃伅
@@ -434,8 +438,10 @@
 //        json.addProperty("is_diff", is_diff);//true=澧為噺鍖咃紝false=鍏ㄩ噺鍖�
         json.addProperty("size", size);//鍗囩骇鍖呭ぇ灏�
         json.addProperty("url", url);//鍗囩骇鍖呬笅杞藉湴鍧�
-        json.addProperty("sign_method", sign_method);//鍗囩骇鍖呯鍚嶇被鍨�:md5
-        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() {
+        json.addProperty("sign", sign_method);//鍗囩骇鍖呯鍚嶇被鍨�:md5
+        json.addProperty("sign_method", "md5");//鍗囩骇鍖呯鍚嶇被鍨�:md5
+        jsonArray.add(json);
+        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, jsonArray, "", new HDLLinkCallBack() {
             @Override
             public void onSuccess(String msg) {
                 if (linkCallBack != null) {
@@ -453,6 +459,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());
+//        //瑙e瘑璐熻浇鏁版嵁(鍐欏瘑閽ョ粰缃戝叧涓�瀹氭槸鏄庢枃锛屽洜涓洪偅鏃剁綉鍏宠繕娌℃湁瀵嗛挜)
+//        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);
+//                }
+//            }
+//        });
+    }
+
 
     /**
      * 鍚姩鏈湴鏈嶅姟

--
Gitblit v1.8.0