aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-05-20 11:18:17 +1200
committerGitHub <noreply@github.com>2017-05-20 11:18:17 +1200
commit6879624fd6290eea9a7f45047ba089ee1435d3ce (patch)
tree5e7de0a5669fb22af0bd3d2b70a5847113d37f80 /src
parentf523e3b995f5f1895cf3dea700be34f4b74dccf9 (diff)
parentab46ebf23066f91369b0d037f273bed1ea814d82 (diff)
downloadtrackermap-server-6879624fd6290eea9a7f45047ba089ee1435d3ce.tar.gz
trackermap-server-6879624fd6290eea9a7f45047ba089ee1435d3ce.tar.bz2
trackermap-server-6879624fd6290eea9a7f45047ba089ee1435d3ce.zip
Merge pull request #3174 from Abyss777/battery_level
Adjust battery and batteryLevel type
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/model/Position.java3
-rw-r--r--src/org/traccar/protocol/Ardi01ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CguardProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/DishaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GpsMarkerProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Xt013ProtocolDecoder.java4
18 files changed, 45 insertions, 37 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 1345a9cb2..bfd142b7d 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -41,7 +41,8 @@ public class Position extends Message {
// The units for the below four KEYs currently vary.
// The preferred units of measure are specified in the comment for each.
public static final String KEY_POWER = "power"; // volts
- public static final String KEY_BATTERY = "battery"; // volts (or percentage appending %)
+ public static final String KEY_BATTERY = "battery"; // volts
+ public static final String KEY_BATTERY_LEVEL = "batteryLevel"; // percentage
public static final String KEY_FUEL_LEVEL = "fuel"; // liters
public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
index c0d1a78fd..7a5bd217c 100644
--- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
@@ -78,7 +78,7 @@ public class Ardi01ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, satellites);
position.set(Position.KEY_EVENT, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set(Position.PREFIX_TEMP + 1, parser.next());
return position;
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java
index e1274d9d8..54f83fb73 100644
--- a/src/org/traccar/protocol/CguardProtocolDecoder.java
+++ b/src/org/traccar/protocol/CguardProtocolDecoder.java
@@ -102,7 +102,7 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, Integer.parseInt(value));
break;
case "BAT1":
- position.set(Position.KEY_BATTERY, Integer.parseInt(value) + "%");
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value));
break;
case "PWR1":
position.set(Position.KEY_POWER, Double.parseDouble(value));
diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java
index 2b25f01fa..ba2f5a5a4 100644
--- a/src/org/traccar/protocol/DishaProtocolDecoder.java
+++ b/src/org/traccar/protocol/DishaProtocolDecoder.java
@@ -88,7 +88,7 @@ public class DishaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, parser.next());
position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_CHARGE, parser.nextInt(0) == 2);
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
position.set(Position.PREFIX_ADC + 2, parser.nextInt(0));
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 51e0a9789..7e76fd6c9 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -399,9 +399,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextDouble(0));
position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
- if (parser.hasNext()) {
- position.set(Position.KEY_BATTERY, parser.next() + "%");
- }
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
position.set(Position.PREFIX_TEMP + 1, parser.next());
@@ -546,13 +544,13 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
position.set(Position.KEY_HOURS, parser.next());
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
decodeStatus(position, parser);
@@ -599,7 +597,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HOURS, parser.next());
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
decodeStatus(position, parser);
@@ -664,7 +662,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(network);
- position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
return position;
}
@@ -712,7 +710,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index 4357c93dc..317a253ec 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -165,7 +165,12 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(Double.parseDouble(value));
break;
case 'N':
- position.set(Position.KEY_BATTERY, value);
+ if (value.endsWith("mV")) {
+ position.set(Position.KEY_BATTERY,
+ Integer.parseInt(value.substring(0, value.length() - 2)) / 1000.0);
+ } else {
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value));
+ }
break;
default:
// Unsupported
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index ce3a5f0af..900e68236 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -164,8 +164,8 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextInt(0));
}
- position.set(Position.KEY_POWER, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
if (parser.hasNext(6)) {
long status = parser.nextLong(16, 0);
diff --git a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
index 2af307c25..f65f5b2bb 100644
--- a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
@@ -79,7 +79,7 @@ public class GpsMarkerProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_SATELLITES, parser.nextHexInt(0));
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
position.set(Position.PREFIX_TEMP + 1, parser.next());
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index fdef2e3c1..800ad0953 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -82,18 +82,18 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
- private String decodeBattery(int value) {
+ private Integer decodeBattery(int value) {
switch (value) {
case 6:
- return "100%";
+ return 100;
case 5:
- return "80%";
+ return 80;
case 4:
- return "60%";
+ return 60;
case 3:
- return "20%";
+ return 20;
case 2:
- return "10%";
+ return 10;
default:
return null;
}
@@ -123,7 +123,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
double latitude = readCoordinate(buf, false);
- position.set(Position.KEY_BATTERY, decodeBattery(buf.readUnsignedByte()));
+ position.set(Position.KEY_BATTERY_LEVEL, decodeBattery(buf.readUnsignedByte()));
double longitude = readCoordinate(buf, true);
int flags = buf.readUnsignedByte() & 0x0f;
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index ef20a9534..2bd02d3f1 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -107,7 +107,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
if (battery == 0xff) {
position.set(Position.KEY_CHARGE, true);
} else {
- position.set(Position.KEY_BATTERY, battery + "%");
+ position.set(Position.KEY_BATTERY_LEVEL, battery);
}
CellTower cellTower = CellTower.fromCidLac(buf.readUnsignedShort(), buf.readUnsignedShort());
@@ -218,7 +218,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*),") // speed
.number("(d+),") // course
.number("(d+),") // satellites
- .number("(d+%),") // battery
+ .number("(d+)%,") // battery
.expression("([01]+),") // status
.number("(d+),") // cid
.number("(d+),") // lac
@@ -257,7 +257,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_SATELLITES, parser.nextInt(0));
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set(Position.KEY_STATUS, parser.nextBinInt(0));
CellTower cellTower = CellTower.fromCidLac(parser.nextInt(0), parser.nextInt(0));
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index 579dbe3e6..7457fbd0c 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -126,7 +126,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, Double.parseDouble(value));
break;
case "batt":
- position.set(Position.KEY_BATTERY, value);
+ position.set(Position.KEY_BATTERY, Double.parseDouble(value));
break;
default:
try {
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index efd647ad3..82766cc60 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -137,7 +137,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, parser.hasNext() && parser.next().equals("1"));
position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
- position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt());
}
if (parser.hasNext()) {
@@ -219,7 +219,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 280db0b31..d67292fd3 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -175,7 +175,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
break;
case "bl":
- position.set(Position.KEY_BATTERY, value);
+ position.set(Position.KEY_BATTERY, Integer.parseInt(value));
break;
case "vo":
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index d2ceebde9..71ef4f7cd 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -252,7 +252,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.PREFIX_IO + 1, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ if (pattern == PATTERN1) {
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.01);
+ } else {
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
+ }
position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index 3ec33d210..f0d06a3cc 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -160,7 +160,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_BATTERY, values[3]);
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(values[3]));
return position;
}
@@ -193,7 +193,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.nextInt(0));
position.set(Position.KEY_RSSI, parser.nextInt(0));
- position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0));
position.set("steps", parser.nextInt(0));
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index b1b06a5da..dc334becc 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -110,7 +110,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, satellites);
position.set(Position.KEY_EVENT, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
}
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index 77327e001..cf1f1575e 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -152,7 +152,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_FUEL_CONSUMPTION, parser.next());
}
- position.set(Position.KEY_BATTERY, parser.next());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
position.set(Position.KEY_RSSI, parser.next());
if (!newFormat) {
diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
index a18758b81..f53178621 100644
--- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
@@ -85,8 +85,8 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_GPS, parser.next());
position.set(Position.KEY_RSSI, parser.next());
- position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_CHARGE, parser.next());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
+ position.set(Position.KEY_CHARGE, parser.next().equals("1"));
return position;
}