aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-26 21:02:26 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-03-26 21:02:26 -0700
commit2b9897a9595855385233429d42ed6971b456258a (patch)
tree3247598056eb44c317c8c3228e0d1aff3362a396
parent0cd2d9e4d78fd586f71027e4eab486b047a7383e (diff)
downloadtraccar-server-2b9897a9595855385233429d42ed6971b456258a.tar.gz
traccar-server-2b9897a9595855385233429d42ed6971b456258a.tar.bz2
traccar-server-2b9897a9595855385233429d42ed6971b456258a.zip
Decode additional data
-rw-r--r--src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java17
-rw-r--r--src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java11
2 files changed, 25 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
index ab89f10c8..a6aa44898 100644
--- a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
@@ -30,7 +30,9 @@ import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DataConverter;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -139,7 +141,15 @@ public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder {
ByteBuf buf = Unpooled.wrappedBuffer(
DataConverter.parseHex(xPath.evaluate("payload", node).substring(2)));
- buf.readUnsignedByte(); // flags
+ int flags = buf.readUnsignedByte();
+ position.set(Position.PREFIX_IN + 1, BitUtil.check(flags, 1));
+ position.set(Position.PREFIX_IN + 2, BitUtil.check(flags, 2));
+ position.set(Position.KEY_CHARGE, BitUtil.check(flags, 3));
+ if (BitUtil.check(flags, 4)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
+ }
+
+ position.setCourse(BitUtil.from(flags, 5) * 45);
position.setLatitude(buf.readUnsignedMedium() * 90.0 / (1 << 23));
if (position.getLatitude() > 90) {
@@ -151,8 +161,9 @@ public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder {
position.setLongitude(position.getLongitude() - 360);
}
- buf.readUnsignedByte(); // status
- buf.readUnsignedByte(); // status
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+
+ position.set("batteryReplace", BitUtil.check(buf.readUnsignedByte(), 7));
positions.add(position);
diff --git a/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java
index f9ea95a4f..f7bf8f514 100644
--- a/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java
@@ -13,6 +13,17 @@ public class GlobalstarProtocolDecoderTest extends ProtocolTest {
verifyPositions(decoder, request(HttpMethod.POST, "/", buffer(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+ "<stuMessages xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://cody.glpconnect.com/XSD/StuMessage_Rev1_0_1.xsd\" timeStamp=\"25/03/2020 03:02:32 GMT\" messageID=\"300421a0fd2a100585bdde409d6f601a\">",
+ "<stuMessage>",
+ "<esn>0-2682225</esn>",
+ "<unixTime>1585105370</unixTime>",
+ "<gps>N</gps>",
+ "<payload length=\"9\" source=\"pc\" encoding=\"hex\">0x8EFE2D97DDEA420018</payload>",
+ "</stuMessage>",
+ "</stuMessages>")));
+
+ verifyPositions(decoder, request(HttpMethod.POST, "/", buffer(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<stuMessages xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://cody.glpconnect.com/XSD/StuMessage_Rev1_0_1.xsd\" timeStamp=\"17/02/2019 21:56:15 GMT\" messageID=\"2a471778dda31005850dc52bb93ae81a\">",
"<stuMessage>",
"<esn>0-2654816</esn>",