aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-09-19 20:58:04 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-09-19 20:58:04 +1200
commit5bced58f76ef64bab98c4ef5323860cee1c4bbec (patch)
tree66a134c7240357fb713917d99954712209c7c541
parentc4a796e698d7ecbb733a361af8d8b42c8f2b9d22 (diff)
downloadtrackermap-server-5bced58f76ef64bab98c4ef5323860cee1c4bbec.tar.gz
trackermap-server-5bced58f76ef64bab98c4ef5323860cee1c4bbec.tar.bz2
trackermap-server-5bced58f76ef64bab98c4ef5323860cee1c4bbec.zip
Fix GPS103 UDP mode (fix #863)
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java7
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java60
2 files changed, 34 insertions, 33 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 72be07bb6..124df4377 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -15,6 +15,7 @@
*/
package org.traccar.protocol;
+import java.net.SocketAddress;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
@@ -58,7 +59,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, Object msg)
+ ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, Object msg)
throws Exception {
String sentence = (String) msg;
@@ -66,7 +67,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
// Send response #1
if (sentence.contains("##")) {
if (channel != null) {
- channel.write("LOAD");
+ channel.write("LOAD", remoteAddress);
}
return null;
}
@@ -74,7 +75,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
// Send response #2
if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) {
if (channel != null) {
- channel.write("ON");
+ channel.write("ON", remoteAddress);
}
return null;
}
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index c536c58f9..655d4f05f 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -14,98 +14,98 @@ public class Gps103ProtocolDecoderTest {
decoder.setDataManager(new TestDataManager());
// Log on request
- assertNull(decoder.decode(null, null, "##,imei:359586015829802,A"));
+ assertNull(decoder.decode(null, null, null, "##,imei:359586015829802,A"));
// Heartbeat package
- assertNull(decoder.decode(null, null, "359586015829802"));
+ assertNull(decoder.decode(null, null, null, "359586015829802"));
// No GPS signal
- assertNull(decoder.decode(null, null, "imei:359586015829802,tracker,000000000,13554900601,L,;"));
+ assertNull(decoder.decode(null, null, null, "imei:359586015829802,tracker,000000000,13554900601,L,;"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:869039001186913,tracker,1308282156,0,F,215630.000,A,5602.11015,N,9246.30767,E,1.4,,175.9,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359710040656622,tracker,13/02/27 23:40,,F,125952.000,A,3450.9430,S,13828.6753,E,0.00,0"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359710040565419,tracker,13/05/25 14:23,,F,062209.000,A,0626.0411,N,10149.3904,E,0.00,0"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:353451047570260,tracker,1302110948,,F,144807.000,A,0805.6615,S,07859.9763,W,0.00,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359587016817564,tracker,1301251602,,F,080251.000,A,3223.5832,N,11058.9449,W,0.03,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:012497000208821,tracker,1301080525,,F,212511.000,A,2228.5279,S,06855.6328,W,18.62,268.98,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:012497000208821,tracker,1301072224,,F,142411.077,A,2227.0739,S,06855.2912,,0,0,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:012497000431811,tracker,1210260609,,F,220925.000,A,0845.5500,N,07024.7673,W,0.00,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:100000000000000,help me,1004171910,,F,010203.000,A,0102.0003,N,00102.0003,E,1.02,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:353451040164707,tracker,1105182344,+36304665439,F,214418.000,A,4804.2222,N,01916.7593,E,0.37,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:353451042861763,tracker,1106132241,,F,144114.000,A,2301.9052,S,04909.3676,W,0.13,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359587010124900,tracker,0809231929,13554900601,F,112909.397,A,2234.4669,N,11354.3287,E,0.11,321.53,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:353451049926460,tracker,1208042043,123456 99008026,F,124336.000,A,3509.8668,N,03322.7636,E,0.00,,"));
// SOS alarm
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359586015829802,help me,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
// Low battery alarm
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359586015829802,low battery,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
// Geo-fence alarm
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359586015829802,stockade,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
// Move alarm
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359586015829802,move,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
// Over speed alarm
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359586015829802,speed,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:863070010423167,tracker,1211051840,,F,104000.000,A,2220.6483,N,11407.6377,,0,0,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:863070010423167,tracker,1211051951,63360926,F,115123.000,A,2220.6322,N,11407.5313,E,0.00,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:863070010423167,tracker,1211060621,,F,062152.000,A,2220.6914,N,11407.5506,E,15.85,347.84,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:863070012698733,tracker,1303092334,,F,193427.000,A,5139.0369,N,03907.2791,E,0.00,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:869039001186913,tracker,130925065533,0,F,065533.000,A,5604.11015,N,9232.12238,E,0.0,,329.0,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359710041641581,acc alarm,1402231159,,F,065907.000,A,2456.2591,N,06708.8335,E,7.53,76.10,,1,0,0.03%,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:359710041641581,acc alarm,1402231159,,F,065907.000,A,2456.2591,N,06708.8335,E,7.53,76.10,,1,0,0.03%,,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:313009071131684,tracker,1403211928,,F,112817.000,A,0610.1133,N,00116.5840,E,0.00,,,0,0,0.0,0.0,"));
- verify(decoder.decode(null, null,
+ verify(decoder.decode(null, null, null,
"imei:866989771979791,tracker,140527055653,,F,215653.00,A,5050.33113,N,00336.98783,E,0.066,0"));
}