diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 15:51:11 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 15:51:11 +1200 |
commit | 5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0 (patch) | |
tree | e290b09c50900b4700ac244827c337ff0fc3450c /src/org/traccar/protocol/SigfoxProtocolDecoder.java | |
parent | c40928cd674144fa5ed3dc7306c33b16823b2fad (diff) | |
download | trackermap-server-5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0.tar.gz trackermap-server-5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0.tar.bz2 trackermap-server-5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0.zip |
Fix various issues
Diffstat (limited to 'src/org/traccar/protocol/SigfoxProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/SigfoxProtocolDecoder.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/org/traccar/protocol/SigfoxProtocolDecoder.java index 5b0855cc3..f18eb015b 100644 --- a/src/org/traccar/protocol/SigfoxProtocolDecoder.java +++ b/src/org/traccar/protocol/SigfoxProtocolDecoder.java @@ -60,22 +60,25 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder { position.setTime(new Date(json.getInt("time") * 1000L)); ByteBuf buf = Unpooled.wrappedBuffer(DataConverter.parseHex(json.getString("data"))); + try { + int type = buf.readUnsignedByte() >> 4; + if (type == 0) { - int type = buf.readUnsignedByte() >> 4; - if (type == 0) { + position.setValid(true); + position.setLatitude(buf.readIntLE() * 0.0000001); + position.setLongitude(buf.readIntLE() * 0.0000001); + position.setCourse(buf.readUnsignedByte() * 2); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); - position.setValid(true); - position.setLatitude(buf.readIntLE() * 0.0000001); - position.setLongitude(buf.readIntLE() * 0.0000001); - position.setCourse(buf.readUnsignedByte() * 2); - position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.025); - position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.025); + } else { - } else { - - getLastLocation(position, position.getDeviceTime()); + getLastLocation(position, position.getDeviceTime()); + } + } finally { + buf.release(); } position.set(Position.KEY_RSSI, json.getJsonNumber("rssi").doubleValue()); |