|
@@ -1,6 +1,8 @@
|
|
|
package com.tidecloud.dataacceptance.service.impl;
|
|
|
|
|
|
import com.accept.client.DeviceMsgClient;
|
|
|
+import com.accept.model.DeviceMsgDto;
|
|
|
+import com.smartsanitation.common.util.StringUtil;
|
|
|
import com.tidecloud.dataacceptance.codec.HeaderTailDelimiterFrameDecoder;
|
|
|
import com.tidecloud.dataacceptance.common.*;
|
|
|
import com.tidecloud.dataacceptance.entity.YiTongGPSDevice;
|
|
@@ -60,8 +62,25 @@ public class GK309GpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
|
|
|
|
|
|
private static final Integer DATA_SIZE = 6;
|
|
|
|
|
|
- @Autowired
|
|
|
- private DeviceMsgClient deviceMsgClient;
|
|
|
+ private static final byte MARK = 0B00111100;
|
|
|
+
|
|
|
+ private static final byte SIGN_IN = 0B00000100;
|
|
|
+ private static final byte SIGN_OUT = 0B00001000;
|
|
|
+
|
|
|
+
|
|
|
+ private DeviceMsgClient deviceMsgClient = new DeviceMsgClient() {
|
|
|
+ @Override
|
|
|
+ public void acceptDeviceMsg(DeviceMsgDto deviceMsgDto) {
|
|
|
+ logger.info(StringUtil.convert2String(deviceMsgDto));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void acceptDeviceMsgParam(String s, String s1, Integer integer, String s2, Long aLong) {
|
|
|
+ logger.info("111");
|
|
|
+
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
@Override
|
|
|
protected void handle(ByteBuf in, Channel channel) throws Exception {
|
|
@@ -135,13 +154,30 @@ public class GK309GpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
|
|
|
short terminalReservedWord = in.readShort();
|
|
|
byte[] reservedWorkBytes = short2Bytes(terminalReservedWord);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ ByteBuf byteBuf = in.readBytes(13);
|
|
|
+ byteBuf.skipBytes(12);
|
|
|
+ byte b = byteBuf.readByte();
|
|
|
+
|
|
|
+ byte i = (byte) (b & MARK);
|
|
|
+
|
|
|
+
|
|
|
+ Byte signResponse = null;
|
|
|
+ if (i == SIGN_IN) {
|
|
|
+ signResponse = 0X01;
|
|
|
+ } else {
|
|
|
+ signResponse = 0x02;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- in.skipBytes(length - 8 - 2 - 2);
|
|
|
+ in.skipBytes(length - 8 - 2 - 2 - 15);
|
|
|
short serNum = in.readShort();
|
|
|
byte[] serNumBytes = short2Bytes(serNum);
|
|
|
|
|
|
-
|
|
|
- byte[] signResult = new byte[]{0x01, 0x01};
|
|
|
+
|
|
|
+ byte[] signResult = new byte[]{0x01, signResponse};
|
|
|
|
|
|
byte[] contentsOfPackage = mergeByteArray(new byte[]{0X0F, SIGN_IN_MSG},
|
|
|
dataBytes, signResult, reservedWorkBytes, serNumBytes);
|