diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-19 14:32:30 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-01-19 14:32:30 +1300 |
commit | cf58cb80662af0a14f5e9bbb1faaa8915ae23244 (patch) | |
tree | 04dc04cba9e3858c04bfc5e6763188505c000f6d /src | |
parent | ba4af96c2b771e3984887de0a4d2d7338aed1270 (diff) | |
download | trackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.tar.gz trackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.tar.bz2 trackermap-server-cf58cb80662af0a14f5e9bbb1faaa8915ae23244.zip |
Add YWT sync response
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/YwtProtocolDecoder.java | 19 |
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); |