diff options
author | Kevin Goos <kevingoos@telenet.be> | 2018-03-14 16:42:09 +0100 |
---|---|---|
committer | Kevin Goos <kevingoos@telenet.be> | 2018-03-14 16:42:09 +0100 |
commit | 2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c (patch) | |
tree | 32251825e6909b090819dbd79837adf2101085f2 | |
parent | 82eace30ab2bd8742301519e6157c8ef238f4885 (diff) | |
download | traccar-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.tar.gz traccar-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.tar.bz2 traccar-server-2bc0b397c1aeb28bb82b887a78ceb8c8de940e8c.zip |
Added extra info for laipac
-rw-r--r-- | setup/default.xml | 3 | ||||
-rw-r--r-- | src/org/traccar/model/Position.java | 7 | ||||
-rw-r--r-- | src/org/traccar/protocol/LaipacSFKamelProtocol.java (renamed from src/org/traccar/protocol/Laipac2Protocol.java) | 8 | ||||
-rw-r--r-- | src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java (renamed from src/org/traccar/protocol/Laipac2ProtocolDecoder.java) | 33 | ||||
-rw-r--r-- | test/org/traccar/protocol/LaipacSFKamelProtocolDecoderTest.java | 35 |
5 files changed, 66 insertions, 20 deletions
diff --git a/setup/default.xml b/setup/default.xml index 6be2c08e3..515abf61d 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -116,7 +116,8 @@ <entry key='pt3000.port'>5045</entry> <entry key='ruptela.port'>5046</entry> <entry key='topflytech.port'>5047</entry> - <entry key='laipac.port'>5048</entry> + <!--<entry key='laipac.port'>5048</entry>--> + <entry key='laipacsfkamel.port'>5048</entry> <entry key='aplicom.port'>5049</entry> <entry key='gotop.port'>5050</entry> <entry key='sanav.port'>5051</entry> diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 981c2292f..fdecb7e20 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -52,6 +52,8 @@ public class Position extends Message { public static final String KEY_BATTERY_LEVEL = "batteryLevel"; // percentage public static final String KEY_FUEL_LEVEL = "fuel"; // liters public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour + public static final String KEY_ANALOG_1 = "analog 1"; // volts + public static final String KEY_ANALOG_2 = "analog 2"; // volts public static final String KEY_VERSION_FW = "versionFw"; public static final String KEY_VERSION_HW = "versionHw"; @@ -88,6 +90,10 @@ public class Position extends Message { public static final String KEY_DRIVER_UNIQUE_ID = "driverUniqueId"; + public static final String KEY_CELL_NET_CODE = "cellNetCode"; + public static final String KEY_CELL_ID_CODE = "cellIdCode"; + public static final String KEY_COUNTRY_CODE = "countryCode"; + // Start with 1 not 0 public static final String PREFIX_TEMP = "temp"; public static final String PREFIX_ADC = "adc"; @@ -290,5 +296,4 @@ public class Position extends Message { public String getType() { return super.getType(); } - } diff --git a/src/org/traccar/protocol/Laipac2Protocol.java b/src/org/traccar/protocol/LaipacSFKamelProtocol.java index 5f132f626..5e1beabbd 100644 --- a/src/org/traccar/protocol/Laipac2Protocol.java +++ b/src/org/traccar/protocol/LaipacSFKamelProtocol.java @@ -25,10 +25,10 @@ import org.traccar.TrackerServer; import java.util.List; -public class Laipac2Protocol extends BaseProtocol { +public class LaipacSFKamelProtocol extends BaseProtocol { - public Laipac2Protocol() { - super("laipac2"); + public LaipacSFKamelProtocol() { + super("laipacsfkamel"); } @Override @@ -39,7 +39,7 @@ public class Laipac2Protocol extends BaseProtocol { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new Laipac2ProtocolDecoder(Laipac2Protocol.this)); + pipeline.addLast("objectDecoder", new LaipacSFKamelProtocolDecoder(LaipacSFKamelProtocol.this)); } }); } diff --git a/src/org/traccar/protocol/Laipac2ProtocolDecoder.java b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java index ba40c0dce..decf279df 100644 --- a/src/org/traccar/protocol/Laipac2ProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacSFKamelProtocolDecoder.java @@ -27,9 +27,9 @@ import org.traccar.model.Position; import java.net.SocketAddress; import java.util.regex.Pattern; -public class Laipac2ProtocolDecoder extends BaseProtocolDecoder { +public class LaipacSFKamelProtocolDecoder extends BaseProtocolDecoder { - public Laipac2ProtocolDecoder(Laipac2Protocol protocol) { + public LaipacSFKamelProtocolDecoder(LaipacSFKamelProtocol protocol) { super(protocol); } @@ -49,11 +49,12 @@ public class Laipac2ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // battery voltage .number("(d+),") // current mileage .number("(d),") // GPS on/off (1 = on, 0 = off) - .number("(d),") // Analog port 1 + .number("(d+),") // Analog port 1 .number("(d+),") // Analog port 2 .expression("([0-9a-fA-F]{4})") // Cell 1 - Cell Net Code .expression("([0-9a-fA-F]{4}),") // Cell 1 - Cell ID Code - .number("(d+)") // Cell 2 + .number("(d{3})") // Cell 2 - Country Code + .number("(d{3})") // Cell 2 - Operator Code .text("*") .number("(xx)") // checksum .compile(); @@ -94,27 +95,31 @@ public class Laipac2ProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); position.setTime(dateBuilder.getDate()); - String type = parser.next(); - position.set(Position.KEY_BATTERY_LEVEL, parser.nextDouble()); - //position.set(Position.KEY_, parser.nextDouble()); + String eventCode = parser.next(); + position.set(Position.KEY_EVENT, eventCode); + position.set(Position.KEY_BATTERY, parser.nextDouble() * 0.001); + position.set(Position.KEY_TOTAL_DISTANCE, parser.nextDouble()); + position.set(Position.KEY_GPS, parser.nextInt()); + position.set(Position.KEY_ANALOG_1, parser.nextDouble() * 0.001); + position.set(Position.KEY_ANALOG_2, parser.nextDouble() * 0.001); + position.set(Position.KEY_CELL_NET_CODE, parser.next()); + position.set(Position.KEY_CELL_ID_CODE, parser.next()); + position.set(Position.KEY_COUNTRY_CODE, parser.next()); + position.set(Position.KEY_OPERATOR, parser.next()); String checksum = parser.next(); if (channel != null) { - if (Character.isLowerCase(status.charAt(0))) { - String response = "$EAVACK," + type + "," + checksum; + String response = "$EAVACK," + eventCode + "," + checksum; response += Checksum.nmea(response); channel.write(response); } - if (type.equals("S") || type.equals("T")) { - channel.write("$AVCFG,00000000,t*21"); - } else if (type.equals("3")) { + if (eventCode.equals("3")) { channel.write("$AVCFG,00000000,d*31"); - } else if (type.equals("X") || type.equals("4")) { + } else if (eventCode.equals("X") || eventCode.equals("4")) { channel.write("$AVCFG,00000000,x*2D"); } - } return position; diff --git a/test/org/traccar/protocol/LaipacSFKamelProtocolDecoderTest.java b/test/org/traccar/protocol/LaipacSFKamelProtocolDecoderTest.java new file mode 100644 index 000000000..05de5dcbe --- /dev/null +++ b/test/org/traccar/protocol/LaipacSFKamelProtocolDecoderTest.java @@ -0,0 +1,35 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class LaipacSFKamelProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + LaipacSFKamelProtocolDecoder decoder = new LaipacSFKamelProtocolDecoder(new LaipacSFKamelProtocol()); + + verifyPosition(decoder, text( + "$AVRMC,358174067149865,084514,r,5050.1314,N,00419.9719,E,0.68,306.39,120318,0,3882,84,1,0,0,3EE4A617,020610*4E")); + + verifyNull(decoder, text( + "$AVSYS,99999999,V1.50,SN0000103,32768*15")); + + verifyNull(decoder, text( + "$ECHK,99999999,0*35")); + + verifyNull(decoder, text( + "$AVSYS,MSG00002,14406,7046811160,64*1A")); + + verifyNull(decoder, text( + "$EAVSYS,MSG00002,8931086013104404999,,Owner,0x52014406*76")); + + verifyNull(decoder, text( + "$ECHK,MSG00002,0*5E")); + + verifyPosition(decoder, text( + "$AVRMC,358174067149865,111602,r,5050.1262,N,00419.9660,E,0.00,0.00,120318,0,3843,95,1,0,0,3EE4A617,020610*44")); + } + +} |