From 37058629a3b39da810baeef92f70a6a5693d0f33 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 Mar 2018 15:05:23 +1300 Subject: Update Traccar version --- setup/traccar.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/traccar.iss b/setup/traccar.iss index 96cd5fdc0..1d6501d31 100644 --- a/setup/traccar.iss +++ b/setup/traccar.iss @@ -1,6 +1,6 @@ [Setup] AppName=Traccar -AppVersion=3.15 +AppVersion=3.16 DefaultDirName={pf}\Traccar AlwaysRestart=yes OutputBaseFilename=traccar-setup -- cgit v1.2.3 From 4d7c36cbd2ec7f6e7d971f4de013603d4cb80d0e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 Mar 2018 15:30:28 +1300 Subject: Fix setup script issues --- setup/setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/setup.sh b/setup/setup.sh index 39a00d8e8..d2e5b2dec 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -9,7 +9,8 @@ then rm -r ../out rm /opt/traccar/setup.sh chmod -R go+rX /opt/traccar - /opt/traccar/bin/installDaemon.sh + cd /opt/traccar/bin/ + . /opt/traccar/bin/installDaemon.sh else echo 'Java 7 or higher is required' fi -- cgit v1.2.3 From 755874d6e42a68178db75d9037785fc8271382a1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 11 Mar 2018 08:56:53 +1300 Subject: Fix setup script issue (fix #3804) --- setup/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/setup.sh b/setup/setup.sh index d2e5b2dec..51a139dd1 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -10,7 +10,7 @@ then rm /opt/traccar/setup.sh chmod -R go+rX /opt/traccar cd /opt/traccar/bin/ - . /opt/traccar/bin/installDaemon.sh + /opt/traccar/bin/installDaemon.sh else echo 'Java 7 or higher is required' fi -- cgit v1.2.3 From b2ab0b471591494523b12e5f1810a481b2cd1a65 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 12 Mar 2018 06:44:27 +1300 Subject: Cautela NMEA conversion protocol --- setup/default.xml | 1 + src/org/traccar/protocol/CautelaProtocol.java | 47 +++++++++++++ .../traccar/protocol/CautelaProtocolDecoder.java | 77 ++++++++++++++++++++++ .../protocol/CautelaProtocolDecoderTest.java | 18 +++++ 4 files changed, 143 insertions(+) create mode 100644 src/org/traccar/protocol/CautelaProtocol.java create mode 100644 src/org/traccar/protocol/CautelaProtocolDecoder.java create mode 100644 test/org/traccar/protocol/CautelaProtocolDecoderTest.java (limited to 'setup') diff --git a/setup/default.xml b/setup/default.xml index 6be2c08e3..81a3cd128 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -228,5 +228,6 @@ 5157 5158 5159 + 5160 diff --git a/src/org/traccar/protocol/CautelaProtocol.java b/src/org/traccar/protocol/CautelaProtocol.java new file mode 100644 index 000000000..89ab7a1d0 --- /dev/null +++ b/src/org/traccar/protocol/CautelaProtocol.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder; +import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; +import org.traccar.BaseProtocol; +import org.traccar.TrackerServer; + +import java.util.List; + +public class CautelaProtocol extends BaseProtocol { + + public CautelaProtocol() { + super("cautela"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("objectDecoder", new CautelaProtocolDecoder(CautelaProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/CautelaProtocolDecoder.java b/src/org/traccar/protocol/CautelaProtocolDecoder.java new file mode 100644 index 000000000..94ba35c91 --- /dev/null +++ b/src/org/traccar/protocol/CautelaProtocolDecoder.java @@ -0,0 +1,77 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.jboss.netty.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.DateBuilder; +import org.traccar.helper.Parser; +import org.traccar.helper.PatternBuilder; +import org.traccar.model.Position; + +import java.net.SocketAddress; +import java.util.regex.Pattern; + +public class CautelaProtocolDecoder extends BaseProtocolDecoder { + + public CautelaProtocolDecoder(CautelaProtocol protocol) { + super(protocol); + } + + private static final Pattern PATTERN = new PatternBuilder() + .number("(d+),") // type + .number("(d+),") // imei + .number("(dd),(dd),(dd),") // date (ddmmyy) + .number("(-?d+.d+),") // longitude + .number("(-?d+.d+),") // latitude + .number("(dd)(dd),") // time (hhmm) + .any() + .compile(); + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + Parser parser = new Parser(PATTERN, (String) msg); + if (!parser.matches()) { + return null; + } + + String type = parser.next(); + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder(); + dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + + position.setValid(true); + position.setLongitude(parser.nextDouble()); + position.setLatitude(parser.nextDouble()); + + dateBuilder.setHour(parser.nextInt()).setMinute(parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + return position; + } + +} diff --git a/test/org/traccar/protocol/CautelaProtocolDecoderTest.java b/test/org/traccar/protocol/CautelaProtocolDecoderTest.java new file mode 100644 index 000000000..4fd785c9f --- /dev/null +++ b/test/org/traccar/protocol/CautelaProtocolDecoderTest.java @@ -0,0 +1,18 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class CautelaProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + CautelaProtocolDecoder decoder = new CautelaProtocolDecoder(new CautelaProtocol()); + + verifyPosition(decoder, text( + "20,010907000000,14,02,18,16.816667,96.166667,1325,S,*2E")); + + } + +} -- cgit v1.2.3 From 2a30c9de983223a3af1070543975165ceb0710f9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Mar 2018 05:27:23 +1300 Subject: Option to ignore duplicate alarms --- setup/default.xml | 1 + src/org/traccar/events/AlertEventHandler.java | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'setup') diff --git a/setup/default.xml b/setup/default.xml index 81a3cd128..8701ddc4c 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -19,6 +19,7 @@ ./logs/tracker-server.log true + true true ./media diff --git a/src/org/traccar/events/AlertEventHandler.java b/src/org/traccar/events/AlertEventHandler.java index 003ccb662..7db371c70 100644 --- a/src/org/traccar/events/AlertEventHandler.java +++ b/src/org/traccar/events/AlertEventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,18 +19,34 @@ import java.util.Collections; import java.util.Map; import org.traccar.BaseEventHandler; +import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Position; public class AlertEventHandler extends BaseEventHandler { + private final boolean ignoreDuplicateAlerts; + + public AlertEventHandler() { + ignoreDuplicateAlerts = Context.getConfig().getBoolean("event.ignoreDuplicateAlerts"); + } + @Override protected Map analyzePosition(Position position) { Object alarm = position.getAttributes().get(Position.KEY_ALARM); if (alarm != null) { - Event event = new Event(Event.TYPE_ALARM, position.getDeviceId(), position.getId()); - event.set(Position.KEY_ALARM, (String) alarm); - return Collections.singletonMap(event, position); + boolean ignoreAlert = false; + if (ignoreDuplicateAlerts) { + Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId()); + if (lastPosition != null && alarm.equals(lastPosition.getAttributes().get(Position.KEY_ALARM))) { + ignoreAlert = true; + } + } + if (!ignoreAlert) { + Event event = new Event(Event.TYPE_ALARM, position.getDeviceId(), position.getId()); + event.set(Position.KEY_ALARM, (String) alarm); + return Collections.singletonMap(event, position); + } } return null; } -- cgit v1.2.3 From 38c1ff9bccc1c417a0c2b412271aa7240a3b7db7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 16 Mar 2018 22:57:59 +1300 Subject: Implement Continental RVS protocol --- setup/default.xml | 1 + src/org/traccar/protocol/ContinentalProtocol.java | 43 ++++++++++ .../protocol/ContinentalProtocolDecoder.java | 93 ++++++++++++++++++++++ .../protocol/ContinentalProtocolDecoderTest.java | 25 ++++++ 4 files changed, 162 insertions(+) create mode 100644 src/org/traccar/protocol/ContinentalProtocol.java create mode 100644 src/org/traccar/protocol/ContinentalProtocolDecoder.java create mode 100644 test/org/traccar/protocol/ContinentalProtocolDecoderTest.java (limited to 'setup') diff --git a/setup/default.xml b/setup/default.xml index 8701ddc4c..68465011e 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -230,5 +230,6 @@ 5158 5159 5160 + 5161 diff --git a/src/org/traccar/protocol/ContinentalProtocol.java b/src/org/traccar/protocol/ContinentalProtocol.java new file mode 100644 index 000000000..e2b1226cf --- /dev/null +++ b/src/org/traccar/protocol/ContinentalProtocol.java @@ -0,0 +1,43 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; +import org.traccar.BaseProtocol; +import org.traccar.TrackerServer; + +import java.util.List; + +public class ContinentalProtocol extends BaseProtocol { + + public ContinentalProtocol() { + super("continental"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2)); + pipeline.addLast("objectDecoder", new ContinentalProtocolDecoder(ContinentalProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/ContinentalProtocolDecoder.java b/src/org/traccar/protocol/ContinentalProtocolDecoder.java new file mode 100644 index 000000000..2138eb39e --- /dev/null +++ b/src/org/traccar/protocol/ContinentalProtocolDecoder.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.UnitsConverter; +import org.traccar.model.Position; + +import java.net.SocketAddress; +import java.util.Date; + +public class ContinentalProtocolDecoder extends BaseProtocolDecoder { + + public ContinentalProtocolDecoder(ContinentalProtocol protocol) { + super(protocol); + } + + public static final int MSG_KEEPALIVE = 0x00; + public static final int MSG_STATUS = 0x02; + public static final int MSG_ACK = 0x06; + public static final int MSG_NACK = 0x15; + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + ChannelBuffer buf = (ChannelBuffer) msg; + + buf.skipBytes(2); // header + buf.readUnsignedShort(); // length + buf.readUnsignedByte(); // software version + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(buf.readUnsignedInt())); + if (deviceSession == null) { + return null; + } + + buf.readUnsignedByte(); // product + + int type = buf.readUnsignedByte(); + + if (type == MSG_STATUS) { + + Position position = new Position(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + position.setFixTime(new Date(buf.readUnsignedInt() * 1000L)); + + buf.readUnsignedByte(); + position.setLatitude(buf.readMedium() / 3600.0); + + buf.readUnsignedByte(); + position.setLongitude(buf.readMedium() / 3600.0); + + position.setCourse(buf.readUnsignedShort()); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); + + position.setValid(buf.readUnsignedByte() > 0); + + position.setDeviceTime(new Date(buf.readUnsignedInt() * 1000L)); + + position.set(Position.KEY_EVENT, buf.readUnsignedShort()); + position.set(Position.KEY_INPUT, buf.readUnsignedShort()); + position.set(Position.KEY_OUTPUT, buf.readUnsignedShort()); + position.set(Position.KEY_BATTERY, buf.readUnsignedByte()); + position.set(Position.KEY_DEVICE_TEMP, buf.readByte()); + + buf.readUnsignedShort(); // reserved + + return position; + + } + + return null; + } + +} diff --git a/test/org/traccar/protocol/ContinentalProtocolDecoderTest.java b/test/org/traccar/protocol/ContinentalProtocolDecoderTest.java new file mode 100644 index 000000000..fbc7c3219 --- /dev/null +++ b/test/org/traccar/protocol/ContinentalProtocolDecoderTest.java @@ -0,0 +1,25 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class ContinentalProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + ContinentalProtocolDecoder decoder = new ContinentalProtocolDecoder(new ContinentalProtocol()); + + verifyPosition(decoder, binary( + "5356002A1100003039030243A68B5700FEB5AB00FD715F012700000143A68B57000E000000000C2F00000130"), + position("2005-12-19 10:28:39.000", true, -23.49027, -46.55138)); + + verifyPosition(decoder, binary( + "5356002a0d0010a12403025a9ea47f00feb48400fd6e63000c0000015a9ea480000e000100000c000000")); + + verifyPosition(decoder, binary( + "5356002a0d0010a1240302581b944100febed800fd9fa30139001300581c73fa000e000000000d000001")); + + } + +} -- cgit v1.2.3