diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-04-10 22:27:31 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-04-10 22:27:31 +1200 |
commit | 241c36e94bf70a14523c49bfffe0f354664a8b93 (patch) | |
tree | c615c0cc36b545b55e0e8bc78756cd81e623241d /src/org/traccar | |
parent | a946d34d83b76023dcf7cbec23519078a1169749 (diff) | |
download | traccar-server-241c36e94bf70a14523c49bfffe0f354664a8b93.tar.gz traccar-server-241c36e94bf70a14523c49bfffe0f354664a8b93.tar.bz2 traccar-server-241c36e94bf70a14523c49bfffe0f354664a8b93.zip |
Add GT-110M support (fix #190)
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 7181456fe..9a5cfb134 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,13 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + //"134743.003,A,0648.9866,S,10707.5795,E,000.0,000.0,260313" + /** * Regular expressions pattern */ static private Pattern pattern = Pattern.compile( - "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) "([AV])," + // Validity "(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) "([NS])," + @@ -50,8 +52,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { "(\\d+.\\d+)," + // Speed "(\\d+\\.?\\d*)?," + // Course "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) - "[^\\|]*\\|(\\d+\\.\\d)\\|" + // Dilution of precision - "(\\d+\\.?\\d*)\\|" + // Altitude + "(?:[^\\|]*\\|(\\d+\\.\\d+)\\|" + // Dilution of precision + "(\\d+\\.?\\d*)\\|)?" + // Altitude "([0-9a-fA-F]+)?" + // State "(?:\\|([0-9a-fA-F]+),([0-9a-fA-F]+))?" + // ADC "(?:\\|([0-9a-fA-F]+))?" + // Cell @@ -82,14 +84,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { return id; } - /** - * Decode message - */ @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { - + ChannelBuffer buf = (ChannelBuffer) msg; int command = buf.getUnsignedShort(7); @@ -113,8 +112,21 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { return null; } - // Data offset + // Payload offset int offset = 7 + 2; + + // Create new position + Position position = new Position(); + StringBuilder extendedInfo = new StringBuilder("<protocol>meiligao</protocol>"); + + // Alarm + if (command == 0x9999) { + extendedInfo.append("<alarm>"); + extendedInfo.append(buf.getUnsignedByte(offset)); + extendedInfo.append("</alarm>"); + } + + // Data offset if (command == 0x9955) { offset += 0; } else if (command == 0x9016) { @@ -125,10 +137,6 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { return null; } - // Create new position - Position position = new Position(); - StringBuilder extendedInfo = new StringBuilder("<protocol>meiligao</protocol>"); - // Get device by id String id = getId(buf); try { |