From 4a2d7f9ac055d10ba7baf58df690e0ad62826f52 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 13 三月 2024 17:34:51 +0800 Subject: [PATCH] 2024年03月13日17:23:53 --- app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 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 3ac4c25..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>() { @@ -893,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