diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-27 06:47:20 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-27 06:47:20 -0700 |
commit | dd6a607b66d0a0f794448e8ac148288a7bba484d (patch) | |
tree | 15e1aece006ca2a9de9556a020d308cf58bc6713 /src | |
parent | decde70bcf90490a3fe8d24a9bd43a17074af718 (diff) | |
download | traccar-server-dd6a607b66d0a0f794448e8ac148288a7bba484d.tar.gz traccar-server-dd6a607b66d0a0f794448e8ac148288a7bba484d.tar.bz2 traccar-server-dd6a607b66d0a0f794448e8ac148288a7bba484d.zip |
Update Avema protocol decoder
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/AvemaProtocolDecoder.java | 13 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/AvemaProtocolDecoder.java b/src/main/java/org/traccar/protocol/AvemaProtocolDecoder.java index 16a31162a..37836ad5f 100644 --- a/src/main/java/org/traccar/protocol/AvemaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/AvemaProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,17 +48,19 @@ public class AvemaProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // event .number("(d+.d+),") // odometer .number("(d+),") // input - .number("(d+.d+)V,") // adc 1 - .number("(d+.d+)V,") // adc 2 + .number("(d+.d+)V?,") // adc 1 + .number("(d+.d+)V?,") // adc 2 .number("(d+),") // output .number("(d),") // roaming .number("(d+),") // rssi .number("d,") // communication system - .number("(ddd)") // mcc - .number("(dd),") // mnc + .number("(ddd)-?") // mcc + .number("(d+),") // mnc .number("(x+),") // lac .number("(x+),") // cid + .number("(d+.d+),").optional() // battery .number("([^,]+)?") // rfid + .any() .compile(); @Override @@ -99,6 +101,7 @@ public class AvemaProtocolDecoder extends BaseProtocolDecoder { position.setNetwork(new Network(CellTower.from( parser.nextInt(), parser.nextInt(), parser.nextHexInt(), parser.nextHexInt(), rssi))); + position.set(Position.KEY_BATTERY, parser.nextDouble()); position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); return position; diff --git a/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java index d3be0b6d6..71bc83b4f 100644 --- a/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class AvemaProtocolDecoderTest extends ProtocolTest { @@ -10,7 +11,14 @@ public class AvemaProtocolDecoderTest extends ProtocolTest { AvemaProtocolDecoder decoder = new AvemaProtocolDecoder(null); - verifyNull(decoder, text( + verifyAttribute(decoder, text( + "1000000000,20190527072358,121.646024,25.062135,0,0,0,0,10,0.0,1,0.02,12.32,0,0,15,2,466-5,10275,0,0.01,65EB812A000104E0,8000001234,NormanChang"), + Position.KEY_DRIVER_UNIQUE_ID, "65EB812A000104E0"); + + verifyNotNull(decoder, text( + "1000000000,20190522093835,121.645898,25.062268,0,0,0,0,3,0.0,1,0.02,11.48,0,0,19,4,466-5,65534,56589841,0.01")); + + verifyNotNull(decoder, text( "8,20180927150956,19.154864,49.124862,7,56,0,12,3,0.0,0,0.02,14.01,0,0,26,0,219-2,65534,10255884,0.01")); verifyPosition(decoder, text( |