From cee735f6934c18b44b5529787224344aa3412ffa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 13 Mar 2015 12:08:16 +1300 Subject: Add Wialon extended info (fix #1113) --- .../traccar/protocol/WialonProtocolDecoder.java | 42 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 5b8d9a24e..6c4c0e8db 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -49,9 +49,16 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { "([EW]);" + "(\\d+\\.?\\d*)?;" + // Speed "(\\d+\\.?\\d*)?;" + // Course - "(?:(\\d+\\.?\\d*)|NA);" + // Altitude - "(?:(\\d+)|NA)" + // Satellites - ".*"); // Full format + "(?:NA|(\\d+\\.?\\d*));" + // Altitude + "(?:NA|(\\d+))" + // Satellites + "(?:;" + + "(?:NA|(\\d+\\.?\\d*));" + // hdop + "(?:NA|(\\d+));" + // inputs + "(?:NA|(\\d+));" + // outputs + "(?:NA|([^;]*));" + // adc + "(?:NA|([^;]*));" + // ibutton + "(?:NA|(.*))" + // params + ")?"); private void sendResponse(Channel channel, String prefix, Integer number) { if (channel != null) { @@ -135,6 +142,35 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { position.setValid(false); } + // Other + extendedInfo.set("hdop", parser.group(index++)); + extendedInfo.set("inputs", parser.group(index++)); + extendedInfo.set("outputs", parser.group(index++)); + + // ADC + String adc = parser.group(index++); + if (adc != null) { + String[] values = adc.split(","); + for (int i = 0; i < values.length; i++) { + extendedInfo.set("adc" + (i + 1), values[i]); + } + } + + // iButton + extendedInfo.set("ibutton", parser.group(index++)); + + // Params + String params = parser.group(index); + if (params != null) { + String[] values = params.split(","); + for (String param : values) { + Matcher paramParser = Pattern.compile( "(.*):[1-3]:(.*)").matcher(param); + if (paramParser.matches()) { + extendedInfo.set(paramParser.group(1).toLowerCase(), paramParser.group(2)); + } + } + } + // Extended info position.setExtendedInfo(extendedInfo.toString()); -- cgit v1.2.3