aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java7
-rw-r--r--src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java3
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java b/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java
index d1e079711..aff722c46 100644
--- a/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/OrbcommProtocolDecoder.java
@@ -27,6 +27,7 @@ import org.traccar.model.Position;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.json.JsonValue;
import java.io.StringReader;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
@@ -49,7 +50,7 @@ public class OrbcommProtocolDecoder extends BaseProtocolDecoder {
String content = response.content().toString(StandardCharsets.UTF_8);
JsonObject json = Json.createReader(new StringReader(content)).readObject();
- if (channel != null) {
+ if (channel != null && !json.getString("NextStartUTC").isEmpty()) {
OrbcommProtocolPoller poller =
BasePipelineFactory.getHandler(channel.pipeline(), OrbcommProtocolPoller.class);
if (poller != null) {
@@ -59,6 +60,10 @@ public class OrbcommProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (json.get("Messages").getValueType() == JsonValue.ValueType.NULL) {
+ return null;
+ }
+
LinkedList<Position> positions = new LinkedList<>();
JsonArray messages = json.getJsonArray("Messages");
diff --git a/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java
index 604ccef6e..af35505d5 100644
--- a/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class OrbcommProtocolDecoderTest extends ProtocolTest {
var decoder = new OrbcommProtocolDecoder(null);
+ verifyNull(decoder, response(
+ buffer("{\"ErrorID\":0,\"NextStartUTC\":\"\",\"Messages\":null}")));
+
verifyPositions(decoder, response(
buffer("{\"ErrorID\":0,\"NextStartUTC\":\"2022-01-20 21:17:19\",\"Messages\":[{\"ID\":21545955455454,\"MessageUTC\":\"2022-01-20 21:17:19\",\"ReceiveUTC\":\"2022-01-20 21:17:19\",\"SIN\":19,\"MobileID\":\"01097623SKY2C68\",\"Payload\":{\"Name\":\"simpleReport\",\"SIN\":19,\"MIN\":1,\"Fields\":[{\"Name\":\"latitude\",\"Value\":\"2717900\",\"Type\":\"signedint\"},{\"Name\":\"longitude\",\"Value\":\"-4555211\",\"Type\":\"signedint\"},{\"Name\":\"speed\",\"Value\":\"0\",\"Type\":\"unsignedint\"},{\"Name\":\"heading\",\"Value\":\"1439\",\"Type\":\"unsignedint\"}]},\"RegionName\":\"\",\"OTAMessageSize\":17,\"CustomerID\":0,\"Transport\":1,\"MobileOwnerID\":60000934}]}")));