aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorKevin Goos <kevingoos@telenet.be>2018-03-21 09:04:15 +0100
committerKevin Goos <kevingoos@telenet.be>2018-03-21 09:04:15 +0100
commit917e631284d8e4054f9036eb39c249fe6bdf4248 (patch)
treea87c707611eb129d5f3d16b278fec6077cec1549 /src/org/traccar/protocol
parent69f270e4b80803e919f16495b0102dd0f5d6acfe (diff)
downloadtrackermap-server-917e631284d8e4054f9036eb39c249fe6bdf4248.tar.gz
trackermap-server-917e631284d8e4054f9036eb39c249fe6bdf4248.tar.bz2
trackermap-server-917e631284d8e4054f9036eb39c249fe6bdf4248.zip
Fixed small laipac issues
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java74
1 files changed, 33 insertions, 41 deletions
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index b6d3dd8b2..c319c96c0 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -102,10 +102,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
String eventCode = parser.next();
- String decodedAlarm = decodeAlarm(eventCode);
- if (decodedAlarm != null) {
- position.set(Position.KEY_ALARM, decodeAlarm(eventCode));
- }
+ position.set(Position.KEY_ALARM, decodeAlarm(eventCode));
position.set(Position.KEY_EVENT, eventCode);
double batteryVoltage = parser.nextDouble();
@@ -117,31 +114,24 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Position.KEY_BATTERY, batteryVoltage);
- position.set(Position.KEY_TOTAL_DISTANCE, parser.nextDouble());
+ position.set(Position.KEY_ODOMETER, parser.nextDouble());
position.set(Position.KEY_GPS, parser.nextInt());
position.set(Position.PREFIX_ADC + 1, parser.nextDouble() * 0.001);
position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001);
- String cellNetCodeString = parser.next();
- String cellIdString = parser.next();
- String countryCodeString = parser.next();
- String operatorCodeString = parser.next();
- if (cellNetCodeString != null
- && cellIdString != null
- && countryCodeString != null
- && operatorCodeString != null) {
- int cellNetCode = Integer.parseInt(cellNetCodeString, 16);
- Long cellId = Long.parseLong(cellIdString, 16);
- int countryCode = Integer.parseInt(countryCodeString);
- int operatorCode = Integer.parseInt(operatorCodeString);
- position.setNetwork(new Network(CellTower.from(countryCode, operatorCode, cellNetCode, cellId)));
+ String lac = parser.next();
+ String cid = parser.next();
+ String mcc = parser.next();
+ String mnc = parser.next();
+ if (lac != null
+ && cid != null
+ && mcc != null
+ && mnc != null) {
+ position.setNetwork(new Network(CellTower.from(Integer.parseInt(mcc), Integer.parseInt(mnc),
+ Integer.parseInt(lac, 16), Long.parseLong(cid, 16))));
}
String checksum = parser.next();
- String result = sentence.replaceAll("^\\$(.*)\\*[0-9a-fA-F]{2}$", "$1");
- if (checksum == null || Integer.parseInt(checksum, 16) != Checksum.xor(result)) {
- return null;
- }
if (channel != null) {
if (eventCode.equals("3")) {
@@ -162,25 +152,27 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
}
private String decodeAlarm(String event) {
- if (event.equals('Z')) {
- return Position.ALARM_LOW_BATTERY;
- } else if (event.equals('X')) {
- return Position.ALARM_GEOFENCE_ENTER;
- } else if (event.equals('T')) {
- return Position.ALARM_TAMPERING;
- } else if (event.equals("H")) {
- return Position.ALARM_POWER_OFF;
- } else if (event.equals('X')) {
- return Position.ALARM_GEOFENCE_ENTER;
- } else if (event.equals('8')) {
- return Position.ALARM_SHOCK;
- } else if (event.equals('7') && event.equals('4')) {
- return Position.ALARM_GEOFENCE_EXIT;
- } else if (event.equals('6')) {
- return Position.ALARM_OVERSPEED;
- } else if (event.equals('3')) {
- return Position.ALARM_SOS;
+ switch (event)
+ {
+ case "Z":
+ return Position.ALARM_LOW_BATTERY;
+ case "X":
+ return Position.ALARM_GEOFENCE_ENTER;
+ case "T":
+ return Position.ALARM_TAMPERING;
+ case "H":
+ return Position.ALARM_POWER_OFF;
+ case "8":
+ return Position.ALARM_SHOCK;
+ case "7":
+ case "4":
+ return Position.ALARM_GEOFENCE_EXIT;
+ case "6":
+ return Position.ALARM_OVERSPEED;
+ case "3":
+ return Position.ALARM_SOS;
+ default:
+ return null;
}
- return null;
}
}