aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/BaseProtocolPoller.java4
-rw-r--r--src/main/java/org/traccar/protocol/ArmoliProtocol.java1
-rw-r--r--src/main/java/org/traccar/protocol/ArmoliProtocolDecoder.java35
-rw-r--r--src/main/java/org/traccar/protocol/ArmoliProtocolPoller.java35
-rw-r--r--src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java2
5 files changed, 72 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolPoller.java b/src/main/java/org/traccar/BaseProtocolPoller.java
index 88138577c..5f4121fc1 100644
--- a/src/main/java/org/traccar/BaseProtocolPoller.java
+++ b/src/main/java/org/traccar/BaseProtocolPoller.java
@@ -29,8 +29,8 @@ public abstract class BaseProtocolPoller extends ChannelDuplexHandler {
private final long interval;
private Future<?> timeout;
- public BaseProtocolPoller(Protocol protocol) {
- interval = Context.getConfig().getLong(Keys.PROTOCOL_INTERVAL.withPrefix(protocol.getName()));
+ public BaseProtocolPoller(Protocol protocol, long interval) {
+ this.interval = interval;
}
protected abstract void sendRequest(Channel channel, SocketAddress remoteAddress);
diff --git a/src/main/java/org/traccar/protocol/ArmoliProtocol.java b/src/main/java/org/traccar/protocol/ArmoliProtocol.java
index 1b8ce871c..7ee4289b0 100644
--- a/src/main/java/org/traccar/protocol/ArmoliProtocol.java
+++ b/src/main/java/org/traccar/protocol/ArmoliProtocol.java
@@ -32,6 +32,7 @@ public class ArmoliProtocol extends BaseProtocol {
pipeline.addLast(new StringEncoder());
pipeline.addLast(new StringDecoder());
pipeline.addLast(new ArmoliProtocolDecoder(ArmoliProtocol.this));
+ pipeline.addLast(new ArmoliProtocolPoller(ArmoliProtocol.this));
}
});
}
diff --git a/src/main/java/org/traccar/protocol/ArmoliProtocolDecoder.java b/src/main/java/org/traccar/protocol/ArmoliProtocolDecoder.java
index 46bdb484e..40beedbf6 100644
--- a/src/main/java/org/traccar/protocol/ArmoliProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/ArmoliProtocolDecoder.java
@@ -50,6 +50,13 @@ public class ArmoliProtocolDecoder extends BaseProtocolDecoder {
.number("(xx)") // status
.number("(xx)") // max speed
.number("(x{6})") // distance
+ .number("(dd)?") // hdop
+ .number("xx") // idle
+ .number(":(x+)").optional() // alarms
+ .number("G(x{6})").optional() // g-sensor
+ .number("H(x{3})").optional() // power
+ .number("E(x{3})").optional() // battery
+ .number("!(x+)").optional() // driver
.any()
.compile();
@@ -60,8 +67,14 @@ public class ArmoliProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
char type = sentence.charAt(1);
+ Position position = new Position(getProtocolName());
+
if (type != 'M') {
- if (channel != null && (type == 'Q' || type == 'L')) {
+ if (type == 'W') {
+ getLastLocation(position, null);
+ position.set(Position.KEY_RESULT, sentence.substring(sentence.indexOf(',') + 1, sentence.length() - 2));
+ return position;
+ } else if (channel != null && (type == 'Q' || type == 'L')) {
channel.writeAndFlush(new NetworkMessage("[TX,];;", remoteAddress));
}
return null;
@@ -77,7 +90,6 @@ public class ArmoliProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
@@ -96,6 +108,25 @@ public class ArmoliProtocolDecoder extends BaseProtocolDecoder {
position.set("maxSpeed", parser.nextHexInt());
position.set(Position.KEY_ODOMETER, parser.nextHexInt());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_HDOP, parser.nextInt() * 0.1);
+ }
+ if (parser.hasNext()) {
+ position.set("alarms", parser.next());
+ }
+ if (parser.hasNext()) {
+ position.set(Position.KEY_G_SENSOR, parser.next());
+ }
+ if (parser.hasNext()) {
+ position.set(Position.KEY_POWER, parser.nextHexInt() * 0.01);
+ }
+ if (parser.hasNext()) {
+ position.set(Position.KEY_BATTERY, parser.nextHexInt() * 0.01);
+ }
+ if (parser.hasNext()) {
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next());
+ }
+
return position;
}
diff --git a/src/main/java/org/traccar/protocol/ArmoliProtocolPoller.java b/src/main/java/org/traccar/protocol/ArmoliProtocolPoller.java
new file mode 100644
index 000000000..446ce8c39
--- /dev/null
+++ b/src/main/java/org/traccar/protocol/ArmoliProtocolPoller.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2022 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 io.netty.channel.Channel;
+import org.traccar.BaseProtocolPoller;
+import org.traccar.Protocol;
+
+import java.net.SocketAddress;
+
+public class ArmoliProtocolPoller extends BaseProtocolPoller {
+
+ public ArmoliProtocolPoller(Protocol protocol) {
+ super(protocol, 180000);
+ }
+
+ @Override
+ protected void sendRequest(Channel channel, SocketAddress remoteAddress) {
+ channel.writeAndFlush("[TX,];;");
+ }
+
+}
diff --git a/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java b/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java
index bf1093654..65e98474b 100644
--- a/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java
+++ b/src/main/java/org/traccar/protocol/OrbcommProtocolPoller.java
@@ -47,7 +47,7 @@ public class OrbcommProtocolPoller extends BaseProtocolPoller {
}
public OrbcommProtocolPoller(Protocol protocol) {
- super(protocol);
+ super(protocol, Context.getConfig().getLong(Keys.PROTOCOL_INTERVAL.withPrefix(protocol.getName())));
accessId = Context.getConfig().getString(Keys.ORBCOMM_ACCESS_ID);
password = Context.getConfig().getString(Keys.ORBCOMM_PASSWORD);
host = Context.getConfig().getString(Keys.PROTOCOL_ADDRESS.withPrefix(protocol.getName()));