bd239f436776d16724a054ad11dffe917e0e4abd..4a4ed8210c58dba28deea1a6e69c3671ae1a7dd0
2021-12-10 JLChen
2021-12-10 1.更新
4a4ed8 对比 | 目录
2021-12-10 JLChen
2021-12-10 1.更新
a37eca 对比 | 目录
2021-12-10 JLChen
2021-12-10 1.开启UDP心跳
739d5b 对比 | 目录
2021-12-10 JLChen
2021-12-10 1.增加tcp和UDP 单次发送,不监听回复
dfb62a 对比 | 目录
11个文件已修改
397 ■■■■ 已修改文件
HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/app/src/main/java/com/hdl/hdlsdk/device/DevicesListAdapter.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/HDLLink.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK_DEMO/app/libs/hdl-common-V1.0.1.aar 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK_DEMO/app/libs/hdl-connect-V1.0.1.aar 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK_DEMO/app/libs/hdl-socket-V1.0.1.aar 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/MainActivity.java 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/device/DevicesListAdapter.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -19,14 +19,17 @@
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.hdlsdk.device.DevicesListActivity;
import com.hdl.sdk.common.config.TopicConstant;
import com.hdl.sdk.common.event.EventListener;
import com.hdl.sdk.common.exception.HDLLinkException;
import com.hdl.sdk.common.utils.IdUtils;
import com.hdl.sdk.common.utils.IpUtils;
import com.hdl.sdk.common.utils.gson.GsonConvert;
import com.hdl.sdk.connect.HDLLink;
import com.hdl.sdk.connect.bean.LinkRequest;
import com.hdl.sdk.connect.bean.LinkResponse;
import com.hdl.sdk.connect.bean.request.AuthenticateRequest;
import com.hdl.sdk.connect.bean.request.PropertyReadRequest;
@@ -100,6 +103,8 @@
        beans.add(new DemoBean("获取场景列表"));
        beans.add(new DemoBean("场景控制"));
        beans.add(new DemoBean("设备功能列表"));
        beans.add(new DemoBean("UDP发送"));
        beans.add(new DemoBean("TCP发送"));
        demoAdapter = new DemoAdapter(beans);
        rv.setAdapter(demoAdapter);
@@ -150,10 +155,21 @@
                        //功能列表
                        startDevicesListActivity();
                        break;
                    case 9:
                        //UDP发送
                        udpSend();
                        break;
                    case 10:
                        //TCP发送
                        tcpSend();
                        break;
                }
            }
        });
    }
    public void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }
@@ -231,9 +247,9 @@
        tv.setText("开始入网认证...");
        //认证提交参数准备
        String spkStr = "ir.module";//产品spk
        String macStr = "AA000000000000BB";//设备唯一MAC地址
        String secret = "87ae414b7a853f65";//通过spk和mac提交云端认证后分配的secret
        String spkStr = "screen.mirror";//产品spk
        String macStr = "AA000000000000AC";//设备唯一MAC地址
        String secret = "ee62124c151b737c";//通过spk和mac提交云端认证后分配的secret
        String mac_key = stringToMD5(stringToMD5(macStr + secret));
        String versionString = "HDL_V1.0.1";//
        String time = String.valueOf(System.currentTimeMillis());
@@ -241,7 +257,7 @@
        //1.设置认证信息
        AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean();
        requestBean.setMAC(macStr);
        requestBean.setSupplier("HDL");
        requestBean.setSupplier("raysgem");
        requestBean.setFirmwareVersion(versionString);
        requestBean.setHardwareModel("1956F");
        AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean();
@@ -256,7 +272,7 @@
        infoBean.setDeviceName("红外宝");//设备名字
        infoBean.setDeviceModel("HDL");//
        infoBean.setAccessMode("WIFI");
        infoBean.setIPGateway("192.168.12.1");
        infoBean.setIPGateway("192.168.88.1");
        infoBean.setIPAddress(IpUtils.getIP(this));
        infoBean.setOID("010105000000FE08");
