hxb
2023-06-30 07671116767c77058b3ce584be161b4b194ec9bd
Merge branch 'hxb' of http://172.16.1.23:6688/r/~wjc/HDLPhotovoltaicDebugAPP into hxb
10个文件已修改
161 ■■■■ 已修改文件
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/res/values/strings_code.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/config/AppConfigManage.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkCode.java
@@ -14,31 +14,32 @@
 * @Description : HDLError
 */
public class HDLLinkCode {
    public static final HDLLinkCode HDL_UNKOWN_CODE=new HDLLinkCode(-1000,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_UNKOWN_CODE));
    public static final HDLLinkCode HDL_DATA_ERROR =new HDLLinkCode(-2000, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_ERROR)) ;
    public static final HDLLinkCode HDL_DATA_NULL_ERROR=new HDLLinkCode(-2001, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_NULL_ERROR));
    public static final HDLLinkCode HDL_AUTH_ERROR=new HDLLinkCode(2002,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_ERROR) );
    public static final HDLLinkCode HDL_SEND_ERROR=new HDLLinkCode(2003, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_SEND_ERROR));
    public static final HDLLinkCode HDL_TIMEOUT_ERROR=new HDLLinkCode(2004, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_TIMEOUT_ERROR));
    public static final HDLLinkCode HDL_UNAUTHORIZED_ERROR=new HDLLinkCode(-2005,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_UNAUTHORIZED_ERROR));
    public static final HDLLinkCode HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED=new HDLLinkCode(-2006, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
    public static final HDLLinkCode HDL_SEARCH_GATEWAY_TIMEOUT_ERROR=new HDLLinkCode(-2007, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_SEARCH_GATEWAY_TIMEOUT_ERROR));
    public static final HDLLinkCode HDL_AUTH_MAC_KEY_ERROR=new HDLLinkCode(-2008, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_MAC_KEY_ERROR));
    public static final HDLLinkCode HDL_DATA_PARSING_ERROR=new HDLLinkCode(-2009, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_PARSING_ERROR));
    public static final HDLLinkCode HDL_GET_DEVICE_LIST_ERROR=new HDLLinkCode(-2100, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_DEVICE_LIST_ERROR));
    public static final HDLLinkCode HDL_GET_FUNCTION_LIST_ERROR=new HDLLinkCode(-2101, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_FUNCTION_LIST_ERROR));
    public static final HDLLinkCode HDL_GET_FUNCTION_PROPERTIES_ERROR=new HDLLinkCode(-2102, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_FUNCTION_PROPERTIES_ERROR));
    public static final HDLLinkCode HDL_CONTROL_FAILURE_ERROR=new HDLLinkCode(-2103, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_CONTROL_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GET_GATEWAY_FAILURE_ERROR=new HDLLinkCode(-2104, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_GATEWAY_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GET_Zigbee_FAILURE_ERROR=new HDLLinkCode(-2105, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_Zigbee_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GATEWAY_NOT_EXIST=new HDLLinkCode(-2106,HDLLinkLocalSdk.getInstance().getContext().getString( R.string.HDL_GATEWAY_NOT_EXIST));
    public static final HDLLinkCode HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR=new HDLLinkCode(-2107, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR));
    public static final HDLLinkCode HDL_MILLIMETER_NOT_EXIST=new HDLLinkCode(-2108, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_MILLIMETER_NOT_EXIST));
    public static final HDLLinkCode HDL_APPLICATION_CODE=new HDLLinkCode(-2109,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_APPLICATION_EXCEPTION));
    public static final HDLLinkCode HDL_TOPIC_NOT_RIGHT=new HDLLinkCode(-2110,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_TOPIC_NOT_RIGHT));
    public static final HDLLinkCode HDL_OBJECT_NOT_SUPPORT=new HDLLinkCode(-2111,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_OBJECT_NOT_SUPPORT));
    public static final HDLLinkCode HDL_GATEWAY_REMOTE_NOT_RESPONSE=new HDLLinkCode(-2112,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GATEWAY_REMOTE_NOT_RESPONSE));
    public static final HDLLinkCode HDL_SUCCESS=new HDLLinkCode(0,HDLLinkLocalSdk.getInstance().getContext().getString(R.string.SUCCESS));
    public static final HDLLinkCode HDL_UNKOWN_CODE = new HDLLinkCode(-1000, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_UNKOWN_CODE));
    public static final HDLLinkCode HDL_DATA_ERROR = new HDLLinkCode(-2000, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_ERROR));
    public static final HDLLinkCode HDL_DATA_NULL_ERROR = new HDLLinkCode(-2001, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_NULL_ERROR));
    public static final HDLLinkCode HDL_AUTH_ERROR = new HDLLinkCode(2002, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_ERROR));
    public static final HDLLinkCode HDL_SEND_ERROR = new HDLLinkCode(2003, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_SEND_ERROR));
    public static final HDLLinkCode HDL_TIMEOUT_ERROR = new HDLLinkCode(2004, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_TIMEOUT_ERROR));
    public static final HDLLinkCode HDL_UNAUTHORIZED_ERROR = new HDLLinkCode(-2005, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_UNAUTHORIZED_ERROR));
    public static final HDLLinkCode HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED = new HDLLinkCode(-2006, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
    public static final HDLLinkCode HDL_SEARCH_GATEWAY_TIMEOUT_ERROR = new HDLLinkCode(-2007, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_SEARCH_GATEWAY_TIMEOUT_ERROR));
    public static final HDLLinkCode HDL_AUTH_MAC_KEY_ERROR = new HDLLinkCode(-2008, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_AUTH_MAC_KEY_ERROR));
    public static final HDLLinkCode HDL_DATA_PARSING_ERROR = new HDLLinkCode(-2009, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_DATA_PARSING_ERROR));
    public static final HDLLinkCode HDL_GET_DEVICE_LIST_ERROR = new HDLLinkCode(-2100, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_DEVICE_LIST_ERROR));
    public static final HDLLinkCode HDL_GET_FUNCTION_LIST_ERROR = new HDLLinkCode(-2101, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_FUNCTION_LIST_ERROR));
    public static final HDLLinkCode HDL_GET_FUNCTION_PROPERTIES_ERROR = new HDLLinkCode(-2102, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_FUNCTION_PROPERTIES_ERROR));
    public static final HDLLinkCode HDL_CONTROL_FAILURE_ERROR = new HDLLinkCode(-2103, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_CONTROL_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GET_GATEWAY_FAILURE_ERROR = new HDLLinkCode(-2104, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_GATEWAY_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GET_Zigbee_FAILURE_ERROR = new HDLLinkCode(-2105, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_Zigbee_FAILURE_ERROR));
    public static final HDLLinkCode HDL_GATEWAY_NOT_EXIST = new HDLLinkCode(-2106, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GATEWAY_NOT_EXIST));
    public static final HDLLinkCode HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR = new HDLLinkCode(-2107, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR));
    public static final HDLLinkCode HDL_MILLIMETER_NOT_EXIST = new HDLLinkCode(-2108, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_MILLIMETER_NOT_EXIST));
    public static final HDLLinkCode HDL_APPLICATION_CODE = new HDLLinkCode(-2109, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_APPLICATION_EXCEPTION));
    public static final HDLLinkCode HDL_TOPIC_NOT_RIGHT = new HDLLinkCode(-2110, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_TOPIC_NOT_RIGHT));
    public static final HDLLinkCode HDL_OBJECT_NOT_SUPPORT = new HDLLinkCode(-2111, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_OBJECT_NOT_SUPPORT));
    public static final HDLLinkCode HDL_GATEWAY_REMOTE_NOT_RESPONSE = new HDLLinkCode(-2112, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GATEWAY_REMOTE_NOT_RESPONSE));
    public static final HDLLinkCode HDL_SUCCESS = new HDLLinkCode(0, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.SUCCESS));
    public static final HDLLinkCode HDL_GATEWAY_FOUND_LOCALLY = new HDLLinkCode(-2113, HDLLinkLocalSdk.getInstance().getContext().getString(R.string.HDL_GATEWAY_FOUND_LOCALLY));
    private String msg;
    private int code;
