diff options
Diffstat (limited to 'src/org/traccar/protocol/H02ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolDecoder.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index c4ba6ffa3..b316d8016 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -22,8 +22,8 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.helper.BcdUtil; import org.traccar.helper.BitUtil; -import org.traccar.helper.ChannelBufferTools; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -38,7 +38,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { private static double readCoordinate(ChannelBuffer buf, boolean lon) { - int degrees = ChannelBufferTools.readHexInteger(buf, 2); + int degrees = BcdUtil.readInteger(buf, 2); if (lon) { degrees = degrees * 10 + (buf.getUnsignedByte(buf.readerIndex()) >> 4); } @@ -53,7 +53,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { length = 5; } - result = result * 10 + ChannelBufferTools.readHexInteger(buf, length) * 0.0001; + result = result * 10 + BcdUtil.readInteger(buf, length) * 0.0001; result /= 60; result += degrees; @@ -83,12 +83,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(getDeviceId()); DateBuilder dateBuilder = new DateBuilder() - .setHour(ChannelBufferTools.readHexInteger(buf, 2)) - .setMinute(ChannelBufferTools.readHexInteger(buf, 2)) - .setSecond(ChannelBufferTools.readHexInteger(buf, 2)) - .setDay(ChannelBufferTools.readHexInteger(buf, 2)) - .setMonth(ChannelBufferTools.readHexInteger(buf, 2)) - .setYear(ChannelBufferTools.readHexInteger(buf, 2)); + .setHour(BcdUtil.readInteger(buf, 2)) + .setMinute(BcdUtil.readInteger(buf, 2)) + .setSecond(BcdUtil.readInteger(buf, 2)) + .setDay(BcdUtil.readInteger(buf, 2)) + .setMonth(BcdUtil.readInteger(buf, 2)) + .setYear(BcdUtil.readInteger(buf, 2)); position.setTime(dateBuilder.getDate()); double latitude = readCoordinate(buf, false); @@ -107,8 +107,8 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(latitude); position.setLongitude(longitude); - position.setSpeed(ChannelBufferTools.readHexInteger(buf, 3)); - position.setCourse((buf.readUnsignedByte() & 0x0f) * 100.0 + ChannelBufferTools.readHexInteger(buf, 2)); + position.setSpeed(BcdUtil.readInteger(buf, 3)); + position.setCourse((buf.readUnsignedByte() & 0x0f) * 100.0 + BcdUtil.readInteger(buf, 2)); processStatus(position, buf.readUnsignedInt()); return position; |