Skip to content

Commit

Permalink
Handle zero MCC and MNC
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Aug 20, 2018
1 parent 73ca03b commit 98fd364
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/org/traccar/protocol/AtrackProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ private void readTextCustomData(Position position, String data, String form) {
cellTower.setLocationAreaCode(Integer.parseInt(values[i]));
break;
case "CN":
cellTower.setMobileCountryCode(Integer.parseInt(values[i].substring(0, 3)));
cellTower.setMobileNetworkCode(Integer.parseInt(values[i].substring(3)));
if (values[i].length() > 3) {
cellTower.setMobileCountryCode(Integer.parseInt(values[i].substring(0, 3)));
cellTower.setMobileNetworkCode(Integer.parseInt(values[i].substring(3)));
}
break;
case "PC":
position.set(Position.PREFIX_COUNT + 1, Integer.parseInt(values[i]));
Expand Down
7 changes: 7 additions & 0 deletions test/org/traccar/protocol/AtrackProtocolDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public void testDecode() throws Exception {

decoder.setCustom(true);

verifyPositions(decoder, buffer(
"@P,0EBB,687,1917,357298070426498,1534718280,1534718279,1534739774,-88643875,44210148,270,2,57128,6,1,130,0,0,,2000,2000,,%CI%GQ%GS%CN%CE%MV%SA,5,10,310260,7888593,137,16\r\n",
"1534718283,1534718283,1534739774,-88645243,44210145,269,2,57129,6,1,129,0,0,,2000,2000,,%CI%GQ%GS%CN%CE%MV%SA,5,10,310260,7888593,137,16\r\n",
"1534718286,1534718285,1534739774,-88646581,44210136,269,2,57130,6,1,127,0,0,,2000,2000,,%CI%GQ%GS%CN%CE%MV%SA,99,10,0,0,137,16\r\n",
"1534718289,1534718288,1534739774,-88647911,44210123,269,2,57131,6,1,127,0,0,,2000,2000,,%CI%GQ%GS%CN%CE%MV%SA,99,10,0,0,137,16\r\n",
"1534718292,1534718291,1534739774,-88649229,44210111,269,2,57132,6,1,124,0,0,,2000,2000,,%CI%GQ%GS%CN%CE%MV%SA,99,10,0,0,136,16\r\n"));

verifyPositions(decoder, binary(
"4050b63b02c401af000144a77a21281d5b79d8ef5b79d8ef5b79d8f0fab84831029f35580056020003144d00080100130000000007d007d00025434925434525434e25475125475325464c254d4c25564e25504425464325454c254554254344254154254d46254d5625425625434d25445425474c25474e254756254c43254d4525524c25525025534125534d255452254941254d5000000000000004bbf41f0900003254314b5233324532384337303631383500000000000053005f3839303132363038383132313532343737353900000000fd078e0085002900011a2e3da1882700687474703a2f2f6d6170732e676f6f676c652e636f6d2f6d6170733f713d34332e3938383331322c2d38382e35383631383920000013ff4e04190023ff13041100a3ffdc0402009affde03fc00a4ffe3040c0093ffab03ee004dffbb04130012ff7a04180010ff6e04100037ff4d0402ffd8000c04140000000144a77a21281d0009470c00131b2b005b79d8f05b79d8f05b79d8f0fab8488e029f356f0043020003144d00080100170000000007d007d00025434925434525434e25475125475325464c254d4c25564e25504425464325454c254554254344254154254d46254d5625425625434d25445425474c25474e254756254c43254d4525524c25525025534125534d255452254941254d5000000000000004bbf41f0900003254314b5233324532384337303631383500000000000052005f3839303132363038383132313532343737353900000000fd09190085002900011a2e3da1882700687474703a2f2f6d6170732e676f6f676c652e636f6d2f6d6170733f713d34332e3938383333352c2d38382e35383630393820000013ff4e04190023ff1304110017ff0c0424000cff30041a00a4ffe3040c0093ffab03ee004dffbb04130012ff7a04180010ff6e04100037ff4d0402ffd8000c04140000000144a77a21281d0009470c00171c2b00"));

Expand Down

0 comments on commit 98fd364

Please sign in to comment.