| | |
| | | package com.hdl.sdk.connect.protocol;
|
| | |
|
| | |
|
| | | import android.annotation.TargetApi;
|
| | | import android.os.Build;
|
| | | import android.util.Log;
|
| | |
|
| | |
|
| | | import com.google.gson.internal.bind.DateTypeAdapter;
|
| | | import com.hdl.sdk.common.utils.LogUtils;
|
| | | import com.hdl.sdk.connect.config.HDLLinkConfig;
|
| | | import com.hdl.sdk.common.event.EventDispatcher;
|
| | | import com.hdl.sdk.common.utils.ByteUtils;
|
| | | import com.hdl.sdk.common.utils.LogUtils;
|
| | | import com.hdl.sdk.connect.bean.LinkResponse;
|
| | | import com.hdl.sdk.connect.config.HDLLinkConfig;
|
| | | import com.hdl.sdk.connect.utils.AesUtil;
|
| | | import com.hdl.sdk.connect.utils.ProtocolParse;
|
| | | import com.hdl.sdk.socket.codec.ByteToMessageDecoder;
|
| | |
|
| | | import java.util.ArrayList;
|
| | |
| | | }
|
| | |
|
| | | list.clear();
|
| | | for(int i=0;i<tempList.size();i++){
|
| | | for (int i = 0; i < tempList.size(); i++) {
|
| | | list.add(tempList.get(i));
|
| | | }
|
| | | }
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | protected synchronized LinkResponse decoder(Object msg,String ipaddress) throws Exception {
|
| | | protected synchronized LinkResponse decoder(Object msg, String ipaddress) throws Exception {
|
| | | if (msg instanceof byte[]) {
|
| | | bytes.addAll(ByteUtils.toByteList((byte[]) msg));
|
| | | //如果多条命令打包在一条数据中,都需要处理完
|
| | |
| | |
|
| | | String bodyString = new String(body, "utf-8");
|
| | | response.setData(bodyString);
|
| | | LogUtils.i( "接收到数据:" + response.getTopic() + "\r\n" + response.getData());
|
| | | LogUtils.i("接收到数据:" + response.getTopic() + "\r\n" + response.getData());
|
| | | //非正常数据,返回
|
| | | if (!((bodyString.startsWith("{") &&bodyString.endsWith("}"))
|
| | | || (bodyString.startsWith("[")&&bodyString.endsWith("]")))) {
|
| | | if (!((bodyString.startsWith("{") && bodyString.endsWith("}"))
|
| | | || (bodyString.startsWith("[") && bodyString.endsWith("]")))) {
|
| | | continue;
|
| | | }
|
| | | //解析完成,topic发送一次
|