diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java index 0966e83ff..0d3995144 100644 --- a/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java @@ -50,8 +50,8 @@ public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // current mileage .number("(d),") // GPS on/off (1 = on, 0 = off) .number("(d+),") // Analog port 1 - .number("(d+),") // Analog port 2 - .expression("([0-9a-fA-F]{4})") // Cell 1 - Cell Net Code + .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{3})") // Cell 2 - Country Code .number("(d{3})") // Cell 2 - Operator Code @@ -87,6 +87,7 @@ public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder { String status = parser.next(); position.setValid(status.toUpperCase().equals("A")); + position.set(Position.KEY_STATUS, status); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); @@ -97,6 +98,10 @@ public class LaipacSFKamelProtocolDecoder 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_EVENT, eventCode); position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.001); position.set(Position.KEY_TOTAL_DISTANCE, parser.nextDouble()); @@ -124,6 +129,8 @@ public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder { channel.write("$AVCFG,00000000,d*31\r\n"); } else if (eventCode.equals("X") || eventCode.equals("4")) { channel.write("$AVCFG,00000000,x*2D\r\n"); + } else if (eventCode.equals("Z")) { + channel.write("$AVCFG,00000000,z*2F\r\n"); } else if (Character.isLowerCase(status.charAt(0))) { String response = "$EAVACK," + eventCode + "," + checksum; response += Checksum.nmea(response); @@ -134,4 +141,27 @@ public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder { return position; } + + 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; + } + return null; + } } |