diff options
author | Kevin Goos <kevingoos@telenet.be> | 2018-03-21 10:37:48 +0100 |
---|---|---|
committer | Kevin Goos <kevingoos@telenet.be> | 2018-03-21 10:37:48 +0100 |
commit | 64e342442d74116c2247d85467e49722b7ab45ef (patch) | |
tree | 7fd9c4f967c2ad75d42e83755bfdbf434de60810 | |
parent | 8cc019cf5c43af6dc741138511623551a772b739 (diff) | |
download | trackermap-server-64e342442d74116c2247d85467e49722b7ab45ef.tar.gz trackermap-server-64e342442d74116c2247d85467e49722b7ab45ef.tar.bz2 trackermap-server-64e342442d74116c2247d85467e49722b7ab45ef.zip |
Simplify battery voltage
-rw-r--r-- | src/org/traccar/helper/DataConverter.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/LaipacProtocolDecoder.java | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/org/traccar/helper/DataConverter.java b/src/org/traccar/helper/DataConverter.java index 0df0219ad..7abd4ae93 100644 --- a/src/org/traccar/helper/DataConverter.java +++ b/src/org/traccar/helper/DataConverter.java @@ -26,7 +26,7 @@ public final class DataConverter { public static byte[] parseHex(String string) { try { - return Hex.decodeHex(string.toCharArray()); + return Hex.decodeHex(string); } catch (DecoderException e) { throw new RuntimeException(e); } diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index f243fc629..0a7df26fa 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -48,7 +48,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+),") // course .number("(dd)(dd)(dd),") // date (ddmmyy) .expression("([abZXTSMHFE86430]),") // event code - .number("(d+)").expression("(\\.?)").number("(d*),") // battery voltage + .number("(d.+),") // battery voltage .number("(d+),") // current mileage .number("(d),") // GPS on/off (1 = on, 0 = off) .number("(d+),") // Analog port 1 @@ -105,14 +105,9 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, decodeAlarm(eventCode)); position.set(Position.KEY_EVENT, eventCode); - double batteryVoltage = parser.nextDouble(); - if (parser.next().isEmpty()) { - parser.next(); - batteryVoltage *= 0.001; - } else { - batteryVoltage += parser.nextDouble() * 0.001; - } - position.set(Position.KEY_BATTERY, batteryVoltage); + String batteryVoltage = parser.next(); + batteryVoltage = batteryVoltage.replaceAll("\\.",""); + position.set(Position.KEY_BATTERY, Double.parseDouble(batteryVoltage) * 0.001); position.set(Position.KEY_ODOMETER, parser.nextDouble()); position.set(Position.KEY_GPS, parser.nextInt()); |