From fb8fcb940ee0faedecff130554ae62971f5ccb85 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 27 Feb 2021 15:06:14 -0800 Subject: Update Topin protocol --- .../org/traccar/protocol/TopinProtocolDecoder.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java index 4042e348c..fe8de3710 100644 --- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2019 - 2021 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. @@ -24,6 +24,7 @@ import org.traccar.DeviceSession; import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BcdUtil; +import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.UnitsConverter; import org.traccar.model.CellTower; @@ -151,6 +152,21 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { Gt06ProtocolDecoder.decodeGps(position, buf, false, TimeZone.getTimeZone("UTC")); + if (buf.readableBytes() >= 5) { + position.setAltitude(buf.readShort()); + + int alarms = buf.readUnsignedByte(); + if (BitUtil.check(alarms, 0)) { + position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION); + } + if (BitUtil.check(alarms, 1)) { + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + } + if (BitUtil.check(alarms, 4)) { + position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER); + } + } + ByteBuf content = Unpooled.buffer(); content.writeBytes(time); sendResponse(channel, length, type, content); -- cgit v1.2.3