diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-18 22:04:41 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-18 22:04:41 +1300 |
commit | a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4 (patch) | |
tree | 23eb64d9a56b62db63b0154ee2e40a37b9727fa0 /src/org/traccar/protocol | |
parent | a0bc8e67dba450ab1ba3a61340f6c06bf0fa448b (diff) | |
download | trackermap-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.tar.gz trackermap-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.tar.bz2 trackermap-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.zip |
Support GSM based locations (fix #346)
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index aa693f42e..a91848f5b 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -63,6 +63,17 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private static final Pattern PATTERN_NETWORK = new PatternBuilder() + .text("imei:") + .number("(d+),") // imei + .expression("[^,]+,") // alarm + .number("d+,,") + .text("L,,,") + .number("(x+),,") // lac + .number("(x+),,,") // cid + .any() + .compile(); + private static final Pattern PATTERN_HANDSHAKE = new PatternBuilder() .number("##,imei:(d+),A") .compile(); @@ -93,14 +104,31 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { return null; } - Parser parser = new Parser(PATTERN, sentence); + Position position = new Position(); + position.setProtocol(getProtocolName()); + + Parser parser = new Parser(PATTERN_NETWORK, sentence); + if (parser.matches()) { + + if (!identify(parser.next(), channel, remoteAddress)) { + return null; + } + position.setDeviceId(getDeviceId()); + + getLastLocation(position, null); + + position.set(Event.KEY_LAC, parser.nextInt(16)); + position.set(Event.KEY_CID, parser.nextInt(16)); + + return position; + + } + + parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; } - Position position = new Position(); - position.setProtocol(getProtocolName()); - String imei = parser.next(); if (!identify(imei, channel, remoteAddress)) { return null; |