aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk103ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-17 16:32:02 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-17 16:32:02 +1200
commit1c756c57653b72a656407da9c53ac292c5551cdb (patch)
tree69e88e24aae184508ab51932ef2692ae9515eef2 /src/org/traccar/protocol/Tk103ProtocolDecoder.java
parent4ab007201bd177a2fbf46a90b7b73262c5792caf (diff)
downloadtrackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.gz
trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.bz2
trackermap-server-1c756c57653b72a656407da9c53ac292c5551cdb.zip
Allow optional primitives
Diffstat (limited to 'src/org/traccar/protocol/Tk103ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 64314f6c8..baaa6c6fe 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -140,12 +140,12 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- int battery = parser.nextInt();
+ int battery = parser.nextInt(0);
if (battery != 65535) {
position.set(Position.KEY_BATTERY, battery * 0.01);
}
- int power = parser.nextInt();
+ int power = parser.nextInt(0);
if (power != 65535) {
position.set(Position.KEY_POWER, power * 0.1);
}
@@ -164,7 +164,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
+ parser.nextInt(0), parser.nextInt(0), parser.nextHexInt(0), parser.nextHexInt(0))));
return position;
}
@@ -187,9 +187,9 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder();
if (parser.next() == null) {
- dateBuilder.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDate(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
} else {
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
}
position.setValid(parser.next().equals("A"));
@@ -198,20 +198,20 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
switch (Context.getConfig().getString(getProtocolName() + ".speed", "kmh")) {
case "kn":
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
break;
case "mph":
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
break;
default:
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
break;
}
- dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
String status = parser.next();
if (status != null) {
@@ -224,11 +224,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_STATUS, parser.next()); // hex status
if (parser.hasNext()) {
- position.set(Position.KEY_ODOMETER, parser.nextLong(16));
+ position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0));
}
if (parser.hasNext()) {
- position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextDouble(0));
}
return position;