aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-10-08 14:13:04 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-10-08 14:13:04 -0700
commit6e85d9023c67cd7f8c35c78665381b6dc732b0a8 (patch)
treef696580aaaea4099717ab547870899621d063173 /src/main/java/org
parentb6dfdef54b8fab3c7bca9b6a2057d8a27f9df4a8 (diff)
downloadtraccar-server-6e85d9023c67cd7f8c35c78665381b6dc732b0a8.tar.gz
traccar-server-6e85d9023c67cd7f8c35c78665381b6dc732b0a8.tar.bz2
traccar-server-6e85d9023c67cd7f8c35c78665381b6dc732b0a8.zip
Decode GL500M battery level
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java79
1 files changed, 47 insertions, 32 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index c42b2716b..ec569b71b 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -232,6 +232,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
.expression("((?:")
.expression(PATTERN_LOCATION.pattern())
.expression(")+)")
+ .groupBegin()
.number("(d{1,7}.d)?,") // odometer
.number("(d{5}:dd:dd)?,") // hour meter
.number("(x+)?,") // adc 1
@@ -239,6 +240,11 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
.number("(d{1,3})?,") // battery
.number("(?:(xx)(xx)(xx))?,") // device status
.expression("(.*)") // additional data
+ .or()
+ .number("d*,,")
+ .number("(d+),") // battery
+ .any()
+ .groupEnd()
.number("(dddd)(dd)(dd)") // date (yyyymmdd)
.number("(dd)(dd)(dd)").optional(2) // time (hhmmss)
.text(",")
@@ -913,49 +919,58 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (power != null) {
position.set(Position.KEY_POWER, power * 0.001);
}
- position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
- position.set(Position.KEY_HOURS, parseHours(parser.next()));
- position.set(Position.PREFIX_ADC + 1, parser.next());
- position.set(Position.PREFIX_ADC + 2, parser.next());
- position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
- decodeStatus(position, parser);
+ if (parser.hasNext(9)) {
- int index = 0;
- String[] data = parser.next().split(",");
+ position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000);
+ position.set(Position.KEY_HOURS, parseHours(parser.next()));
+ position.set(Position.PREFIX_ADC + 1, parser.next());
+ position.set(Position.PREFIX_ADC + 2, parser.next());
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
- index += 1; // device type
+ decodeStatus(position, parser);
- if (BitUtil.check(mask, 0)) {
- index += 1; // digital fuel sensor data
- }
+ int index = 0;
+ String[] data = parser.next().split(",");
- if (BitUtil.check(mask, 1)) {
- int deviceCount = Integer.parseInt(data[index++]);
- for (int i = 1; i <= deviceCount; i++) {
- index += 1; // id
- index += 1; // type
- if (!data[index++].isEmpty()) {
- position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index - 1], 16) * 0.0625);
+ index += 1; // device type
+
+ if (BitUtil.check(mask, 0)) {
+ index += 1; // digital fuel sensor data
+ }
+
+ if (BitUtil.check(mask, 1)) {
+ int deviceCount = Integer.parseInt(data[index++]);
+ for (int i = 1; i <= deviceCount; i++) {
+ index += 1; // id
+ index += 1; // type
+ if (!data[index++].isEmpty()) {
+ position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index - 1], 16) * 0.0625);
+ }
}
}
- }
- if (BitUtil.check(mask, 2)) {
- index += 1; // can data
- }
+ if (BitUtil.check(mask, 2)) {
+ index += 1; // can data
+ }
- if (BitUtil.check(mask, 3) || BitUtil.check(mask, 4)) {
- int deviceCount = Integer.parseInt(data[index++]);
- for (int i = 1; i <= deviceCount; i++) {
- index += 1; // type
- if (BitUtil.check(mask, 3)) {
- position.set(Position.KEY_FUEL_LEVEL, Double.parseDouble(data[index++]));
- }
- if (BitUtil.check(mask, 4)) {
- index += 1; // volume
+ if (BitUtil.check(mask, 3) || BitUtil.check(mask, 4)) {
+ int deviceCount = Integer.parseInt(data[index++]);
+ for (int i = 1; i <= deviceCount; i++) {
+ index += 1; // type
+ if (BitUtil.check(mask, 3)) {
+ position.set(Position.KEY_FUEL_LEVEL, Double.parseDouble(data[index++]));
+ }
+ if (BitUtil.check(mask, 4)) {
+ index += 1; // volume
+ }
}
}
+
+ }
+
+ if (parser.hasNext()) {
+ position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt());
}
decodeDeviceTime(position, parser);