From 516bfa1d3919e2236aba5c07348b2bd1234ed94f Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期三, 18 十二月 2019 14:56:11 +0800
Subject: [PATCH] 修改消息基类 @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); Log.i(TAG, "channelActive: ");
---
app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java b/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java
index 4448329..527c20c 100644
--- a/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java
@@ -23,7 +23,7 @@
//鏍囪瘑浣�
private byte MESSAGE_TAIL = 0x7e;
//鏍¢獙鐮� 鍏堟殏鏃跺啓姝�
- private int checkCode = 0x78;
+ private byte checkCode = 0x78;
/***===========浠ヤ笅鏄秷鎭ご=============***/
@@ -35,8 +35,8 @@
//娑堟伅浣撳睘鎬�
private int msg_property;
- //缁堢鎵嬫満鍙�
- private String phoneOnTerminal;
+ //缁堢鎵嬫満鍙� 瀛楃涓查暱搴﹀繀椤讳负16
+ private String phoneOnTerminal = "0008618513021245";
//13 娑堟伅娴佹按鍙� WORD 鎸夊彂閫侀『搴忎粠0寮�濮嬪惊鐜疮鍔�
public static short msg_serial_num=0;
@@ -65,29 +65,31 @@
//鏍囪瘑浣�
desBytes[pos] = MESSAGE_HEAD;
pos++;
+
+
//鍗忚鐗堟湰鍙�
byte[] protoVersion = ByteUtil.shortGetByte(protocol_version);
System.arraycopy(protoVersion,0,desBytes,pos,protoVersion.length);
pos +=protoVersion.length;
-//娑堟伅ID
+ //娑堟伅ID
byte[] msgIdBytes = ByteUtil.shortGetBytes(msg_id);
System.arraycopy(msgIdBytes,0,desBytes,pos,msgIdBytes.length);
pos+=msgIdBytes.length;
-//娑堟伅浣撳睘鎬�
+ //娑堟伅浣撳睘鎬�
byte[] msg_pro_bytes = ByteUtil.shortGetBytes((short)2);
System.arraycopy(msg_pro_bytes,0,desBytes,pos,msg_pro_bytes.length);
pos+=msg_pro_bytes.length;
//缁堢鎵嬫満鍙�
- byte[] phoneBytes = ByteUtil.str2Bcd("1234567890121518");
+ byte[] phoneBytes = ByteUtil.str2Bcd(phoneOnTerminal);
System.arraycopy(phoneBytes,0,desBytes,pos,phoneBytes.length);
pos+=phoneBytes.length;
-//娑堟伅娴佹按鍙�
+ //娑堟伅娴佹按鍙�
byte[] msg_serialNum = ByteUtil.shortGetBytes(msg_serial_num++);
System.arraycopy(msg_serialNum,0,desBytes,pos,msg_serialNum.length);
pos+=msg_serialNum.length;
-//淇濈暀
+ //淇濈暀
desBytes[pos] = 0;
pos++;
@@ -97,13 +99,15 @@
pos+=messageBodyBytes.length;
//鏍¢獙鐮�
- desBytes[pos] = 0x01;
+ // TODO: 2019/12/18 鏍¢獙鐮侀渶瑕佽绠� 杩樻湁杞箟闇�瑕佸鐞�
+ desBytes[pos] = checkCode;
pos++;
//鏈熬缁撴潫鏍囪瘑浣�
desBytes[pos] = MESSAGE_TAIL;
Log.i(TAG, "鍖呴暱搴�="+(pos+1));
Log.i(TAG, "鍖呭唴瀹�: "+ByteUtil.byte2HexStr(desBytes));
+
return desBytes;
}
--
Gitblit v1.8.0