aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-18 07:36:33 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-18 07:36:33 -0800
commita9029f335cd8a6493ee6b817e659e690bf0af614 (patch)
tree8f7bbc84510dcc8c62f7e72c603aa9b8e5816313 /src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
parent2d584e225ac56de1432a15243f981e294215fd10 (diff)
downloadtrackermap-server-a9029f335cd8a6493ee6b817e659e690bf0af614.tar.gz
trackermap-server-a9029f335cd8a6493ee6b817e659e690bf0af614.tar.bz2
trackermap-server-a9029f335cd8a6493ee6b817e659e690bf0af614.zip
Support GL521M light sensor
Diffstat (limited to 'src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index a4ace7a1c..290f35d83 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -1282,6 +1282,46 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private static final Pattern PATTERN_LSA = new PatternBuilder()
+ .text("+RESP:GTLSA,")
+ .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version
+ .number("(d{15}|x{14}),") // imei
+ .expression("[^,]*,") // device name
+ .number("d,") // event state 1
+ .number("d,") // event state 2
+ .number("d+,") // number
+ .expression(PATTERN_LOCATION.pattern())
+ .number("d+,") // bit error rate
+ .number("(d),") // light level
+ .number("(d+),") // battery level
+ .number("[01],") // mode selection
+ .number("[01]?,") // movement status
+ .number("(-?d+.d)?,") // temperature
+ .number("(dddd)(dd)(dd)") // date (yyyymmdd)
+ .number("(dd)(dd)(dd)").optional(2) // time (hhmmss)
+ .text(",")
+ .number("(xxxx)") // count number
+ .text("$").optional()
+ .compile();
+
+ private Object decodeLsa(Channel channel, SocketAddress remoteAddress, String sentence) {
+ Parser parser = new Parser(PATTERN_LSA, sentence);
+ Position position = initPosition(parser, channel, remoteAddress);
+ if (position == null) {
+ return null;
+ }
+
+ decodeLocation(position, parser);
+
+ position.set("lightLevel", parser.nextInt());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextDouble());
+
+ decodeDeviceTime(position, parser);
+
+ return position;
+ }
+
private static final Pattern PATTERN = new PatternBuilder()
.text("+").expression("(?:RESP|BUFF):GT...,")
.number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version
@@ -1536,6 +1576,9 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
case "BID":
result = decodeBid(channel, remoteAddress, sentence);
break;
+ case "LSA":
+ result = decodeLsa(channel, remoteAddress, sentence);
+ break;
default:
result = decodeOther(channel, remoteAddress, sentence, type);
break;