diff options
Diffstat (limited to 'src/org/traccar/protocol/EskyProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/EskyProtocolDecoder.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/EskyProtocolDecoder.java b/src/org/traccar/protocol/EskyProtocolDecoder.java index 60ef4f846..bf790541b 100644 --- a/src/org/traccar/protocol/EskyProtocolDecoder.java +++ b/src/org/traccar/protocol/EskyProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,16 +37,18 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder { .number("d+;") // index .number("(d+);") // imei .text("R;") // data type - .number("(d+)").text("+") // satellites + .number("(d+)[+;]") // satellites .number("(dd)(dd)(dd)") // date - .number("(dd)(dd)(dd)").text("+") // time - .number("(-?d+.d+)").text("+") // latitude - .number("(-?d+.d+)").text("+") // longitude - .number("(d+.d+)").text("+") // speed - .number("(d+)").text("+") // course - .text("0x").number("(d+)").text("+") // input - .number("(d+)").text("+") // message type - .number("(d+)").text("+") // odometer + .number("(dd)(dd)(dd)[+;]") // time + .number("(-?d+.d+)[+;]") // latitude + .number("(-?d+.d+)[+;]") // longitude + .number("(d+.d+)[+;]") // speed + .number("(d+)[+;]") // course + .groupBegin() + .text("0x").number("(d+)[+;]") // input + .number("(d+)[+;]") // message type + .number("(d+)[+;]") // odometer + .groupEnd("?") .number("(d+)") // voltage .any() .compile(); @@ -77,10 +79,13 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromMps(parser.nextDouble())); position.setCourse(parser.nextDouble()); - position.set(Position.KEY_INPUT, parser.nextHexInt()); - position.set(Position.KEY_EVENT, parser.nextInt()); - position.set(Position.KEY_ODOMETER, parser.nextInt()); - position.set(Position.KEY_POWER, parser.nextInt()); + if (parser.hasNext(3)) { + position.set(Position.KEY_INPUT, parser.nextHexInt()); + position.set(Position.KEY_EVENT, parser.nextInt()); + position.set(Position.KEY_ODOMETER, parser.nextInt()); + } + + position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001); return position; } |