diff options
6 files changed, 28 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java index 90444cc9f..4c28ae59b 100644 --- a/src/main/java/org/traccar/model/Position.java +++ b/src/main/java/org/traccar/model/Position.java @@ -83,6 +83,7 @@ public class Position extends Message { public static final String KEY_DOOR = "door"; public static final String KEY_AXLE_WEIGHT = "axleWeight"; public static final String KEY_G_SENSOR = "gSensor"; + public static final String KEY_ICCID = "iccid"; public static final String KEY_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; // knots diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java index 71bb6791c..c018b2651 100644 --- a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java @@ -84,6 +84,10 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { this.custom = custom; } + public void setForm(String form) { + this.form = form; + } + private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) { if (channel != null) { ByteBuf response = Unpooled.buffer(12); @@ -167,6 +171,12 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { case "AV1": position.set(Position.PREFIX_ADC + 1, Integer.parseInt(values[i])); break; + case "CD": + position.set(Position.KEY_ICCID, values[i]); + break; + case "EH": + position.set(Position.KEY_HOURS, UnitsConverter.msFromHours(Integer.parseInt(values[i]))); + break; default: break; } @@ -274,7 +284,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // pending code status break; case "CD": - readString(buf); // sim cid + position.set(Position.KEY_ICCID, readString(buf)); break; case "CM": buf.readLong(); // imsi diff --git a/src/main/java/org/traccar/protocol/CarcellProtocolDecoder.java b/src/main/java/org/traccar/protocol/CarcellProtocolDecoder.java index 344b2f1ea..ec640ba71 100644 --- a/src/main/java/org/traccar/protocol/CarcellProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/CarcellProtocolDecoder.java @@ -155,7 +155,7 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder { Double mainVoltage = parser.nextDouble(0) / 100d; position.set(Position.KEY_POWER, mainVoltage); - position.set("iccid", parser.next()); + position.set(Position.KEY_ICCID, parser.next()); } return position; diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index 4665290c3..d942edbfe 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -824,7 +824,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else if (subType == 0x0a) { buf.skipBytes(8); // imei buf.skipBytes(8); // imsi - position.set("iccid", ByteBufUtil.hexDump(buf.readSlice(8))); + position.set(Position.KEY_ICCID, ByteBufUtil.hexDump(buf.readSlice(8))); return position; } else if (subType == 0x0d) { if (buf.getByte(buf.readerIndex()) != '!') { diff --git a/src/main/java/org/traccar/protocol/XirgoProtocolDecoder.java b/src/main/java/org/traccar/protocol/XirgoProtocolDecoder.java index 08809307f..4d0cc314b 100644 --- a/src/main/java/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/XirgoProtocolDecoder.java @@ -266,7 +266,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.setValid(Integer.parseInt(values[i]) == 3); break; case "SI": - position.set("iccid", values[i]); + position.set(Position.KEY_ICCID, values[i]); break; case "IG": int ignition = Integer.parseInt(values[i]); diff --git a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java index 0fe18640d..68e08443b 100644 --- a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java @@ -99,4 +99,17 @@ public class AtrackProtocolDecoderTest extends ProtocolTest { } + @Test + public void testDecodeCustom() throws Exception { + + AtrackProtocolDecoder decoder = new AtrackProtocolDecoder(null); + + decoder.setCustom(true); + decoder.setForm("%AT%BV%CD%CE%CM%CN%DT%GN%GQ%GS%GV%LC%ME%MV%RL%SA%SM%CS%HT%VN%PD%IA%MP%EL%ET%FC%FL%RP%ML%MF%TR%EH%CR%DL%EG%HA%HB%HC%IP%MT%PF"); + + verifyPositions(decoder, buffer( + "@P,DCCE,422,5818,357766091026083,1557904779,1557904780,1557904780,-121899644,37406291,129,2,21,10,0,0,0,0,,2000,2000,,13,40,8942310017000752067,21096194,295050910083206,310260,0,FF00001F0393FF01001E0395FF01001E0394FF01001F0393FF02001D0393FF00001F0394FF0100200394FF01001F0393FF02001F0395FF0100200394,20,10,002C005C03B4,14953,357766091026083,125,38,11,0,1,Device:Fail,JN8AZ1MU1BW066090,0,0,0,0,0,99,0,0,0,0,0,264,5,0,0,0,0,0,0,0,0\r\n")); + + } + } |