aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk103ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-11-10 14:11:49 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-11-10 14:11:49 +1300
commit9e63b6d2a7c0e954fca3c99cffed2ecd94faac4e (patch)
treee67868f263f5b89965d0cb646edda8d32681ca6f /src/org/traccar/protocol/Tk103ProtocolDecoder.java
parent81f568a2b63f0a882db0b0ba23ac5d173cd30465 (diff)
downloadtrackermap-server-9e63b6d2a7c0e954fca3c99cffed2ecd94faac4e.tar.gz
trackermap-server-9e63b6d2a7c0e954fca3c99cffed2ecd94faac4e.tar.bz2
trackermap-server-9e63b6d2a7c0e954fca3c99cffed2ecd94faac4e.zip
Add TK103 responses
Diffstat (limited to 'src/org/traccar/protocol/Tk103ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index d83f1bce4..d90cdd7d7 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -33,7 +33,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"(\\d{12})" + // Device ID
".{4}" + // Command
"\\d*" + // IMEI (?)
@@ -61,9 +61,18 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
if (beginIndex != -1) {
sentence = sentence.substring(beginIndex + 1);
}
-
- // TODO: Send answer?
- //(090411121854AP05)
+
+ // Send response
+ if (channel != null) {
+ String id = sentence.substring(0, 12);
+ String type = sentence.substring(12, 16);
+ if (type.equals("BP00")) {
+ String content = sentence.substring(sentence.length() - 3);
+ channel.write("(" + id + "AP01" + content + ")");
+ } else if (type.equals("BP05")) {
+ channel.write("(" + id + "AP05)");
+ }
+ }
// Parse message
Matcher parser = pattern.matcher(sentence);
@@ -98,7 +107,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));