aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-05-19 14:41:23 +0500
committerAbyss777 <abyss@fox5.ru>2017-05-19 14:58:08 +0500
commit9e758d437c048b954d224935664b76d6f6f8416c (patch)
tree6e1468437fc094245ae484e2eb9e6cc92116a2d6 /src/org/traccar/protocol
parentf523e3b995f5f1895cf3dea700be34f4b74dccf9 (diff)
downloadtraccar-server-9e758d437c048b954d224935664b76d6f6f8416c.tar.gz
traccar-server-9e758d437c048b954d224935664b76d6f6f8416c.tar.bz2
traccar-server-9e758d437c048b954d224935664b76d6f6f8416c.zip
Adjust battery and batteryLevel type
Diffstat (limited to 'src/org/traccar/protocol')
-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.java12
-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.java2
-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
17 files changed, 42 insertions, 33 deletions
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..081048a40 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -400,7 +400,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
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(0));
}
position.set(Position.PREFIX_TEMP + 1, parser.next());
@@ -546,13 +546,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(0));
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(0));
decodeStatus(position, parser);
@@ -599,7 +599,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(0));
decodeStatus(position, parser);
@@ -664,7 +664,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 +712,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..604dcad32 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(0));
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..f1a03ed44 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -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..d490fbfb0 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(0));
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;
}