@@ -469,4 +485,26 @@
        Intent intent = new Intent(this, DevicesListActivity.class);
        startActivity(intent);
    }
    /**
     * TCP发送 只发一次,不监听回复,不重发
     */
    private void tcpSend() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().tcpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString());
    }
    /**
     * 只发一次,不监听回复,不重发
     */
    private void udpSend() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().udpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString());
    }
}
HDLSDK/app/src/main/java/com/hdl/hdlsdk/device/DevicesListAdapter.java
@@ -1,9 +1,12 @@
package com.hdl.hdlsdk.device;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -14,7 +17,18 @@
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hdl.hdlsdk.DemoBean;
import com.hdl.hdlsdk.R;
import com.hdl.sdk.common.config.TopicConstant;
import com.hdl.sdk.common.exception.HDLLinkException;
import com.hdl.sdk.common.utils.IdUtils;
import com.hdl.sdk.common.utils.LogUtils;
import com.hdl.sdk.common.utils.gson.GsonConvert;
import com.hdl.sdk.connect.HDLLink;
import com.hdl.sdk.connect.bean.request.DeviceControlRequest;
import com.hdl.sdk.connect.bean.response.BaseLocalResponse;
import com.hdl.sdk.connect.callback.HDLLinkCallBack;
import com.hdl.sdk.connect.config.HDLLinkConfig;
import java.util.ArrayList;
import java.util.List;
public class DevicesListAdapter extends RecyclerView.Adapter<DevicesListAdapter.ViewHolder> {
@@ -50,6 +64,12 @@
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.item_tv.setText(mList.get(position).getName());
        holder.device_on_off_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                propertyDown(mList.get(position), isChecked);
            }
        });
    }
    @Override
@@ -60,10 +80,39 @@
    //自定义的ViewHolder,持有每个Item的的所有界面元素
    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView item_tv;
        public Switch device_on_off_switch;
        public ViewHolder(View view) {
            super(view);
            item_tv = (TextView) view.findViewById(R.id.device_title_tv);
            device_on_off_switch = view.findViewById(R.id.device_on_off_switch);
        }
    }
    private void propertyDown(FunctionBean functionBean, Boolean isOn){
        List<DeviceControlRequest> requestList = new ArrayList<>();
        DeviceControlRequest request = new DeviceControlRequest();
        request.setSid(functionBean.getSid());
        List<DeviceControlRequest.StatusBean>  statusBeanList= new ArrayList<>();
        DeviceControlRequest.StatusBean bean =  new DeviceControlRequest.StatusBean();
        bean.setKey("on_off");
        bean.setValue(isOn ? "on" : "off");
        statusBeanList.add(bean);
        request.setStatus(statusBeanList);
        requestList.add(request);
        String time = String.valueOf(System.currentTimeMillis());
        HDLLink.getInstance().propertyDown(requestList, new HDLLinkCallBack() {
            @Override
            public void onSuccess(String data) {
                Log.i("propertyDown",data);
            }
            @Override
            public void onError(HDLLinkException e) {
                Log.e("propertyDown", "ERROR :"+ e.getMsg());
            }
        });
    }
}
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/HDLLink.java
@@ -198,4 +198,24 @@
    public void tcpSendMsg(String topic, String bodyStr, HDLLinkCallBack callBack) {
        HDLSocket.getInstance().tcpSendMsg(topic, bodyStr, callBack);
    }
    /**
     * 通用发送指令 只发一次,不监听回复,不重发
     *
     * @param topic    发送数据
     * @param bodyStr  回复的主题
     */
    public void udpSendMsg(String topic, String bodyStr) {
        HDLAuthSocket.getInstance().udpSendMsg(topic, bodyStr);
    }
    /**
     * 通用TCP发送指令 只发一次,不监听回复,不重发
     *
     * @param topic    发送数据
     * @param bodyStr  回复的主题
     */
    public void tcpSendMsg(String topic, String bodyStr) {
        HDLSocket.getInstance().tcpSendMsg(topic, bodyStr);
    }
}
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
@@ -99,7 +99,9 @@
        pipeLine.add(new LinkMessageDecoder());
        pipeLine.add(new LinkMessageEncoder());
        options.setHandleMessage(pipeLine);
        options.setEnabledHeartbeat(false);
        options.setHeartbeatTimeInterval(10*1000L);
        options.setHeartbeatData("UDP");
        options.setEnabledHeartbeat(true);//是否开启心跳包发送检测
        return options;
    }
