aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/RuptelaProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-21 19:30:57 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-21 19:30:57 +1300
commit787f10186dff867f67d5f3f486797d9fb7a70b38 (patch)
tree8b762a5878eee499937d6d8b7381bd209c345ae0 /src/org/traccar/protocol/RuptelaProtocolDecoder.java
parentb6bf899a4fc9a97a69f8424cad6990e4d533e57d (diff)
downloadtrackermap-server-787f10186dff867f67d5f3f486797d9fb7a70b38.tar.gz
trackermap-server-787f10186dff867f67d5f3f486797d9fb7a70b38.tar.bz2
trackermap-server-787f10186dff867f67d5f3f486797d9fb7a70b38.zip
Implement Ruptela responses
Diffstat (limited to 'src/org/traccar/protocol/RuptelaProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 1409c7c4d..5e67acc21 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -37,15 +37,42 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
public static final int MSG_RECORDS = 1;
+ public static final int MSG_DEVICE_CONFIGURATION = 2;
+ public static final int MSG_DEVICE_VERSION = 3;
+ public static final int MSG_FIRMWARE_UPDATE = 4;
+ public static final int MSG_SET_CONNECTION = 5;
+ public static final int MSG_SET_ODOMETER = 6;
+ public static final int MSG_SMS_VIA_GPRS_RESPONSE = 7;
+ public static final int MSG_SMS_VIA_GPRS = 8;
public static final int MSG_DTCS = 9;
+ public static final int MSG_SET_IO = 17;
public static final int MSG_EXTENDED_RECORDS = 68;
- public static final int MSG_DEVICE_CONFIGURATION = 102;
- public static final int MSG_DEVICE_VERSION = 103;
- public static final int MSG_FIRMWARE_UPDATE = 104;
- public static final int MSG_SET_CONNECTION = 105;
- public static final int MSG_SET_ODOMETER = 106;
- public static final int MSG_SMS_VIA_GPRS = 108;
- public static final int MSG_SET_IO = 117;
+
+ private Position decodeCommandResponse(DeviceSession deviceSession, int type, ChannelBuffer buf) {
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ position.set(Position.KEY_TYPE, type);
+
+ switch (type) {
+ case MSG_DEVICE_CONFIGURATION:
+ case MSG_DEVICE_VERSION:
+ case MSG_FIRMWARE_UPDATE:
+ case MSG_SMS_VIA_GPRS_RESPONSE:
+ position.set(Position.KEY_RESULT,
+ buf.toString(buf.readerIndex(), buf.readableBytes() - 2, StandardCharsets.US_ASCII).trim());
+ return position;
+ case MSG_SET_IO:
+ position.set(Position.KEY_RESULT,
+ String.valueOf(buf.readUnsignedByte()));
+ return position;
+ default:
+ return null;
+ }
+ }
@Override
protected Object decode(
@@ -173,9 +200,11 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
return positions;
- }
+ } else {
+
+ return decodeCommandResponse(deviceSession, type, buf);
- return null;
+ }
}
}