From 31f12e5bcf409111b86e8fff571ee95c3186e241 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 24 Mar 2014 22:52:48 +1300 Subject: Fix device id decoding (fix #610) --- src/org/traccar/protocol/NoranProtocolDecoder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index fc4654016..dc400ff66 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -107,7 +107,12 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Identification - String id = buf.readBytes(11).toString(Charset.defaultCharset()); + ChannelBuffer rawId = buf.readBytes(11); + int index = 0; + while (rawId.readable() && rawId.readByte() != 0) { + index += 1; + } + String id = rawId.toString(0, index, Charset.defaultCharset()); try { position.setDeviceId(getDataManager().getDeviceByImei(id).getId()); } catch(Exception error) { -- cgit v1.2.3