package com.hdl.sdk.link; 
 | 
  
 | 
import android.content.Context; 
 | 
import android.text.TextUtils; 
 | 
import android.widget.Toast; 
 | 
  
 | 
import com.alibaba.fastjson.JSONArray; 
 | 
import com.alibaba.fastjson.JSONObject; 
 | 
import com.google.gson.JsonArray; 
 | 
import com.google.gson.JsonElement; 
 | 
import com.google.gson.JsonObject; 
 | 
import com.google.gson.reflect.TypeToken; 
 | 
import com.hdl.linkpm.sdk.core.exception.HDLLinkCopyException; 
 | 
import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; 
 | 
import com.hdl.sdk.link.bean.GatewayLocationBean; 
 | 
import com.hdl.sdk.link.bean.LinkGroupControlCreateBean; 
 | 
import com.hdl.sdk.link.bean.LinkIrDeviceBean; 
 | 
import com.hdl.sdk.link.bean.LinkOtaBean; 
 | 
import com.hdl.sdk.link.bean.LinkSidNameBean; 
 | 
import com.hdl.sdk.link.bean.MMWAreaBean; 
 | 
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.ErrorUtils; 
 | 
import com.hdl.sdk.link.common.utils.IdUtils; 
 | 
import com.hdl.sdk.link.common.utils.LogUtils; 
 | 
import com.hdl.sdk.link.common.utils.gson.GsonConvert; 
 | 
import com.hdl.sdk.link.bean.LinkCreateLogicBean; 
 | 
import com.hdl.sdk.link.bean.LinkCreateSceneBean; 
 | 
import com.hdl.sdk.link.bean.LinkEnableLogicBean; 
 | 
import com.hdl.sdk.link.bean.LinkEnableSecurityBean; 
 | 
import com.hdl.sdk.link.bean.LinkFunctionBean; 
 | 
import com.hdl.sdk.link.bean.LinkLogicBean; 
 | 
import com.hdl.sdk.link.bean.LinkOidBean; 
 | 
import com.hdl.sdk.link.bean.LinkReNameGWBean; 
 | 
import com.hdl.sdk.link.bean.LinkRoomBean; 
 | 
import com.hdl.sdk.link.bean.LinkRoomBindBean; 
 | 
import com.hdl.sdk.link.bean.LinkSceneBean; 
 | 
import com.hdl.sdk.link.bean.LinkSidStrBean; 
 | 
import com.hdl.sdk.link.bean.LinkSidUidBean; 
 | 
import com.hdl.sdk.link.core.bean.FileRequest; 
 | 
import com.hdl.sdk.link.core.bean.LinkRequest; 
 | 
import com.hdl.sdk.link.core.bean.LinkResponse; 
 | 
import com.hdl.sdk.link.core.bean.request.AuthenticateRequest; 
 | 
import com.hdl.sdk.link.core.bean.request.DeviceControlRequest; 
 | 
import com.hdl.sdk.link.core.bean.request.FunctionAttributeRequest; 
 | 
import com.hdl.sdk.link.core.bean.request.PropertyReadRequest; 
 | 
import com.hdl.sdk.link.core.bean.response.BaseLocalResponse; 
 | 
import com.hdl.sdk.link.core.bean.scenebatch.SceneCanDeleteInfo; 
 | 
import com.hdl.sdk.link.core.bean.scenebatch.SceneGroupInfo; 
 | 
import com.hdl.sdk.link.core.callback.GatewayCallBack; 
 | 
import com.hdl.sdk.link.core.callback.HDLLinkCallBack; 
 | 
import com.hdl.sdk.link.core.callback.HDLLinkResponseCallBack; 
 | 
import com.hdl.sdk.link.common.event.EventDispatcher; 
 | 
import com.hdl.sdk.link.common.event.EventListener; 
 | 
import com.hdl.sdk.link.core.callback.HDLLinkTCallBack; 
 | 
import com.hdl.sdk.link.core.config.HDLLinkConfig; 
 | 
import com.hdl.sdk.link.core.connect.HDLUdpConnect; 
 | 
import com.hdl.sdk.link.core.bean.gateway.GatewayBean; 
 | 
import com.hdl.sdk.link.core.connect.HDLConnectHelper; 
 | 
import com.hdl.sdk.link.core.utils.LinkResponseUtils; 
 | 
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; 
 | 
  
 | 
import java.lang.reflect.Type; 
 | 
import java.nio.charset.StandardCharsets; 
 | 
import java.util.ArrayList; 
 | 
import java.util.HashMap; 
 | 
import java.util.List; 
 | 
import java.util.Locale; 
 | 
import java.util.Map; 
 | 
  
 | 
/** 
 | 
 * Created by jlchen on 11/15/21. 
 | 
 * 
 | 
 * @Description : HDLLink 
 | 
 */ 
 | 
public class HDLLinkLocalSdk { 
 | 
    /** 
 | 
     * instance 
 | 
     */ 
 | 
    private volatile static HDLLinkLocalSdk instance; 
 | 
  
