From aa59b968c7d6a89b8e6285647ab2e6e62f02cf7f Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Mon, 27 Dec 2021 20:48:47 -0600 Subject: Revert "Merge branch 'master' into suntech-fixes" This reverts commit f03b999d6d17e53c1c1e1aa2f9271d03f12f2264, reversing changes made to 3a528ddc88f72f39ff9566cf5e0f54938b1584ef. --- .../org/traccar/protocol/TopinProtocolDecoder.java | 50 ++++++---------------- 1 file changed, 14 insertions(+), 36 deletions(-) (limited to 'src/main/java/org/traccar/protocol/TopinProtocolDecoder.java') diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java index 4fe261aa4..87db95946 100644 --- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java @@ -50,11 +50,7 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_STATUS = 0x13; public static final int MSG_WIFI_OFFLINE = 0x17; public static final int MSG_TIME_UPDATE = 0x30; - public static final int MSG_SOS_NUMBER = 0x41; public static final int MSG_WIFI = 0x69; - public static final int MSG_VIBRATION_ON = 0x92; - public static final int MSG_VIBRATION_OFF = 0x93; - public static final int MSG_VIBRATION = 0x94; private void sendResponse(Channel channel, int length, int type, ByteBuf content) { if (channel != null) { @@ -93,19 +89,6 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { return negative ? -result : result; } - private String decodeAlarm(int alarms) { - if (BitUtil.check(alarms, 0)) { - return Position.ALARM_VIBRATION; - } - if (BitUtil.check(alarms, 1)) { - return Position.ALARM_OVERSPEED; - } - if (BitUtil.check(alarms, 4)) { - return Position.ALARM_LOW_POWER; - } - return null; - } - @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -171,7 +154,17 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { if (buf.readableBytes() >= 5) { position.setAltitude(buf.readShort()); - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + + 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(); @@ -193,12 +186,10 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, null); - ByteBuf content = buf.retainedSlice(buf.readerIndex(), buf.readableBytes() - 2); - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); buf.readUnsignedByte(); // timezone - buf.readUnsignedByte(); // interval + int interval = buf.readUnsignedByte(); if (buf.readableBytes() >= 1 + 2) { position.set(Position.KEY_RSSI, buf.readUnsignedByte()); } @@ -212,6 +203,8 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_HEART_RATE, buf.readUnsignedByte()); } + ByteBuf content = Unpooled.buffer(); + content.writeByte(interval); sendResponse(channel, length, type, content); return position; @@ -249,10 +242,6 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedShort(), buf.readUnsignedByte())); } - if (buf.readableBytes() > 2) { - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); - } - position.setNetwork(network); ByteBuf content = Unpooled.buffer(); @@ -261,17 +250,6 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { return position; - } else if (type == MSG_VIBRATION) { - - Position position = new Position(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - - getLastLocation(position, null); - - position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION); - - return position; - } return null; -- cgit v1.2.3