From 58fe1d2bb7055a953277666a2c5e6101cdcf64d7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 29 Oct 2015 11:18:47 +1300 Subject: Apply Tytan changes for 2.0 protocol --- src/org/traccar/protocol/TytanProtocolDecoder.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index d9ffc98b0..e8549d913 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -39,12 +39,6 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - private static float readSwappedFloat(ChannelBuffer buf) { - byte[] bytes = new byte[4]; - buf.readBytes(bytes); - return ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes).readFloat(); - } - private void decodeExtraData(Position position, ChannelBuffer buf, int end) { while (buf.readerIndex() < end) { @@ -66,9 +60,9 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { case 6: n = buf.readUnsignedByte() >> 4; if (n < 2) { - position.set(Event.PREFIX_ADC + n, readSwappedFloat(buf)); + position.set(Event.PREFIX_ADC + n, buf.readFloat()); } else { - position.set("di" + (n - 2), readSwappedFloat(buf)); + position.set("di" + (n - 2), buf.readFloat()); } break; case 7: @@ -82,10 +76,10 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.set("antihijack", buf.readUnsignedByte()); break; case 9: - position.set("authorized", ChannelBuffers.hexDump(buf.readBytes(8))); + position.set("unauthorized", ChannelBuffers.hexDump(buf.readBytes(8))); break; case 10: - position.set("unauthorized", ChannelBuffers.hexDump(buf.readBytes(8))); + position.set("authorized", ChannelBuffers.hexDump(buf.readBytes(8))); break; case 24: Set temps = new LinkedHashSet<>(); @@ -105,7 +99,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); break; case 90: - position.set(Event.KEY_POWER, readSwappedFloat(buf)); + position.set(Event.KEY_POWER, buf.readFloat()); break; case 101: position.set(Event.KEY_OBD_SPEED, buf.readUnsignedByte()); -- cgit v1.2.3