aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-11-23 14:48:40 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-11-23 14:48:40 -0800
commitca41538149dc6fd549f9c6f7565e3cfd71957d1e (patch)
tree7c78a5efe739a9bf7d009523abfe4f5594e61312 /src/main/java/org/traccar
parent3392dc3ee2cfb08542d7c2bf00e01305bcefc28c (diff)
downloadtrackermap-server-ca41538149dc6fd549f9c6f7565e3cfd71957d1e.tar.gz
trackermap-server-ca41538149dc6fd549f9c6f7565e3cfd71957d1e.tar.bz2
trackermap-server-ca41538149dc6fd549f9c6f7565e3cfd71957d1e.zip
Decode binary data
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java
index e513edcc2..304f61836 100644
--- a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java
@@ -24,6 +24,7 @@ import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DataConverter;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Network;
@@ -97,8 +98,8 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder {
position.setTime(new Date());
}
- if (json.containsKey("location") || json.containsKey("lat") && json.containsKey("lng")) {
-
+ if (json.containsKey("location")
+ || json.containsKey("lat") && json.containsKey("lng") && !json.containsKey("data")) {
JsonObject location;
if (json.containsKey("location")) {
@@ -117,7 +118,25 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder {
ByteBuf buf = Unpooled.wrappedBuffer(DataConverter.parseHex(data));
try {
int event = buf.readUnsignedByte();
- if (event >> 4 == 0) {
+ if (event == 0x0f || event == 0x1f) {
+
+ position.setValid(event >> 4 > 0);
+
+ long value;
+ value = buf.readUnsignedInt();
+ position.setLatitude(BitUtil.to(value, 31) * 0.000001);
+ if (BitUtil.check(value, 31)) {
+ position.setLatitude(-position.getLatitude());
+ }
+ value = buf.readUnsignedInt();
+ position.setLongitude(BitUtil.to(value, 31) * 0.000001);
+ if (BitUtil.check(value, 31)) {
+ position.setLongitude(-position.getLongitude());
+ }
+
+ position.set(Position.KEY_BATTERY, (int) buf.readUnsignedByte());
+
+ } else if (event >> 4 == 0) {
position.setValid(true);
position.setLatitude(buf.readIntLE() * 0.0000001);