 | 
    /** 
 | 
     * getInstance 
 | 
     * 
 | 
     * @return HDLLink 
 | 
     */ 
 | 
    public static synchronized HDLLinkLocalSdk getInstance() { 
 | 
        if (instance == null) { 
 | 
            synchronized (HDLLinkLocalSdk.class) { 
 | 
                if (instance == null) { 
 | 
                    instance = new HDLLinkLocalSdk(); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        return instance; 
 | 
    } 
 | 
  
 | 
    private static Context context; 
 | 
  
 | 
  
 | 
    public void init(Context context) { 
 | 
        this.context = context.getApplicationContext(); 
 | 
  
 | 
        String[] gatewayErrors = context.getResources().getStringArray(R.array.gateway); 
 | 
        Map<String, String> codeAndMsgMap = new HashMap<>(); 
 | 
        for (String gatewayError : gatewayErrors) { 
 | 
            String codeMsg[] = gatewayError.split("="); 
 | 
            codeAndMsgMap.put(codeMsg[0], codeMsg[1]); 
 | 
        } 
 | 
        //初始化状态码多语言信息 
 | 
        ErrorUtils.errorsMap.putAll(codeAndMsgMap); 
 | 
    } 
 | 
  
 | 
    public Context getContext() { 
 | 
        return context; 
 | 
    } 
 | 
  
 | 
    public boolean isZh() { 
 | 
        Locale locale = getContext().getResources().getConfiguration().locale; 
 | 
        String language = locale.getLanguage(); 
 | 
        if (language.endsWith("zh")) 
 | 
            return true; 
 | 
        else 
 | 
            return false; 
 | 
    } 
 | 
  
 | 
    public static void showToast(String msg){ 
 | 
//        runOnUiThread(new Runnable() { 
 | 
//            @Override 
 | 
//            public void run() { 
 | 
//                try { 
 | 
//                    if (toast == null) { 
 | 
//                        toast = Toast.makeText(HDLGlobal.getInstance().getContext(), message, Toast.LENGTH_SHORT); 
 | 
//                    } else { 
 | 
//                        toast.setText(message); 
 | 
//                    } 
 | 
//                    toast.show(); 
 | 
//                } catch (Exception ignored) { 
 | 
// 
 | 
//                } 
 | 
//            } 
 | 
// 
 | 
//        }); 
 | 
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 设置打印是否开启 
 | 
     * 
 | 
     * @param enable 
 | 
     */ 
 | 
    public void setLogEnabled(boolean enable) { 
 | 
        LogUtils.setEnabled(enable); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 注册所有主题消息的监听 
 | 
     * 
 | 
     * @param listener 
 | 
     */ 
 | 
    public synchronized void registerAllTopicsListener(EventListener listener) { 
 | 
        EventDispatcher.getInstance().registerAllTopicsListener(listener); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 取消所有主题消息的监听 
 | 
     * 
 | 
     * @param listener 
 | 
     */ 
 | 
    public synchronized void removeAllTopicsListener(EventListener listener) { 
 | 
        if (listener == null) return; 
 | 
        EventDispatcher.getInstance().removeAllTopicsListener(listener); 
 | 
    } 
 | 
  
 | 
    /***********************三方设备和网关通信之前的认证流程****************************/ 
 | 
    /** 
 | 
     * 检测是否已经认证过 
 | 
     * 认证通过才能进行设备控制 
 | 
     * 
 | 
     * @return 
 | 
     */ 
 | 
    public boolean checkIfCertified() { 
 | 
        return HDLLinkConfig.getInstance().checkIfCertified(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 开始监听和发起入网及认证请求 
 | 
     * 
 | 
     * @param request  认证请求信息 
 | 
     * @param callBack 结果回调 
 | 
     */ 
 | 
    public void startAuthenticateRequest(AuthenticateRequest request, HDLLinkCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().startAuthenticateRequest(request, callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 发送入网及认证请求 
 | 
     * 
 | 
     * @param ip       网关IP 
 | 
     * @param request  认证请求信息 
 | 
     * @param callBack 结果回调 
 | 
     */ 
 | 
    public void sendAuthenticateRequest(String ip, AuthenticateRequest request, HDLLinkCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().sendAuthenticateRequest(ip, request, callBack); 
 | 
    } 
 | 
  
 | 
    /***********************三方设备请先认证成功 再调用下面的接口和网关通信****************************/ 
 | 
    /** 
 | 
     * 组播搜索指定网关是否在线,搜索到则返回指定的网关对象 
 | 
     * 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void searchGatewayMulticast(HDLUdpConnect.SearchGatewayCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().searchGatewayMulticast(callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 组播搜索指定网关是否在线,搜索到则返回指定的网关对象 
 | 
     * 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void searchGatewayBroadcast(HDLUdpConnect.SearchGatewayCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().searchGatewayBroadcast(callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取设备列表 
 | 
     */ 
 | 
    public void getDeviceList(HDLLinkTCallBack<List<LinkOidBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            String topic = String.format(TopicConstant.GET_DEVICE_LIST, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getDeviceList onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<List<LinkOidBean>>>() { 
 | 
                        }.getType(); 
 | 
                        List<LinkOidBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝/遥控器定位 
 | 
     */ 
 | 
    public void locationIr(String sid, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            List<JSONObject> stringList = new ArrayList<>(); 
 | 
            JSONObject jsonObject1 = new JSONObject(); 
 | 
            jsonObject1.put("sid", sid); 
 | 
            jsonObject1.put("duration_time", "5"); 
 | 
            stringList.add(jsonObject1); 
 | 
            jsonObject.put("objects", stringList); 
 | 
            String topic = String.format(TopicConstant.IR_FIND_REMOTE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("locationIr onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝删除(采用link协议通知删除并退网子设备拓扑关系) 
 | 
     */ 
 | 
    public void deleteLinkDevice(String oid, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            List<JSONObject> stringList = new ArrayList<>(); 
 | 
            JSONObject jsonObject1 = new JSONObject(); 
 | 
            jsonObject1.put("oid", oid); 
 | 
            stringList.add(jsonObject1); 
 | 
            jsonObject.put("objects", stringList); 
 | 
            String topic = String.format(TopicConstant.DELETING_GATEWAY_SLAVE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("deleteLinkDevice onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 遥控器删除(采用link协议通知删除并退网子设备拓扑关系) 
 | 
     */ 
 | 
    public void deleteIrControlDevice(String sid, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            List<JSONObject> stringList = new ArrayList<>(); 
 | 
            JSONObject jsonObject1 = new JSONObject(); 
 | 
            jsonObject1.put("sid", sid); 
 | 
            stringList.add(jsonObject1); 
 | 
            jsonObject.put("objects", stringList); 
 | 
            String topic = String.format(TopicConstant.DELETING_GATEWAY_SLAVE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("deleteIrControlDevice onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 设备控制 
 | 
     */ 
 | 
    public void controlDevice(Object object, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            List<Object> stringList = new ArrayList<>(); 
 | 
            stringList.add(object); 
 | 
            jsonObject.put("objects", stringList); 
 | 
            String topic = String.format(TopicConstant.PROPERTY_DOWN, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("controlDevice onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public void controlDevice(Object object, String gatewayId, String ipAddress, String mac, boolean encrypt, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        JSONObject jsonObject = new JSONObject(); 
 | 
        jsonObject.put("id", IdUtils.getUUId()); 
 | 
        jsonObject.put("time_stamp", time); 
 | 
        List<Object> stringList = new ArrayList<>(); 
 | 
        stringList.add(object); 
 | 
        jsonObject.put("objects", stringList); 
 | 
        String topic = String.format(TopicConstant.PROPERTY_DOWN, gatewayId); 
 | 
        LinkRequest request = new LinkRequest(topic, jsonObject.toString(), encrypt); 
 | 
        new HDLConnectHelper(ipAddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("controlDevice onSuccess"); 
 | 
                    callBack.onSuccess(""); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true, mac).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 更改主网关备注名 
 | 
     */ 
 | 
    public void changeGWName(String gateWayName, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<LinkReNameGWBean> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            LinkReNameGWBean linkReNameGWBean = new LinkReNameGWBean(); 
 | 
            linkReNameGWBean.setDevice_name(gateWayName); 
 | 
            data.setObjects(linkReNameGWBean); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_RENAME, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("changeGWName onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 更改从网关备注名 
 | 
     */ 
 | 
    public void changeCongGWName(String gateWayName, String gatewayId, String ipAddress, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<LinkReNameGWBean> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            LinkReNameGWBean linkReNameGWBean = new LinkReNameGWBean(); 
 | 
            linkReNameGWBean.setDevice_name(gateWayName); 
 | 
            data.setObjects(linkReNameGWBean); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_RENAME, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            request.setCloudTopic(String.format(TopicConstant.NATIVE_LINK_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayId)); 
 | 
            new HDLConnectHelper(ipAddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("changeCongGWName onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * sid更改名字 
 | 
     */ 
 | 
    public void sidNameChange(List<LinkSidNameBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidNameBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.EDIT_FUNCTION, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("sidNameChange onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public void sidNameChange(List<LinkSidNameBean> bean, String gatewayId, String ipaddress, boolean isLocalEncrypt, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        final BaseLocalResponse<List<LinkSidNameBean>> data = new BaseLocalResponse<>(); 
 | 
        data.setId(IdUtils.getUUId()); 
 | 
        data.setTime_stamp(time); 
 | 
        data.setObjects(bean); 
 | 
        String topic = String.format(TopicConstant.EDIT_FUNCTION, gatewayId); 
 | 
        LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), isLocalEncrypt); 
 | 
        new HDLConnectHelper(ipaddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("sidNameChange onSuccess"); 
 | 
                    callBack.onSuccess(""); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * sid绑定房间 
 | 
     */ 
 | 
    public void sidBindUid(List<LinkSidUidBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidUidBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SID_BIND_ROOM, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("sidBindUid onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * sid绑定房间 
 | 
     */ 
 | 
    public void sidBindUid(List<LinkSidUidBean> bean, String gatewayId, String ipaddress, boolean isLocalEncrypt, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        final BaseLocalResponse<List<LinkSidUidBean>> data = new BaseLocalResponse<>(); 
 | 
        data.setId(IdUtils.getUUId()); 
 | 
        data.setTime_stamp(time); 
 | 
        data.setObjects(bean); 
 | 
        String topic = String.format(TopicConstant.SID_BIND_ROOM, gatewayId); 
 | 
        LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), isLocalEncrypt); 
 | 
        new HDLConnectHelper(ipaddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("sidBindUid onSuccess"); 
 | 
                    callBack.onSuccess("Success"); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * sid删除绑定房间关系 
 | 
     */ 
 | 
    public void sidDeleteUid(List<LinkSidUidBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidUidBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SID_DELETE_ROOM, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("sidDeleteUid onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 创建场景 
 | 
     */ 
 | 
    public void createScene(List<LinkCreateSceneBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkCreateSceneBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.CREATE_SCENE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("createScene onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 编辑场景 批量处理组 
 | 
     */ 
 | 
    public void editSceneBatchGroup(List<SceneGroupInfo> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<SceneGroupInfo>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SCENE_EDIT, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("editSceneBatchGroup onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 编辑场景 批量处理删除 
 | 
     */ 
 | 
    public void editSceneBatchDelete(List<SceneCanDeleteInfo> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<SceneCanDeleteInfo>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SCENE_EDIT, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("editSceneBatchDelete onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 编辑场景 
 | 
     */ 
 | 
    public void editScene(List<LinkCreateSceneBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkCreateSceneBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SCENE_EDIT, gatewayId); 
 | 
            for (int i = 0; i < data.getObjects().size(); i++) { 
 | 
                if (data.getObjects().get(i).getFunctions().size() == 0) { 
 | 
                    data.getObjects().get(i).setFunctions(null); 
 | 
                } 
 | 
//                if (data.getObjects().get(i).getUids().size() == 0) { 
 | 
//                    data.getObjects().get(i).setUids(null); 
 | 
//                } 
 | 
            } 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("editScene onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 删除场景 
 | 
     */ 
 | 
    public void deleteScene(List<LinkSidStrBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SCENE_DELETE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("deleteScene onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取自动化列表 
 | 
     */ 
 | 
    public void getLogicList(HDLLinkTCallBack<List<LinkLogicBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            String topic = String.format(TopicConstant.LOGIC_LIST_GET, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getLogicList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkLogicBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkLogicBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取自动化详情 
 | 
     */ 
 | 
    public void getLogicDetail(List<LinkSidStrBean> list, HDLLinkTCallBack<List<LinkCreateLogicBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.LOGIC_GET, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getLogicDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkCreateLogicBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkCreateLogicBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 新建自动化 
 | 
     */ 
 | 
    public void createLogic(List<LinkCreateLogicBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkCreateLogicBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.LOGIC_EDIT, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("createLogic onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 开启关闭自动化 
 | 
     */ 
 | 
    public void enableLogic(List<LinkEnableLogicBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkEnableLogicBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.LOGIC_ENABLE_EDIT, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("enableLogic onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 删除自动化 
 | 
     */ 
 | 
    public void deleteLogic(List<LinkSidStrBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.LOGIC_DELETE, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("deleteLogic onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝试码 
 | 
     */ 
 | 
    public void irCodeTest(JSONObject content, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            JSONArray jsonArray = new JSONArray(); 
 | 
            jsonArray.add(content); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            jsonObject.put("objects", jsonArray); 
 | 
            String topic = String.format(TopicConstant.IR_CODE_TEST, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("irCodeTest onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝添加遥控器 
 | 
     */ 
 | 
    public void irDeviceAdd(JSONObject content, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            JSONArray jsonArray = new JSONArray(); 
 | 
            jsonArray.add(content); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            jsonObject.put("objects", jsonArray); 
 | 
            String topic = String.format(TopicConstant.IR_DEVICE_ADD, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneList onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝自学码 
 | 
     */ 
 | 
    public void irCodeStudy(JSONObject content, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            JSONArray jsonArray = new JSONArray(); 
 | 
            jsonArray.add(content); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            jsonObject.put("objects", jsonArray); 
 | 
            String topic = String.format(TopicConstant.IR_CODE_STUDY, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("irCodeStudy onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 红外宝自学码删除 
 | 
     */ 
 | 
    public void irCodeRemove(JSONObject content, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            JSONArray jsonArray = new JSONArray(); 
 | 
            jsonArray.add(content); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            jsonObject.put("objects", jsonArray); 
 | 
            String topic = String.format(TopicConstant.IR_CODE_REMOVE, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("irCodeRemove onSuccess"); 
 | 
                        callBack.onSuccess(""); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 红外宝遥控器列表获取 
 | 
     */ 
 | 
    public void irDeviceList(JSONObject content, HDLLinkTCallBack<List<LinkIrDeviceBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            JSONArray jsonArray = new JSONArray(); 
 | 
            jsonArray.add(content); 
 | 
            jsonObject.put("id", IdUtils.getUUId()); 
 | 
            jsonObject.put("time_stamp", time); 
 | 
            jsonObject.put("objects", jsonArray); 
 | 
            String topic = String.format(TopicConstant.IR_DEVICE_LIST, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("irDeviceList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkIrDeviceBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkIrDeviceBean> response = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (response == null) { 
 | 
                                callBack.onSuccess(new ArrayList<>()); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(response); 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 获取安防列表 
 | 
     */ 
 | 
    public void getSecurityList(HDLLinkTCallBack<List<LinkLogicBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.SECURITY_LIST_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSecurityList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkLogicBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkLogicBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取自动化详情 
 | 
     */ 
 | 
    public void getSecurityDetail(List<LinkSidStrBean> list, HDLLinkTCallBack<List<LinkCreateLogicBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(list); 
 | 
  
 | 
            String topic = String.format(TopicConstant.SECURITY_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSecurityDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkCreateLogicBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkCreateLogicBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 新建安防 
 | 
     */ 
 | 
    public void createSecurity(List<LinkCreateLogicBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkCreateLogicBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SECURITY_EDIT, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("createSecurity onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 删除安防 
 | 
     */ 
 | 
    public void deleteSecurity(List<LinkSidStrBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SECURITY_DELETE, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("deleteSecurity onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 开启关闭自动化 
 | 
     */ 
 | 
    public void enableSecurity(List<LinkEnableSecurityBean> bean, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkEnableSecurityBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.SECURITY_STATUS_SET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("enableSecurity onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 获取功能列表 
 | 
     */ 
 | 
    public void getFunctionList(HDLLinkTCallBack<List<LinkFunctionBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.GET_FUNCTION_LIST, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getFunctionList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkFunctionBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkFunctionBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 模拟云端ota 
 | 
     */ 
 | 
    public void otaDeviceUpgradeDown(String oid, String module, HDLLinkTCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkOtaBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            List<LinkOtaBean> bean = new ArrayList<>(); 
 | 
            LinkOtaBean linkOtaBean = new LinkOtaBean(); 
 | 
            linkOtaBean.setOid(oid); 
 | 
            linkOtaBean.setModule(module); 
 | 
            linkOtaBean.setSize(291710); 
 | 
            linkOtaBean.setSign_method("md5"); 
 | 
            linkOtaBean.setSign("05afc42e715b724e01b4ecd0ee2bde5d"); 
 | 
            linkOtaBean.setUrl("https://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2023/05/37886160-375a-4bf0-8a32-4093dac38679.ota"); 
 | 
            linkOtaBean.setVersion("V02.04.16"); 
 | 
            bean.add(linkOtaBean); 
 | 
            data.setObjects(bean); 
 | 
            String topic = String.format(TopicConstant.OTA_UPGRADE_DOWN, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getFunctionList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            callBack.onSuccess("Success"); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更改Sid备注名 
 | 
     */ 
 | 
    public void editSidName(BaseLocalResponse<List<JsonObject>> data, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
//            LinkReNameGWBean linkReNameGWBean = new LinkReNameGWBean(); 
 | 
//            linkReNameGWBean.setDevice_name(sidName); 
 | 
//            data.setObjects(linkReNameGWBean); 
 | 
            String topic = String.format(TopicConstant.EDIT_FUNCTION_ATTRIBUTE, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("editSidName onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取功能属性 
 | 
     * 支持批量 
 | 
     * 
 | 
     * @param sids 
 | 
     * @param callBack 
 | 
     */ 
 | 
    public void getFunctionAttribute(List<String> sids, HDLLinkTCallBack<List<LinkFunctionBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
  
 | 
            final BaseLocalResponse<List<FunctionAttributeRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            List<FunctionAttributeRequest> list = new ArrayList<>(); 
 | 
            for (String s : sids) { 
 | 
                list.add(new FunctionAttributeRequest(s)); 
 | 
            } 
 | 
            data.setObjects(list); 
 | 
  
 | 
            String topic = String.format(TopicConstant.GET_FUNCTION_ATTRIBUTE, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getFunctionAttribute onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkFunctionBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkFunctionBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 设备控制 
 | 
     * 
 | 
     * @param requestList 控制状态参数 
 | 
     * @param callBack    结果回调 
 | 
     */ 
 | 
    public void propertyDown(List<DeviceControlRequest> requestList, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
  
 | 
            final BaseLocalResponse<List<DeviceControlRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(requestList); 
 | 
            String topic = String.format(TopicConstant.PROPERTY_DOWN, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("propertyDown onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
  
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 服务调用 
 | 
     * 
 | 
     * @param topic    主题 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void serviceDown(String topic, JSONArray jsonArray, String ipAddress, boolean encrypt, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        final BaseLocalResponse<JSONArray> data = new BaseLocalResponse<>(); 
 | 
        data.setId(IdUtils.getUUId()); 
 | 
        data.setTime_stamp(time); 
 | 
        data.setObjects(jsonArray); 
 | 
  
 | 
        LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), encrypt); 
 | 
        new HDLConnectHelper(ipAddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("propertyRead onSuccess"); 
 | 
                    callBack.onSuccess(msg.toString()); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 服务调用 
 | 
     * 
 | 
     * @param topic    主题 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void serviceDown(String topic, JSONArray jsonArray, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<JSONArray> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(jsonArray); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("propertyRead onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 服务状态获取 
 | 
     * 
 | 
     * @param topic    主题 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void serviceRead(String topic, JSONArray jsonArray, String ipAddress, boolean encrypt, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        final BaseLocalResponse<JSONArray> data = new BaseLocalResponse<>(); 
 | 
        data.setId(IdUtils.getUUId()); 
 | 
        data.setTime_stamp(time); 
 | 
        data.setObjects(jsonArray); 
 | 
  
 | 
        LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), encrypt); 
 | 
        new HDLConnectHelper(ipAddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("propertyRead onSuccess"); 
 | 
                    callBack.onSuccess(msg.toString()); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 服务状态获取 
 | 
     * 
 | 
     * @param topic    主题 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void serviceRead(String topic, JSONArray jsonArray, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<JSONArray> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(jsonArray); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("propertyRead onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取毫米波区域 
 | 
     * 
 | 
     * @param sid      请求参数 指定读取的设备sid 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void getMillimeterArea(String sid, HDLLinkTCallBack<List<MMWAreaBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<PropertyReadRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
  
 | 
            List<PropertyReadRequest> list = new ArrayList<>(); 
 | 
            list.add(new PropertyReadRequest(sid)); 
 | 
            data.setObjects(list); 
 | 
  
 | 
            String topic = String.format(TopicConstant.MMW_AREA_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("propertyRead onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<List<MMWAreaBean>>>() { 
 | 
                        }.getType(); 
 | 
                        List<MMWAreaBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 读取状态 
 | 
     * 
 | 
     * @param sids     请求参数 指定读取的设备sid列表 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void propertyRead(List<String> sids, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<PropertyReadRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
  
 | 
            List<PropertyReadRequest> list = new ArrayList<>(); 
 | 
            for (String s : sids) { 
 | 
                list.add(new PropertyReadRequest(s)); 
 | 
            } 
 | 
            data.setObjects(list); 
 | 
  
 | 
            String topic = String.format(TopicConstant.PROPERTY_READ, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("propertyRead onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<String>>() { 
 | 
                        }.getType(); 
 | 
                        String list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 读取状态 
 | 
     * 
 | 
     * @param sids     请求参数 指定读取的设备sid列表 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void propertyRead(List<String> sids, String gatewayId, String ipAddress, String mac, boolean encrypt, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        final BaseLocalResponse<List<PropertyReadRequest>> data = new BaseLocalResponse<>(); 
 | 
        data.setId(IdUtils.getUUId()); 
 | 
        data.setTime_stamp(time); 
 | 
  
 | 
        List<PropertyReadRequest> list = new ArrayList<>(); 
 | 
        for (String s : sids) { 
 | 
            list.add(new PropertyReadRequest(s)); 
 | 
        } 
 | 
        data.setObjects(list); 
 | 
  
 | 
        String topic = String.format(TopicConstant.PROPERTY_READ, gatewayId); 
 | 
  
 | 
        LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), encrypt); 
 | 
        new HDLConnectHelper(ipAddress, request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("propertyRead onSuccess"); 
 | 
                    Type type = new TypeToken<BaseLocalResponse<String>>() { 
 | 
                    }.getType(); 
 | 
                    String list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                    if (list == null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                    } else { 
 | 
                        callBack.onSuccess(list); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true, mac).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取场景列表 
 | 
     */ 
 | 
    public void getSceneList(HDLLinkTCallBack<List<LinkSceneBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.SCENE_LIST_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkSceneBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkSceneBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public void getSceneListaa(HDLLinkTCallBack<List<LinkSceneBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        if (!TextUtils.isEmpty("18FE8588AC73E526")) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.SCENE_LIST_GET, "18FE8588AC73E526"); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper("192.168.1.100", request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkSceneBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkSceneBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public void getSceneListAiks(GatewayBean bean, HDLLinkTCallBack<List<LinkSceneBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
  
 | 
        if (!TextUtils.isEmpty(bean.getDevice_mac())) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.SCENE_LIST_GET, bean.getDevice_mac()); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), false); 
 | 
            new HDLConnectHelper(bean.getIp_address(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneList onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkSceneBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkSceneBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
  
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取场景详情 
 | 
     */ 
 | 
    public void getSceneDetail(List<LinkSidStrBean> list, HDLLinkTCallBack<List<LinkCreateSceneBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkSidStrBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.SCENE_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkCreateSceneBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkCreateSceneBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 场景控制 
 | 
     * 
 | 
     * @param sids     场景sid列表 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void controlScene(List<String> sids, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<PropertyReadRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
  
 | 
            List<PropertyReadRequest> list = new ArrayList<>(); 
 | 
            for (String s : sids) { 
 | 
                list.add(new PropertyReadRequest(s)); 
 | 
            } 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.SCENE_CONTROL, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("controlScene onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 场景控制 
 | 
     * 
 | 
     * @param sids     场景sid列表 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void controlAiksScene(GatewayBean bean, List<String> sids, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String device_mac = bean.getDevice_mac(); 
 | 
        if (!TextUtils.isEmpty(device_mac)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<PropertyReadRequest>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
  
 | 
            List<PropertyReadRequest> list = new ArrayList<>(); 
 | 
            for (String s : sids) { 
 | 
                list.add(new PropertyReadRequest(s)); 
 | 
            } 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.SCENE_CONTROL, device_mac); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), false); 
 | 
            new HDLConnectHelper(bean.getIp_address(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("controlScene onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 群控增删 
 | 
     */ 
 | 
    public void groupControlEdit(List<LinkGroupControlCreateBean> list, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkGroupControlCreateBean>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.GROUPCONTROL_EDIT, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            callBack.onSuccess(msg.toString()); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 群控控制 
 | 
     */ 
 | 
    public void groupControlControl(JSONObject object, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<JSONObject>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            List<JSONObject> objectList = new ArrayList<>(); 
 | 
            objectList.add(object); 
 | 
            data.setObjects(objectList); 
 | 
            String topic = String.format(TopicConstant.GROUPCONTROL_CONTROL, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            callBack.onSuccess(msg.toString()); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 群控删除 
 | 
     */ 
 | 
    public void groupControlDelete(JSONObject object, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<JSONObject>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            List<JSONObject> objectList = new ArrayList<>(); 
 | 
            objectList.add(object); 
 | 
            data.setObjects(objectList); 
 | 
            String topic = String.format(TopicConstant.GROUPCONTROL_DELETE, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            callBack.onSuccess(msg.toString()); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                        HDLLinkLocalSdk.showToast(hdlLinkCode.getMsg()); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 群控列表获取 
 | 
     */ 
 | 
    public void getGroupControlList(List<JSONObject> list, HDLLinkTCallBack<List<LinkGroupControlCreateBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<JSONObject>> data = new BaseLocalResponse<>(); 
 | 
            data.setId(IdUtils.getUUId()); 
 | 
            data.setTime_stamp(time); 
 | 
            data.setObjects(list); 
 | 
            String topic = String.format(TopicConstant.GROUPCONTROL_LIST_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(data), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getSceneDetail onSuccess"); 
 | 
                        if (callBack != null) { 
 | 
                            Type type = new TypeToken<BaseLocalResponse<List<LinkGroupControlCreateBean>>>() { 
 | 
                            }.getType(); 
 | 
                            List<LinkGroupControlCreateBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                            if (list == null) { 
 | 
                                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                            } else { 
 | 
                                callBack.onSuccess(list); 
 | 
                            } 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 通用UDP发送指令 
 | 
     * 1秒没响应就让他重新发送,重试3次 
 | 
     * 
 | 
     * @param topic    发送数据 
 | 
     * @param bodyStr  body内容 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void udpSendMsg(String topic, String bodyStr, HDLLinkResponseCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().udpSendMsg(topic, bodyStr, false, callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 通用广播UDP发送指令 
 | 
     * 1秒没响应就让他重新发送,重试3次 
 | 
     * 
 | 
     * @param topic    发送数据 
 | 
     * @param bodyStr  body内容 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void udpBroadcastSendMsg(String topic, String bodyStr, HDLLinkResponseCallBack callBack) { 
 | 
        HDLUdpConnect.getInstance().udpSendMsg(topic, bodyStr, true, callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 通用TCP发送指令 
 | 
     * 1秒没响应就让他重新发送,重试3次 
 | 
     * 
 | 
     * @param topic    发送数据 
 | 
     * @param body     body内容 
 | 
     * @param callBack 回调 
 | 
     */ 
 | 
    public void tcpSendMsg(String topic, String body, HDLLinkCallBack callBack) { 
 | 
  
 | 
        LinkRequest request = new LinkRequest(topic, body, HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
        new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
                if (msg instanceof LinkResponse) { 
 | 
                    LogUtils.i("sendMsg onSuccess"); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                if (callBack != null) { 
 | 
                    callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                } 
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 通用TCP发送指令 只发一次,不监听回复,不重发 
 | 
     * 
 | 
     * @param topic 发送数据 
 | 
     * @param body  回复的主题 
 | 
     */ 
 | 
    public void tcpSendMsg(String topic, String body) { 
 | 
        LinkRequest request = new LinkRequest(topic, body, HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
        new HDLConnectHelper(1, HDLLinkConfig.getInstance().getIpAddress(), request, true); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 创新网关列表,重新读取 
 | 
     * 
 | 
     * @param homeId   住宅Id 
 | 
     * @param callBack 回调所有读取到的网关列表 
 | 
     */ 
 | 
    public void refreshGatewayByHome(String homeId, GatewayCallBack callBack) { 
 | 
        HDLLinkLocalGateway.getInstance().refreshGatewayByHome(homeId, callBack); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 创新网关列表,重新读取 
 | 
     * 
 | 
     * @param callBack 回调所有读取到的网关列表 
 | 
     */ 
 | 
    public void refreshGateway(GatewayCallBack callBack) { 
 | 
        HDLLinkLocalGateway.getInstance().refreshGateway(callBack); 
 | 
    } 
 | 
  
 | 
    public void refreshGateway(GatewayCallBack callBack,List<String> spks) { 
 | 
        HDLLinkLocalGateway.getInstance().refreshGateway(callBack,spks); 
 | 
    } 
 | 
    /** 
 | 
     * 获取当前住宅缓存的所有网关,一般是调试软件使用,三方不用调试此方法 
 | 
     * 如果之前还没有读取过网关,先调用方法refreshGatewayByHome读取一次 
 | 
     * 
 | 
     * @return 
 | 
     */ 
 | 
    public List<GatewayBean> getGatewayByHome() { 
 | 
        return HDLLinkLocalGateway.getInstance().getGatewayList(); 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 获取房间列表 
 | 
     * 
 | 
     * @param callBack 
 | 
     */ 
 | 
    public void getRoomList(HDLLinkTCallBack<List<LinkRoomBean>> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
  
 | 
            String topic = String.format(TopicConstant.ROOM_LIST_GET, gatewayId); 
 | 
  
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getRoomList onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<List<LinkRoomBean>>>() { 
 | 
                        }.getType(); 
 | 
                        List<LinkRoomBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 全量更新房间列表 
 | 
     * 
 | 
     * @param list 
 | 
     * @param callBack 
 | 
     */ 
 | 
    public void coverAddRoomList(List<LinkRoomBean> list, HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<List<LinkRoomBean>> senData = new BaseLocalResponse<>(); 
 | 
            senData.setId(IdUtils.getUUId()); 
 | 
            senData.setTime_stamp(time); 
 | 
            senData.setObjects(list); 
 | 
  
 | 
            String topic = String.format(TopicConstant.ROOM_COVER_ADD, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(senData), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("coverAddRoomList onSuccess"); 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 全量更新房间列表 
 | 
     * 
 | 
     * @param callBack 
 | 
     */ 
 | 
    public void getGatewaylist(HDLLinkCallBack callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            final BaseLocalResponse<JSONObject> senData = new BaseLocalResponse<>(); 
 | 
            senData.setId(IdUtils.getUUId()); 
 | 
            senData.setTime_stamp(time); 
 | 
            JSONObject jsonObject = new JSONObject(); 
 | 
            jsonObject.put("device_mac", "0C811A93EA13F1F5"); 
 | 
            senData.setObjects(jsonObject); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_INFO, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, GsonConvert.getGson().toJson(senData), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        callBack.onSuccess(msg.toString()); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 获取房间绑定关系 
 | 
     */ 
 | 
    public void getRoomBindList(HDLLinkTCallBack<List<LinkRoomBindBean>> callBack, List<String> uidRoomList) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = HDLLinkConfig.getInstance().getGatewayId(); 
 | 
  
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            JsonArray array = new JsonArray(); 
 | 
            for (String uid : uidRoomList) { 
 | 
                array.add(uid); 
 | 
            } 
 | 
            jsonObject.add("objects", array); 
 | 
            String topic = String.format(TopicConstant.ROOM_BIND_LIST_GET, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getRoomBindList onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<List<LinkRoomBindBean>>>() { 
 | 
                        }.getType(); 
 | 
                        List<LinkRoomBindBean> list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
  
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 读取网关经纬度 
 | 
     */ 
 | 
    public void getGatewayLocation(String gatewayId, HDLLinkTCallBack<GatewayLocationBean> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_LOCATION_GET, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getGatewayLocation onSuccess"); 
 | 
                        Type type = new TypeToken<BaseLocalResponse<GatewayLocationBean>>() { 
 | 
                        }.getType(); 
 | 
                        GatewayLocationBean list = LinkResponseUtils.convertLinkResponse(msg, type); 
 | 
                        if (list == null) { 
 | 
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_PARSING_ERROR)); 
 | 
                        } else { 
 | 
                            callBack.onSuccess(list); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 设置网关经纬度 
 | 
     */ 
 | 
    public void gatewayLocation(GatewayBean bean, String longitude, String lat, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = bean.getGatewayId(); 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            JsonObject jsonObject1 = new JsonObject(); 
 | 
            jsonObject1.addProperty("longitude", longitude); 
 | 
            jsonObject1.addProperty("latitude", lat); 
 | 
            jsonObject.add("objects", jsonObject1); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_LOCATION_EDIT, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("getRoomBindList onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 刚刚绑定网关的时候设置网关经纬度  不需要加密 
 | 
     */ 
 | 
    public void gatewayLocation(String mGatewayId, String longitude, String lat, boolean isEncrypt, HDLLinkTCallBack<String> callBack) { 
 | 
        if (null == callBack) { 
 | 
            return; 
 | 
        } 
 | 
        String gatewayId = mGatewayId; 
 | 
        if (!TextUtils.isEmpty(gatewayId)) { 
 | 
            String time = String.valueOf(System.currentTimeMillis()); 
 | 
            JsonObject jsonObject = new JsonObject(); 
 | 
            jsonObject.addProperty("id", IdUtils.getUUId()); 
 | 
            jsonObject.addProperty("time_stamp", time); 
 | 
            JsonObject jsonObject1 = new JsonObject(); 
 | 
            jsonObject1.addProperty("longitude", longitude); 
 | 
            jsonObject1.addProperty("latitude", lat); 
 | 
            jsonObject.add("objects", jsonObject1); 
 | 
            String topic = String.format(TopicConstant.GATEWAY_LOCATION_EDIT, gatewayId); 
 | 
            LinkRequest request = new LinkRequest(topic, jsonObject.toString(), isEncrypt); 
 | 
            new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), request, new HDLConnectHelper.HdlSocketListener() { 
 | 
                @Override 
 | 
                public void onSucceed(Object msg) { 
 | 
                    if (msg instanceof LinkResponse) { 
 | 
                        LogUtils.i("gatewayLocation onSuccess"); 
 | 
                        callBack.onSuccess("Success"); 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                @Override 
 | 
                public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
                    HDLExceptionSubmitUtils.submit(topic, request, HDLLinkCopyException.getErrorWithCode(hdlLinkCode.getCode(), hdlLinkCode.getMsg())); 
 | 
                    if (callBack != null) { 
 | 
                        callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); 
 | 
                    } 
 | 
                } 
 | 
            }, true).send(); 
 | 
        } else { 
 | 
            if (callBack != null) { 
 | 
                callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /*********************** 文件传输 ****************************/ 
 | 
    /** 
 | 
     * 文件用途通知 
 | 
     * 
 | 
     * @param fileId   文件Id 
 | 
     * @param fileName 文件名称 
 | 
     * @param purpose  用途 用途枚举 
 | 
     *                 zigbee设备配置恢复: ConfigRecoveryForZigbeeDevices 
 | 
     *                 数据备份:DataBackup 
 | 
     *                 数据恢复:DataRecovery 
 | 
     * @param callBack 
 | 
     */ 
 | 
    public void sendFileUserNotification(String fileId, String fileName, String purpose, HDLLinkCallBack callBack) { 
 | 
        //帧格式:head+命令字+数据长度+二进制数据 
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
        String data = "hex" + "0001" + fileId + "\r\n" + fileName + "\r\n" + purpose; 
 | 
        byte[] dataBytes = data.getBytes(StandardCharsets.UTF_8); 
 | 
        FileRequest linkRequest = new FileRequest(fileId, 0x0011, dataBytes, HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
        linkRequest.setReplyTopic(linkRequest.getAckTopic()); 
 | 
        new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), linkRequest, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
  
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
  
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 发送文件相关命令 
 | 
     */ 
 | 
    public void sendFileCommand(byte[] dataBytes, Integer command, HDLLinkCallBack callBack) { 
 | 
        //帧格式:head+命令字+数据长度+二进制数据 
 | 
        String time = String.valueOf(System.currentTimeMillis()); 
 | 
//        byte []dataBytes=data.getBytes(StandardCharsets.UTF_8); 
 | 
        FileRequest linkRequest = new FileRequest("65531", command, dataBytes, HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
        linkRequest.setReplyTopic(linkRequest.getAckTopic()); 
 | 
        linkRequest.setCloudTopic(String.format(TopicConstant.NATIVE_LINK_DOWN, HDLLinkConfig.getInstance().getGatewayId())); 
 | 
        new HDLConnectHelper(HDLLinkConfig.getInstance().getIpAddress(), linkRequest, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
  
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
  
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
  
 | 
    /********************************驱动升级***********************************/ 
 | 
    /** 
 | 
     * 发送文件相关命令 
 | 
     */ 
 | 
    public void sendFileCommand(String ipAddress, byte[] dataBytes, String fileId, Integer command, HDLLinkCallBack callBack) { 
 | 
        //帧格式:head+命令字+数据长度+二进制数据 
 | 
        FileRequest linkRequest = new FileRequest(fileId, command, dataBytes, HDLLinkConfig.getInstance().isLocalEncrypt()); 
 | 
        linkRequest.setReplyTopic(linkRequest.getAckTopic()); 
 | 
        new HDLConnectHelper(ipAddress, linkRequest, new HDLConnectHelper.HdlSocketListener() { 
 | 
            @Override 
 | 
            public void onSucceed(Object msg) { 
 | 
  
 | 
            } 
 | 
  
 | 
            @Override 
 | 
            public void onFailure(HDLLinkCode hdlLinkCode) { 
 | 
  
 | 
            } 
 | 
        }, true).send(); 
 | 
    } 
 | 
  
 | 
} 
 |