aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-10-19 04:35:39 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-10-19 04:35:39 +1300
commit4ba8252588c0d280434c83b9d855098be3a15dd9 (patch)
treec5b1660200e305281c8e2e5aace11706f37824ee /src/org
parent3f5a5e81fe08c7ae0b136d52b4840d5085e12f23 (diff)
downloadtraccar-server-4ba8252588c0d280434c83b9d855098be3a15dd9.tar.gz
traccar-server-4ba8252588c0d280434c83b9d855098be3a15dd9.tar.bz2
traccar-server-4ba8252588c0d280434c83b9d855098be3a15dd9.zip
Update Cradlepoint decoder (fix #3581)
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/CradlepointProtocolDecoder.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/CradlepointProtocolDecoder.java b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
index 67a140cf7..e8f95a60c 100644
--- a/src/org/traccar/protocol/CradlepointProtocolDecoder.java
+++ b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
@@ -18,11 +18,13 @@ package org.traccar.protocol;
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;
import java.net.SocketAddress;
+import java.util.Date;
import java.util.regex.Pattern;
public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
@@ -33,7 +35,7 @@ public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.expression("([^,]+),") // id
- .number("(dd)(dd)(dd),") // time (hhmmss)
+ .number("(d{1,6}),") // time (hhmmss)
.number("(d+)(dd.d+),") // latitude
.expression("([NS]),")
.number("(d+)(dd.d+),") // longitude
@@ -58,16 +60,21 @@ public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position();
- position.setProtocol(getProtocolName());
-
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
}
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS));
+ int time = parser.nextInt();
+ DateBuilder dateBuilder = new DateBuilder(new Date());
+ dateBuilder.setHour(time / 100 / 100);
+ dateBuilder.setMinute(time / 100 % 100);
+ dateBuilder.setSecond(time % 100);
+ position.setTime(dateBuilder.getDate());
position.setValid(true);
position.setLatitude(parser.nextCoordinate());
@@ -75,9 +82,12 @@ public class CradlepointProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(parser.nextDouble(0));
position.setCourse(parser.nextDouble(0));
- parser.skip(3);
-
- position.set(Position.KEY_RSSI, parser.nextDouble());
+ position.set("carrid", parser.next());
+ position.set("serdis", parser.next());
+ position.set("rsrp", parser.next());
+ position.set("dbm", parser.next());
+ position.set("rsrq", parser.next());
+ position.set("ecio", parser.next());
return position;
}