aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java60
-rw-r--r--src/test/java/org/traccar/protocol/PebbellProtocolDecoderTest.java4
2 files changed, 62 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java b/src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java
index acc4fedad..7271c60d8 100644
--- a/src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java
@@ -16,12 +16,17 @@
package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
import org.traccar.model.Position;
+import org.traccar.model.WifiAccessPoint;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
@@ -34,6 +39,28 @@ public class PebbellProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_DATA = 0x01;
+ private String decodeAlarm(int code) {
+ if (BitUtil.check(code, 0)) {
+ return Position.ALARM_LOW_BATTERY;
+ }
+ if (BitUtil.check(code, 1)) {
+ return Position.ALARM_OVERSPEED;
+ }
+ if (BitUtil.check(code, 2)) {
+ return Position.ALARM_FALL_DOWN;
+ }
+ if (BitUtil.check(code, 8)) {
+ return Position.ALARM_POWER_OFF;
+ }
+ if (BitUtil.check(code, 9)) {
+ return Position.ALARM_POWER_ON;
+ }
+ if (BitUtil.check(code, 12)) {
+ return Position.ALARM_SOS;
+ }
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -63,6 +90,9 @@ public class PebbellProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
break;
+ case 0x02:
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readIntLE()));
+ break;
case 0x20:
position.setLatitude(buf.readIntLE() * 0.0000001);
position.setLongitude(buf.readIntLE() * 0.0000001);
@@ -73,6 +103,36 @@ public class PebbellProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
break;
+ case 0x21:
+ int mcc = buf.readUnsignedShortLE();
+ int mnc = buf.readUnsignedByte();
+ if (position.getNetwork() == null) {
+ position.setNetwork(new Network());
+ }
+ while (buf.readerIndex() < endIndex) {
+ int rssi = buf.readByte();
+ position.getNetwork().addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShortLE(), buf.readUnsignedShortLE(), rssi));
+ }
+ break;
+ case 0x22:
+ if (position.getNetwork() == null) {
+ position.setNetwork(new Network());
+ }
+ while (buf.readerIndex() < endIndex) {
+ int rssi = buf.readByte();
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
+ position.getNetwork().addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), rssi));
+ }
+ break;
+ case 0x40:
+ buf.readUnsignedIntLE(); // timestamp
+ int heartRate = buf.readUnsignedByte();
+ if (heartRate > 1) {
+ position.set(Position.KEY_HEART_RATE, heartRate);
+ }
+ break;
default:
break;
}
diff --git a/src/test/java/org/traccar/protocol/PebbellProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PebbellProtocolDecoderTest.java
index d6a4d88d1..a6555dd76 100644
--- a/src/test/java/org/traccar/protocol/PebbellProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/PebbellProtocolDecoderTest.java
@@ -10,10 +10,10 @@ public class PebbellProtocolDecoderTest extends ProtocolTest {
PebbellProtocolDecoder decoder = new PebbellProtocolDecoder(null);
- verifyNotNull(decoder, binary(
+ verifyAttributes(decoder, binary(
"ab1845005d39370301100133353836383830303030303338303209245b92b55c84004b610502001000002221ca00050b4a005cc30f4a0056c80f4a003ba90e4a0055c8074a005dc3034a0057c8"));
- verifyNotNull(decoder, binary(
+ verifyAttributes(decoder, binary(
"ab185c001db78b03011001333538363838303030303033383032092448bd8a5c82003b130502010000003922ca923bad10f794bd30b5c2cb0595b2944a0c49a4f9b6a4b1e9991e79ba0026bb78c08fb4581faae7ee3fb0e091f5778e96b074a78ed46528"));
verifyNotNull(decoder, binary(