aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-04-21 16:36:23 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-04-21 16:36:23 -0700
commitaa27adb6a4765d051b03f0a37ef1e61547d50bf3 (patch)
tree5bd829dcdbb97d490a3acceba1578c4cfdab8ce5 /src/main/java
parent88bf0a165493bb7e554e7fa12d4520a01ba3ca87 (diff)
downloadtraccar-server-aa27adb6a4765d051b03f0a37ef1e61547d50bf3.tar.gz
traccar-server-aa27adb6a4765d051b03f0a37ef1e61547d50bf3.tar.bz2
traccar-server-aa27adb6a4765d051b03f0a37ef1e61547d50bf3.zip
Decode additional data
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/PebbellProtocolDecoder.java60
1 files changed, 60 insertions, 0 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;
}