aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-27 21:51:29 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-27 21:51:29 +1200
commitfefce2dff1931e430deb4d8723d7e8362b7e7698 (patch)
tree8ba373f0bff00c6250546dc62cca2fb0c55e9ee1 /src/org/traccar
parent38e77023844a5c76112ed79ddf8308cedfc3e099 (diff)
downloadtraccar-server-fefce2dff1931e430deb4d8723d7e8362b7e7698.tar.gz
traccar-server-fefce2dff1931e430deb4d8723d7e8362b7e7698.tar.bz2
traccar-server-fefce2dff1931e430deb4d8723d7e8362b7e7698.zip
Support Vodofo protocol
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index 1c2944a6c..7efe3b94f 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -31,7 +31,6 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
-import java.text.ParseException;
import java.util.regex.Pattern;
public class UproProtocolDecoder extends BaseProtocolDecoder {
@@ -42,7 +41,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN_HEADER = new PatternBuilder()
.text("*")
- .expression("..20")
+ .expression("(..20)") // head
.expression("([01])") // ack
.number("(d+),") // device id
.expression("(.)") // type
@@ -96,7 +95,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
ByteBuf buf = (ByteBuf) msg;
if (buf.getByte(buf.readerIndex()) != '*') {
- throw new ParseException(null, 0);
+ return null;
}
int headerIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '&');
@@ -110,6 +109,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ String head = parser.next();
boolean reply = parser.next().equals("1");
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
@@ -124,7 +124,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
String subtype = parser.next();
if (reply && channel != null) {
- channel.writeAndFlush(new NetworkMessage("*MG20Y" + type + subtype + "#", remoteAddress));
+ channel.writeAndFlush(new NetworkMessage("*" + head + "Y" + type + subtype + "#", remoteAddress));
}
while (buf.isReadable()) {
@@ -155,6 +155,13 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_ODOMETER, odometer * 2 * 1852 / 3600);
break;
+ case 'F':
+ position.setSpeed(
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)) * 0.1);
+ break;
+ case 'K':
+ position.set("statusExtended", data.toString(StandardCharsets.US_ASCII));
+ break;
case 'P':
position.setNetwork(new Network(CellTower.from(
Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)),
@@ -163,13 +170,28 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16))));
break;
case 'Q':
- position.set("obd-pid", ByteBufUtil.hexDump(data));
+ position.set("obdPid", ByteBufUtil.hexDump(data));
break;
case 'R':
- position.set("odb-travel", ByteBufUtil.hexDump(data));
+ if (head.startsWith("HQ")) {
+ position.set(Position.KEY_RSSI,
+ Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII)));
+ position.set(Position.KEY_SATELLITES,
+ Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII)));
+ } else {
+ position.set("odbTravel", ByteBufUtil.hexDump(data));
+ }
break;
case 'S':
- position.set("obd-traffic", ByteBufUtil.hexDump(data));
+ position.set("obdTraffic", ByteBufUtil.hexDump(data));
+ break;
+ case 'T':
+ position.set(Position.KEY_BATTERY_LEVEL,
+ Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII)));
+ break;
+ case 'V':
+ position.set(Position.KEY_POWER,
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)) * 0.1);
break;
default:
break;