From 398a3a71fef1d7610940a8118bcf9b13782c21f3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 15 Jul 2019 23:40:56 -0700 Subject: Decode WiFi info --- src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java index e9a943e0e..0e0d8d608 100644 --- a/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SigfoxProtocolDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.handler.codec.http.FullHttpRequest; @@ -25,7 +26,9 @@ import org.traccar.DeviceSession; import org.traccar.Protocol; import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; +import org.traccar.model.Network; import org.traccar.model.Position; +import org.traccar.model.WifiAccessPoint; import javax.json.Json; import javax.json.JsonObject; @@ -104,7 +107,9 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder { position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); break; case 0x06: - buf.skipBytes(7); // wifi + String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:"); + position.setNetwork(new Network(WifiAccessPoint.from( + mac.substring(0, mac.length() - 1), buf.readUnsignedByte()))); break; case 0x07: buf.skipBytes(10); // wifi extended @@ -126,6 +131,10 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder { buf.release(); } + if (position.getLatitude() == 0 && position.getLongitude() == 0) { + getLastLocation(position, position.getDeviceTime()); + } + if (json.containsKey("rssi")) { position.set(Position.KEY_RSSI, json.getJsonNumber("rssi").doubleValue()); } -- cgit v1.2.3