刘卫锦
2023-08-14 bd80ca98ffb4f483ca2eba47051281fa69e790ac
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;
@@ -8,6 +9,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网关
@@ -23,4 +43,18 @@
        HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, isEncrypt, topic, jObject, sendPath, callBack);
    }
    /**
     * 发送数据到Link网关
     *
     * @param mac      网关mac
     * @param topic    请求主题
     * @param jObject  负载数据<没有填null></>
     * @param sendPath 发送路径<类名+方法名>class->methodName</>
     */
    public void sendDataToLinkGateway(String mac,
                                      String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) {
        HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, topic, jObject, sendPath, callBack);
    }
}