From 05ad09e2aa9c16fff17476a61d24cd953db82197 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 6 Jun 2017 23:12:52 -0700 Subject: Add ignition support for Xexun --- src/org/traccar/protocol/XexunProtocolDecoder.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index fb8107d3a..20804bbb4 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.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. @@ -66,16 +66,25 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); - private String decodeAlarm(String value) { + private String decodeStatus(Position position, String value) { if (value != null) { - switch (value) { + switch (value.toLowerCase()) { + case "acc on": + position.set(Position.KEY_IGNITION, true); + break; + case "acc off": + position.set(Position.KEY_IGNITION, false); + break; case "help me!": - return Position.ALARM_SOS; + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + break; case "low battery": - return Position.ALARM_LOW_BATTERY; + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; case "move!": case "moved!": - return Position.ALARM_MOVEMENT; + position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT); + break; default: break; } @@ -127,7 +136,8 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); position.set("signal", parser.next()); - position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); + + decodeStatus(position, parser.next()); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { -- cgit v1.2.3