diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-01-24 23:08:16 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-01-24 23:08:16 -0800 |
commit | 08c744db5dd60956827c6002841c30067ae55744 (patch) | |
tree | 3b052dbaeeb9e9fd4b5db30fe60ced6f23af2ad2 | |
parent | 6ff2508c0019c443da7b943f2f71eb9221c47f55 (diff) | |
download | trackermap-server-08c744db5dd60956827c6002841c30067ae55744.tar.gz trackermap-server-08c744db5dd60956827c6002841c30067ae55744.tar.bz2 trackermap-server-08c744db5dd60956827c6002841c30067ae55744.zip |
Handle Vodofo protocol differences
-rw-r--r-- | src/org/traccar/protocol/UproProtocolDecoder.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/UproProtocolDecoderTest.java | 3 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java index c5b72ea0a..dc7a9200d 100644 --- a/src/org/traccar/protocol/UproProtocolDecoder.java +++ b/src/org/traccar/protocol/UproProtocolDecoder.java @@ -164,11 +164,13 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { position.set("statusExtended", data.toString(StandardCharsets.US_ASCII)); break; case 'P': - position.setNetwork(new Network(CellTower.from( - Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)), - Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)), - Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16), - Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16)))); + if (data.readableBytes() >= 16) { + position.setNetwork(new Network(CellTower.from( + Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)), + Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)), + Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16), + Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16)))); + } break; case 'Q': position.set("obdPid", ByteBufUtil.hexDump(data)); diff --git a/test/org/traccar/protocol/UproProtocolDecoderTest.java b/test/org/traccar/protocol/UproProtocolDecoderTest.java index ff7ead961..dbbe4591f 100644 --- a/test/org/traccar/protocol/UproProtocolDecoderTest.java +++ b/test/org/traccar/protocol/UproProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class UproProtocolDecoderTest extends ProtocolTest { UproProtocolDecoder decoder = new UproProtocolDecoder(null); verifyPosition(decoder, buffer( + "*HQ200861810538000002,BA&A0206033302618209658563620115180119&B0100000040&C6328680=&F0039&R2710&V0036&T09&K50000&N04&P0200#")); + + verifyPosition(decoder, buffer( "*HQ200999999,AB1&A1656512233362911356523660000230618&B0100060010&C00000<6<&F0000&R2405&V0109&W0000003E&K00100&T65&X(k89860045191536000374)#")); verifyPosition(decoder, buffer( |