wjc
2023-06-29 4a209c4c6ef8b4402114ca26b45dd4bbe869190b
2023年06月29日15:31:33
6个文件已修改
414 ■■■■■ 已修改文件
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/res/values/strings_code.xml 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/data/dcloud_control.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java 308 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/HDLLinkLocalGateway.java
@@ -716,25 +716,26 @@
    /**
     * 发送数据到Link网关
     *
     * @param ip        网关IP
     * @param mac       网关mac
     * @param isEncrypt 是否加密
     * @param topic     请求主题
     * @param jObject   负载数据<没有填null></>
     * @param sendPath  发送路径<类名+方法名>class->methodName</>
     */
    public void sendDataToLinkGateway(String ip, String mac, boolean isEncrypt,
    public void sendDataToLinkGateway(String mac, boolean isEncrypt,
                                      String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
        String topicSend = topic.replace("%s", mac);
        GatewayBean gatewayBean = this.getLocalGateway(mac);
        if (gatewayBean == null) {
            callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode));
            return;
        }
        String topicSend = topic.replace("%s", gatewayBean.getOid());
        //组装需要发送的数据
        String sendStr = createSendData(jObject);
//        LogUtils.i("sendDataToLinkGateway->" + sendPath + "->本地发送\r\n" + topicSend + "\r\n" + sendStr);
        LinkRequest message = new LinkRequest(topicSend, sendStr, isEncrypt);
        GatewayBean gatewayBean = this.getLocalGateway(mac);
        if (gatewayBean != null) {
            message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId()));
        }
        new HDLConnectHelper(ip, message, new HDLConnectHelper.HdlSocketListener() {
        message.setCloudTopic(topic.replace("%s", gatewayBean.getGatewayId()));
        new HDLConnectHelper(gatewayBean.getIp_address(), message, new HDLConnectHelper.HdlSocketListener() {
            @Override
            public void onSucceed(Object msg) {
                if (callBack == null) return;
HDLLinkLocalSdk/src/main/res/values/strings_code.xml
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="HDL_DATA_ERROR">Parameter exception</string>
<string name="HDL_DATA_NULL_ERROR">Parameter cannot be empty</string>
<string name="HDL_AUTH_ERROR">Authentication failed</string>
<string name="HDL_SEND_ERROR">fail in send</string>
<string name="HDL_TIMEOUT_ERROR">timeout,gateway no response</string>
<string name="HDL_UNAUTHORIZED_ERROR">Not certified, please authenticate first</string>
<string name="HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED">Authentication failed. The gateway is not registered to the cloud</string>
<string name="HDL_SEARCH_GATEWAY_TIMEOUT_ERROR">Failed to search gateway, timeout</string>
<string name="HDL_AUTH_MAC_KEY_ERROR">Authentication failed. The device key corresponding to the MAC does not exist</string>
<string name="HDL_DATA_PARSING_ERROR">Data parsing error</string>
<string name="HDL_GET_DEVICE_LIST_ERROR">Failed to get device list</string>
<string name="HDL_GET_FUNCTION_LIST_ERROR">Failed to get function list</string>
<string name="HDL_GET_FUNCTION_PROPERTIES_ERROR">Failed to get function attribute</string>
<string name="HDL_CONTROL_FAILURE_ERROR">Control failure</string>
<string name="HDL_GET_GATEWAY_FAILURE_ERROR">Failed to get gateway list</string>
<string name="HDL_GET_Zigbee_FAILURE_ERROR">Sending timeout, no response from gateway</string>
<string name="HDL_GATEWAY_NOT_EXIST">Gateway does not exist</string>
<string name="HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR">Failed to get the device list</string>
<string name="HDL_MILLIMETER_NOT_EXIST">Millimeter does not exist</string>
<string name="HDL_UNKOWN_CODE">Unkown Error</string>
<string name="HDL_APPLICATION_EXCEPTION">System Exception</string>
<string name="HDL_TOPIC_NOT_RIGHT">Theme does not match</string>
<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="HDL_DATA_ERROR">Parameter exception</string>
    <string name="HDL_DATA_NULL_ERROR">Parameter cannot be empty</string>
    <string name="HDL_AUTH_ERROR">Authentication failed</string>
    <string name="HDL_SEND_ERROR">fail in send</string>
    <string name="HDL_TIMEOUT_ERROR">timeout,gateway no response</string>
    <string name="HDL_UNAUTHORIZED_ERROR">Not certified, please authenticate first</string>
    <string name="HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED">Authentication failed. The gateway is not registered to the cloud</string>
    <string name="HDL_SEARCH_GATEWAY_TIMEOUT_ERROR">Failed to search gateway, timeout</string>
    <string name="HDL_AUTH_MAC_KEY_ERROR">Authentication failed. The device key corresponding to the MAC does not exist</string>
    <string name="HDL_DATA_PARSING_ERROR">Data parsing error</string>
    <string name="HDL_GET_DEVICE_LIST_ERROR">Failed to get device list</string>
    <string name="HDL_GET_FUNCTION_LIST_ERROR">Failed to get function list</string>
    <string name="HDL_GET_FUNCTION_PROPERTIES_ERROR">Failed to get function attribute</string>
    <string name="HDL_CONTROL_FAILURE_ERROR">Control failure</string>
    <string name="HDL_GET_GATEWAY_FAILURE_ERROR">Failed to get gateway list</string>
    <string name="HDL_GET_Zigbee_FAILURE_ERROR">Sending timeout, no response from gateway</string>
    <string name="HDL_GATEWAY_NOT_EXIST">Gateway does not exist</string>
    <string name="HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR">Failed to get the device list</string>
    <string name="HDL_MILLIMETER_NOT_EXIST">Millimeter does not exist</string>
    <string name="HDL_UNKOWN_CODE">Unkown Error</string>
    <string name="HDL_APPLICATION_EXCEPTION">System Exception</string>
    <string name="HDL_TOPIC_NOT_RIGHT">Theme does not match</string>
    <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>
</resources>
app/src/main/assets/data/dcloud_control.xml
@@ -1,6 +1,6 @@
<hbuilder version="1.9.9.80110" debug="false" syncDebug ="false">
<hbuilder debug="true" syncDebug="false" version="1.9.9.80110">
    <apps>
        <app appid="unimp" appver="1.0"/>
        <app appid="unimp" appver="1.0" />
    </apps>
</hbuilder>
app/src/main/java/com/hdl/photovoltaic/internet/TcpClient.java
@@ -1,4 +1,26 @@
package com.hdl.photovoltaic.internet;
import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
/**
 * 客户端操作逻辑
 */
public class TcpClient {
    /**
     * 发送数据到Link网关
     *
     * @param mac       网关mac
     * @param isEncrypt 是否加密
     * @param topic     请求主题
     * @param jObject   负载数据<没有填null></>
     * @param sendPath  发送路径<类名+方法名>class->methodName</>
     */
    public void sendDataToLinkGateway(String mac, boolean isEncrypt,
                                      String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
        HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, isEncrypt, topic, jObject, sendPath, callBack);
    }
}
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
@@ -1,4 +1,312 @@
package com.hdl.photovoltaic.internet.api;
public class TopicApi {
    /*
     *通知删除并退网子设备拓扑关系
     *删除从网关
     * */
    public static final String DELETING_GATEWAY_SLAVE = "/base/%s/thing/topo/delete/notify";
    /*
     *网关物理退网后上报删除(退网)子设备
     * */
    public static final String DELETING_GATEWAY_SLAVE_RESULT = "/base/%s/thing/topo/delete/up";
    /*
    网关数据备份还原
     * */
    public static final String GATEWAY_BACKUP_RESTORE_DOWN = "/base/%s/device/backup/restore/down";
    /*
   调试人员主动通知网关备份数据
    * */
    public static final String GATEWAY_BACKUP_NOTICE_DOWN = "/base/%s/device/backup/notice/down";
    /*
   备份还原进度获取
    * */
    public static final String GATEWAY_BACKUP_PROGRESS_GET = "/base/%s/device/backup/restore/progress/get";
    /*
     * 网关编辑命令
     * 写远程信息的,例如服务器地址、HomeId、密钥之类
     * 与服务器相关的
     * */
    public static final String GATEWAY_EDIT_REMOTE = "/user/%s/custom/gateway/remote/edit";
    /*
     * 网关恢复出场设置命令
     * */
    public static final String GATEWAY_INITIALIZE_REMOTE = "/user/%s/custom/gateway/initialize";
    public static final String GATEWAY_FIND_REMOTE = "/base/%s/thing/service/mmv_device_find/down";
    /**
     * 红外宝的定位
     */
    public static final String IR_FIND_REMOTE = "/base/%s/thing/service/irDeviceFind/down";
    /**
     * 红外宝试码
     */
    public static final String IR_CODE_TEST = "/base/%s/thing/service/irCodeTest/down";
    /**
     * 红外宝遥控器添加
     */
    public static final String IR_DEVICE_ADD = "/base/%s/thing/service/irDeviceAdd/down";
    /**
     * 红外宝遥控器列表获取
     */
    public static final String IR_DEVICE_LIST = "/base/%s/thing/service/irDeviceListGet/down";
    /**
     * 红外宝自学码
     */
    public static final String IR_CODE_STUDY = "/base/%s/thing/service/irCodeStudy/down";
    /**
     * 红外宝自学码删除
     */
    public static final String IR_CODE_REMOVE = "/base/%s/thing/service/irCodeRemove/down";
    /*
     * 网关编辑命令
     * 与服务器无关的
     * */
    public static final String GATEWAY_SEND_EDIT = "/user/%s/custom/gateway/edit";
    /**
     * 设置网关入网模式
     * 入网从机设备使用
     * 从网关、红外宝等网络设备
     */
    public static final String GATEWAY_AUTH = "/user/%s/custom/device/auth_gateway";
    //获取网关信息
    public static final String GATEWAY_GET = "/user/%s/custom/gateway/remote/get";
    //网关广播入网指令
    public static final String GATEWAY_AUTH_BROADCAST = "/user/all/custom/device/network_access/broadcast";
    //设备入网和认证
    public static final String DEIVCE_AUTH_REQUEST = "/user/all/custom/device/network_access/request";
    //设备入网和认证响应
    public static final String DEIVCE_AUTH_REQUEST_REPLY = "/user/all/custom/device/network_access/request_reply";
    /**
     * 搜索网关
     */
    public static final String GATEWAY_SEARCH = "/user/all/custom/gateway/search";
    /**
     * 搜索网关响应
     */
    public static final String GATEWAY_SEARCH_REPLY = "/user/all/custom/gateway/search_reply";
    //网关详细信息获取s=gw_id
    public static final String GATEWAY_INFO = "/user/%s/custom/gateway/get";
    //获取物理设备列表
    public static final String GET_DEVICE_LIST = "/user/%s/custom/device/list/get";
    //获取物理设备列表响应
    public static final String GET_DEVICE_LIST_REPLY = "/user/%s/custom/device/list/get_reply";
    //获取功能列表
    public static final String GET_FUNCTION_LIST = "/user/%s/custom/function/list/get";
    //模拟云端ota
    public static final String OTA_UPGRADE_DOWN = "/base/%s/ota/device/upgrade/down";
    /**
     * 编辑sid
     */
    public static final String EDIT_FUNCTION = "/user/%s/custom/function/attribute/edit";
    //获取功能响应
    public static final String GET_FUNCTION_LIST_REPLY = "/user/%s/custom/function/list/get_reply";
    //功能属性读取
    public static final String GET_FUNCTION_ATTRIBUTE = "/user/%s/custom/function/attribute/get";
    //功能属性编辑
    public static final String EDIT_FUNCTION_ATTRIBUTE = "/user/%s/custom/function/attribute/edit";
    //功能属性响应
    public static final String GET_FUNCTION_ATTRIBUTE_REPLY = "/user/%s/custom/function/attribute/get_reply";
    //控制
    public static final String PROPERTY_DOWN = "/base/%s/thing/property/down";
    //控制响应
    public static final String PROPERTY_DOWN_REPLY = "/base/%s/thing/property/down_reply";
    //状态上报
    public static final String PROPERTY_UP = "/base/%s/thing/property/up";
    //状态上报响应
    public static final String PROPERTY_UP_REPLY = "/base/%s/thing/property/up_reply";
    //读取状态
    public static final String PROPERTY_READ = "/base/%s/thing/property/read";
    //读取状态响应
    public static final String PROPERTY_READ_REPLY = "/base/%s/thing/property/read_reply";
    //更改网关备注名
    public static final String GATEWAY_RENAME = "/user/%s/custom/gateway/edit";
    //8.1获取场景列表
    public static final String SCENE_LIST_GET = "/user/%s/custom/scene/list/get";
    //8.2获取场景
    public static final String SCENE_GET = "/user/%s/custom/scene/get";
    //8.3执行场景
    public static final String SCENE_CONTROL = "/user/%s/custom/scene/execute";
    //8.4场景增加
    public static final String CREATE_SCENE = "/user/%s/custom/scene/add";
    //8.5场景编辑
    public static final String SCENE_EDIT = "/user/%s/custom/scene/edit";
    //8.6场景删除
    public static final String SCENE_DELETE = "/user/%s/custom/scene/delete";
    //9.1 房间信息列表获取
    public static final String ROOM_LIST_GET = "/user/%s/custom/room/list/get";
    //9.2 房间信息添加(增量)
    public static final String ROOM_ADD = "/user/%s/custom/room/add";
    //9.2.1 房间信息添加(全量)
    public static final String ROOM_COVER_ADD = "/user/%s/custom/room/cover/add";
    //9.3 房间信息编辑
    public static final String ROOM_EDIT = "/user/%s/custom/room/edit";
    //9.4 房间信息删除
    public static final String ROOM_DELETE = "/user/%s/custom/room/delete";
    //9.5 房间绑定关系列表获取
    public static final String ROOM_BIND_LIST_GET = "/user/%s/custom/room/bind/list/get";
    //9.6 房间绑定关系添加(增量)
    public static final String ROOM_BIND_ADD = "/user/%s/custom/room/bind/add";
    //9.6.1 房间绑定关系添加(全量)
    public static final String ROOM_BIND_COVER_ADD = "/user/%s/custom/room/bind/cover/add";
    //9.7 房间绑定关系删除
    public static final String ROOM_BIND_DELETE = "/user/%s/custom/room/bind/delete";
    //10.1 自动化列表获取
    public static final String LOGIC_LIST_GET = "/user/%s/custom/logic/list/get";
    //10.2 自动化手动执行
    public static final String LOGIC_execute = "/user/%s/custom/logic/execute";
    //10.3 自动化获取 列表一次性读全
    public static final String LOGIC_GET = "/user/%s/custom/logic/get";
    //10.4 自动化新增/编辑
    public static final String LOGIC_EDIT = "/user/%s/custom/logic/edit";
    //10.5 自动化删除
    public static final String LOGIC_DELETE = "/user/%s/custom/logic/delete";
    //10.6 自动化启用禁用
    public static final String LOGIC_ENABLE_EDIT = "/user/%s/custom/logic/enable/edit";
    //10.7 自动化状态上报 执行结果、本地启用禁用状态上报
    public static final String LOGIC_STATUS_UP = "/user/%s/custom/logic/status/up";
    //11.1 安防列表获取
    public static final String SECURITY_LIST_GET = "/user/%s/custom/security/list/get";
    //11.2 安防获取
    public static final String SECURITY_GET = "/user/%s/custom/security/get";
    //11.3 安防新增/编辑
    public static final String SECURITY_EDIT = "/user/%s/custom/security/edit";
    //11.4 安防删除
    public static final String SECURITY_DELETE = "/user/%s/custom/security/delete";
    //11.5 布防设置
    public static final String SECURITY_STATUS_SET = "/user/%s/custom/security/status/set";
    //11.6 安防防区状态读取
    public static final String SECURITY_STATUS_GET = "/user/%s/custom/security/status/get";
    //11.7 安防防区报警状态上报
    public static final String SECURITY_STATUS_UP = "/user/%s/custom/security/status/up";
    //11.8 安防Bypass读取
    public static final String SECURITY_BYPASS_GET = "/user/%s/custom/security/bypass/get";
    //11.9 安防Bypass设置
    public static final String SECURITY_BYPASS_SET = "/user/%s/custom/security/bypass/set";
    /**
     * 设备连接TCP之前广播
     */
    public static final String BROADCAST = "/user/all/custom/gateway/broadcast";
    /**
     * 主网关回复
     */
    public static final String BROADCAST_REPLY = "/user/all/custom/gateway/broadcast_reply";
    /**
     * sid绑定房间
     */
    public static final String SID_BIND_ROOM = "/user/%s/custom/room/bind/add";
    /**
     * sid解绑房间
     */
    public static final String SID_DELETE_ROOM = "/user/%s/custom/room/bind/delete";
    /**
     * 心跳检测
     */
    public static final String HEARTBEAT = "/user/%s/custom/gateway/heartbeat";
//    public static final String HEARTBEAT="/user/%s/custom/gateway1/qqheartbeat";
    /**
     * 心跳检测回复
     */
    public static final String HEARTBEAT_REPLY = "/user/%s/custom/gateway/heartbeat_reply";
    public static final String NATIVE_ZIGBEE_DOWN = "/user/%s/custom/native/zigbee/down";
    public static final String NATIVE_ZIGBEE_DOWN_REPLY = "/user/%s/custom/native/zigbee/down_reply";
    public static final String NATIVE_ZIGBEE_UP = "/user/%s/custom/native/zigbee/up";
    public static final String NATIVE_ZIGBEE_DOWN_SLAVE = "/user/%s/custom/native/zigbee/down/slaveoid/%s";
    public static final String NATIVE_ZIGBEE_DOWN_SLAVE_REPLY = "/user/%s/custom/native/zigbee/down_reply/slaveoid/%s";
    public static final String NATIVE_ZIGBEE_UP_SLAVE = "/user/%s/custom/native/zigbee/up/slaveoid/%s";
    public static final String NATIVE_LINK_DOWN = "/user/%s/custom/native/a/down";
    public static final String NATIVE_LINK_DOWN_REPLY = "/user/%s/custom/native/a/down_reply";
    public static final String NATIVE_LINK_UP = "/user/%s/custom/native/a/up";
    public static final String NATIVE_LINK_DOWN_SLAVE = "/user/%s/custom/native/a/down/slaveoid/%s";
    public static final String NATIVE_LINK_DOWN_SLAVE_REPLY = "/user/%s/custom/native/a/down_reply/slaveoid/%s";
    public static final String NATIVE_LINK_UP_SLAVE = "/user/%s/custom/native/a/up/slaveoid/%s";
    public static final String GATEWAY_LOCATION_EDIT = "/user/%s/custom/gateway/location/edit";
    public static final String GATEWAY_LOCATION_GET = "/user/%s/custom/gateway/location/get";
    public static final String NATIVE_MODBUS_DOWN = "/user/%s/custom/native/inverter/down";
    public static final String NATIVE_MODBUS_UP = "/user/%s/custom/native/inverter/up";
    public static final String NATIVE_MODBUS_DOWN_REPLY = "/user/%s/custom/native/inverter/down_reply";
    public static final String NATIVE_MODBUS_DOWN_SLAVE = "/user/%s/custom/native/inverter/down/slaveoid/%s";
    public static final String NATIVE_MODBUS_DOWN_SLAVE_REPLY = "/user/%s/custom/native/inverter/down_reply/slaveoid/%s";
}
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -52,6 +52,8 @@
        return sHdlUniLogic;
    }
    //region ******【原生】和【小程序】通讯的方法 onOtherUniMPEventReceive();openUniMP();sendUni();******
    /**
     * 原生接收到uni发来的数据
     *
@@ -99,10 +101,10 @@
                        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
                            @Override
                            public void onSuccess(List<GatewayBean> gatewayBeanList) {
                                HDLUniMP.UniCallBackBaseBean callBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                                callBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_LIST);
                                callBackBaseBean.setData(gatewayBeanList);
                                sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, callBackBaseBean);
//                                HDLUniMP.UniCallBackBaseBean callBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
//                                callBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_LIST);
//                                callBackBaseBean.setData(gatewayBeanList);
//                                uniCallbackData(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, "", "", callBackBaseBean);
                            }
                            @Override
@@ -190,6 +192,10 @@
    public void checkRemoveOtherUniMPEventCallBack() {
        HDLUniMPSDKManager.getInstance().checkRemoveOtherUniMPEventCallBack(this);
    }
    //endregion
    //region ******一般方法******
    /**
     * 组装uni发送数据格式
@@ -284,6 +290,7 @@
            return "";
        }
    }
    //endregion
}