From 1d5420e54b4d542e3af7dcc4f1878092e15813ad Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期四, 13 二月 2020 22:01:48 +0800 Subject: [PATCH] 接收消息转义还原 --- app/src/main/java/safeluck/drive/evaluation/util/Utils.java | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java index e5bf8e6..a0548a7 100644 --- a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java +++ b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java @@ -71,4 +71,29 @@ Log.i(TAG,"杞箟杩囧悗锛�"+ ByteUtil.byte2hex(temp)); return temp; } + + /** + *鎺ユ敹娑堟伅鏃�:杞箟杩樺師 + * @param datas + * @return + */ + public static byte[] parseMsg(byte[] datas){ + byte[] temp = new byte[datas.length]; + int y =0 ; + for (int i = 0; i < datas.length; i++) { + if (datas[i]==0x7d && datas[i+1]==0x02 ){ + temp[y++] = 0x7e; + i++; + continue; + }else if (datas[i]==0x7d && datas[i+1]==0x01 ){ + + temp[y++] = 0x7d; + i++; + continue; + }else{ + temp[y++] = datas[i]; + } + } + return temp; + } } -- Gitblit v1.8.0