aboutsummaryrefslogtreecommitdiff
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
parent4ab007201bd177a2fbf46a90b7b73262c5792caf (diff)
downloadtraccar-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.gz
traccar-server-1c756c57653b72a656407da9c53ac292c5551cdb.tar.bz2
traccar-server-1c756c57653b72a656407da9c53ac292c5551cdb.zip
Allow optional primitives
-rw-r--r--src/org/traccar/helper/Parser.java211
-rw-r--r--src/org/traccar/protocol/AisProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AppelloProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/AquilaProtocolDecoder.java43
-rw-r--r--src/org/traccar/protocol/Ardi01ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/ArknavProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/ArknavX8ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/ArnaviProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/AuroProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/AutoGradeProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/BoxProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/CarTrackProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/CarcellProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/CarscopProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/CguardProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/CradlepointProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/DishaProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocolDecoder.java30
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/ExtremTracProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/FifotrackProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/FlextrackProtocolDecoder.java25
-rw-r--r--src/org/traccar/protocol/FoxProtocolDecoder.java26
-rw-r--r--src/org/traccar/protocol/FreedomProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java100
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/GnxProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java26
-rw-r--r--src/org/traccar/protocol/GotopProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java32
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/GpsMarkerProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/GpsmtaProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gt30ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java32
-rw-r--r--src/org/traccar/protocol/HaicomProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/HomtecsProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/HunterProProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/IdplProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/IntellitracProtocolDecoder.java42
-rw-r--r--src/org/traccar/protocol/JpKorjarProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/KenjiProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/L100ProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MaestroProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/ManPowerProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java38
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java68
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java26
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/MtxProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/PathAwayProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/PretraceProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/Pt3000ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/RaveonProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/RitiProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/SanavProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/SiwiProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/StarLinkProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Stl060ProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/SupermateProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/TmgProtocolDecoder.java30
-rw-r--r--src/org/traccar/protocol/TopflytechProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java56
-rw-r--r--src/org/traccar/protocol/Tr20ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Tr900ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/TrackboxProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/TrakMateProtocolDecoder.java34
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java30
-rw-r--r--src/org/traccar/protocol/Tt8850ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/WialonProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/Xt013ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java8
92 files changed, 913 insertions, 856 deletions
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java
index 2253b79fc..69c80adb2 100644
--- a/src/org/traccar/helper/Parser.java
+++ b/src/org/traccar/helper/Parser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 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.
@@ -61,35 +61,71 @@ public class Parser {
return matcher.group(position++);
}
- public int nextInt() {
- return nextInt(10);
+ public Integer nextInt() {
+ if (hasNext()) {
+ return Integer.parseInt(next());
+ } else {
+ return null;
+ }
+ }
+
+ public int nextInt(int defaultValue) {
+ if (hasNext()) {
+ return Integer.parseInt(next());
+ } else {
+ return defaultValue;
+ }
+ }
+
+ public Integer nextHexInt() {
+ if (hasNext()) {
+ return Integer.parseInt(next(), 16);
+ } else {
+ return null;
+ }
+ }
+
+ public int nextHexInt(int defaultValue) {
+ if (hasNext()) {
+ return Integer.parseInt(next(), 16);
+ } else {
+ return defaultValue;
+ }
}
- public int nextInt(int radix) {
+ public Integer nextBinInt() {
if (hasNext()) {
- return Integer.parseInt(next(), radix);
+ return Integer.parseInt(next(), 2);
} else {
- return 0;
+ return null;
}
}
- public long nextLong() {
- return nextLong(10);
+ public int nextBinInt(int defaultValue) {
+ if (hasNext()) {
+ return Integer.parseInt(next(), 2);
+ } else {
+ return defaultValue;
+ }
+ }
+
+ public long nextLong(long defaultValue) {
+ return nextLong(10, defaultValue);
}
- public long nextLong(int radix) {
+ public long nextLong(int radix, long defaultValue) {
if (hasNext()) {
return Long.parseLong(next(), radix);
} else {
- return 0;
+ return defaultValue;
}
}
- public double nextDouble() {
+ public double nextDouble(double defaultValue) {
if (hasNext()) {
return Double.parseDouble(next());
} else {
- return 0.0;
+ return defaultValue;
}
}
@@ -114,44 +150,44 @@ public class Parser {
coordinate = Double.parseDouble(next() + '.' + next());
break;
case DEG_HEM:
- coordinate = nextDouble();
+ coordinate = nextDouble(0);
hemisphere = next();
break;
case DEG_MIN_MIN:
- coordinate = nextInt();
+ coordinate = nextInt(0);
coordinate += Double.parseDouble(next() + '.' + next()) / 60;
break;
case DEG_MIN_MIN_HEM:
- coordinate = nextInt();
+ coordinate = nextInt(0);
coordinate += Double.parseDouble(next() + '.' + next()) / 60;
hemisphere = next();
break;
case HEM_DEG:
hemisphere = next();
- coordinate = nextDouble();
+ coordinate = nextDouble(0);
break;
case HEM_DEG_MIN:
hemisphere = next();
- coordinate = nextInt();
- coordinate += nextDouble() / 60;
+ coordinate = nextInt(0);
+ coordinate += nextDouble(0) / 60;
break;
case HEM_DEG_MIN_HEM:
hemisphere = next();
- coordinate = nextInt();
- coordinate += nextDouble() / 60;
+ coordinate = nextInt(0);
+ coordinate += nextDouble(0) / 60;
if (hasNext()) {
hemisphere = next();
}
break;
case HEM_DEG_MIN_MIN:
hemisphere = next();
- coordinate = nextInt();
+ coordinate = nextInt(0);
coordinate += Double.parseDouble(next() + '.' + next()) / 60;
break;
case DEG_MIN_HEM:
default:
- coordinate = nextInt();
- coordinate += nextDouble() / 60;
+ coordinate = nextInt(0);
+ coordinate += nextDouble(0) / 60;
hemisphere = next();
break;
}
@@ -168,77 +204,108 @@ public class Parser {
}
public enum DateTimeFormat {
- HMS, // HHMMSS
- SMH, // SSMMHH
-
- HMS_YMD, // HHMMSSYYYYMMDD or HHMMSSYYMMDD
- HMS_DMY, // HHMMSSDDMMYYYY or HHMMSSDDMMYY
- SMH_YMD, // SSMMHHYYYYMMDD or SSMMHHYYMMDD
- SMH_DMY, // SSMMHHDDMMYYYY or SSMMHHDDMMYY
-
- DMY_HMS, // DDMMYYYYHHMMSS or DDMMYYHHMMSS
- DMY_HMSS, // DDMMYYYYHHMMSS.sss or DDMMYYHHMMSS.sss
- YMD_HMS, // YYYYMMDDHHMMSS or YYMMDDHHMMSS
- YMD_HMSS, // YYYYMMDDHHMMSS.sss or YYMMDDHHMMSS.sss
+ HMS,
+ SMH,
+ HMS_YMD,
+ HMS_DMY,
+ SMH_YMD,
+ SMH_DMY,
+ DMY_HMS,
+ DMY_HMSS,
+ YMD_HMS,
+ YMD_HMSS,
}
- private static final DateTimeFormat DEFAULT_FORMAT = DateTimeFormat.YMD_HMS;
- private static final String DEFAULT_TZ = "UTC";
- private static final int DEFAULT_RADIX = 10;
-
- public Date nextDateTime(DateTimeFormat format, String tz, int radix) {
+ public Date nextDateTime(DateTimeFormat format, String timeZone) {
int year = 0, month = 0, day = 0;
int hour = 0, minute = 0, second = 0, millisecond = 0;
- TimeZone timeZone = TimeZone.getTimeZone(tz);
switch (format) {
case HMS:
- hour = nextInt(radix); minute = nextInt(radix); second = nextInt(radix);
+ hour = nextInt(0);
+ minute = nextInt(0);
+ second = nextInt(0);
break;
case SMH:
- second = nextInt(radix); minute = nextInt(radix); hour = nextInt(radix);
+ second = nextInt(0);
+ minute = nextInt(0);
+ hour = nextInt(0);
break;
case HMS_YMD:
- hour = nextInt(radix); minute = nextInt(radix); second = nextInt(radix);
- year = nextInt(radix); month = nextInt(radix); day = nextInt(radix);
+ hour = nextInt(0);
+ minute = nextInt(0);
+ second = nextInt(0);
+ year = nextInt(0);
+ month = nextInt(0);
+ day = nextInt(0);
break;
case HMS_DMY:
- hour = nextInt(radix); minute = nextInt(radix); second = nextInt(radix);
- day = nextInt(radix); month = nextInt(radix); year = nextInt(radix);
+ hour = nextInt(0);
+ minute = nextInt(0);
+ second = nextInt(0);
+ day = nextInt(0);
+ month = nextInt(0);
+ year = nextInt(0);
break;
case SMH_YMD:
- second = nextInt(radix); minute = nextInt(radix); hour = nextInt(radix);
- year = nextInt(radix); month = nextInt(radix); day = nextInt(radix);
+ second = nextInt(0);
+ minute = nextInt(0);
+ hour = nextInt(0);
+ year = nextInt(0);
+ month = nextInt(0);
+ day = nextInt(0);
break;
case SMH_DMY:
- second = nextInt(radix); minute = nextInt(radix); hour = nextInt(radix);
- day = nextInt(radix); month = nextInt(radix); year = nextInt(radix);
+ second = nextInt(0);
+ minute = nextInt(0);
+ hour = nextInt(0);
+ day = nextInt(0);
+ month = nextInt(0);
+ year = nextInt(0);
break;
case DMY_HMS:
case DMY_HMSS:
- day = nextInt(radix); month = nextInt(radix); year = nextInt(radix);
- hour = nextInt(radix); minute = nextInt(radix); second = nextInt(radix);
+ day = nextInt(0);
+ month = nextInt(0);
+ year = nextInt(0);
+ hour = nextInt(0);
+ minute = nextInt(0);
+ second = nextInt(0);
break;
case YMD_HMS:
case YMD_HMSS:
default:
- year = nextInt(radix); month = nextInt(radix); day = nextInt(radix);
- hour = nextInt(radix); minute = nextInt(radix); second = nextInt(radix);
+ year = nextInt(0);
+ month = nextInt(0);
+ day = nextInt(0);
+ hour = nextInt(0);
+ minute = nextInt(0);
+ second = nextInt(0);
break;
}
if (format == DateTimeFormat.YMD_HMSS || format == DateTimeFormat.DMY_HMSS) {
- millisecond = nextInt(radix); // (ddd)
+ millisecond = nextInt(0); // (ddd)
}
if (year >= 0 && year < 100) {
year += 2000;
}
- DateBuilder dateBuilder = new DateBuilder(timeZone);
-
- if (format != DateTimeFormat.HMS || format != DateTimeFormat.SMH) {
- dateBuilder.setDate(year, month, day);
+ DateBuilder dateBuilder;
+ if (format != DateTimeFormat.HMS && format != DateTimeFormat.SMH) {
+ if (timeZone != null) {
+ dateBuilder = new DateBuilder(TimeZone.getTimeZone(timeZone));
+ } else {
+ dateBuilder = new DateBuilder();
+ }
+ dateBuilder.setDate(year, month, day);
+ } else {
+ if (timeZone != null) {
+ dateBuilder = new DateBuilder(new Date(), TimeZone.getTimeZone(timeZone));
+ } else {
+ dateBuilder = new DateBuilder(new Date());
+ }
}
dateBuilder.setTime(hour, minute, second, millisecond);
@@ -246,32 +313,12 @@ public class Parser {
return dateBuilder.getDate();
}
- public Date nextDateTime(String tz, int radix) {
- return nextDateTime(DEFAULT_FORMAT, tz, radix);
- }
-
- public Date nextDateTime(DateTimeFormat format, int radix) {
- return nextDateTime(format, DEFAULT_TZ, radix);
- }
-
- public Date nextDateTime(DateTimeFormat format, String tz) {
- return nextDateTime(format, tz, DEFAULT_RADIX);
- }
-
public Date nextDateTime(DateTimeFormat format) {
- return nextDateTime(format, DEFAULT_TZ, DEFAULT_RADIX);
- }
-
- public Date nextDateTime(String tz) {
- return nextDateTime(DEFAULT_FORMAT, tz, DEFAULT_RADIX);
- }
-
- public Date nextDateTime(int radix) {
- return nextDateTime(DEFAULT_FORMAT, DEFAULT_TZ, radix);
+ return nextDateTime(format, null);
}
public Date nextDateTime() {
- return nextDateTime(DEFAULT_FORMAT, DEFAULT_TZ, DEFAULT_RADIX);
+ return nextDateTime(DateTimeFormat.YMD_HMS, null);
}
}
diff --git a/src/org/traccar/protocol/AisProtocolDecoder.java b/src/org/traccar/protocol/AisProtocolDecoder.java
index f04c558c2..1f7a12595 100644
--- a/src/org/traccar/protocol/AisProtocolDecoder.java
+++ b/src/org/traccar/protocol/AisProtocolDecoder.java
@@ -103,9 +103,9 @@ public class AisProtocolDecoder extends BaseProtocolDecoder {
Parser parser = new Parser(PATTERN, sentence);
if (parser.matches()) {
- int count = parser.nextInt();
- int index = parser.nextInt();
- int id = parser.nextInt();
+ int count = parser.nextInt(0);
+ int index = parser.nextInt(0);
+ int id = parser.nextInt(0);
Position position = null;
diff --git a/src/org/traccar/protocol/AppelloProtocolDecoder.java b/src/org/traccar/protocol/AppelloProtocolDecoder.java
index 38f4315de..30dec3941 100644
--- a/src/org/traccar/protocol/AppelloProtocolDecoder.java
+++ b/src/org/traccar/protocol/AppelloProtocolDecoder.java
@@ -75,14 +75,14 @@ public class AppelloProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
}
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
position.setValid(parser.next().equals("F"));
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java
index 5f421727f..9c7b1bb12 100644
--- a/src/org/traccar/protocol/AquilaProtocolDecoder.java
+++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java
@@ -142,20 +142,20 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_EVENT, parser.nextInt());
+ position.set(Position.KEY_EVENT, parser.nextInt(0));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime());
position.setValid(parser.next().equals("A"));
- position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
if (parser.hasNext(9)) {
@@ -164,21 +164,22 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_CHARGE, parser.next());
position.set(Position.PREFIX_IN + 2, parser.next());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
- int course = (parser.nextInt() << 3) + (parser.nextInt() << 2) + (parser.nextInt() << 1) + parser.nextInt();
+ int course = (parser.nextInt(0) << 3) + (parser.nextInt(0) << 2)
+ + (parser.nextInt(0) << 1) + parser.nextInt(0);
if (course > 0 && course <= 8) {
position.setCourse((course - 1) * 45);
}
} else if (parser.hasNext(7)) {
- position.setCourse(parser.nextInt());
+ position.setCourse(parser.nextInt(0));
position.set(Position.KEY_CHARGE, parser.next());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_POWER, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_POWER, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
String obd = parser.next();
position.set("obd", obd.substring(1, obd.length() - 1));
@@ -188,17 +189,17 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
} else {
- position.setCourse(parser.nextInt());
+ position.setCourse(parser.nextInt(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
- position.set(Position.PREFIX_IN + 1, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
+ position.set(Position.PREFIX_IN + 1, parser.nextInt(0));
position.set(Position.KEY_CHARGE, parser.next());
- position.set(Position.PREFIX_IN + 2, parser.nextInt());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_POWER, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.PREFIX_IN + 2, parser.nextInt(0));
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_POWER, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
}
diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
index 47d79ccd8..c0d1a78fd 100644
--- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
@@ -67,13 +67,13 @@ public class Ardi01ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- int satellites = parser.nextInt();
+ int satellites = parser.nextInt(0);
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
diff --git a/src/org/traccar/protocol/ArknavProtocolDecoder.java b/src/org/traccar/protocol/ArknavProtocolDecoder.java
index 2b343e7c3..927c50c29 100644
--- a/src/org/traccar/protocol/ArknavProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavProtocolDecoder.java
@@ -70,10 +70,10 @@ public class ArknavProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
index 5f15323e6..8a80901b5 100644
--- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
@@ -76,10 +76,10 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
position.set(Position.KEY_STATUS, parser.next());
return position;
diff --git a/src/org/traccar/protocol/ArnaviProtocolDecoder.java b/src/org/traccar/protocol/ArnaviProtocolDecoder.java
index 56f58f2b5..9c4ab5d05 100644
--- a/src/org/traccar/protocol/ArnaviProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArnaviProtocolDecoder.java
@@ -74,23 +74,23 @@ public class ArnaviProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_INDEX, parser.nextInt());
- position.set(Position.KEY_POWER, parser.nextInt() * 0.01);
- position.set(Position.KEY_BATTERY, parser.nextInt() * 0.01);
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_INPUT, parser.nextInt());
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_INDEX, parser.nextInt(0));
+ position.set(Position.KEY_POWER, parser.nextInt(0) * 0.01);
+ position.set(Position.KEY_BATTERY, parser.nextInt(0) * 0.01);
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_INPUT, parser.nextInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(true);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/AuroProtocolDecoder.java b/src/org/traccar/protocol/AuroProtocolDecoder.java
index 72dea3b61..a45d14709 100644
--- a/src/org/traccar/protocol/AuroProtocolDecoder.java
+++ b/src/org/traccar/protocol/AuroProtocolDecoder.java
@@ -65,7 +65,7 @@ public class AuroProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.set(Position.KEY_INDEX, parser.nextInt());
+ position.set(Position.KEY_INDEX, parser.nextInt(0));
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
@@ -79,11 +79,11 @@ public class AuroProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- position.setCourse(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setCourse(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
- position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
return position;
}
diff --git a/src/org/traccar/protocol/AutoGradeProtocolDecoder.java b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
index 4f691171c..753509f31 100644
--- a/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
@@ -77,17 +77,17 @@ public class AutoGradeProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
- 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));
int status = parser.next().charAt(0);
position.set(Position.KEY_STATUS, status);
diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java
index 82c1c9c24..562731657 100644
--- a/src/org/traccar/protocol/BoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/BoxProtocolDecoder.java
@@ -83,15 +83,15 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_ODOMETER_TRIP, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER_TRIP, parser.nextDouble(0) * 1000);
position.set(Position.KEY_EVENT, parser.next());
- int status = parser.nextInt();
+ int status = parser.nextInt(0);
position.setValid((status & 0x04) == 0);
position.set(Position.KEY_STATUS, status);
diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
index 40af1c812..3064bbb35 100644
--- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
@@ -77,15 +77,15 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_COMMAND, parser.next());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.PREFIX_IO + 1, parser.next());
diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java
index 40e40a40f..fedc65168 100644
--- a/src/org/traccar/protocol/CarcellProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java
@@ -107,24 +107,24 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(parser.nextCoordinate(CoordinateFormat.HEM_DEG));
}
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
- position.setCourse(parser.nextInt());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
+ position.setCourse(parser.nextInt(0));
if (parser.hasNext(3)) {
- position.set("x", parser.nextInt());
- position.set("y", parser.nextInt());
- position.set("z", parser.nextInt());
+ position.set("x", parser.nextInt(0));
+ position.set("y", parser.nextInt(0));
+ position.set("z", parser.nextInt(0));
}
if (parser.hasNext(1)) {
- position.set(Position.KEY_ACCELERATION, parser.nextInt());
+ position.set(Position.KEY_ACCELERATION, parser.nextInt(0));
}
- Double internalBattery = (parser.nextDouble() + 100d) * 0.0294d;
+ Double internalBattery = (parser.nextDouble(0) + 100d) * 0.0294d;
position.set(Position.KEY_BATTERY, internalBattery);
- position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
position.set("jamming", parser.next().equals("1"));
- position.set(Position.KEY_GPS, parser.nextInt());
+ position.set(Position.KEY_GPS, parser.nextInt(0));
position.set("clockType", parser.next());
@@ -144,16 +144,16 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder {
}
position.set("painel", painelStatus.equals("2"));
- Double mainVoltage = parser.nextDouble() / 100d;
+ Double mainVoltage = parser.nextDouble(0) / 100d;
position.set(Position.KEY_POWER, mainVoltage);
}
if (parser.hasNext(5)) {
- position.set("timeUntilDelivery", parser.nextInt());
+ position.set("timeUntilDelivery", parser.nextInt(0));
parser.next(); // panic button status
position.set(Position.KEY_INPUT, parser.next());
- Double mainVoltage = parser.nextDouble() / 100d;
+ Double mainVoltage = parser.nextDouble(0) / 100d;
position.set(Position.KEY_POWER, mainVoltage);
position.set("iccid", parser.next());
diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java
index 144b29f49..ac3df1cd7 100644
--- a/src/org/traccar/protocol/CarscopProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java
@@ -76,20 +76,20 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
- dateBuilder.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDate(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_STATUS, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java
index f1d593944..e1274d9d8 100644
--- a/src/org/traccar/protocol/CguardProtocolDecoder.java
+++ b/src/org/traccar/protocol/CguardProtocolDecoder.java
@@ -65,14 +65,14 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
position.setValid(true);
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
- position.setAccuracy(parser.nextDouble());
+ position.setAccuracy(parser.nextDouble(0));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index a9fee9fe7..6f2764e84 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -105,9 +105,9 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
- position.setSpeed(parser.nextDouble());
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
} else {
@@ -116,7 +116,7 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
}
position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt())));
+ parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0))));
return position;
}
diff --git a/src/org/traccar/protocol/CradlepointProtocolDecoder.java b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
index 0656b831f..a4ad118aa 100644
--- a/src/org/traccar/protocol/CradlepointProtocolDecoder.java
+++ b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
@@ -72,8 +72,8 @@ public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
parser.skip(4);
diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java
index 26ca1a856..2b25f01fa 100644
--- a/src/org/traccar/protocol/DishaProtocolDecoder.java
+++ b/src/org/traccar/protocol/DishaProtocolDecoder.java
@@ -81,19 +81,19 @@ public class DishaProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_SATELLITES, parser.next());
position.set(Position.KEY_HDOP, parser.next());
position.set(Position.KEY_RSSI, parser.next());
- position.set(Position.KEY_CHARGE, parser.nextInt() == 2);
+ position.set(Position.KEY_CHARGE, parser.nextInt(0) == 2);
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
- position.set(Position.PREFIX_ADC + 2, parser.nextInt());
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 2, parser.nextInt(0));
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
position.set(Position.KEY_INPUT, parser.next());
return position;
diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
index 7c91b843c..f44c91c4a 100644
--- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
+import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -74,30 +75,33 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
- position.setTime(parser.nextDateTime(16));
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0))
+ .setTime(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0));
+ position.setTime(dateBuilder.getDate());
- if (BitUtil.check(parser.nextInt(16), 3)) {
- position.setLatitude(-parser.nextInt(16) / 600000.0);
+ if (BitUtil.check(parser.nextHexInt(0), 3)) {
+ position.setLatitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLatitude(parser.nextInt(16) / 600000.0);
+ position.setLatitude(parser.nextHexInt(0) / 600000.0);
}
- if (BitUtil.check(parser.nextInt(16), 3)) {
- position.setLongitude(-parser.nextInt(16) / 600000.0);
+ if (BitUtil.check(parser.nextHexInt(0), 3)) {
+ position.setLongitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLongitude(parser.nextInt(16) / 600000.0);
+ position.setLongitude(parser.nextHexInt(0) / 600000.0);
}
- position.setSpeed(parser.nextInt(16) / 100.0);
- position.setCourse(parser.nextInt(16) / 100.0);
+ position.setSpeed(parser.nextHexInt(0) / 100.0);
+ position.setCourse(parser.nextHexInt(0) / 100.0);
position.set(Position.KEY_STATUS, parser.next());
position.set("signal", parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble());
- position.set("oil", parser.nextInt(16));
- position.set(Position.KEY_ODOMETER, parser.nextInt(16) * 100);
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set("oil", parser.nextHexInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextHexInt(0) * 100);
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index f9045a6f6..f0b79aa1f 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -100,15 +100,15 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/ExtremTracProtocolDecoder.java b/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
index deb1ed24b..79e3306df 100644
--- a/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
+++ b/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
@@ -66,15 +66,15 @@ public class ExtremTracProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
index bec212f30..f8f4fb078 100644
--- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
@@ -87,23 +87,23 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
position.setValid(parser.next().equals("A"));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
- position.setCourse(parser.nextInt());
- position.setAltitude(parser.nextInt());
-
- position.set(Position.KEY_ODOMETER, parser.nextLong());
- position.set(Position.KEY_STATUS, parser.nextInt(16));
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
+ position.setCourse(parser.nextInt(0));
+ position.setAltitude(parser.nextInt(0));
+
+ position.set(Position.KEY_ODOMETER, parser.nextLong(0));
+ position.set(Position.KEY_STATUS, parser.nextHexInt(0));
if (parser.hasNext()) {
- position.set(Position.KEY_INPUT, parser.nextInt(16));
+ position.set(Position.KEY_INPUT, parser.nextHexInt(0));
}
if (parser.hasNext()) {
- position.set(Position.KEY_OUTPUT, parser.nextInt(16));
+ position.set(Position.KEY_OUTPUT, parser.nextHexInt(0));
}
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))));
String[] adc = parser.next().split("\\|");
for (int i = 0; i < adc.length; i++) {
diff --git a/src/org/traccar/protocol/FlextrackProtocolDecoder.java b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
index 2d7414f82..ab2e4d24c 100644
--- a/src/org/traccar/protocol/FlextrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
@@ -114,24 +114,25 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
- position.setCourse(parser.nextInt());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
+ position.setCourse(parser.nextInt(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
- int rssi = parser.nextInt();
- position.set(Position.KEY_STATUS, parser.nextInt(16));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ int rssi = parser.nextInt(0);
+ position.set(Position.KEY_STATUS, parser.nextHexInt(0));
- int mcc = parser.nextInt();
- int mnc = parser.nextInt();
+ int mcc = parser.nextInt(0);
+ int mnc = parser.nextInt(0);
- position.setAltitude(parser.nextInt());
+ position.setAltitude(parser.nextInt(0));
- position.set(Position.KEY_HDOP, parser.nextInt() * 0.1);
+ position.set(Position.KEY_HDOP, parser.nextInt(0) * 0.1);
- position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(16), parser.nextInt(16), rssi)));
+ position.setNetwork(new Network(CellTower.from(
+ mcc, mnc, parser.nextHexInt(0), parser.nextHexInt(0), rssi)));
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/FoxProtocolDecoder.java b/src/org/traccar/protocol/FoxProtocolDecoder.java
index 83bebd7c0..9b2cf0e1d 100644
--- a/src/org/traccar/protocol/FoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/FoxProtocolDecoder.java
@@ -92,25 +92,25 @@ public class FoxProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_STATUS, parser.nextInt());
+ position.set(Position.KEY_STATUS, parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
-
- position.set(Position.KEY_INPUT, parser.nextInt(2));
- position.set(Position.KEY_POWER, parser.nextDouble() * 0.1);
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
- position.set(Position.PREFIX_ADC + 2, parser.nextInt());
- position.set(Position.KEY_OUTPUT, parser.nextInt(2));
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+
+ position.set(Position.KEY_INPUT, parser.nextBinInt(0));
+ position.set(Position.KEY_POWER, parser.nextDouble(0) * 0.1);
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 2, parser.nextInt(0));
+ position.set(Position.KEY_OUTPUT, parser.nextBinInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
position.set("statusData", parser.next());
diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java
index 50546782c..56b6b9e19 100644
--- a/src/org/traccar/protocol/FreedomProtocolDecoder.java
+++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java
@@ -69,7 +69,7 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index 0b3c72a91..945edfff0 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -81,12 +81,12 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.setValid(parser.nextInt() == 0);
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
+ position.setValid(parser.nextInt(0) == 0);
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime());
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index f8ad60d4d..eb1099adc 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -396,8 +396,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // odometer or external power
- position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
+ 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() + "%");
@@ -413,7 +413,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, parser.nextDateTime());
- position.set(Position.KEY_INDEX, parser.nextInt(16));
+ position.set(Position.KEY_INDEX, parser.nextHexInt(0));
return position;
}
@@ -426,8 +426,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.set("deviceType", parser.next());
- position.set(Position.KEY_VERSION_FW, parser.nextInt(16));
- position.set(Position.KEY_VERSION_HW, parser.nextInt(16));
+ position.set(Position.KEY_VERSION_FW, parser.nextHexInt(0));
+ position.set(Position.KEY_VERSION_HW, parser.nextHexInt(0));
getLastLocation(position, parser.nextDateTime());
@@ -435,35 +435,35 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
private void decodeLocation(Position position, Parser parser) {
- int hdop = parser.nextInt();
+ int hdop = parser.nextInt(0);
position.setValid(hdop > 0);
position.set(Position.KEY_HDOP, hdop);
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
if (parser.hasNext(8)) {
position.setValid(true);
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime());
} else {
getLastLocation(position, null);
}
if (parser.hasNext(6)) {
- int mcc = parser.nextInt();
- int mnc = parser.nextInt();
+ int mcc = parser.nextInt(0);
+ int mnc = parser.nextInt(0);
if (parser.hasNext(2)) {
- position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(), parser.nextInt())));
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(0), parser.nextInt(0))));
}
if (parser.hasNext(2)) {
- position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextInt(16), parser.nextInt(16))));
+ position.setNetwork(new Network(CellTower.from(mcc, mnc, parser.nextHexInt(0), parser.nextHexInt(0))));
}
}
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
}
private Object decodeObd(Channel channel, SocketAddress remoteAddress, String sentence) {
@@ -473,21 +473,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set(Position.KEY_OBD_SPEED, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set(Position.KEY_OBD_SPEED, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
position.set(Position.KEY_FUEL_CONSUMPTION, parser.next());
- position.set("dtcsClearedDistance", parser.nextInt());
- position.set("odbConnect", parser.nextInt() == 1);
- position.set("dtcsNumber", parser.nextInt());
+ position.set("dtcsClearedDistance", parser.nextInt(0));
+ position.set("odbConnect", parser.nextInt(0) == 1);
+ position.set("dtcsNumber", parser.nextInt(0));
position.set("dtcsCodes", parser.next());
- position.set(Position.KEY_THROTTLE, parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.KEY_OBD_ODOMETER, parser.nextInt() * 1000);
+ position.set(Position.KEY_THROTTLE, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
+ position.set(Position.KEY_OBD_ODOMETER, parser.nextInt(0) * 1000);
decodeLocation(position, parser);
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
decodeDeviceTime(position, parser);
@@ -496,14 +496,14 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
private void decodeStatus(Position position, Parser parser) {
if (parser.hasNext(3)) {
- int ignition = parser.nextInt(16);
+ int ignition = parser.nextHexInt(0);
if (BitUtil.check(ignition, 4)) {
position.set(Position.KEY_IGNITION, false);
} else if (BitUtil.check(ignition, 5)) {
position.set(Position.KEY_IGNITION, true);
}
- position.set(Position.KEY_INPUT, parser.nextInt(16));
- position.set(Position.KEY_OUTPUT, parser.nextInt(16));
+ position.set(Position.KEY_INPUT, parser.nextHexInt(0));
+ position.set(Position.KEY_OUTPUT, parser.nextHexInt(0));
}
}
@@ -521,7 +521,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
LinkedList<Position> positions = new LinkedList<>();
String vin = parser.next();
- int power = parser.nextInt();
+ int power = parser.nextInt(0);
Parser itemParser = new Parser(PATTERN_LOCATION, parser.next());
while (itemParser.find()) {
@@ -545,10 +545,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, power);
}
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ 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());
@@ -556,8 +556,8 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeStatus(position, parser);
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
decodeDeviceTime(position, parser);
@@ -577,7 +577,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
LinkedList<Position> positions = new LinkedList<>();
- int power = parser.nextInt();
+ int power = parser.nextInt(0);
Parser itemParser = new Parser(PATTERN_LOCATION, parser.next());
while (itemParser.find()) {
@@ -595,7 +595,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
position.set(Position.KEY_POWER, power);
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ 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());
@@ -618,7 +618,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
position.set(Position.KEY_HOURS, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
decodeDeviceTime(position, parser);
@@ -636,7 +636,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
decodeDeviceTime(position, parser);
@@ -654,7 +654,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
Network network = new Network();
- parser.nextInt(); // count
+ parser.nextInt(0); // count
Matcher matcher = Pattern.compile("([0-9a-fA-F]{12}),(-?\\d+),,,,").matcher(parser.next());
while (matcher.find()) {
String mac = matcher.group(1).replaceAll("(..)", "$1:");
@@ -664,7 +664,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(network);
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
return position;
}
@@ -702,7 +702,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- int reportType = parser.nextInt();
+ int reportType = parser.nextInt(0);
if (type.equals("NMR")) {
position.set(Position.KEY_MOTION, reportType);
} else if (type.equals("SOS")) {
@@ -711,10 +711,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
decodeLocation(position, parser);
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
decodeDeviceTime(position, parser);
@@ -732,17 +732,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- int hdop = parser.nextInt();
+ int hdop = parser.nextInt(0);
position.setValid(hdop > 0);
position.set(Position.KEY_HDOP, hdop);
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
if (parser.hasNext(2)) {
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
} else {
getLastLocation(position, null);
}
@@ -753,7 +753,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext(4)) {
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))));
}
decodeDeviceTime(position, parser);
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index 50d621271..4357c93dc 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -215,11 +215,11 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setAltitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
position.set(Position.KEY_HDOP, parser.next());
return position;
diff --git a/src/org/traccar/protocol/GnxProtocolDecoder.java b/src/org/traccar/protocol/GnxProtocolDecoder.java
index cb29f5d23..070d394e8 100644
--- a/src/org/traccar/protocol/GnxProtocolDecoder.java
+++ b/src/org/traccar/protocol/GnxProtocolDecoder.java
@@ -89,14 +89,14 @@ public class GnxProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- if (parser.nextInt() == 1) {
+ if (parser.nextInt(0) == 1) {
position.set(Position.KEY_ARCHIVE, true);
}
position.setDeviceTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY, "GMT+5:30"));
position.setFixTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY, "GMT+5:30"));
- position.setValid(parser.nextInt() != 0);
+ position.setValid(parser.nextInt(0) != 0);
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index 51479ad52..ce3a5f0af 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -150,25 +150,25 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.set(Position.KEY_VDOP, parser.nextDouble());
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.KEY_VDOP, parser.nextDouble(0));
if (parser.hasNext(5)) {
- position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), parser.nextInt())));
+ position.setNetwork(new Network(CellTower.from(parser.nextInt(0), parser.nextInt(0),
+ parser.nextHexInt(0), parser.nextHexInt(0), parser.nextInt(0))));
}
if (parser.hasNext()) {
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
}
position.set(Position.KEY_POWER, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
if (parser.hasNext(6)) {
- long status = parser.nextLong(16);
+ long status = parser.nextLong(16, 0);
position.set(Position.KEY_IGNITION, BitUtil.check(status, 13));
position.set(Position.KEY_STATUS, status);
position.set("ioStatus", parser.next());
@@ -223,17 +223,17 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_HDOP, parser.next());
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java
index aa1ab57fb..f938887e2 100644
--- a/src/org/traccar/protocol/GotopProtocolDecoder.java
+++ b/src/org/traccar/protocol/GotopProtocolDecoder.java
@@ -70,11 +70,11 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
position.set(Position.KEY_STATUS, parser.next());
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 890465ab9..b0113e0be 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -189,7 +189,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.setNetwork(new Network(
- CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+ CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0))));
return position;
@@ -206,15 +206,15 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, parser.nextDateTime());
- position.set(Position.KEY_ODOMETER, parser.nextInt());
- parser.nextDouble(); // instant fuel consumption
- position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble());
- position.set(Position.KEY_HOURS, parser.nextInt());
- position.set(Position.KEY_OBD_SPEED, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
+ parser.nextDouble(0); // instant fuel consumption
+ position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble(0));
+ position.set(Position.KEY_HOURS, parser.nextInt(0));
+ position.set(Position.KEY_OBD_SPEED, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
position.set(Position.KEY_THROTTLE, parser.next());
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
position.set(Position.KEY_DTCS, parser.next().replace(',', ' ').trim());
return position;
@@ -250,10 +250,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setDate(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
- int localHours = parser.nextInt();
- int localMinutes = parser.nextInt();
+ int localHours = parser.nextInt(0);
+ int localMinutes = parser.nextInt(0);
String rfid = parser.next();
if (alarm.equals("rfid")) {
@@ -263,7 +263,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
String utcHours = parser.next();
String utcMinutes = parser.next();
- dateBuilder.setTime(localHours, localMinutes, parser.nextInt());
+ dateBuilder.setTime(localHours, localMinutes, parser.nextInt(0));
// Timezone calculation
if (utcHours != null && utcMinutes != null) {
@@ -281,9 +281,9 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_HEM));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
for (int i = 1; i <= 5; i++) {
position.set(Position.PREFIX_IO + i, parser.next());
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index 701b1874b..ca1d6453e 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -123,15 +123,15 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
@@ -154,9 +154,9 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setAltitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
diff --git a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
index 36f4a19c6..2af307c25 100644
--- a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
@@ -75,10 +75,10 @@ public class GpsMarkerProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN_MIN));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt(16));
+ position.set(Position.KEY_SATELLITES, parser.nextHexInt(0));
position.set(Position.KEY_BATTERY, parser.next());
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
diff --git a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
index e0dd5fd51..11777bece 100644
--- a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
@@ -69,17 +69,17 @@ public class GpsmtaProtocolDecoder extends BaseProtocolDecoder {
String time = parser.next();
position.setTime(new Date(Long.parseLong(time) * 1000));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(parser.nextInt());
- position.setCourse(parser.nextInt());
- position.setAccuracy(parser.nextInt());
- position.setAltitude(parser.nextInt());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextInt(0));
+ position.setCourse(parser.nextInt(0));
+ position.setAccuracy(parser.nextInt(0));
+ position.setAltitude(parser.nextInt(0));
- position.set(Position.KEY_STATUS, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
+ position.set(Position.KEY_STATUS, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
if (channel != null) {
channel.write(time, remoteAddress);
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index c697191ee..5ddca8096 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -232,8 +232,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextDouble(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/Gt30ProtocolDecoder.java b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
index c034300d0..ca5a23380 100644
--- a/src/org/traccar/protocol/Gt30ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
@@ -93,20 +93,20 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_HDOP, parser.next());
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 465bf8395..fdef2e3c1 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -224,7 +224,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder();
if (parser.hasNext(3)) {
- dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
}
if (parser.hasNext()) {
@@ -245,31 +245,31 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(parser.nextCoordinate());
}
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
if (parser.hasNext(3)) {
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
} else {
position.setTime(new Date());
}
- processStatus(position, parser.nextLong(16));
+ processStatus(position, parser.nextLong(16, 0));
if (parser.hasNext(6)) {
- position.set(Position.KEY_ODOMETER, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextDouble(0));
- position.setAltitude(parser.nextInt());
+ position.setAltitude(parser.nextInt(0));
- position.setNetwork(new Network(CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+ position.setNetwork(new Network(CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0))));
}
if (parser.hasNext(4)) {
for (int i = 1; i <= 4; i++) {
- position.set(Position.PREFIX_IO + i, parser.nextInt());
+ position.set(Position.PREFIX_IO + i, parser.nextInt(0));
}
}
@@ -293,11 +293,11 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
Network network = new Network();
- int mcc = parser.nextInt();
- int mnc = parser.nextInt();
+ int mcc = parser.nextInt(0);
+ int mnc = parser.nextInt(0);
String[] cells = parser.next().split(",");
for (int i = 0; i < cells.length / 3; i++) {
@@ -307,11 +307,11 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(network);
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
getLastLocation(position, dateBuilder.getDate());
- processStatus(position, parser.nextLong(16));
+ processStatus(position, parser.nextLong(16, 0));
return position;
}
diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java
index 45a56cc10..7130405f6 100644
--- a/src/org/traccar/protocol/HaicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java
@@ -75,33 +75,33 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- int flags = parser.nextInt();
+ int flags = parser.nextInt(0);
position.setValid(BitUtil.check(flags, 0));
- double latitude = parser.nextDouble() + parser.nextDouble() / 60000;
+ double latitude = parser.nextDouble(0) + parser.nextDouble(0) / 60000;
if (BitUtil.check(flags, 2)) {
position.setLatitude(latitude);
} else {
position.setLatitude(-latitude);
}
- double longitude = parser.nextDouble() + parser.nextDouble() / 60000;
+ double longitude = parser.nextDouble(0) + parser.nextDouble(0) / 60000;
if (BitUtil.check(flags, 1)) {
position.setLongitude(longitude);
} else {
position.setLongitude(-longitude);
}
- position.setSpeed(parser.nextDouble() / 10);
- position.setCourse(parser.nextDouble() / 10);
+ position.setSpeed(parser.nextDouble(0) / 10);
+ position.setCourse(parser.nextDouble(0) / 10);
position.set(Position.KEY_STATUS, parser.next());
position.set(Position.KEY_RSSI, parser.next());
position.set(Position.KEY_GPS, parser.next());
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
- position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1);
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0) * 0.1);
return position;
}
diff --git a/src/org/traccar/protocol/HomtecsProtocolDecoder.java b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
index 375fa27b8..508de173c 100644
--- a/src/org/traccar/protocol/HomtecsProtocolDecoder.java
+++ b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
@@ -72,18 +72,18 @@ public class HomtecsProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.YMD_HMS));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.setValid(parser.nextInt() > 0);
+ position.setValid(parser.nextInt(0) > 0);
- position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/HunterProProtocolDecoder.java b/src/org/traccar/protocol/HunterProProtocolDecoder.java
index 6f2bb8fd8..b1e3f84a2 100644
--- a/src/org/traccar/protocol/HunterProProtocolDecoder.java
+++ b/src/org/traccar/protocol/HunterProProtocolDecoder.java
@@ -66,15 +66,15 @@ public class HunterProProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder();
- dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java
index b5a23e1f2..e56a0f022 100644
--- a/src/org/traccar/protocol/IdplProtocolDecoder.java
+++ b/src/org/traccar/protocol/IdplProtocolDecoder.java
@@ -72,7 +72,7 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.set(Position.KEY_TYPE, parser.nextInt());
+ position.set(Position.KEY_TYPE, parser.nextInt(0));
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
@@ -85,23 +85,23 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate(CoordinateFormat.DEG_MIN_MIN_HEM));
position.setLongitude(parser.nextCoordinate(CoordinateFormat.DEG_MIN_MIN_HEM));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
position.set("vehicleStatus", parser.next());
- position.set(Position.KEY_POWER, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextDouble());
- if (parser.nextInt() == 1) {
+ position.set(Position.KEY_POWER, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
+ if (parser.nextInt(0) == 1) {
position.set(Position.KEY_ALARM, Position.ALARM_SOS);
}
- parser.nextInt(); // body tamper
- position.set("acStatus", parser.nextInt());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_OUTPUT, parser.nextInt());
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
- position.set(Position.PREFIX_ADC + 2, parser.nextInt());
+ parser.nextInt(0); // body tamper
+ position.set("acStatus", parser.nextInt(0));
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_OUTPUT, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 2, parser.nextInt(0));
position.set(Position.KEY_VERSION_FW, parser.next());
position.set(Position.KEY_ARCHIVE, parser.next().equals("R"));
diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
index f43fa4aac..daba15a90 100644
--- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java
+++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
@@ -83,34 +83,34 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- int satellites = parser.nextInt();
+ int satellites = parser.nextInt(0);
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
- position.set(Position.KEY_INDEX, parser.nextLong());
- position.set(Position.KEY_INPUT, parser.nextInt());
- position.set(Position.KEY_OUTPUT, parser.nextInt());
+ position.set(Position.KEY_INDEX, parser.nextLong(0));
+ position.set(Position.KEY_INPUT, parser.nextInt(0));
+ position.set(Position.KEY_OUTPUT, parser.nextInt(0));
- position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
- position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble(0));
+ position.set(Position.PREFIX_ADC + 2, parser.nextDouble(0));
// J1939 data
- position.set(Position.KEY_OBD_SPEED, parser.nextInt());
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set("coolant", parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_CHARGE, parser.nextInt());
- position.set("tpl", parser.nextInt());
- position.set("axle", parser.nextInt());
- position.set(Position.KEY_OBD_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_OBD_SPEED, parser.nextInt(0));
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set("coolant", parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_CHARGE, parser.nextInt(0));
+ position.set("tpl", parser.nextInt(0));
+ position.set("axle", parser.nextInt(0));
+ position.set(Position.KEY_OBD_ODOMETER, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
index 9a23a95fe..654b3e3d0 100644
--- a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
+++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
@@ -73,15 +73,15 @@ public class JpKorjarProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
- position.setValid(parser.nextInt() == 1);
+ position.setValid(parser.nextInt(0) == 1);
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;
}
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 05b4abbb0..ef20a9534 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -194,13 +194,13 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_POWER, parser.nextDouble());
- position.set(Position.KEY_GPS, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
- position.set("alertType", parser.nextInt());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set(Position.KEY_GPS, parser.nextInt(0));
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
+ position.set("alertType", parser.nextInt(0));
return position;
}
@@ -253,19 +253,19 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_STATUS, parser.nextInt(2));
+ position.set(Position.KEY_STATUS, parser.nextBinInt(0));
- CellTower cellTower = CellTower.fromCidLac(parser.nextInt(), parser.nextInt());
- cellTower.setSignalStrength(parser.nextInt());
+ CellTower cellTower = CellTower.fromCidLac(parser.nextInt(0), parser.nextInt(0));
+ cellTower.setSignalStrength(parser.nextInt(0));
position.setNetwork(new Network(cellTower));
- position.set(Position.KEY_ODOMETER, parser.nextLong() * 1000);
- position.set(Position.KEY_INDEX, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextLong(0) * 1000);
+ position.set(Position.KEY_INDEX, parser.nextInt(0));
if (channel != null) {
if (type.equals("U01") || type.equals("U02") || type.equals("U03")) {
diff --git a/src/org/traccar/protocol/KenjiProtocolDecoder.java b/src/org/traccar/protocol/KenjiProtocolDecoder.java
index 43038ec94..4216da0c3 100644
--- a/src/org/traccar/protocol/KenjiProtocolDecoder.java
+++ b/src/org/traccar/protocol/KenjiProtocolDecoder.java
@@ -85,24 +85,24 @@ public class KenjiProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(16)));
- position.set(Position.KEY_OUTPUT, parser.nextInt(16));
- position.set(Position.KEY_INPUT, parser.nextInt(16));
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt(0)));
+ position.set(Position.KEY_OUTPUT, parser.nextHexInt(0));
+ position.set(Position.KEY_INPUT, parser.nextHexInt(0));
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/L100ProtocolDecoder.java b/src/org/traccar/protocol/L100ProtocolDecoder.java
index b7c91bc7f..f98e532bc 100644
--- a/src/org/traccar/protocol/L100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/L100ProtocolDecoder.java
@@ -92,26 +92,26 @@ public class L100ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_STATUS, parser.next());
position.set(Position.PREFIX_ADC + 1, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble());
- position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
- position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextDouble(0));
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
- int rssi = parser.nextInt();
+ int rssi = parser.nextInt(0);
position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt(), rssi)));
+ parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), rssi)));
return position;
}
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index d0bc7583c..32d4ff0e6 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -76,17 +76,17 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
String status = parser.next();
position.setValid(status.toUpperCase().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
String type = parser.next();
diff --git a/src/org/traccar/protocol/MaestroProtocolDecoder.java b/src/org/traccar/protocol/MaestroProtocolDecoder.java
index dfda3d693..7d779a0a0 100644
--- a/src/org/traccar/protocol/MaestroProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaestroProtocolDecoder.java
@@ -74,27 +74,27 @@ public class MaestroProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setValid(parser.nextInt() == 1);
+ position.setValid(parser.nextInt(0) == 1);
- position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_RSSI, parser.nextInt());
- position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
+ position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
position.setTime(parser.nextDateTime());
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34);
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1609.34);
if (parser.hasNext()) {
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
}
return position;
diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
index 08cb8b818..6cff8b961 100644
--- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java
+++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
@@ -73,7 +73,7 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 6be4845a7..3501dce67 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -88,15 +88,15 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return true;
@@ -168,9 +168,9 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.next());
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
String charger = parser.next();
if (charger != null) {
@@ -179,7 +179,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext(4)) {
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))));
}
} else {
@@ -203,8 +203,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), parser.nextInt())));
+ position.setNetwork(new Network(CellTower.from(parser.nextInt(0), parser.nextInt(0),
+ parser.nextHexInt(0), parser.nextHexInt(0), parser.nextInt(0))));
position.set(Position.KEY_BATTERY, Double.parseDouble(parser.next()));
@@ -293,25 +293,25 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
if (parser.hasNext()) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
}
position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), parser.nextInt())));
+ parser.nextInt(0), parser.nextInt(0), parser.nextHexInt(0), parser.nextHexInt(0), parser.nextInt(0))));
- position.set(Position.KEY_INPUT, parser.nextInt(2));
- position.set(Position.KEY_OUTPUT, parser.nextInt(2));
+ position.set(Position.KEY_INPUT, parser.nextBinInt(0));
+ position.set(Position.KEY_OUTPUT, parser.nextBinInt(0));
for (int i = 1; i <= 3; i++) {
- position.set(Position.PREFIX_ADC + i, parser.nextInt());
+ position.set(Position.PREFIX_ADC + i, parser.nextInt(0));
}
for (int i = 1; i <= 2; i++) {
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index af0b356a6..b947b2855 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -210,50 +210,50 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
if (parser.hasNext()) {
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
}
if (parser.hasNext()) {
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
}
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_HDOP, parser.next());
if (parser.hasNext()) {
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
}
position.set(Position.KEY_STATUS, parser.next());
for (int i = 1; i <= 8; i++) {
if (parser.hasNext()) {
- position.set(Position.PREFIX_ADC + i, parser.nextInt(16));
+ position.set(Position.PREFIX_ADC + i, parser.nextHexInt(0));
}
}
if (parser.hasNext()) {
- position.set(Position.KEY_RSSI, parser.nextInt(16));
+ position.set(Position.KEY_RSSI, parser.nextHexInt(0));
}
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.KEY_ODOMETER, parser.nextLong(16));
+ position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0));
}
if (parser.hasNext()) {
- position.set(Position.KEY_RFID, parser.nextInt(16));
+ position.set(Position.KEY_RFID, parser.nextHexInt(0));
}
return position;
@@ -282,21 +282,21 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set(Position.KEY_OBD_SPEED, parser.nextInt());
- position.set(Position.KEY_THROTTLE, parser.nextDouble());
- position.set("engineLoad", parser.nextDouble());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble());
- position.set("averageFuelConsumption", parser.nextDouble());
- position.set("drivingRange", parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.nextDouble());
- position.set("singleFuelConsumption", parser.nextDouble());
- position.set("totalFuelConsumption", parser.nextDouble());
- position.set(Position.KEY_DTCS, parser.nextInt());
- position.set("harshAcelerationNo", parser.nextInt());
- position.set("harshBreakerNo", parser.nextInt());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
+ position.set(Position.KEY_RPM, parser.nextInt(0));
+ position.set(Position.KEY_OBD_SPEED, parser.nextInt(0));
+ position.set(Position.KEY_THROTTLE, parser.nextDouble(0));
+ position.set("engineLoad", parser.nextDouble(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble(0));
+ position.set("averageFuelConsumption", parser.nextDouble(0));
+ position.set("drivingRange", parser.nextDouble(0));
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0));
+ position.set("singleFuelConsumption", parser.nextDouble(0));
+ position.set("totalFuelConsumption", parser.nextDouble(0));
+ position.set(Position.KEY_DTCS, parser.nextInt(0));
+ position.set("harshAcelerationNo", parser.nextInt(0));
+ position.set("harshBreakerNo", parser.nextInt(0));
return position;
}
@@ -309,15 +309,15 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set("totalIgnitionNo", parser.nextInt());
- position.set("totalDrivingTime", parser.nextDouble());
- position.set("totalIdlingTime", parser.nextDouble());
- position.set("averageHotStartTime", parser.nextInt());
- position.set("averageSpeed", parser.nextInt());
- position.set("historyHighestSpeed", parser.nextInt());
- position.set("historyHighestRpm", parser.nextInt());
- position.set("totalHarshAccerleration", parser.nextInt());
- position.set("totalHarshBrake", parser.nextInt());
+ position.set("totalIgnitionNo", parser.nextInt(0));
+ position.set("totalDrivingTime", parser.nextDouble(0));
+ position.set("totalIdlingTime", parser.nextDouble(0));
+ position.set("averageHotStartTime", parser.nextInt(0));
+ position.set("averageSpeed", parser.nextInt(0));
+ position.set("historyHighestSpeed", parser.nextInt(0));
+ position.set("historyHighestRpm", parser.nextInt(0));
+ position.set("totalHarshAccerleration", parser.nextInt(0));
+ position.set("totalHarshBrake", parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 9189d2a66..658359789 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -121,43 +121,43 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- int event = parser.nextInt();
+ int event = parser.nextInt(0);
position.set(Position.KEY_EVENT, event);
position.set(Position.KEY_ALARM, decodeAlarm(event));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime());
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
- int rssi = parser.nextInt();
+ int rssi = parser.nextInt(0);
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_HDOP, parser.next());
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
position.set("runtime", parser.next());
- position.setNetwork(new Network(
- CellTower.from(parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16), rssi)));
+ position.setNetwork(new Network(CellTower.from(
+ parser.nextInt(0), parser.nextInt(0), parser.nextHexInt(0), parser.nextHexInt(0), rssi)));
position.set(Position.KEY_STATUS, parser.next());
for (int i = 1; i <= 3; i++) {
if (parser.hasNext()) {
- position.set(Position.PREFIX_ADC + i, parser.nextInt(16));
+ position.set(Position.PREFIX_ADC + i, parser.nextHexInt(0));
}
}
- position.set(Position.KEY_BATTERY, parser.nextInt(16));
- position.set(Position.KEY_POWER, parser.nextInt(16));
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0));
+ position.set(Position.KEY_POWER, parser.nextHexInt(0));
String eventData = parser.next();
if (eventData != null && !eventData.isEmpty()) {
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index c7b0aecb2..bb0057964 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -78,8 +78,8 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
private void decodeFix(Position position, Parser parser) {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
}
private void decodeFlags(Position position, int flags) {
@@ -114,25 +114,25 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
private void decodeState(Position position, Parser parser) {
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
if (position.getCourse() > 360) {
position.setCourse(0);
}
- decodeFlags(position, parser.nextInt(16));
+ decodeFlags(position, parser.nextHexInt(0));
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
}
private void decodeGPSPrecision(Position position, Parser parser) {
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt());
- position.set(Position.KEY_HDOP, parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt(0));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
}
@Override
diff --git a/src/org/traccar/protocol/MtxProtocolDecoder.java b/src/org/traccar/protocol/MtxProtocolDecoder.java
index 8ad4ad314..d7b572670 100644
--- a/src/org/traccar/protocol/MtxProtocolDecoder.java
+++ b/src/org/traccar/protocol/MtxProtocolDecoder.java
@@ -80,12 +80,12 @@ public class MtxProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
position.setValid(true);
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
position.set(Position.PREFIX_ADC + 1, parser.next());
diff --git a/src/org/traccar/protocol/PathAwayProtocolDecoder.java b/src/org/traccar/protocol/PathAwayProtocolDecoder.java
index 0a2204222..1c4531612 100644
--- a/src/org/traccar/protocol/PathAwayProtocolDecoder.java
+++ b/src/org/traccar/protocol/PathAwayProtocolDecoder.java
@@ -79,11 +79,11 @@ public class PathAwayProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.setValid(true);
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
if (channel != null) {
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
diff --git a/src/org/traccar/protocol/PretraceProtocolDecoder.java b/src/org/traccar/protocol/PretraceProtocolDecoder.java
index dc83b7ed2..77d94068f 100644
--- a/src/org/traccar/protocol/PretraceProtocolDecoder.java
+++ b/src/org/traccar/protocol/PretraceProtocolDecoder.java
@@ -81,14 +81,14 @@ public class PretraceProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
- position.setCourse(parser.nextInt());
- position.setAltitude(parser.nextInt(16));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
+ position.setCourse(parser.nextInt(0));
+ position.setAltitude(parser.nextHexInt(0));
- position.set(Position.KEY_ODOMETER, parser.nextInt(16));
- position.set(Position.KEY_SATELLITES, parser.nextInt(16));
- position.set(Position.KEY_HDOP, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextHexInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextHexInt(0));
+ position.set(Position.KEY_HDOP, parser.nextInt(0));
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
index 11df9d218..c36be7976 100644
--- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
@@ -66,15 +66,15 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index e2d7f059a..eb86f01ff 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -109,15 +109,15 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_INPUT, parser.next());
@@ -130,11 +130,11 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
}
}
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
position.set(Position.KEY_RFID, parser.next());
if (parser.hasNext()) {
- int value = parser.nextInt(16);
+ int value = parser.nextHexInt(0);
position.set(Position.KEY_BATTERY, value >> 8);
position.set(Position.KEY_RSSI, (value >> 4) & 0xf);
position.set(Position.KEY_SATELLITES, value & 0xf);
diff --git a/src/org/traccar/protocol/RaveonProtocolDecoder.java b/src/org/traccar/protocol/RaveonProtocolDecoder.java
index 1fd5e6636..75027246e 100644
--- a/src/org/traccar/protocol/RaveonProtocolDecoder.java
+++ b/src/org/traccar/protocol/RaveonProtocolDecoder.java
@@ -77,19 +77,19 @@ public class RaveonProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS));
- position.setValid(parser.nextInt() != 0);
+ position.setValid(parser.nextInt(0) != 0);
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
- position.setAltitude(parser.nextInt());
+ position.setAltitude(parser.nextInt(0));
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_POWER, parser.nextDouble());
- position.set(Position.KEY_INPUT, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set(Position.KEY_INPUT, parser.nextInt(0));
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
- position.setCourse(parser.nextInt());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
+ position.setCourse(parser.nextInt(0));
position.set(Position.KEY_ALARM, parser.next());
diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java
index fd31ee4e2..5c298e8c5 100644
--- a/src/org/traccar/protocol/RitiProtocolDecoder.java
+++ b/src/org/traccar/protocol/RitiProtocolDecoder.java
@@ -85,15 +85,15 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java
index bd49585f6..c736b2ba3 100644
--- a/src/org/traccar/protocol/SanavProtocolDecoder.java
+++ b/src/org/traccar/protocol/SanavProtocolDecoder.java
@@ -69,15 +69,15 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/SiwiProtocolDecoder.java b/src/org/traccar/protocol/SiwiProtocolDecoder.java
index 76b1e4322..198df24d5 100644
--- a/src/org/traccar/protocol/SiwiProtocolDecoder.java
+++ b/src/org/traccar/protocol/SiwiProtocolDecoder.java
@@ -76,17 +76,17 @@ public class SiwiProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_EVENT, parser.next());
position.set(Position.KEY_IGNITION, parser.next().equals("1"));
- position.set(Position.KEY_ODOMETER, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt(0)));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
position.setValid(parser.next().equals("A"));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setCourse(parser.nextInt());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setCourse(parser.nextInt(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY, "IST"));
diff --git a/src/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/org/traccar/protocol/StarLinkProtocolDecoder.java
index 97091257f..0e9840766 100644
--- a/src/org/traccar/protocol/StarLinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/StarLinkProtocolDecoder.java
@@ -83,7 +83,7 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- int type = parser.nextInt();
+ int type = parser.nextInt(0);
if (type != MSG_EVENT_REPORT) {
return null;
}
@@ -93,7 +93,7 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.setValid(true);
- position.set(Position.KEY_INDEX, parser.nextInt());
+ position.set(Position.KEY_INDEX, parser.nextInt(0));
String[] data = parser.next().split(",");
Integer lac = null, cid = null;
diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
index 599c16a3c..c81e83aab 100644
--- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
@@ -88,28 +88,28 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
// Old format
if (parser.hasNext(5)) {
- position.set(Position.KEY_ODOMETER, parser.nextInt());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_INPUT, parser.nextInt() + parser.nextInt() << 1);
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_INPUT, parser.nextInt(0) + parser.nextInt(0) << 1);
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
}
// New format
if (parser.hasNext(10)) {
- position.set(Position.KEY_CHARGE, parser.nextInt() == 1);
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_INPUT, parser.nextInt());
+ position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_INPUT, parser.nextInt(0));
position.set(Position.KEY_RFID, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.KEY_ACCELERATION, parser.nextInt() == 1);
- position.set(Position.KEY_OUTPUT, parser.nextInt() + parser.nextInt() << 1);
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0));
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0));
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
+ position.set(Position.KEY_ACCELERATION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_OUTPUT, parser.nextInt(0) + parser.nextInt(0) << 1);
}
position.setValid(parser.next().equals("A"));
diff --git a/src/org/traccar/protocol/SupermateProtocolDecoder.java b/src/org/traccar/protocol/SupermateProtocolDecoder.java
index 17e870950..d9b58a7f4 100644
--- a/src/org/traccar/protocol/SupermateProtocolDecoder.java
+++ b/src/org/traccar/protocol/SupermateProtocolDecoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -79,28 +80,31 @@ public class SupermateProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
- position.setTime(parser.nextDateTime(16));
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0))
+ .setTime(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0));
+ position.setTime(dateBuilder.getDate());
- if (parser.nextInt(16) == 8) {
- position.setLatitude(-parser.nextInt(16) / 600000.0);
+ if (parser.nextHexInt(0) == 8) {
+ position.setLatitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLatitude(parser.nextInt(16) / 600000.0);
+ position.setLatitude(parser.nextHexInt(0) / 600000.0);
}
- if (parser.nextInt(16) == 8) {
- position.setLongitude(-parser.nextInt(16) / 600000.0);
+ if (parser.nextHexInt(0) == 8) {
+ position.setLongitude(-parser.nextHexInt(0) / 600000.0);
} else {
- position.setLongitude(parser.nextInt(16) / 600000.0);
+ position.setLongitude(parser.nextHexInt(0) / 600000.0);
}
- position.setSpeed(parser.nextInt(16) / 100.0);
- position.setCourse(parser.nextInt(16) / 100.0);
+ position.setSpeed(parser.nextHexInt(0) / 100.0);
+ position.setCourse(parser.nextHexInt(0) / 100.0);
position.set(Position.KEY_STATUS, parser.next());
position.set("signal", parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble());
- position.set("oil", parser.nextInt(16));
- position.set(Position.KEY_ODOMETER, parser.nextInt(16));
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
+ position.set("oil", parser.nextHexInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextHexInt(0));
if (channel != null) {
Calendar calendar = Calendar.getInstance();
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index c60c92d45..efd647ad3 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -115,15 +115,15 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
if (parser.hasNext(5)) {
@@ -136,8 +136,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_IGNITION, parser.hasNext() && parser.next().equals("1"));
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
}
if (parser.hasNext()) {
@@ -168,7 +168,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder()
.setCurrentDate()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.setValid(true);
@@ -193,8 +193,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
return position;
}
@@ -213,11 +213,11 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
position.setValid(parser.next().equals("A"));
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
position.set(Position.KEY_BATTERY, parser.next());
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 2e37bbd57..280db0b31 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -105,14 +105,14 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
if (parser.hasNext(3)) {
- position.set(Position.KEY_EVENT, parser.nextInt());
- position.setTime(getTime(parser.nextInt(), parser.nextInt(), parser.nextInt()));
+ position.set(Position.KEY_EVENT, parser.nextInt(0));
+ position.setTime(getTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)));
} else if (parser.hasNext()) {
- position.setTime(getTime(parser.nextInt()));
+ position.setTime(getTime(parser.nextInt(0)));
}
if (parser.hasNext()) {
- position.set(Position.KEY_EVENT, parser.nextInt());
+ position.set(Position.KEY_EVENT, parser.nextInt(0));
}
if (parser.hasNext(6)) {
@@ -128,17 +128,17 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
}
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
if (parser.hasNext(4)) {
- position.set(Position.KEY_INPUT, parser.nextInt(16));
- position.set(Position.KEY_SATELLITES, parser.nextInt(16));
- position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.KEY_ODOMETER, parser.nextLong(16));
+ position.set(Position.KEY_INPUT, parser.nextHexInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextHexInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0));
}
- position.setValid(parser.nextInt() != 0);
+ position.setValid(parser.nextInt(0) != 0);
String[] attributes = null;
beginIndex = sentence.indexOf(';');
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index 579a6466b..62b756ab5 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -96,7 +96,7 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- int event = parser.nextInt();
+ int event = parser.nextInt(0);
position.set(Position.KEY_EVENT, event);
position.set(Position.KEY_ALARM, decodeAlarm(event));
@@ -115,19 +115,19 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(2)) {
- position.setLongitude(parser.nextDouble() / 10000);
- position.setLatitude(parser.nextDouble() / 10000);
+ position.setLongitude(parser.nextDouble(0) / 10000);
+ position.setLatitude(parser.nextDouble(0) / 10000);
}
- position.setValid(parser.nextInt() != 1);
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setValid(parser.nextInt(0) != 1);
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
if (parser.hasNext()) {
- position.set(Position.KEY_SATELLITES, parser.nextInt());
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
}
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
return position;
}
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 45e151897..41d5b7436 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -122,14 +122,14 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
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;
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index 1d6093b94..cbc851de0 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -91,15 +91,15 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // base station info
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_STATUS, status);
diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java
index 223f1e419..c10523117 100644
--- a/src/org/traccar/protocol/TmgProtocolDecoder.java
+++ b/src/org/traccar/protocol/TmgProtocolDecoder.java
@@ -115,24 +115,24 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
- position.setValid(parser.nextInt() > 0);
+ position.setValid(parser.nextInt(0) > 0);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt());
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_SATELLITES_VISIBLE, parser.nextInt(0));
position.set(Position.KEY_OPERATOR, parser.next());
- position.set(Position.KEY_RSSI, parser.nextInt());
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
- int input = parser.nextInt(2);
- int output = parser.nextInt(2);
+ int input = parser.nextBinInt(0);
+ int output = parser.nextBinInt(0);
if (!BitUtil.check(input, 0)) {
position.set(Position.KEY_ALARM, Position.ALARM_SOS);
@@ -141,8 +141,8 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_INPUT, input);
position.set(Position.KEY_OUTPUT, output);
- position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
- position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble(0));
+ position.set(Position.PREFIX_ADC + 2, parser.nextDouble(0));
position.set(Position.KEY_VERSION_FW, parser.next());
position.set(Position.KEY_RFID, parser.next());
diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
index 2f853982f..837ca2557 100644
--- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java
+++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
@@ -67,8 +67,8 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 54eb2b5a5..d2ceebde9 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -220,22 +220,22 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder();
int year = 0, month = 0, day = 0;
if (pattern == PATTERN2) {
- day = parser.nextInt();
- month = parser.nextInt();
- year = parser.nextInt();
+ day = parser.nextInt(0);
+ month = parser.nextInt(0);
+ year = parser.nextInt(0);
}
- dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
if (pattern == PATTERN1) {
- day = parser.nextInt();
- month = parser.nextInt();
- year = parser.nextInt();
+ day = parser.nextInt(0);
+ month = parser.nextInt(0);
+ year = parser.nextInt(0);
}
if (year == 0) {
return null; // ignore invalid data
@@ -253,17 +253,17 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_IO + 1, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
position.set(Position.PREFIX_ADC + 1, parser.next());
- int lac = parser.nextInt(16);
- int cid = parser.nextInt(16);
+ int lac = parser.nextHexInt(0);
+ int cid = parser.nextHexInt(0);
if (lac != 0 && cid != 0) {
position.setNetwork(new Network(CellTower.fromLacCid(lac, cid)));
}
position.set(Position.PREFIX_TEMP + 1, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
} else if (pattern == PATTERN3) {
if (parser.hasNext()) {
@@ -273,22 +273,22 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
position.set(Position.PREFIX_IO + 1, parser.next());
- position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1);
- position.set(Position.KEY_POWER, parser.nextDouble());
+ 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());
position.set(Position.PREFIX_ADC + 2, parser.next());
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
position.setNetwork(new Network(
- CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16))));
+ CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0))));
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
- position.setCourse(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
position.set(Position.KEY_PDOP, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
@@ -298,8 +298,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.1);
- position.set(Position.KEY_POWER, parser.nextDouble());
+ 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());
position.set(Position.PREFIX_ADC + 2, parser.next());
@@ -308,15 +308,15 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1, parser.next());
position.set(Position.PREFIX_TEMP + 2, parser.next());
- CellTower cellTower = CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- cellTower.setSignalStrength(parser.nextInt());
+ CellTower cellTower = CellTower.fromLacCid(parser.nextHexInt(0), parser.nextHexInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ cellTower.setSignalStrength(parser.nextInt(0));
position.setNetwork(new Network(cellTower));
- position.setCourse(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.set(Position.KEY_HDOP, parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
+ position.setCourse(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.set(Position.KEY_HDOP, parser.nextDouble(0));
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.setValid(true);
position.setLatitude(parser.nextCoordinate());
diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
index 605a1e0b5..403a2fda2 100644
--- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
@@ -85,8 +85,8 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
return position;
}
diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
index a566c637c..dda91eed5 100644
--- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
@@ -72,19 +72,19 @@ public class Tr900ProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.setValid(parser.nextInt() == 1);
+ position.setValid(parser.nextInt(0) == 1);
position.setTime(parser.nextDateTime());
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_RSSI, parser.next());
- position.set(Position.KEY_EVENT, parser.nextInt());
- position.set(Position.PREFIX_ADC + 1, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_EVENT, parser.nextInt(0));
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_STATUS, parser.next());
diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
index 677f88cdc..deb2f2775 100644
--- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
@@ -82,23 +82,23 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
position.set(Position.KEY_HDOP, parser.next());
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
- int fix = parser.nextInt();
+ int fix = parser.nextInt(0);
position.set(Position.KEY_GPS, fix);
position.setValid(fix > 0);
- position.setCourse(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set(Position.KEY_SATELLITES, parser.next());
diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
index 03ec6cc67..18718cda0 100644
--- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
@@ -116,8 +116,8 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
@@ -144,16 +144,16 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
parser.next(); // seq
- position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt()));
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(0)));
parser.next(); // alert status or data
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
return position;
}
@@ -176,27 +176,27 @@ public class TrakMateProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // seq
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY));
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) == 1);
position.set("dop1", parser.next());
position.set("dop2", parser.next());
position.set(Position.KEY_INPUT, parser.next());
- position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble(0));
position.set(Position.KEY_POWER, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextDouble());
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0));
position.set("pulseOdometer", parser.next());
- position.set(Position.KEY_STATUS, parser.nextInt());
+ position.set(Position.KEY_STATUS, parser.nextInt(0));
- position.setValid(parser.nextInt() != 0);
+ position.setValid(parser.nextInt(0) != 0);
- position.set(Position.KEY_ARCHIVE, parser.nextInt() == 1);
+ position.set(Position.KEY_ARCHIVE, parser.nextInt(0) == 1);
return position;
}
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index f1a8c7427..415828ffd 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -106,13 +106,13 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
- position.set(Position.KEY_RSSI, parser.nextInt());
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
- position.set(Position.KEY_IGNITION, parser.nextInt() != 0);
+ position.set(Position.KEY_RSSI, parser.nextInt(0));
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
+ position.set(Position.KEY_IGNITION, parser.nextInt(0) != 0);
- position.set("arm", parser.nextInt());
- position.set("mode", parser.nextInt());
+ position.set("arm", parser.nextInt(0));
+ position.set("mode", parser.nextInt(0));
return position;
@@ -128,29 +128,29 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setDate(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
- 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));
- int rssi = parser.nextInt();
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ int rssi = parser.nextInt(0);
+ position.set(Position.KEY_SATELLITES, parser.nextInt(0));
+ position.set(Position.KEY_BATTERY, parser.nextInt(0));
- int acc = parser.nextInt();
+ int acc = parser.nextInt(0);
if (acc != 0) {
position.set(Position.KEY_IGNITION, acc == 1);
}
position.setNetwork(new Network(CellTower.from(
- parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt(), rssi)));
+ parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), parser.nextInt(0), rssi)));
return position;
}
diff --git a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
index 88895ff1a..5e30d0994 100644
--- a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
@@ -79,18 +79,18 @@ public class Tt8850ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.setValid(true);
- position.setAccuracy(parser.nextInt());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
+ position.setAccuracy(parser.nextInt(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
position.setTime(parser.nextDateTime());
if (parser.hasNext(4)) {
position.setNetwork(new Network(
- CellTower.from(parser.nextInt(), parser.nextInt(), parser.nextInt(16), parser.nextInt(16))));
+ CellTower.from(parser.nextInt(0), parser.nextInt(0), parser.nextHexInt(0), parser.nextHexInt(0))));
}
return position;
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index b5d60431d..1b22eeb75 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -193,8 +193,8 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt())
- .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0))
+ .setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
getLastLocation(position, dateBuilder.getDate());
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index 44916988e..7a0dca8a2 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -64,13 +64,13 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
if (parser.matches()) {
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(true);
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN));
- int flags = parser.nextInt();
+ int flags = parser.nextInt(0);
position.setValid(BitUtil.check(flags, 0));
if (!BitUtil.check(flags, 1)) {
position.setLatitude(-position.getLatitude());
@@ -79,10 +79,10 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(-position.getLongitude());
}
- position.setSpeed(parser.nextInt() * 2);
- position.setCourse(parser.nextInt() * 10);
+ position.setSpeed(parser.nextInt(0) * 2);
+ position.setCourse(parser.nextInt(0) * 10);
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
}
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index caa0e5e23..a7853133b 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -85,15 +85,15 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set("user", parser.next());
- position.setValid(parser.nextInt() > 0);
+ position.setValid(parser.nextInt(0) > 0);
position.set("password", parser.next());
position.set(Position.KEY_EVENT, parser.next());
position.set("packet", parser.next());
position.set(Position.KEY_RSSI, parser.next());
- double lon = parser.nextDouble();
+ double lon = parser.nextDouble(0);
boolean west = parser.next().equals("W");
- double lat = parser.nextDouble();
+ double lat = parser.nextDouble(0);
boolean south = parser.next().equals("S");
if (lat > 90 || lon > 180) {
@@ -109,18 +109,18 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(west ? -lon : lon);
position.setLatitude(south ? -lat : lat);
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- int day = parser.nextInt();
- int month = parser.nextInt();
+ int day = parser.nextInt(0);
+ int month = parser.nextInt(0);
if (day == 0 && month == 0) {
return null; // invalid date
}
DateBuilder dateBuilder = new DateBuilder()
- .setDate(parser.nextInt(), month, day)
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setDate(parser.nextInt(0), month, day)
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 7abef7386..c430c86d8 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -104,12 +104,12 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(
parser.next().replace(".", "")) / 10));
- position.setCourse(parser.nextDouble());
+ position.setCourse(parser.nextDouble(0));
if (parser.hasNext(9)) {
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
position.set(Position.KEY_SATELLITES, parser.next());
- position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.set(Position.KEY_IGNITION, parser.next().equals("1"));
position.set(Position.PREFIX_IO + 1, parser.next());
position.set(Position.PREFIX_IO + 2, parser.next());
@@ -120,8 +120,8 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext(7)) {
position.set(Position.KEY_HDOP, parser.next());
- position.setAltitude(parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
+ position.setAltitude(parser.nextDouble(0));
+ position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000);
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.KEY_OUTPUT, parser.next());
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 d95f8c714..9d64776c3 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -186,17 +186,17 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
- position.set(Position.KEY_BATTERY, parser.nextInt());
+ 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("steps", parser.nextInt());
+ position.set("steps", parser.nextInt(0));
- position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(16)));
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt(0)));
decodeTail(position, parser.next());
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java
index c5b8890f3..c1a125601 100644
--- a/src/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/org/traccar/protocol/WialonProtocolDecoder.java
@@ -88,12 +88,12 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
if (parser.hasNext()) {
- int satellites = parser.nextInt();
+ int satellites = parser.nextInt(0);
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
}
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index fff4e9103..b1b06a5da 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -99,20 +99,20 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble(0));
+ position.setLatitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
- int satellites = parser.nextInt();
+ int satellites = parser.nextInt(0);
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
position.set(Position.KEY_EVENT, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
if (parser.hasNext()) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1000);
}
position.set(Position.KEY_INPUT, parser.next());
position.set(Position.PREFIX_ADC + 1, parser.next());
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index f60b3e693..4d44c2326 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -104,15 +104,15 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
}
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
position.set("signal", parser.next());
@@ -127,9 +127,9 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
if (full) {
position.set(Position.KEY_SATELLITES, parser.next().replaceFirst("^0*(?![\\.$])", ""));
- position.setAltitude(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
- position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_POWER, parser.nextDouble(0));
}
return position;
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index cc97a77f9..c6d4b6978 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -121,17 +121,17 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
position.set(Position.KEY_SATELLITES, parser.next());
position.set(Position.KEY_HDOP, parser.next());
if (newFormat) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1609.34);
position.set(Position.KEY_FUEL_CONSUMPTION, parser.next());
}
@@ -139,10 +139,10 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, parser.next());
if (!newFormat) {
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1609.34);
+ position.set(Position.KEY_ODOMETER, parser.nextDouble(0) * 1609.34);
}
- position.setValid(parser.nextInt() == 1);
+ position.setValid(parser.nextInt(0) == 1);
return position;
}
diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
index 93e26e986..a18758b81 100644
--- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
@@ -76,11 +76,11 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime());
- position.setLatitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble(0));
+ position.setLongitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0)));
+ position.setCourse(parser.nextDouble(0));
+ position.setAltitude(parser.nextDouble(0));
position.setValid(parser.next().equals("F"));
position.set(Position.KEY_GPS, parser.next());
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index d79ae4439..6a98ab9e7 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -91,11 +91,11 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG));
- position.setAltitude(parser.nextDouble());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
- int satellites = parser.nextInt();
+ int satellites = parser.nextInt(0);
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);