From de7a373eff79172f0848ca6fce968f99e45af41a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 22 Feb 2022 19:42:25 -0800 Subject: Fix C2STek MT-20N decoding --- src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java index 83e62ff86..e735c67a1 100644 --- a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2022 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. @@ -50,7 +50,7 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder { .number("(d+)#") // battery .number("d+#") // geo area alarm .number("(x+)#") // alarm - .number("([01])") // armed + .number("([01])?") // armed .number("([01])") // door .number("([01])#") // ignition .any() @@ -111,7 +111,9 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001); position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt())); - position.set(Position.KEY_ARMED, parser.nextInt() > 0); + if (parser.hasNext()) { + position.set(Position.KEY_ARMED, parser.nextInt() > 0); + } position.set(Position.KEY_DOOR, parser.nextInt() > 0); position.set(Position.KEY_IGNITION, parser.nextInt() > 0); -- cgit v1.2.3