diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-02 12:19:27 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-02 12:19:27 -0700 |
commit | 86822bb4b96637a9db32c3299dfee5614cfceda8 (patch) | |
tree | 770652a6d40751d7607c74d2aa721e3fc7c47b8f /src | |
parent | aa421b17d86b70f80f84c4d7c086a1e56bb80059 (diff) | |
download | trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.tar.gz trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.tar.bz2 trackermap-server-86822bb4b96637a9db32c3299dfee5614cfceda8.zip |
Implement GYPSEE protocol
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/ItsProtocolDecoder.java | 29 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java | 3 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java index 8c1b9b480..d76d9c92e 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java @@ -44,7 +44,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]+,") // vendor .expression("[^,]+,") // firmware version .expression("(..),") // status - .number("(d+),") // event + .number("(d+),").optional() // event .expression("([LH]),") // history .or() .expression("([^,]+),") // type @@ -56,7 +56,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]*,") // vehicle registration .number("([01]),").optional() // valid .groupEnd() - .number("(dd),?(dd),?(dddd),") // date (ddmmyyyy) + .number("(dd),?(dd),?(d{2,4}),") // date (ddmmyyyy) .number("(dd),?(dd),?(dd),") // time (hhmmss) .expression("([01AV]),").optional() // valid .number("(d+.d+),([NS]),") // latitude @@ -69,16 +69,15 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // altitude .number("d+.?d*,") // pdop .number("d+.?d*,") // hdop - .expression("[^,]*,") + .expression("[^,]*,") // operator .number("([01]),") // ignition .number("([01]),") // charging .number("(d+.?d*),") // power .number("(d+.?d*),") // battery .number("([01]),") // emergency .expression("[CO]?,") // tamper - .number("((?:x+,){5}") // main cell - .number("(?:-?x+,){12})") // other cells - .number("([01]{4}),") // inputs + .expression("(.*),") // cells + .number("([012]{4}),") // inputs .number("([01]{2}),") // outputs .groupBegin() .number("d+,") // index @@ -202,16 +201,22 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { 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]))); - 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)); + 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.set(Position.KEY_INPUT, parser.nextBinInt()); + String input = parser.next(); + if (input.charAt(input.length() - 1) == '2') { + input = input.substring(0, input.length() - 1) + '0'; + } + position.set(Position.KEY_INPUT, Integer.parseInt(input, 2)); position.set(Position.KEY_OUTPUT, parser.nextBinInt()); } diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java index f4f095518..eac8cd9e2 100644 --- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java @@ -12,6 +12,9 @@ public class ItsProtocolDecoderTest extends ProtocolTest { ItsProtocolDecoder decoder = new ItsProtocolDecoder(null); verifyPosition(decoder, text( + "$NMP,GPSBOX,1.6.8,NR,H,868997035844834,0000,1,220519,035419,28.6291409,N,77.3928299,E,015.2,157.40,07,197.86,2.1,1.0,airtel,1,1,13.3,4.1,0,O,31,404,10,0099,79b4,(-57,0099,334c,x,x,x,x,x,x,x,x,x),0012,00,000348,2,08.4,00.3,(0,0,0),CD*")); + + verifyPosition(decoder, text( "$RLP,N.A,2.0.2,NR,01,L,869867030181814,N.A,28022019,180155,1,28.688226,N,076.993570,E,0.0,80.26,17,201.0,0.89,0.60,VODAFONE I,0,1,25.0,4.20,0,C,14,404,11,415,F34A,51f7,415,13,840b,415,8,a3f7,0c2,5,ef77,415,5,0001,00,17888,47,*")); verifyAttribute(decoder, text( |