@@ -47,6 +48,7 @@
        this.msg = msg;
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java
@@ -726,7 +726,7 @@
                                      String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
        GatewayBean gatewayBean = this.getLocalGateway(mac);
        if (gatewayBean == null) {
//            callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode));
            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_FOUND_LOCALLY));
            return;
        }
        String topicSend = topic.replace("%s", gatewayBean.getOid());
HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml
@@ -25,4 +25,5 @@
    <string name="HDL_OBJECT_NOT_SUPPORT">对象不支持</string>
    <string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">网关本地连接失败,通过远程通讯不回复</string>
    <string name="SUCCESS">成功</string>
    <string name="HDL_GATEWAY_FOUND_LOCALLY">本地找不到网关</string>
</resources>
HDLLinkLocalSdk/src/main/res/values/strings_code.xml
@@ -25,4 +25,5 @@
<string name="HDL_OBJECT_NOT_SUPPORT">Object not supported</string>
<string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">Gateway local connection failed, unable to reply through remote communication</string>
<string name="SUCCESS">success</string>
<string name="HDL_GATEWAY_FOUND_LOCALLY">The gateway cannot be found locally</string>
</resources>
app/src/main/java/com/hdl/photovoltaic/config/AppConfigManage.java
@@ -21,7 +21,7 @@
        return isOnlineServer;
    }
    /// 用户注册所在服务器域名地址
    /// 用户注册所在服务器域名地址(用户请求网络用的)
    private static String sUserRegionUrl;
    public static String getUserRegionUrl() {
app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java
@@ -1,6 +1,7 @@
package com.hdl.photovoltaic.internet;
import com.hdl.photovoltaic.other.HdlAccountLogic;
import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
@@ -9,6 +10,25 @@
 */
public class TcpClient {
    private static volatile TcpClient sTcpClient;
    /**
     * 获取当前对象
     *
     * @return HdlAccountLogic
     */
    public static synchronized TcpClient getInstance() {
        if (sTcpClient == null) {
            synchronized (TcpClient.class) {
                if (sTcpClient == null) {
                    sTcpClient = new TcpClient();
                }
            }
        }
        return sTcpClient;
    }
    /**
     * 发送数据到Link网关
     *
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
@@ -32,7 +32,7 @@
     * 写远程信息的,例如服务器地址、HomeId、密钥之类
     * 与服务器相关的
     * */
    public static final String GATEWAY_EDIT_REMOTE = "/user/%s/custom/gateway/remote/edit";
    public static final String GATEWAY_SEND_REMOTE_EDIT = "/user/%s/custom/gateway/remote/edit";
    /*
     * 网关恢复出场设置命令
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -6,9 +6,12 @@
import com.google.gson.reflect.TypeToken;
import com.hdl.hdlhttp.HxHttp;
import com.hdl.photovoltaic.bean.HttpResponsePack;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.TcpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.internet.api.TopicApi;
import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean;
@@ -20,6 +23,7 @@
import com.hdl.sdk.link.common.exception.HDLLinkException;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import java.lang.reflect.Type;
@@ -190,9 +194,9 @@
     * 全量更新OID
     *
     * @param oidList       oid列表
     * @param cloudCallBeak 回调
     * @param cloudCallBeak 回调update
     */
    public void fullRenewalOid(List<OidBean> oidList, CloudCallBeak<Boolean> cloudCallBeak) {
    public void fullUpdateOid(List<OidBean> oidList, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = HttpApi.POST_Device_ChildDevices_List;
        JsonObject json = new JsonObject();
        json.addProperty("operationSource", "PROGRAM_ENERGY");//
@@ -237,6 +241,56 @@
    /**
     * 设置网关远程参数
     *
     * @param mac           设备mac
     * @param cloudCallBeak 回调update
     */
    public void steGatewayParam(String mac, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = TopicApi.GATEWAY_SEND_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, true, requestUrl, json, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String msg) {
            }
            @Override
            public void onError(HDLLinkException e) {
            }
        });
    }
    /**
     * 编辑网关参数
     *
     * @param mac           设备mac
     * @param cloudCallBeak 回调update
     */
    public void steEditGatewayParam(String mac, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = TopicApi.GATEWAY_SEND_EDIT;
        JsonObject json = new JsonObject();
        json.addProperty("master", "true");
        TcpClient.getInstance().sendDataToLinkGateway(mac, true, requestUrl, json, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String msg) {
            }
            @Override
            public void onError(HDLLinkException e) {
            }
        });
    }
    /**
     * 搜索网关列表
     *
     * @param gatewayCallBack -
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -91,13 +91,14 @@
                }
                if (callback != null) {
                    uniCallbackData(null, "0", "", callback);
                    uniCallbackData(null, callback);
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(event)) {
                //设备模块
                switch (type) {
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: {
                        //添加
                    }
                    break;
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
@@ -111,7 +112,7 @@
                            @Override
                            public void onError(HDLLinkException e) {
                                //发送失败
                                uniCallbackData(null, e.getCode() + "", "", callback);
                                uniCallbackData(null, e.getCode(), "", callback);
                            }
                        });
                    }
@@ -183,7 +184,7 @@
            @Override
            public void onError(HDLLinkException e) {
                uniCallbackData(null, e.getCode() + "", "失败", callback);
                uniCallbackData(null, e.getCode(), e.getMsg(), callback);
            }
        });
    }
@@ -262,7 +263,7 @@
     * @param msg      结果描述的信息
     * @param callback 回调
     */
    private void uniCallbackData(Object obj, String code, String msg, DCUniMPJSCallback callback) {
    private void uniCallbackData(Object obj, int code, String msg, DCUniMPJSCallback callback) {
        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
        try {
            uniCallBackBaseBean.setCode(code);
@@ -279,7 +280,7 @@
    }
    private void uniCallbackData(Object obj, DCUniMPJSCallback callback) {
        uniCallbackData(obj, HDLLinkCode.HDL_SUCCESS.getCode() + "", HDLLinkCode.HDL_SUCCESS.getMsg(), callback);
        uniCallbackData(obj, HDLLinkCode.HDL_SUCCESS.getCode(), HDLLinkCode.HDL_SUCCESS.getMsg(), callback);
    }
    /**
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -69,27 +69,27 @@
     */
    public static class UniCallBackBaseBean implements Serializable {
        private String code;//状态码
        private int code;//状态码
        private String mes;//信息描述
        private String type;//功能类型
        private Object data;//附加json数据
        public UniCallBackBaseBean(String code, String mes) {
        public UniCallBackBaseBean(int code, String mes) {
            this.code = code;
            this.mes = mes;
        }
        public UniCallBackBaseBean() {
            this.code = "0";
            this.code = 0;
            this.mes = "成功";
        }
        public String getCode() {
            return code == null ? "" : code;
        public int getCode() {
            return code;
        }
        public void setCode(String code) {
        public void setCode(int code) {
            this.code = code;
        }