aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-03 17:22:26 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-03 17:22:26 -0700
commit3e6929ff362d53aea19516cb5b903d1d753e8ddc (patch)
treee648984215789d79cfba7e05b80ad91823ad440a /src/main/java
parent45cec80f310c966b63388b18a773533d0e9b9102 (diff)
downloadtrackermap-server-3e6929ff362d53aea19516cb5b903d1d753e8ddc.tar.gz
trackermap-server-3e6929ff362d53aea19516cb5b903d1d753e8ddc.tar.bz2
trackermap-server-3e6929ff362d53aea19516cb5b903d1d753e8ddc.zip
Add GalileoSky Iridium format
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
index 3ff8eb2fb..b1deded3b 100644
--- a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.helper.BitUtil;
import org.traccar.session.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
@@ -229,7 +230,11 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
int header = buf.readUnsignedByte();
if (header == 0x01) {
- return decodePositions(channel, remoteAddress, buf);
+ if (buf.getUnsignedMedium(buf.readerIndex() + 2) == 0x01001c) {
+ return decodeIridiumPosition(channel, remoteAddress, buf);
+ } else {
+ return decodePositions(channel, remoteAddress, buf);
+ }
} else if (header == 0x07) {
return decodePhoto(channel, remoteAddress, buf);
}
@@ -237,7 +242,38 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodePositions(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
+ private Position decodeIridiumPosition(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
+
+ buf.readUnsignedShortLE(); // length
+
+ buf.skipBytes(3); // identification header
+ buf.readUnsignedIntLE(); // index
+
+ DeviceSession deviceSession = getDeviceSession(
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ buf.readUnsignedByte(); // session status
+ buf.skipBytes(4); // reserved
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
+
+ buf.skipBytes(3); // coordinates header
+ int flags = buf.readUnsignedByte();
+ double latitude = buf.readUnsignedByte() + buf.readUnsignedShortLE() / 60000.0;
+ double longitude = buf.readUnsignedByte() + buf.readUnsignedShortLE() / 60000.0;
+ position.setLatitude(BitUtil.check(flags, 1) ? -latitude : latitude);
+ position.setLongitude(BitUtil.check(flags, 0) ? -longitude : longitude);
+ position.setAccuracy(buf.readUnsignedIntLE());
+
+ return position;
+ }
+
+ private List<Position> decodePositions(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
int endIndex = (buf.readUnsignedShortLE() & 0x7fff) + buf.readerIndex();