From fd466266940a49a55b3b2b4ad89a2a4b07326da5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 19 Mar 2021 23:16:38 -0700 Subject: Decode cell information --- .../traccar/protocol/HuabaoProtocolDecoder.java | 48 ++++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index e715547ed..675a08aef 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -335,24 +335,36 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { position.set("cover", BitUtil.check(deviceStatus, 3)); break; case 0xEB: - while (buf.readerIndex() < endIndex) { - int extendedLength = buf.readUnsignedShort(); - int extendedType = buf.readUnsignedShort(); - switch (extendedType) { - case 0x0001: - position.set("fuel1", buf.readUnsignedShort() * 0.1); - buf.readUnsignedByte(); // unused - break; - case 0x0023: - position.set("fuel2", Double.parseDouble( - buf.readCharSequence(6, StandardCharsets.US_ASCII).toString())); - break; - case 0x00CE: - position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); - break; - default: - buf.skipBytes(extendedLength - 2); - break; + if (buf.getUnsignedShort(buf.readerIndex()) > 200) { + Network network = new Network(); + int mcc = buf.readUnsignedShort(); + int mnc = buf.readUnsignedByte(); + while (buf.readerIndex() < endIndex) { + network.addCellTower(CellTower.from( + mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedShort(), + buf.readUnsignedByte())); + } + position.setNetwork(network); + } else { + while (buf.readerIndex() < endIndex) { + int extendedLength = buf.readUnsignedShort(); + int extendedType = buf.readUnsignedShort(); + switch (extendedType) { + case 0x0001: + position.set("fuel1", buf.readUnsignedShort() * 0.1); + buf.readUnsignedByte(); // unused + break; + case 0x0023: + position.set("fuel2", Double.parseDouble( + buf.readCharSequence(6, StandardCharsets.US_ASCII).toString())); + break; + case 0x00CE: + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + break; + default: + buf.skipBytes(extendedLength - 2); + break; + } } } break; -- cgit v1.2.3