From 17484333e6621a0285b61d50ceedc8698861120b Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期一, 11 三月 2024 20:54:41 +0800
Subject: [PATCH] 2024年03月11日20:54:25

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
index e8cd9ea..1b6d81d 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -7,6 +7,7 @@
 import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.linkpm.sdk.home.type.GatewayType;
 import com.hdl.photovoltaic.config.AppConfigManage;
 import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.internet.HttpClient;
@@ -35,6 +36,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
+
+import io.dcloud.common.adapter.util.DeviceInfo;
 
 
 /**
@@ -162,6 +165,50 @@
         json.addProperty("sid", sid);
         json.addProperty("oid", oid);
         json.addProperty("name", name);
+        // json.addProperty("zoneType", "password");//鍖哄煙
+
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String str) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(true);
+                    //涓存椂鐨勯�昏緫锛屼笂浼爋id鍒楄〃鍒颁簯绔�
+                    uploadDataToCloud(UserConfigManage.getInstance().getHomeId(), mac, null);
+                }
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(e);
+                }
+            }
+        });
+    }
+
+    /**
+     * 娣诲姞澶氫釜閫嗗彉鍣ㄥ埌浜戠涓�
+     *
+     * @param mac           -
+     * @param cloudCallBeak -
+     */
+    public void addAllInverterDeviceToCloud(String homeId, String mac, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) {
+
+        String requestUrl = HttpApi.POST_Device_Add_All;
+        JsonObject json = new JsonObject();
+        json.addProperty("homeId", homeId);
+        JsonArray ary = new JsonArray();
+        for (int i = 0; i < list.size(); i++) {
+            GatewayBean gatewayBean=list.get(i);
+            JsonObject inverterInfo = new JsonObject();
+            inverterInfo.addProperty("mac",gatewayBean.getDevice_mac());
+            inverterInfo.addProperty("spk",gatewayBean.getGatewayType());
+            inverterInfo.addProperty("sid",gatewayBean.getSid());
+            inverterInfo.addProperty("oid",gatewayBean.getOid());
+            inverterInfo.addProperty("name",gatewayBean.getDevice_name());
+            ary.add(inverterInfo);
+        }
+        json.add("devices", ary);
         // json.addProperty("zoneType", "password");//鍖哄煙
 
         HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@@ -442,7 +489,7 @@
      * 缃戝叧鏃堕棿璇诲彇
      *
      * @param mac          璁惧mac
-     * @param linkCallBack 鍥炶皟update
+     * @param linkCallBack 鍥炶皟updatetime
      */
     public void getGatewayTime(String mac, LinkCallBack<DeviceTimeBean> linkCallBack) {
         String requestUrl = TopicApi.GET_GATEWAY_TIME;
@@ -770,7 +817,7 @@
                                             cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId));
                                         }
                                     }
-                                    HdlLogLogic.print("鑾峰彇璁惧杩滅▼閫氳淇℃伅澶辫触->msg->" + e.getMsg() + "(" + e.getCode() + ")");
+                                    HdlLogLogic.print("鑾峰彇璁惧杩滅▼閫氳淇℃伅澶辫触--->msg--->" + e.getMsg() + "(" + e.getCode() + ")");
                                 }
                             });
                         }
@@ -850,6 +897,7 @@
         JsonObject json = new JsonObject();
         json.addProperty("homeId", "");
         json.addProperty("server_addr", "");
+        json.addProperty("local_secret", "");
         TcpClient.getInstance().sendDataToLinkGateway(mac, true, requestUrl, json, "", new HDLLinkCallBack() {
             @Override
             public void onSuccess(String msg) {
@@ -892,7 +940,7 @@
      *
      * @param gatewayCallBack -
      */
-    public void searchAllGateway(GatewayCallBack gatewayCallBack) {
+    public void searchAllNetworkGateway(GatewayCallBack gatewayCallBack) {
         //缃戝叧鎼滅储
         HDLLinkLocalSdk.getInstance().refreshGateway(gatewayCallBack, this.getGatewaySpk());
     }

--
Gitblit v1.8.0