aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-20 22:19:17 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-20 22:19:17 +1200
commit669d33472a3e23f84a873b740e21ddc3499da9f6 (patch)
tree1adb1163c03bb94202387d20ba75dcc8bd11b80b /src
parent6e127788ca5d9908a18cce338af989d77a2f3560 (diff)
downloadtrackermap-server-669d33472a3e23f84a873b740e21ddc3499da9f6.tar.gz
trackermap-server-669d33472a3e23f84a873b740e21ddc3499da9f6.tar.bz2
trackermap-server-669d33472a3e23f84a873b740e21ddc3499da9f6.zip
Minor Meitrack decoder cleanup
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index c32a5b482..f4d23a90e 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -157,31 +157,40 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
String deviceModel = Context.getIdentityManager().getDeviceById(deviceSession.getDeviceId()).getModel();
- if (deviceModel != null && deviceModel.length() > 0) {
- switch (Context.getIdentityManager().getDeviceById(deviceSession.getDeviceId()).getModel().toUpperCase()) {
- case "MVT340": case "MVT380":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.0 * 2.0 / 1024.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.0 * 16.0 / 1024.0);
- break;
- case "MT90":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0));
- break;
- case "T1": case "T3": case "MVT100": case "MVT600": case "MVT800": case "TC68": case "TC68S":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.3 * 16.0 / 4096.0);
- break;
- case "T311": case "T322X": case "T333": case "T355":
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0) / 100.0);
- position.set(Position.KEY_POWER, parser.nextHexInt(0) / 100.0);
- break;
- default:
- position.set(Position.KEY_BATTERY, parser.nextHexInt(0));
- position.set(Position.KEY_POWER, parser.nextHexInt(0));
- }
- } else {
+ if (deviceModel == null) {
+ deviceModel = "";
+ }
+ switch (deviceModel.toUpperCase()) {
+ case "MVT340":
+ case "MVT380":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.0 * 2.0 / 1024.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.0 * 16.0 / 1024.0);
+ break;
+ case "MT90":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0));
+ break;
+ case "T1":
+ case "T3":
+ case "MVT100":
+ case "MVT600":
+ case "MVT800":
+ case "TC68":
+ case "TC68S":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) * 3.3 * 2.0 / 4096.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) * 3.3 * 16.0 / 4096.0);
+ break;
+ case "T311":
+ case "T322X":
+ case "T333":
+ case "T355":
+ position.set(Position.KEY_BATTERY, parser.nextHexInt(0) / 100.0);
+ position.set(Position.KEY_POWER, parser.nextHexInt(0) / 100.0);
+ break;
+ default:
position.set(Position.KEY_BATTERY, parser.nextHexInt(0));
position.set(Position.KEY_POWER, parser.nextHexInt(0));
+ break;
}
String eventData = parser.next();