@@ -170,20 +172,31 @@
            @Override
            public void onSucceed(Object msg) {
                if (callBack == null) return;
                AuthenticateResponse bean = getAuthenticateResponseBean(msg);
                if (bean != null) {
                    String localSecret = bean.getAuth().getLocalSecret();
                    String gatewayId = bean.getObjects().getGatewayID();
                    String ipAddress = bean.getObjects().getIPAddress();
                    //判断网关是否已经注册到云端
                    if (TextUtils.isEmpty(localSecret) || TextUtils.isEmpty(gatewayId)) {
                        //认证失败,网关未注册到云端
                        callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
                try {
                    AuthenticateResponse bean = getAuthenticateResponseBean(msg);
                    if (bean != null) {
                        String localSecret = "";
                        String gatewayId = "";
                        String ipAddress = "";
                        if(bean.getAuth() != null) {
                            localSecret = bean.getAuth().getLocalSecret();
                        }
                        if(bean.getObjects() != null){
                             gatewayId = bean.getObjects().getGatewayID();
                             ipAddress = bean.getObjects().getIPAddress();
                        }
                        //判断网关是否已经注册到云端
                        if (TextUtils.isEmpty(localSecret) || TextUtils.isEmpty(gatewayId)) {
                            //认证失败,网关未注册到云端
                            callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
                        } else {
                            HDLLinkConfig.getInstance().saveConfig(localSecret, gatewayId, ipAddress);
                            callBack.onSuccess("认证成功");
                        }
                    } else {
                        HDLLinkConfig.getInstance().saveConfig(localSecret, gatewayId, ipAddress);
                        callBack.onSuccess("认证成功");
                        callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_ERROR));
                    }
                } else {
                } catch (Exception e) {
                    callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_ERROR));
                }
            }
@@ -285,8 +298,6 @@
    }
    /**
     * 设备控制
     */
