From 34f61800a807370383df1cafd0d442d69325c648 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 20 Mar 2013 23:28:20 +1300 Subject: Another Galileo protocol fix --- .../traccar/protocol/GalileoProtocolDecoder.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index ac820b587..62669eb1c 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -84,6 +84,8 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } } + private Long deviceId; + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, Object msg) @@ -106,10 +108,9 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset()); buf.skipBytes(imei.length()); try { - position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); + deviceId = getDataManager().getDeviceByImei(imei).getId(); } catch(Exception error) { Log.warning("Unknown device - " + imei); - return null; } break; @@ -161,20 +162,22 @@ 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"); + if (deviceId == null) { + Log.warning("Unknown device"); return null; } + position.setDeviceId(deviceId); + sendReply(channel, buf.readUnsignedShort()); + + if (position.getValid() == null || position.getTime() == null || position.getSpeed() == null) { + return null; + } + if (position.getAltitude() == null) { position.setAltitude(0.0); } - sendReply(channel, buf.readUnsignedShort()); - position.setExtendedInfo(extendedInfo.toString()); return position; } -- cgit v1.2.3