diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-07-20 18:07:10 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-07-20 18:07:10 -0700 |
commit | 1bafb567e4a2122acf06540d11f2889ca9b473ad (patch) | |
tree | 0a5862b62ffd0b5008e2bc09d10a93916ceddf3b /src/main/java/org/traccar/protocol | |
parent | 51fe2fc02801e9cac455a0834b4a4510a33a1739 (diff) | |
download | trackermap-server-1bafb567e4a2122acf06540d11f2889ca9b473ad.tar.gz trackermap-server-1bafb567e4a2122acf06540d11f2889ca9b473ad.tar.bz2 trackermap-server-1bafb567e4a2122acf06540d11f2889ca9b473ad.zip |
Support AY-GPS protocol
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/UproProtocolDecoder.java | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/UproProtocolDecoder.java b/src/main/java/org/traccar/protocol/UproProtocolDecoder.java index dc7a9200d..0e328c920 100644 --- a/src/main/java/org/traccar/protocol/UproProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/UproProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2019 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. @@ -89,6 +89,13 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { } } + private String decodeAlarm(int alarm) { + if (BitUtil.check(alarm, 2)) { + return Position.ALARM_TAMPERING; + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -160,9 +167,25 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { position.setSpeed( Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)) * 0.1); break; + case 'G': + position.setAltitude( + Integer.parseInt(data.readSlice(6).toString(StandardCharsets.US_ASCII)) * 0.1); + break; case 'K': position.set("statusExtended", data.toString(StandardCharsets.US_ASCII)); break; + case 'M': + position.set(Position.KEY_BATTERY_LEVEL, + Integer.parseInt(data.readSlice(3).toString(StandardCharsets.US_ASCII)) * 0.1); + break; + case 'N': + position.set(Position.KEY_RSSI, + Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII))); + break; + case 'O': + position.set(Position.KEY_SATELLITES, + Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII))); + break; case 'P': if (data.readableBytes() >= 16) { position.setNetwork(new Network(CellTower.from( @@ -196,17 +219,49 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)) * 0.1); break; + case 'W': + position.set(Position.KEY_ALARM, + decodeAlarm(Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII)))); + break; + case 'X': + Network network = new Network(); + int mcc = 0, mnc = 0; + String[] cells = data.toString(StandardCharsets.US_ASCII).split(";"); + if (!cells[0].startsWith("(")) { + for (int i = 0; i < cells.length; i++) { + String[] values = cells[i].split(","); + int index = 0; + if (i == 0) { + mcc = Integer.parseInt(values[index++]); + mnc = Integer.parseInt(values[index++]); + } + network.addCellTower(CellTower.from( + mcc, mnc, + Integer.parseInt(values[index++]), + Integer.parseInt(values[index++]), + Integer.parseInt(values[index]))); + } + position.setNetwork(network); + } + break; + case 'Y': + position.set(Position.KEY_POWER, + Integer.parseInt(data.readSlice(5).toString(StandardCharsets.US_ASCII)) * 0.001); + break; default: break; } } - if (position.getLatitude() != 0 && position.getLongitude() != 0) { - return position; + if (position.getLatitude() == 0 || position.getLongitude() == 0) { + if (position.getAttributes().isEmpty()) { + return null; + } + getLastLocation(position, position.getDeviceTime()); } - return null; + return position; } } |