@@ -350,6 +361,21 @@
        );
    }
    /**
     * 通用发送指令 只发一次,不监听回复,不重发
     *
     * @param topic   发送数据
     * @param bodyStr 回复的主题
     */
    public void udpSendMsg(String topic, String bodyStr) {
        if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) {
            LogUtils.e("udpSendMsg", "参数不能为空");
            return;
        }
        LinkRequest message = new LinkRequest(topic, bodyStr);
        String ip = IpUtils.getBroadcastAddress();
        getUdpBoot(ip).sendMsg(message.getSendBytes());
    }
    private GatewaySearchBean getGatewaySearchBean(Object msg) {
        GatewaySearchBean searchBean = null;
@@ -399,13 +425,15 @@
    /**
     * 网关搜索相关
     */
    private static final int MAX_SEARCH_COUNT  = 10;//总共搜索测试
    private final AtomicInteger searchGatewayCount = new AtomicInteger(0);;
    private static final int MAX_SEARCH_COUNT = 10;//总共搜索测试
    private final AtomicInteger searchGatewayCount = new AtomicInteger(0);
    ;
    private final AtomicBoolean isSearchGatewaySuccess = new AtomicBoolean(true);
    private String searchGatewayId = "";
    private SearchGatewayCallBack mSearchGatewayCallBack;
    private void initSearchGatewayEvent(){
        LogUtils.i("搜索网关--","initSearchGatewayEvent");
    private void initSearchGatewayEvent() {
        LogUtils.i("搜索网关--", "initSearchGatewayEvent");
        searchGatewayEvent = new EventListener() {
            @Override
            public void onMessage(Object msg) {
@@ -425,7 +453,7 @@
                                    searchGatewayCount.set(11);//次数标记
                                    HDLLinkConfig.getInstance().setCurrentGateway(searchBean);//设置当前网关
                                    HDLLinkConfig.getInstance().setLocalEncrypt(searchBean.isLocalEncrypt());//设置是否加密
                                    if(mSearchGatewayCallBack != null){
                                    if (mSearchGatewayCallBack != null) {
                                        mSearchGatewayCallBack.onSuccess(searchBean);
                                    }
                                }
@@ -463,11 +491,11 @@
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (searchGatewayCount.get() < 10 && (!isSearchGatewaySuccess.get()) ) {
                while (searchGatewayCount.get() < 10 && (!isSearchGatewaySuccess.get())) {
                    try {
                        //搜索网关
                        searchGatewayCount.set(searchGatewayCount.get() + 1);
                        LogUtils.i("搜索网关--","搜索网关第"+searchGatewayCount.get()+"次");
                        LogUtils.i("搜索网关--", "搜索网关第" + searchGatewayCount.get() + "次");
                        getUdpBoot(ip).sendMsg(message.getSendBytes());
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {
@@ -475,10 +503,10 @@
                    }
                }
                if(!isSearchGatewaySuccess.get()){
                if (!isSearchGatewaySuccess.get()) {
                    //搜索10次,指定网关都没回复,回调超时
                    callBackSearchGatewayTimeout();
                    LogUtils.e("搜索网关--","搜索10次,指定网关都没回复,回调超时");
                    LogUtils.e("搜索网关--", "搜索10次,指定网关都没回复,回调超时");
                }
            }
        }).start();
@@ -488,27 +516,28 @@
    /**
     * 注册搜索网关监听
     */
    private void registerSearchGatewayEvent(){
        LogUtils.i("搜索网关--","注册搜索网关监听");
    private void registerSearchGatewayEvent() {
        LogUtils.i("搜索网关--", "注册搜索网关监听");
        EventDispatcher.getInstance().registerIo(TopicConstant.GATEWAY_SEARCH_REPLY, searchGatewayEvent);
    }
    /**
     * 移除搜索网关监听
     */
    private void removeSearchGatewayEvent(){
        LogUtils.i("搜索网关--","移除搜索网关监听");
    private void removeSearchGatewayEvent() {
        LogUtils.i("搜索网关--", "移除搜索网关监听");
        EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_SEARCH_REPLY, searchGatewayEvent);
    }
    /**
     * 回调搜索网关超时
     */
    private void callBackSearchGatewayTimeout(){
    private void callBackSearchGatewayTimeout() {
        removeSearchGatewayEvent();
        ThreadToolUtils.getInstance().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if(mSearchGatewayCallBack != null){
                if (mSearchGatewayCallBack != null) {
                    mSearchGatewayCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_SEARCH_GATEWAY_TIMEOUT_ERROR));
                }
            }
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java
@@ -166,7 +166,10 @@
        pipeLine.add(new LinkMessageDecoder());
        pipeLine.add(new LinkMessageEncoder());
        options.setHandleMessage(pipeLine);
        options.setEnabledHeartbeat(false);
        options.setEnabledHeartbeat(false);//是否开启心跳包发送检测
//        options.setHeartbeatTimeInterval(10*1000L);
//        options.setHeartbeatData("TCP");
//        options.setEnabledHeartbeat(true);//是否开启心跳包发送检测
        return options;
    }
@@ -682,6 +685,24 @@
        }
    }
    /**
     * 通用TCP发送指令 只发一次,不监听回复,不重发
     *
     * @param topic    发送数据
     * @param bodyStr  回复的主题
     */
    public void tcpSendMsg(String topic, String bodyStr) {
        try {
            if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) {
                LogUtils.e("udpSendMsg", "参数不能为空");
                return;
            }
            LinkRequest message = new LinkRequest(topic, bodyStr);
            getTcp().sendMsg(message.getSendBytes());
        } catch (Exception e) {
            LogUtils.e("tcpSendMsg", "发送失败 :"+e.getMessage());
        }
    }
    /**
     * 发送指令
HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java
@@ -209,7 +209,7 @@
            @Override
            public void run() {
                if (isRun.get()) {
                    LogUtils.d("====", "===发送心跳包===");
//                    LogUtils.d("====", "===发送心跳包===");
                    if (client.getOptions() != null) {
                        final byte[] heartBeat = client.getOptions().getHeartbeatData();
                        if (heartBeat != null) {
HDLSDK_DEMO/app/libs/hdl-common-V1.0.1.aar
Binary files differ
HDLSDK_DEMO/app/libs/hdl-connect-V1.0.1.aar
Binary files differ
HDLSDK_DEMO/app/libs/hdl-socket-V1.0.1.aar
Binary files differ
HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -19,14 +19,17 @@
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.hdlsdk.device.DevicesListActivity;
import com.hdl.sdk.common.config.TopicConstant;
import com.hdl.sdk.common.event.EventListener;
import com.hdl.sdk.common.exception.HDLLinkException;
import com.hdl.sdk.common.utils.IdUtils;
import com.hdl.sdk.common.utils.IpUtils;
import com.hdl.sdk.common.utils.gson.GsonConvert;
import com.hdl.sdk.connect.HDLLink;
import com.hdl.sdk.connect.bean.LinkRequest;
import com.hdl.sdk.connect.bean.LinkResponse;
import com.hdl.sdk.connect.bean.request.AuthenticateRequest;
import com.hdl.sdk.connect.bean.request.PropertyReadRequest;
@@ -100,13 +103,17 @@
        beans.add(new DemoBean("获取场景列表"));
        beans.add(new DemoBean("场景控制"));
        beans.add(new DemoBean("设备功能列表"));
        beans.add(new DemoBean("UDP发送,监听主题回复,带重发带回调"));
        beans.add(new DemoBean("TCP发送,监听主题回复,带重发带回调"));
        beans.add(new DemoBean("UDP发送,不回调不重发"));
        beans.add(new DemoBean("TCP发送,不回调不重发"));
        demoAdapter = new DemoAdapter(beans);
        rv.setAdapter(demoAdapter);
//        final SocketOptions options = new SocketOptions();
//
        MessagePipeLine pipeLine = new MessagePipeLine();
//        MessagePipeLine pipeLine = new MessagePipeLine();
//        options.setHandleMessage(pipeLine);
//        options.setEnabledHeartbeat(false);
@@ -150,10 +157,29 @@
                        //功能列表
                        startDevicesListActivity();
                        break;
                    case 9:
                        //UDP发送
                        udpSendWithCallback();
                        break;
                    case 10:
                        //TCP发送
                        tcpSendWithCallback();
                    case 11:
                        //UDP发送
                        udpSend();
                        break;
                    case 12:
                        //TCP发送
                        tcpSend();
                        break;
                }
            }
        });
    }
    public void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }
@@ -176,13 +202,6 @@
            @Override
            public void onMessage(Object msg) {
                LinkResponse response = (LinkResponse)msg;
                if(response != null){
                    Log.i(TAG, "AllTopicsListener"
                            + "\nTopic: " + response.getTopic()
                            +"\n Data: " + response.getData());
                    handleLinkResponse(response);
                }
            }
        };
        HDLLink.getInstance().registerAllTopicsListener(allTopicsListener);
@@ -238,9 +257,9 @@
        tv.setText("开始入网认证...");
        //认证提交参数准备
        String spkStr = "ir.module";//产品spk
        String macStr = "AA000000000000BB";//设备唯一MAC地址
        String secret = "87ae414b7a853f65";//通过spk和mac提交云端认证后分配的secret
        String spkStr = "screen.mirror";//产品spk
        String macStr = "AA000000000000AC";//设备唯一MAC地址
        String secret = "ee62124c151b737c";//通过spk和mac提交云端认证后分配的secret
        String mac_key = stringToMD5(stringToMD5(macStr + secret));
        String versionString = "HDL_V1.0.1";//
        String time = String.valueOf(System.currentTimeMillis());
@@ -248,7 +267,7 @@
        //1.设置认证信息
        AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean();
        requestBean.setMAC(macStr);
        requestBean.setSupplier("HDL");
        requestBean.setSupplier("raysgem");
        requestBean.setFirmwareVersion(versionString);
        requestBean.setHardwareModel("1956F");
        AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean();
@@ -263,7 +282,7 @@
        infoBean.setDeviceName("红外宝");//设备名字
        infoBean.setDeviceModel("HDL");//
        infoBean.setAccessMode("WIFI");
        infoBean.setIPGateway("192.168.12.1");
        infoBean.setIPGateway("192.168.88.1");
        infoBean.setIPAddress(IpUtils.getIP(this));
        infoBean.setOID("010105000000FE08");
@@ -476,4 +495,70 @@
        Intent intent = new Intent(this, DevicesListActivity.class);
        startActivity(intent);
    }
    /**
     * TCP发送,监听主题回复,带重发带回调
     */
    private void tcpSendWithCallback() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().tcpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString(), new HDLLinkCallBack() {
            @Override
            public void onSuccess(String data) {
                responseTv.setText(data);
            }
            @Override
            public void onError(HDLLinkException e) {
                responseTv.setText(e.getMsg());
            }
        });
    }
    /**
     * UDP发送,监听主题回复,带重发带回调
     */
    private void udpSendWithCallback() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().udpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString(), new HDLLinkResponseCallBack() {
            @Override
            public void onSuccess(LinkResponse linkResponse) {
                if(linkResponse != null){
                    responseTv.setText(linkResponse.getData());
                }
            }
            @Override
            public void onError(HDLLinkException e) {
                responseTv.setText(e.getMsg());
            }
        });
    }
    /**
     * TCP发送 只发一次,不监听回复,不重发
     */
    private void tcpSend() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().tcpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString());
    }
    /**
     * 只发一次,不监听回复,不重发
     */
    private void udpSend() {
        String time = String.valueOf(System.currentTimeMillis());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", IdUtils.getUUId());
        jsonObject.addProperty("time_stamp", time);
        HDLLink.getInstance().udpSendMsg(TopicConstant.GATEWAY_SEARCH, jsonObject.toString());
    }
}
HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/device/DevicesListAdapter.java
@@ -1,16 +1,34 @@
package com.hdl.hdlsdk.device;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hdl.hdlsdk.DemoBean;
import com.hdl.hdlsdk.R;
import com.hdl.sdk.common.config.TopicConstant;
import com.hdl.sdk.common.exception.HDLLinkException;
import com.hdl.sdk.common.utils.IdUtils;
import com.hdl.sdk.common.utils.LogUtils;
import com.hdl.sdk.common.utils.gson.GsonConvert;
import com.hdl.sdk.connect.HDLLink;
import com.hdl.sdk.connect.bean.request.DeviceControlRequest;
import com.hdl.sdk.connect.bean.response.BaseLocalResponse;
import com.hdl.sdk.connect.callback.HDLLinkCallBack;
import com.hdl.sdk.connect.config.HDLLinkConfig;
import java.util.ArrayList;
import java.util.List;
public class DevicesListAdapter extends RecyclerView.Adapter<DevicesListAdapter.ViewHolder> {
@@ -46,6 +64,12 @@
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.item_tv.setText(mList.get(position).getName());
        holder.device_on_off_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                propertyDown(mList.get(position), isChecked);
            }
        });
    }
    @Override
