From a418adedfc17642dda161dc373b8fc57ab1dbbdf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 31 Aug 2016 06:27:07 +1200 Subject: Handle Bofan photo response --- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/org/traccar/protocol/Pt502ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index 3edada78a..7dc4fbe5e 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -81,13 +81,6 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { String sentence = (String) msg; - if (sentence.startsWith("$PHO")) { - if (channel != null) { - channel.write("#PHD0," + sentence.substring(4)); - } - return null; - } - Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; @@ -96,7 +89,15 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(); position.setProtocol(getProtocolName()); - position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); + String type = parser.next(); + + if (type.startsWith("PHO")) { + if (channel != null) { + channel.write("#PHD0," + type.substring(3) + "\r\n"); + } + } + + position.set(Position.KEY_ALARM, decodeAlarm(type)); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { -- cgit v1.2.3