| | |
| | |
|
| | |
|
| | | @Override
|
| | | protected synchronized LinkResponse decoder(Object msg) throws Exception {
|
| | | protected synchronized LinkResponse decoder(Object msg,String ipaddress) throws Exception {
|
| | | if (msg instanceof byte[]) {
|
| | | bytes.addAll(ByteUtils.toByteList((byte[]) msg));
|
| | | //如果多条命令打包在一条数据中,都需要处理完
|
| | |
| | | bytes.add(recevieBytes[i]);
|
| | | }
|
| | | LinkResponse response = new LinkResponse();
|
| | | response.setSource_ipAddress(ipaddress);
|
| | | response.setTopic(topic);
|
| | | if (HDLLinkConfig.getInstance().ifNeedEncrypt(response.getTopic())) {
|
| | | //需要解密
|
| | |
| | | response.setData(bodyString);
|
| | | LogUtils.i( "接收到数据:" + response.getTopic() + "\r\n" + response.getData());
|
| | | //非正常数据,返回
|
| | | if (!(bodyString.startsWith("{") || bodyString.startsWith("["))) {
|
| | | if (!((bodyString.startsWith("{") &&bodyString.endsWith("}"))
|
| | | || (bodyString.startsWith("[")&&bodyString.endsWith("]")))) {
|
| | | continue;
|
| | | }
|
| | | //解析完成,topic发送一次
|