aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TotemProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-26 14:59:02 +1300
committerGitHub <noreply@github.com>2017-02-26 14:59:02 +1300
commitaea5d9e8df58b37c937db87a272a9d92c64586f5 (patch)
treedda7693ba067874048c1a90c99b14e5ac75e77e8 /src/org/traccar/protocol/TotemProtocolDecoder.java
parente4aa15f0eb0646d6158fd8386f8f9c5477db6bfe (diff)
parent7152670b20a40de809db57ae21acb73c5ad5bea5 (diff)
downloadtrackermap-server-aea5d9e8df58b37c937db87a272a9d92c64586f5.tar.gz
trackermap-server-aea5d9e8df58b37c937db87a272a9d92c64586f5.tar.bz2
trackermap-server-aea5d9e8df58b37c937db87a272a9d92c64586f5.zip
Merge pull request #2951 from jon-stumpf/jss-celltower
CellTowers and capturing additional protocol information
Diffstat (limited to 'src/org/traccar/protocol/TotemProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 7140190da..86ee09d95 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -50,9 +50,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)(dd)(dd)") // date
.expression("[^*]*").text("*")
.number("xx|") // checksum
- .number("d+.d+|") // pdop
+ .number("(d+.d+)|") // pdop
.number("(d+.d+)|") // hdop
- .number("d+.d+|") // vdop
+ .number("(d+.d+)|") // vdop
.number("(d+)|") // io status
.number("d+|") // time
.number("d") // charged
@@ -151,7 +151,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(xxxx)") // lac
.number("(xxxx)") // cid
.number("(dd)") // satellites
- .number("(dd)") // gsm
+ .number("(dd)") // gsm (rssi)
.number("(ddd)") // course
.number("(ddd)") // speed
.number("(dd.d)") // hdop
@@ -218,11 +218,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
}
DateBuilder dateBuilder = new DateBuilder();
- int year = 0;
+ int year = 0, month = 0, day = 0;
if (pattern == PATTERN2) {
- dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt());
- year = parser.nextInt();
- dateBuilder.setYear(year);
+ day = parser.nextInt();
+ month = parser.nextInt();
+ year = parser.nextInt();
}
dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
@@ -233,16 +233,24 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
if (pattern == PATTERN1) {
- dateBuilder.setDay(parser.nextInt()).setMonth(parser.nextInt());
- year = parser.nextInt();
- dateBuilder.setYear(year);
+ day = parser.nextInt();
+ month = parser.nextInt();
+ year = parser.nextInt();
}
if (year == 0) {
return null; // ignore invalid data
}
+ dateBuilder.setDate(year, month, day);
position.setTime(dateBuilder.getDate());
- position.set(Position.KEY_HDOP, parser.next());
+ if (pattern == PATTERN1) {
+ position.set("pdop", parser.next());
+ position.set(Position.KEY_HDOP, parser.next());
+ position.set("vdop", parser.next());
+ } else if (pattern == PATTERN2) {
+ position.set(Position.KEY_HDOP, parser.next());
+ }
+
position.set(Position.PREFIX_IO + 1, parser.next());
position.set(Position.KEY_BATTERY, parser.next());
position.set(Position.KEY_POWER, parser.nextDouble());
@@ -279,19 +287,15 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
position.set(Position.KEY_SATELLITES, parser.next());
-
position.setCourse(parser.nextDouble());
position.setSpeed(parser.nextDouble());
-
position.set("pdop", parser.next());
-
position.set(Position.KEY_ODOMETER, parser.next());
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
} else if (pattern == PATTERN4) {
-
position.set(Position.KEY_STATUS, parser.next());
DateBuilder dateBuilder = new DateBuilder()
@@ -309,22 +313,19 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
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 cellTower = CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16));
position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_RSSI, parser.nextInt());
+ cellTower.setSignalStrength(parser.nextInt());
+ 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.setValid(true);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
-
}
if (channel != null) {
channel.write("ACK OK\r\n");