diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-05 18:46:26 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-05 18:46:26 +1300 |
commit | 1909b845a8c77a2463c0ad8d4c1952b8c0852ae2 (patch) | |
tree | 98d96af828d4b4c9ae709251ab3e3d1c67d5b76a /src/org/traccar | |
parent | 4e37ce80b615e126f82e567d06a60beff8c82fb0 (diff) | |
download | trackermap-server-1909b845a8c77a2463c0ad8d4c1952b8c0852ae2.tar.gz trackermap-server-1909b845a8c77a2463c0ad8d4c1952b8c0852ae2.tar.bz2 trackermap-server-1909b845a8c77a2463c0ad8d4c1952b8c0852ae2.zip |
Fix GL200 wifi message parsing
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 60addcd04..ab6507122 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -32,6 +32,7 @@ import org.traccar.model.WifiAccessPoint; import java.net.SocketAddress; import java.util.LinkedList; import java.util.List; +import java.util.regex.Matcher; import java.util.regex.Pattern; public class Gl200ProtocolDecoder extends BaseProtocolDecoder { @@ -237,11 +238,13 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { .number("(d{15}|x{14}),") // imei .expression("[^,]*,") // device name .number("(d+),") // count - .groupBegin() - .number("(x{12}),") // bssid - .number("(-?d+),,,,") // rssi - .groupEnd("+") - .any() + .number("((?:x{12},-?d+,,,,)+),,,,") // wifi + .number("(d{1,3}),") // battery + .number("(dddd)(dd)(dd)") // date + .number("(dd)(dd)(dd)").optional(2) // time + .text(",") + .number("(xxxx)") // count number + .text("$").optional() .compile(); private static final Pattern PATTERN = new PatternBuilder() @@ -620,12 +623,18 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { Network network = new Network(); - int count = parser.nextInt(); - for (int i = 0; i < count; i++) { - String mac = parser.next().replaceAll("(..)", "$1:"); - network.addWifiAccessPoint(WifiAccessPoint.from(mac.substring(0, mac.length() - 1), parser.nextInt())); + parser.nextInt(); // count + Matcher matcher = Pattern.compile("([0-9a-fA-F]{12}),(-?\\d+),,,,").matcher(parser.next()); + while (matcher.find()) { + String mac = matcher.group(1).replaceAll("(..)", "$1:"); + network.addWifiAccessPoint(WifiAccessPoint.from( + mac.substring(0, mac.length() - 1), Integer.parseInt(matcher.group(2)))); } + position.setNetwork(network); + + position.set(Position.KEY_BATTERY, parser.nextInt()); + return position; } |