@@ -56,10 +80,39 @@
    //自定义的ViewHolder,持有每个Item的的所有界面元素
    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView item_tv;
        public Switch device_on_off_switch;
        public ViewHolder(View view) {
            super(view);
            item_tv = (TextView) view.findViewById(R.id.device_title_tv);
            device_on_off_switch = view.findViewById(R.id.device_on_off_switch);
        }
    }
    private void propertyDown(FunctionBean functionBean, Boolean isOn){
        List<DeviceControlRequest> requestList = new ArrayList<>();
        DeviceControlRequest request = new DeviceControlRequest();
        request.setSid(functionBean.getSid());
        List<DeviceControlRequest.StatusBean>  statusBeanList= new ArrayList<>();
        DeviceControlRequest.StatusBean bean =  new DeviceControlRequest.StatusBean();
        bean.setKey("on_off");
        bean.setValue(isOn ? "on" : "off");
        statusBeanList.add(bean);
        request.setStatus(statusBeanList);
        requestList.add(request);
        String time = String.valueOf(System.currentTimeMillis());
        HDLLink.getInstance().propertyDown(requestList, new HDLLinkCallBack() {
            @Override
            public void onSuccess(String data) {
                Log.i("propertyDown",data);
            }
            @Override
            public void onError(HDLLinkException e) {
                Log.e("propertyDown", "ERROR :"+ e.getMsg());
            }
        });
    }
}