aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Goos <kevingoos@telenet.be>2018-03-14 16:42:09 +0100
committerKevin Goos <kevingoos@telenet.be>2018-03-14 16:42:09 +0100
commit2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c (patch)
tree32251825e6909b090819dbd79837adf2101085f2 /src
parent82eace30ab2bd8742301519e6157c8ef238f4885 (diff)
downloadtrackermap-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.tar.gz
trackermap-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.tar.bz2
trackermap-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.zip
Added extra info for laipac
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/model/Position.java7
-rw-r--r--src/org/traccar/protocol/LaipacSFKamelProtocol.java (renamed from src/org/traccar/protocol/Laipac2Protocol.java)8
-rw-r--r--src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java (renamed from src/org/traccar/protocol/Laipac2ProtocolDecoder.java)33
3 files changed, 29 insertions, 19 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 981c2292f..fdecb7e20 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -52,6 +52,8 @@ public class Position extends Message {
public static final String KEY_BATTERY_LEVEL = "batteryLevel"; // percentage
public static final String KEY_FUEL_LEVEL = "fuel"; // liters
public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
+ public static final String KEY_ANALOG_1 = "analog 1"; // volts
+ public static final String KEY_ANALOG_2 = "analog 2"; // volts
public static final String KEY_VERSION_FW = "versionFw";
public static final String KEY_VERSION_HW = "versionHw";
@@ -88,6 +90,10 @@ public class Position extends Message {
public static final String KEY_DRIVER_UNIQUE_ID = "driverUniqueId";
+ public static final String KEY_CELL_NET_CODE = "cellNetCode";
+ public static final String KEY_CELL_ID_CODE = "cellIdCode";
+ public static final String KEY_COUNTRY_CODE = "countryCode";
+
// Start with 1 not 0
public static final String PREFIX_TEMP = "temp";
public static final String PREFIX_ADC = "adc";
@@ -290,5 +296,4 @@ public class Position extends Message {
public String getType() {
return super.getType();
}
-
}
diff --git a/src/org/traccar/protocol/Laipac2Protocol.java b/src/org/traccar/protocol/LaipacSFKamelProtocol.java
index 5f132f626..5e1beabbd 100644
--- a/src/org/traccar/protocol/Laipac2Protocol.java
+++ b/src/org/traccar/protocol/LaipacSFKamelProtocol.java
@@ -25,10 +25,10 @@ import org.traccar.TrackerServer;
import java.util.List;
-public class Laipac2Protocol extends BaseProtocol {
+public class LaipacSFKamelProtocol extends BaseProtocol {
- public Laipac2Protocol() {
- super("laipac2");
+ public LaipacSFKamelProtocol() {
+ super("laipacsfkamel");
}
@Override
@@ -39,7 +39,7 @@ public class Laipac2Protocol extends BaseProtocol {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Laipac2ProtocolDecoder(Laipac2Protocol.this));
+ pipeline.addLast("objectDecoder", new LaipacSFKamelProtocolDecoder(LaipacSFKamelProtocol.this));
}
});
}
diff --git a/src/org/traccar/protocol/Laipac2ProtocolDecoder.java b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java
index ba40c0dce..decf279df 100644
--- a/src/org/traccar/protocol/Laipac2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java
@@ -27,9 +27,9 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.util.regex.Pattern;
-public class Laipac2ProtocolDecoder extends BaseProtocolDecoder {
+public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder {
- public Laipac2ProtocolDecoder(Laipac2Protocol protocol) {
+ public LaipacSFKamelProtocolDecoder(LaipacSFKamelProtocol protocol) {
super(protocol);
}
@@ -49,11 +49,12 @@ public class Laipac2ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // battery voltage
.number("(d+),") // current mileage
.number("(d),") // GPS on/off (1 = on, 0 = off)
- .number("(d),") // Analog port 1
+ .number("(d+),") // Analog port 1
.number("(d+),") // Analog port 2
.expression("([0-9a-fA-F]{4})") // Cell 1 - Cell Net Code
.expression("([0-9a-fA-F]{4}),") // Cell 1 - Cell ID Code
- .number("(d+)") // Cell 2
+ .number("(d{3})") // Cell 2 - Country Code
+ .number("(d{3})") // Cell 2 - Operator Code
.text("*")
.number("(xx)") // checksum
.compile();
@@ -94,27 +95,31 @@ public class Laipac2ProtocolDecoder extends BaseProtocolDecoder {
dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0));
position.setTime(dateBuilder.getDate());
- String type = parser.next();
- position.set(Position.KEY_BATTERY_LEVEL, parser.nextDouble());
- //position.set(Position.KEY_, parser.nextDouble());
+ String eventCode = parser.next();
+ position.set(Position.KEY_EVENT, eventCode);
+ position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.001);
+ position.set(Position.KEY_TOTAL_DISTANCE, parser.nextDouble());
+ position.set(Position.KEY_GPS, parser.nextInt());
+ position.set(Position.KEY_ANALOG_1, parser.nextDouble() * 0.001);
+ position.set(Position.KEY_ANALOG_2, parser.nextDouble() * 0.001);
+ position.set(Position.KEY_CELL_NET_CODE, parser.next());
+ position.set(Position.KEY_CELL_ID_CODE, parser.next());
+ position.set(Position.KEY_COUNTRY_CODE, parser.next());
+ position.set(Position.KEY_OPERATOR, parser.next());
String checksum = parser.next();
if (channel != null) {
-
if (Character.isLowerCase(status.charAt(0))) {
- String response = "$EAVACK," + type + "," + checksum;
+ String response = "$EAVACK," + eventCode + "," + checksum;
response += Checksum.nmea(response);
channel.write(response);
}
- if (type.equals("S") || type.equals("T")) {
- channel.write("$AVCFG,00000000,t*21");
- } else if (type.equals("3")) {
+ if (eventCode.equals("3")) {
channel.write("$AVCFG,00000000,d*31");
- } else if (type.equals("X") || type.equals("4")) {
+ } else if (eventCode.equals("X") || eventCode.equals("4")) {
channel.write("$AVCFG,00000000,x*2D");
}
-
}
return position;