mac
2024-03-19 89c38fa6f118d56cb163c245905de8f1c0a75a7c
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -2,12 +2,12 @@
import android.text.TextUtils;
import com.facebook.imagepipeline.image.OriginalEncodedImageInfo;
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;
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;
@@ -22,12 +22,17 @@
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.sdk.link.HDLLinkLocalSdk;
import com.hdl.sdk.link.common.config.TopicConstant;
import com.hdl.sdk.link.common.exception.HDLLinkCode;
import com.hdl.sdk.link.common.exception.HDLLinkException;
import com.hdl.sdk.link.common.utils.IdUtils;
import com.hdl.sdk.link.core.bean.LinkRequest;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.bean.response.BaseLocalResponse;
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.core.connect.HDLConnectHelper;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import com.hdl.sdk.link.gateway.type.GatewayMasterType;
@@ -36,8 +41,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import io.dcloud.common.adapter.util.DeviceInfo;
/**
@@ -62,6 +65,7 @@
        }
        return sHdlDeviceLogic;
    }
    /**
     * 获取当前住宅的逆变器列表(包括从的逆变器)
@@ -110,7 +114,8 @@
                        return;
                    }
                    oidList.addAll(oidBeanList);
                    if (atomicInteger.get() == oidList.size()) {
                    if (atomicInteger.get() == list.size()) {
                        //全部获取后再上传
                        fullUpdateOid(homeId, oidList, new CloudCallBeak<Boolean>() {
                            @Override
                            public void onSuccess(Boolean obj) {
@@ -180,10 +185,10 @@
    /**
     * 添加多个逆变器到云端上
     *
     * @param mac           -
     * @param list          逆变器列表
     * @param cloudCallBeak -
     */
    public void addAllInverterDeviceToCloud(String homeId, String mac, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) {
    public void addAllInverterDeviceToCloud(String homeId, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = HttpApi.POST_Device_Add_All;
        JsonObject json = new JsonObject();
@@ -563,7 +568,7 @@
    public void editGatewayParam(String mac, LinkCallBack<Boolean> linkCallBack) {
        String requestUrl = TopicApi.SET_GATEWAY_EDIT;
        JsonObject json = new JsonObject();
        json.addProperty("master", GatewayMasterType.MasterTrue);
        json.addProperty("master", GatewayMasterType.MasterFalse);
        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String msg) {
@@ -615,6 +620,67 @@
        });
    }
    /**
     * 初始化逆变器
     *
     * @param mac 网关mac
     */
    public void initializeGateway(String mac, LinkCallBack<Boolean> linkCallBack) {
        String requestUrl = TopicApi.GATEWAY_INITIALIZE_REMOTE;
        JsonObject sendJsonObj = new JsonObject();
        JsonObject jObject = new JsonObject();
        jObject.addProperty("device_mac", mac);
        sendJsonObj.add("objects", jObject);
        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, sendJsonObj, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String json) {
                if (linkCallBack != null) {
                    linkCallBack.onSuccess(true);
                }
            }
            @Override
            public void onError(HDLLinkException e) {
                if (linkCallBack != null) {
                    linkCallBack.onError(e);
                }
            }
        });
    }
    /**
     * 删除oid
     *
     * @param mac 网关mac
     * @param oid 设备oid
     */
    public void deleteOid(String mac, String oid, LinkCallBack<Boolean> linkCallBack) {
        String requestUrl = TopicApi.DELETING_GATEWAY_SLAVE;
        JsonArray jsonArray = new JsonArray();
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("oid", oid);//设备oid
        jsonArray.add(jsonObject);
        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, jsonArray, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String json) {
                if (linkCallBack != null) {
                    linkCallBack.onSuccess(true);
                }
            }
            @Override
            public void onError(HDLLinkException e) {
                if (linkCallBack != null) {
                    linkCallBack.onError(e);
                }
            }
        });
    }
    /**
     * 获取逆变器oid列表
@@ -932,8 +998,9 @@
     * @param gatewayCallBack -
     */
    public void searchAllNetworkGateway(GatewayCallBack gatewayCallBack) {
        List<String> spks = this.getGatewaySpk();
        //网关搜索
        HDLLinkLocalSdk.getInstance().refreshGateway(gatewayCallBack, this.getGatewaySpk());
        HDLLinkLocalGateway.getInstance().refreshGatewayBySpk(spks, true, gatewayCallBack);
    }
    /**