aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java51
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MeitrackProtocol.java3
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolEncoder.java7
5 files changed, 68 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index a3d34cf3c..c2eb8a1f5 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -222,7 +222,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
int event = buf.readUnsignedByte();
position.set(Event.KEY_EVENT, event);
- buf.readUnsignedByte();
+ position.set("event-info", buf.readUnsignedByte());
if ((selector & 0x0008) != 0) {
position.setValid((buf.readUnsignedByte() & 0x40) != 0);
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 574f9a8c3..7d0c58c57 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -158,6 +158,22 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text("$").optional()
.compile();
+ private static final Pattern PATTERN_IGN = new PatternBuilder()
+ .text("+").expression("(?:RESP|BUFF):GTIG[NF],")
+ .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version
+ .number("(d{15}),") // imei
+ .expression("[^,]*,") // device name
+ .number("d+,") // ignition off duration
+ .expression(PATTERN_LOCATION.pattern())
+ .number("(d{5}:dd:dd)?,") // hour meter
+ .number("(d{1,7}.d)?,") // odometer
+ .number("(dddd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd)").optional(2) // time
+ .text(",")
+ .number("(xxxx)") // count number
+ .text("$").optional()
+ .compile();
+
private static final Pattern PATTERN = new PatternBuilder()
.text("+").expression("(?:RESP|BUFF):GT...,")
.number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version
@@ -376,6 +392,37 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
+ private Object decodeIgn(Channel channel, SocketAddress remoteAddress, String sentence) {
+ Parser parser = new Parser(PATTERN_IGN, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+
+ if (!identify(parser.next(), channel, remoteAddress)) {
+ return null;
+ }
+ position.setDeviceId(getDeviceId());
+
+ decodeLocation(position, parser);
+
+ position.set(Event.KEY_HOURS, parser.next());
+ position.set(Event.KEY_ODOMETER, parser.next());
+
+ if (parser.hasNext(6)) {
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ if (!position.getOutdated() && position.getFixTime().after(dateBuilder.getDate())) {
+ position.setTime(dateBuilder.getDate());
+ }
+ }
+
+ return position;
+ }
+
private Object decodeOther(Channel channel, SocketAddress remoteAddress, String sentence) {
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
@@ -469,6 +516,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
case "FRI":
result = decodeFri(channel, remoteAddress, sentence);
break;
+ case "IGN":
+ case "IGF":
+ result = decodeIgn(channel, remoteAddress, sentence);
+ break;
default:
result = decodeOther(channel, remoteAddress, sentence);
break;
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index e2aed6309..ce5a54141 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -87,11 +87,13 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // odometer
.number("(d+.d+)?,") // fuel instant
.number("(?:d+.d+)?,") // fuel average
+ .number("(d+),") // hours
.number("(d+),") // speed
- .number("d+,") // power load
- .number("(d+.d+%),") // throttle
+ .number("d+.?d*%,") // power load
+ .number("(d+),") // temperature
+ .number("(d+.?d*%),") // throttle
.number("(d+),") // rpm
- .number("(d+.d+%),") // battery
+ .number("(d+.d+),") // battery
.number("[^,]*,") // dtc 1
.number("[^,]*,") // dtc 2
.number("[^,]*,") // dtc 3
@@ -166,7 +168,9 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ODOMETER, parser.nextInt());
position.set(Event.KEY_FUEL, parser.next());
+ position.set(Event.KEY_HOURS, parser.next());
position.set(Event.KEY_OBD_SPEED, parser.next());
+ position.set(Event.PREFIX_TEMP + 1, parser.next());
position.set(Event.KEY_THROTTLE, parser.next());
position.set(Event.KEY_RPM, parser.next());
position.set(Event.KEY_BATTERY, parser.next());
diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java
index e5b5ddf2b..a004d5cb6 100644
--- a/src/org/traccar/protocol/MeitrackProtocol.java
+++ b/src/org/traccar/protocol/MeitrackProtocol.java
@@ -36,7 +36,8 @@ public class MeitrackProtocol extends BaseProtocol {
Command.TYPE_ENGINE_RESUME,
Command.TYPE_ALARM_ARM,
Command.TYPE_ALARM_DISARM,
- Command.TYPE_REQUEST_PHOTO);
+ Command.TYPE_REQUEST_PHOTO,
+ Command.TYPE_SEND_SMS);
}
@Override
diff --git a/src/org/traccar/protocol/MeitrackProtocolEncoder.java b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
index 381935c58..04cb39637 100644
--- a/src/org/traccar/protocol/MeitrackProtocolEncoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
@@ -20,6 +20,8 @@ import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Command;
+import java.util.Map;
+
public class MeitrackProtocolEncoder extends StringProtocolEncoder {
private Object formatCommand(Command command, char dataId, String content) {
@@ -33,6 +35,8 @@ public class MeitrackProtocolEncoder extends StringProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
+ Map<String, Object> attributes = command.getAttributes();
+
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
return formatCommand(command, 'Q', "A10");
@@ -46,6 +50,9 @@ public class MeitrackProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, 'M', "C01,0,22022");
case Command.TYPE_REQUEST_PHOTO:
return formatCommand(command, 'D', "D03,1,camera_picture.jpg");
+ case Command.TYPE_SEND_SMS:
+ return formatCommand(command, 'f', "C02,0,"
+ + attributes.get(Command.KEY_PHONE_NUMBER) + "," + attributes.get(Command.KEY_MESSAGE));
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;