aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-19 14:32:30 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-19 14:32:30 +1300
commitcf58cb80662af0a14f5e9bbb1faaa8915ae23244 (patch)
tree04dc04cba9e3858c04bfc5e6763188505c000f6d /src/org/traccar/protocol
parentba4af96c2b771e3984887de0a4d2d7338aed1270 (diff)
downloadtrackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.tar.gz
trackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.tar.bz2
trackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.zip
Add YWT sync response
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index e41932177..fd712f100 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"%(..)," + // Type
"(\\d+):" + // Unit identifier
"\\d+," + // Subtype
@@ -57,6 +57,21 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
throws Exception {
String sentence = (String) msg;
+
+ // Synchronization
+ if (sentence.startsWith("%SN") && channel != null) {
+ int start = sentence.indexOf(':');
+ int end = start;
+ for (int i = 0; i < 4; i++) {
+ end = sentence.indexOf(',', end + 1);
+ }
+ if (end == -1) {
+ end = sentence.length();
+ }
+
+ channel.write("%AT+SN=" + sentence.substring(start, end));
+ return null;
+ }
// Parse message
Matcher parser = pattern.matcher(sentence);