aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-02-18 21:54:29 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-02-18 21:54:29 +1300
commit62cba3756334997c9f0fe37409b37e771988691d (patch)
tree667b5cfdc791731c1275e6040f3beb0f8c338a9b /src/org/traccar/protocol
parent65fa2bc1268481e4a3b5beb59d6b72645dc77017 (diff)
downloadtraccar-server-62cba3756334997c9f0fe37409b37e771988691d.tar.gz
traccar-server-62cba3756334997c9f0fe37409b37e771988691d.tar.bz2
traccar-server-62cba3756334997c9f0fe37409b37e771988691d.zip
Fixed GpsGate decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java33
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()) {