diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-17 08:11:29 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-17 08:11:29 -0700 |
commit | 09a85fa9e43b9781d3d8e12bbbe0ff42a7d02b12 (patch) | |
tree | e44bdc5115d8486b746fb3cead81b6d53660bcdb | |
parent | ee30e6e63f110476f557ed4ca8a081eb5b589101 (diff) | |
download | trackermap-server-09a85fa9e43b9781d3d8e12bbbe0ff42a7d02b12.tar.gz trackermap-server-09a85fa9e43b9781d3d8e12bbbe0ff42a7d02b12.tar.bz2 trackermap-server-09a85fa9e43b9781d3d8e12bbbe0ff42a7d02b12.zip |
Support C2Stek variation (fix #4331)
-rw-r--r-- | src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java | 12 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java index 42a61ef85..aef158fc7 100644 --- a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java @@ -49,10 +49,12 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder { .number("(-?d+.d+)#") // altitude .number("(d+)#") // battery .number("d+#") // geo area alarm - .number("(x+)#") // alarm - .number("([01])?") // armed + .number("(x+)") // alarm + .groupBegin() + .number("#([01])?") // armed .number("([01])") // door .number("([01])#") // ignition + .groupEnd("?") .any() .text("$AP") .compile(); @@ -114,8 +116,10 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder { 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); + if (parser.hasNext(2)) { + position.set(Position.KEY_DOOR, parser.nextInt() > 0); + position.set(Position.KEY_IGNITION, parser.nextInt() > 0); + } return position; } diff --git a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java index fbb530e7f..28876075d 100644 --- a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class C2stekProtocolDecoderTest extends ProtocolTest { var decoder = inject(new C2stekProtocolDecoder(null)); verifyPosition(decoder, text( + "PA$012207006145046$D#190607#123157#1#37.947087#023.768669#000.00#314.6#00000.0#4104#000#8$AP")); + + verifyPosition(decoder, text( "PA$867965024889327$D#220222#135059#0#+37.98995#+23.85141#0.00#69.2#0.0#0000#000#8#00#sz-w1001#B2600$AP")); verifyPosition(decoder, text( |