diff options
-rw-r--r-- | src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | 35 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java | 6 |
2 files changed, 25 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java index 4746f7dd5..e8d77f1a8 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2020 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. @@ -81,8 +81,8 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .number("([01]{2}),") // outputs .groupBegin() .number("d+,") // index - .number("(d+.d+),") // adc1 - .number("(d+.d+),") // adc2 + .number("(d+.?d*),") // adc1 + .number("(d+.?d*),") // adc2 .groupEnd("?") .groupEnd("?") .or() @@ -195,22 +195,25 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { position.set("emergency", parser.nextInt() > 0); - String[] cells = parser.next().split(","); - int mcc = Integer.parseInt(cells[1]); - int mnc = Integer.parseInt(cells[2]); - int lac = Integer.parseInt(cells[3], 16); - int cid = Integer.parseInt(cells[4], 16); - Network network = new Network(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(cells[0]))); - if (!cells[5].startsWith("(")) { - for (int i = 0; i < 4; i++) { - lac = Integer.parseInt(cells[5 + 3 * i + 1], 16); - cid = Integer.parseInt(cells[5 + 3 * i + 2], 16); - if (lac > 0 && cid > 0) { - network.addCellTower(CellTower.from(mcc, mnc, lac, cid)); + String cellsString = parser.next(); + if (!cellsString.contains("x")) { + String[] cells = cellsString.split(","); + int mcc = Integer.parseInt(cells[1]); + int mnc = Integer.parseInt(cells[2]); + int lac = Integer.parseInt(cells[3], 16); + int cid = Integer.parseInt(cells[4], 16); + Network network = new Network(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(cells[0]))); + if (!cells[5].startsWith("(")) { + for (int i = 0; i < 4; i++) { + lac = Integer.parseInt(cells[5 + 3 * i + 1], 16); + cid = Integer.parseInt(cells[5 + 3 * i + 2], 16); + if (lac > 0 && cid > 0) { + network.addCellTower(CellTower.from(mcc, mnc, lac, cid)); + } } } + position.setNetwork(network); } - position.setNetwork(network); String input = parser.next(); if (input.charAt(input.length() - 1) == '2') { diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java index dedb30242..8733e9034 100644 --- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java @@ -15,6 +15,12 @@ public class ItsProtocolDecoderTest extends ProtocolTest { "$LGN,,869867037009679,3.2AIH,9.99546000,N,76.35886167,E")); verifyPosition(decoder, text( + "$NRM,ROADRPA,3.5AIS,NR,01,L,869867036940288,,1,04012020,094901,23.18731933,N,77.45079633,E,0.0,0.00,13,545.6,1.10,0.60,Idea Cellular Ltd,0,1,13.2,4.1,0,C,31,404,78,62E1,5799,29,62E1,579B,23,62E1,52EB,22,62E1,52EA,21,62E1,2FF1,0100,00,0,0,001926,8252.226,-,-,-,-,5_5_5_5_0,171B56E1*")); + + verifyPosition(decoder, text( + "$NMP,TRAXSMART,1.7.7,NR,1,L,862818043908237,0000,0,04012020,104208,28.6183987,N,77.3888474,E,001.0,000.00,00,000.0,0.0,0.0,Idea P,0,1,13.3,4.0,0,C,22,404,30,0089,2793,x,x,x,x,x,x,x,x,x,x,x,x,0002,00,000591,00.4,00.4,0,(0,0,0)*FC")); + + verifyPosition(decoder, text( "$NRM,,3.2AIH,NR,01,L,869867037003854,,1,02122019,074801,9.99553167,N,76.35911000,E,0.0,125.73,18,103.7,0.10,0.10,CellOne Kerala,0,1,13.1,4.2,0,C,19,404,72,08FE,0940,13,08FE,093E,11,08FE,7DA7,07,08FE,093F,07,08FE,7DA6,0100,00,0,0,003372,6897.214,,,,,5_5_3_5_0,B74BBD72*")); verifyPosition(decoder, text( |