From 5012663d8688fa521fa7de02116f42ddbb57e7fb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 28 Feb 2017 08:32:46 +1300 Subject: Additional T55 attributes --- src/org/traccar/protocol/T55ProtocolDecoder.java | 12 ++++++++++-- test/org/traccar/protocol/T55ProtocolDecoderTest.java | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index faf9c4b7d..a41da427a 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2017 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,9 +50,10 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]+") .number(",(d+)") // satellites .number(",(d+)") // imei - .number(",([01])") // ignition + .expression(",([01])") // ignition .number(",(d+)") // fuel .number(",(d+)").optional(5) // battery + .number("((?:,d+)+)?") // parameters .any() .compile(); @@ -139,6 +140,13 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, parser.nextInt()); } + if (parser.hasNext()) { + String[] parameters = parser.next().split(","); + for (int i = 1; i < parameters.length; i++) { + position.set(Position.PREFIX_IO + i, parameters[i]); + } + } + if (deviceSession != null) { return position; } else { diff --git a/test/org/traccar/protocol/T55ProtocolDecoderTest.java b/test/org/traccar/protocol/T55ProtocolDecoderTest.java index 4cc5f549a..83f60f5b4 100644 --- a/test/org/traccar/protocol/T55ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/T55ProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class T55ProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, text( "358244017671308")); + verifyPosition(decoder, text( + "$GPRMC,073446.000,A,1255.5125,N,07738.2948,E,0.00,0.53,080316,D*71,11,865733027593268,1,090,086,123,456,789,987,12345")); + verifyNotNull(decoder, text( "$GPRMC,161223.000,A,2517.0545,S,05739.1788,W,0.0,0.0,011196,,,A*61")); -- cgit v1.2.3