diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-20 22:07:09 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 22:07:09 +1200 |
commit | 6e127788ca5d9908a18cce338af989d77a2f3560 (patch) | |
tree | 870d01479e31a1eace7c9621f8305fce5c523e68 /src/org/traccar | |
parent | d8e9e8b26239499a87440ecc6a611b82f07986a7 (diff) | |
parent | 305f1c41d9d00971803d56f4c9c46e50600f472b (diff) | |
download | traccar-server-6e127788ca5d9908a18cce338af989d77a2f3560.tar.gz traccar-server-6e127788ca5d9908a18cce338af989d77a2f3560.tar.bz2 traccar-server-6e127788ca5d9908a18cce338af989d77a2f3560.zip |
Merge pull request #3099 from lalamper/master
Show proper Meitrack Battery and Power values
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 658359789..c32a5b482 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -156,8 +156,33 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { } } - position.set(Position.KEY_BATTERY, parser.nextHexInt(0)); - position.set(Position.KEY_POWER, parser.nextHexInt(0)); + 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 { + position.set(Position.KEY_BATTERY, parser.nextHexInt(0)); + position.set(Position.KEY_POWER, parser.nextHexInt(0)); + } String eventData = parser.next(); if (eventData != null && !eventData.isEmpty()) { |