aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-18 06:56:15 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-01-18 05:56:15 +1300
commit92f9691c9817526bd025377cb44aa336e7625592 (patch)
treed0117fc222a54be32105ceec064605719f051047 /src
parent2cdc0c93b759dfbdaff0c5577862b151d9aadf7f (diff)
downloadtrackermap-server-92f9691c9817526bd025377cb44aa336e7625592.tar.gz
trackermap-server-92f9691c9817526bd025377cb44aa336e7625592.tar.bz2
trackermap-server-92f9691c9817526bd025377cb44aa336e7625592.zip
Properly decode Ulbotech ADC values
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index c4ddca219..ec45be3d1 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,6 +136,31 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ private void decodeAdc(Position position, ChannelBuffer buf, int length) {
+ for (int i = 0; i < length / 2; i++) {
+ int value = buf.readUnsignedShort();
+ int id = BitUtil.from(value, 12);
+ value = BitUtil.to(value, 12);
+ switch (id) {
+ case 0:
+ position.set(Position.KEY_POWER, value * (100 + 10) / 4096.0 - 10);
+ break;
+ case 1:
+ position.set(Position.PREFIX_TEMP + 1, value * (125 + 55) / 4096.0 - 55);
+ break;
+ case 2:
+ position.set(Position.KEY_BATTERY, value * (100 + 10) / 4096.0 - 10);
+ break;
+ case 3:
+ position.set(Position.PREFIX_ADC + 1, value * (100 + 10) / 4096.0 - 10);
+ break;
+ default:
+ position.set(Position.PREFIX_IO + id, value);
+ break;
+ }
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -210,10 +235,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_ADC:
- for (int i = 0; i < length / 2; i++) {
- int value = buf.readUnsignedShort();
- position.set(Position.PREFIX_ADC + BitUtil.from(value, 12), BitUtil.to(value, 12));
- }
+ decodeAdc(position, buf, length);
break;
case DATA_GEOFENCE: