From 1a0a34acfb775385fe37de4992215a2e328cc6f6 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 20 Mar 2013 21:42:05 +1300 Subject: Fix Galileo protocol --- src/org/traccar/protocol/GalileoProtocolDecoder.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index e4b80777e..ac820b587 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -92,7 +92,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; buf.readUnsignedByte(); // header - int length = buf.readUnsignedShort() & 0x7fff + 3; + int length = (buf.readUnsignedShort() & 0x7fff) + 3; // Create new position Position position = new Position(); @@ -109,6 +109,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); } catch(Exception error) { Log.warning("Unknown device - " + imei); + return null; } break; @@ -159,6 +160,18 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } } + + if (position.getDeviceId() == null || + position.getValid() == null || + position.getTime() == null || + position.getSpeed() == null) { + Log.warning("Identifier or location information missing"); + return null; + } + + if (position.getAltitude() == null) { + position.setAltitude(0.0); + } sendReply(channel, buf.readUnsignedShort()); -- cgit v1.2.3