From 241c36e94bf70a14523c49bfffe0f354664a8b93 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 10 Apr 2013 22:27:31 +1200 Subject: Add GT-110M support (fix #190) --- .../traccar/protocol/MeiligaoProtocolDecoder.java | 34 +++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/org/traccar/protocol') 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("meiligao"); + + // Alarm + if (command == 0x9999) { + extendedInfo.append(""); + extendedInfo.append(buf.getUnsignedByte(offset)); + extendedInfo.append(""); + } + + // 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("meiligao"); - // Get device by id String id = getId(buf); try { -- cgit v1.2.3