diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2011-06-16 07:56:59 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2011-06-16 07:56:59 +0000 |
commit | 7bc80dc78894b2cbe241fcaea2838673150fcef1 (patch) | |
tree | dd5893fb7325f2e3966297dc60c01ca99e103f47 /src | |
parent | dcbaac71303e606662c8274d5b936fd8323a01b0 (diff) | |
download | traccar-server-7bc80dc78894b2cbe241fcaea2838673150fcef1.tar.gz traccar-server-7bc80dc78894b2cbe241fcaea2838673150fcef1.tar.bz2 traccar-server-7bc80dc78894b2cbe241fcaea2838673150fcef1.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/net/sourceforge/opentracking/TrackerEventHandler.java | 24 | ||||
-rw-r--r-- | src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java | 7 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/net/sourceforge/opentracking/TrackerEventHandler.java b/src/net/sourceforge/opentracking/TrackerEventHandler.java index 28a8c8fad..18a15480f 100644 --- a/src/net/sourceforge/opentracking/TrackerEventHandler.java +++ b/src/net/sourceforge/opentracking/TrackerEventHandler.java @@ -43,16 +43,20 @@ public class TrackerEventHandler extends SimpleChannelHandler { if (e.getMessage() instanceof Position) { Position position = (Position) e.getMessage(); - - System.out.println( - "id: " + position.getId() + - ", deviceId: " + position.getDeviceId() + - ", valid: " + position.getValid() + - ", time: " + position.getTime() + - ", latitude: " + position.getLatitude() + - ", longitude: " + position.getLongitude() + - ", speed: " + position.getSpeed() + - ", course: " + position.getCourse()); + + if (position == null) { + System.out.println("null message"); + } else { + System.out.println( + "id: " + position.getId() + + ", deviceId: " + position.getDeviceId() + + ", valid: " + position.getValid() + + ", time: " + position.getTime() + + ", latitude: " + position.getLatitude() + + ", longitude: " + position.getLongitude() + + ", speed: " + position.getSpeed() + + ", course: " + position.getCourse()); + } // Write position to database try { diff --git a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java index 30fdcb06f..92d54b551 100644 --- a/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java +++ b/src/net/sourceforge/opentracking/protocol/gps103/Gps103ProtocolDecoder.java @@ -80,10 +80,15 @@ public class Gps103ProtocolDecoder extends OneToOneDecoder { String sentence = (String) msg; - // Send response + // Send response #1 if (sentence.contains("##")) { channel.write("LOAD"); } + + // Send response #2 + if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) { + channel.write("ON"); + } // Parse message Matcher parser = pattern.matcher(sentence); |