diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-02-18 21:54:29 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-02-18 21:54:29 +1300 |
commit | 62cba3756334997c9f0fe37409b37e771988691d (patch) | |
tree | 667b5cfdc791731c1275e6040f3beb0f8c338a9b /src/org/traccar/protocol | |
parent | 65fa2bc1268481e4a3b5beb59d6b72645dc77017 (diff) | |
download | trackermap-server-62cba3756334997c9f0fe37409b37e771988691d.tar.gz trackermap-server-62cba3756334997c9f0fe37409b37e771988691d.tar.bz2 trackermap-server-62cba3756334997c9f0fe37409b37e771988691d.zip |
Fixed GpsGate decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/GpsGateProtocolDecoder.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java index 5f51feab9..f755a4ce5 100644 --- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java @@ -65,30 +65,31 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder { String sentence = (String) msg; // Process login - if (sentence.startsWith("$FRLIN")) { - if (sentence.startsWith("$FRLIN,IMEI")) { - String imei = sentence.substring(12, sentence.length() - 4); - try { - deviceId = getDataManager().getDeviceByImei(imei).getId(); - send(channel, "$FRSES," + channel.getId()); - } catch(Exception error) { - Log.warning("Unknown device - " + imei); - send(channel, "$FRERR,AuthError,Unknown device"); + if (sentence.startsWith("$FRLIN,")) { + int beginIndex = sentence.indexOf(',', 7); + if (beginIndex != -1) { + beginIndex += 1; + int endIndex = sentence.indexOf(',', beginIndex); + if (endIndex != -1) { + String imei = sentence.substring(beginIndex, endIndex); + try { + deviceId = getDataManager().getDeviceByImei(imei).getId(); + send(channel, "$FRSES," + channel.getId()); + } catch(Exception error) { + Log.warning("Unknown device - " + imei); + send(channel, "$FRERR,AuthError,Unknown device"); + } + } else { + send(channel, "$FRERR,AuthError,Parse error"); } } else { - Log.warning("Unsupported login type"); - send(channel, "$FRERR,AuthError,Unsupported login type"); + send(channel, "$FRERR,AuthError,Parse error"); } } // Process data else if (sentence.contains("$GPRMC") && deviceId != null) { - // Send response - if (channel != null) { - channel.write("OK1\r\n"); - } - // Parse message Matcher parser = pattern.matcher(sentence); if (!parser.matches()) { |