diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-03-01 21:02:27 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-03-01 21:02:27 +1300 |
commit | 352a94ba7c3c9162afb4175e6c49515188544797 (patch) | |
tree | f6dd6730a9e95e4bd9185da72423a37758766792 /src/org | |
parent | f78f17199b8f00ac92e1a96c6c8b6981876020a2 (diff) | |
download | traccar-server-352a94ba7c3c9162afb4175e6c49515188544797.tar.gz traccar-server-352a94ba7c3c9162afb4175e6c49515188544797.tar.bz2 traccar-server-352a94ba7c3c9162afb4175e6c49515188544797.zip |
Improve GPS103 date decoding
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 0fa5bb4d2..2e3620179 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.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. @@ -26,14 +26,8 @@ import org.traccar.ServerManager; import org.traccar.helper.Log; import org.traccar.model.Position; -/** - * Gps 103 tracker protocol decoder - */ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { - /** - * Initialize - */ public Gps103ProtocolDecoder(ServerManager serverManager) { super(serverManager); } @@ -45,8 +39,8 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "imei:" + "(\\d+)," + // IMEI "([^,]+)," + // Alarm - "(\\d{2})(\\d{2})(\\d{2})" + // Local Date - "(\\d{2})(\\d{2})," + // Local Time + "(\\d{2})/?(\\d{2})/?(\\d{2})\\s?" + // Local Date + "(\\d{2}):?(\\d{2})," + // Local Time "[^,]*," + "[FL]," + // F - full / L - low "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time UTC (HHMMSS.SSS) @@ -59,9 +53,6 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "(\\d+\\.\\d+)?" + // Course ".*"); - /** - * Decode message - */ @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, Object msg) @@ -71,13 +62,17 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { // Send response #1 if (sentence.contains("##")) { - channel.write("LOAD"); + if (channel != null) { + channel.write("LOAD"); + } return null; } // Send response #2 if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) { - channel.write("ON"); + if (channel != null) { + channel.write("ON"); + } return null; } |