aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
committerIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
commit55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch)
treeb86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
parentc04ad7d48331253c095fc123ded1b00f6ff871d3 (diff)
parent2788174193def918a3a1a5be3bbed24c9613323f (diff)
downloadtrackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip
Merge tag 'tags/v6.3'
Diffstat (limited to 'src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java87
1 files changed, 47 insertions, 40 deletions
diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 1f8c4d2da..524d86289 100644
--- a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -141,6 +141,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_OBD_RT = 0x9901;
public static final int MSG_OBD_RTA = 0x9902;
+ public static final int MSG_DTC = 0x9903;
public static final int MSG_TRACK_ON_DEMAND = 0x4101;
public static final int MSG_TRACK_BY_INTERVAL = 0x4102;
@@ -208,30 +209,35 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
}
- private String decodeAlarm(short value) {
- switch (value) {
- case 0x01:
- return Position.ALARM_SOS;
- case 0x10:
- return Position.ALARM_LOW_BATTERY;
- case 0x11:
- return Position.ALARM_OVERSPEED;
- case 0x12:
- return Position.ALARM_MOVEMENT;
- case 0x13:
- return Position.ALARM_GEOFENCE_ENTER;
- case 0x14:
- return Position.ALARM_ACCIDENT;
- case 0x50:
- return Position.ALARM_POWER_OFF;
- case 0x53:
- return Position.ALARM_GPS_ANTENNA_CUT;
- case 0x72:
- return Position.ALARM_BRAKING;
- case 0x73:
- return Position.ALARM_ACCELERATION;
- default:
- return null;
+ private String decodeAlarm(String model, short value) {
+ if ("TK218".equals(model)) {
+ return switch (value) {
+ case 0x01 -> Position.ALARM_SOS;
+ case 0x10 -> Position.ALARM_LOW_BATTERY;
+ case 0x11 -> Position.ALARM_OVERSPEED;
+ case 0x12 -> Position.ALARM_MOVEMENT;
+ case 0x13 -> Position.ALARM_GEOFENCE;
+ case 0x60 -> Position.ALARM_FATIGUE_DRIVING;
+ case 0x71 -> Position.ALARM_BRAKING;
+ case 0x72 -> Position.ALARM_ACCELERATION;
+ case 0x73 -> Position.ALARM_ACCIDENT;
+ case 0x74 -> Position.ALARM_IDLE;
+ default -> null;
+ };
+ } else {
+ return switch (value) {
+ case 0x01 -> Position.ALARM_SOS;
+ case 0x10 -> Position.ALARM_LOW_BATTERY;
+ case 0x11 -> Position.ALARM_OVERSPEED;
+ case 0x12 -> Position.ALARM_MOVEMENT;
+ case 0x13 -> Position.ALARM_GEOFENCE_ENTER;
+ case 0x14 -> Position.ALARM_ACCIDENT;
+ case 0x50 -> Position.ALARM_POWER_OFF;
+ case 0x53 -> Position.ALARM_GPS_ANTENNA_CUT;
+ case 0x72 -> Position.ALARM_BRAKING;
+ case 0x73 -> Position.ALARM_ACCELERATION;
+ default -> null;
+ };
}
}
@@ -352,6 +358,12 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Position decodeDtc(Position position, String sentence) {
+ getLastLocation(position, null);
+ position.set(Position.KEY_DTCS, sentence.replace(',', ' '));
+ return position;
+ }
+
private List<Position> decodeRetransmission(ByteBuf buf, DeviceSession deviceSession) {
List<Position> positions = new LinkedList<>();
@@ -448,7 +460,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
if (command == MSG_ALARM) {
short alarmCode = buf.readUnsignedByte();
- position.set(Position.KEY_ALARM, decodeAlarm(alarmCode));
+ String model = getDeviceModel(deviceSession);
+ position.set(Position.KEY_ALARM, decodeAlarm(model, alarmCode));
if (alarmCode >= 0x02 && alarmCode <= 0x05) {
position.set(Position.PREFIX_IN + alarmCode, 1);
} else if (alarmCode >= 0x32 && alarmCode <= 0x35) {
@@ -478,21 +491,15 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII);
- switch (command) {
- case MSG_POSITION:
- case MSG_POSITION_LOGGED:
- case MSG_ALARM:
- case MSG_POSITION_IMAGE:
- return decodeRegular(position, sentence);
- case MSG_RFID:
- return decodeRfid(position, sentence);
- case MSG_OBD_RT:
- return decodeObd(position, sentence);
- case MSG_OBD_RTA:
- return decodeObdA(position, sentence);
- default:
- return null;
- }
+ return switch (command) {
+ case MSG_POSITION, MSG_POSITION_LOGGED, MSG_ALARM, MSG_POSITION_IMAGE ->
+ decodeRegular(position, sentence);
+ case MSG_RFID -> decodeRfid(position, sentence);
+ case MSG_OBD_RT -> decodeObd(position, sentence);
+ case MSG_OBD_RTA -> decodeObdA(position, sentence);
+ case MSG_DTC -> decodeDtc(position, sentence);
+ default -> null;
+ };
}
}