diff options
-rw-r--r-- | src/org/traccar/protocol/Gps103Protocol.java | 1 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolEncoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/MiniFinderProtocolDecoder.java | 4 | ||||
-rw-r--r-- | swagger.json | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gl200ProtocolDecoderTest.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gps103ProtocolEncoderTest.java | 16 |
6 files changed, 29 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java index e3beb34e5..a4d563bfc 100644 --- a/src/org/traccar/protocol/Gps103Protocol.java +++ b/src/org/traccar/protocol/Gps103Protocol.java @@ -32,6 +32,7 @@ public class Gps103Protocol extends BaseProtocol { public Gps103Protocol() { super("gps103"); setSupportedCommands( + Command.TYPE_CUSTOM, Command.TYPE_POSITION_SINGLE, Command.TYPE_POSITION_PERIODIC, Command.TYPE_POSITION_STOP, diff --git a/src/org/traccar/protocol/Gps103ProtocolEncoder.java b/src/org/traccar/protocol/Gps103ProtocolEncoder.java index afe87cf8c..36801b401 100644 --- a/src/org/traccar/protocol/Gps103ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolEncoder.java @@ -42,6 +42,8 @@ public class Gps103ProtocolEncoder extends StringProtocolEncoder implements Stri protected Object encodeCommand(Command command) { switch (command.getType()) { + case Command.TYPE_CUSTOM: + return formatCommand(command, "**,imei:{%s},{%s}", Command.KEY_UNIQUE_ID, Command.KEY_DATA); case Command.TYPE_POSITION_STOP: return formatCommand(command, "**,imei:{%s},A", Command.KEY_UNIQUE_ID); case Command.TYPE_POSITION_SINGLE: diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 1b49bccb0..da03dc8bf 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -112,6 +112,9 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(flags, 8)) { position.set(Position.KEY_ALARM, Position.ALARM_FALL_DOWN); } + if (BitUtil.check(flags, 9) || BitUtil.check(flags, 10) || BitUtil.check(flags, 11)) { + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE); + } if (BitUtil.check(flags, 12)) { position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); } @@ -120,6 +123,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_GSM, BitUtil.between(flags, 16, 20)); + position.set(Position.KEY_CHARGE, BitUtil.check(flags, 22)); position.setAltitude(parser.nextDouble()); diff --git a/swagger.json b/swagger.json index f00f7dfe2..bdf23c96a 100644 --- a/swagger.json +++ b/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "3.7", + "version": "3.8", "title": "traccar" }, "host": "traccar.org", diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java index fa8373898..c493d5172 100644 --- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest { Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol()); verifyAttributes(decoder, text( + "+RESP:GTSTR,400201,862365030034957,GL500,0,0,2,23.1,5,2,0.2,0,36.0,0.623089,51.582744,20161129174625,0234,0015,03C3,3550,,,,20161129174625,0026$")); + + verifyNothing(decoder, text( + "+RESP:GTSTR,400201,862365030034957,GL500,0,1,2,21.8,100,0,,,,,,,0234,0015,03C3,3550,,,,20161129174009,0023$")); + + verifyAttributes(decoder, text( "+RESP:GTINF,210102,A10000499AEF9B,,41,,0,0,0,15.0,9,3.87,0,1,1,0,0,20161101140211,72,,,,,20161101140211,00A3$")); verifyAttributes(decoder, text( diff --git a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java index f8652bc9a..54c520c21 100644 --- a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java @@ -8,7 +8,7 @@ import org.traccar.model.Command; public class Gps103ProtocolEncoderTest extends ProtocolTest { @Test - public void testEncode() throws Exception { + public void testEncodePositionPeriodic() throws Exception { Gps103ProtocolEncoder encoder = new Gps103ProtocolEncoder(); @@ -21,4 +21,18 @@ public class Gps103ProtocolEncoderTest extends ProtocolTest { } + @Test + public void testEncodeCustom() throws Exception { + + Gps103ProtocolEncoder encoder = new Gps103ProtocolEncoder(); + + Command command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_CUSTOM); + command.set(Command.KEY_DATA, "H,080"); + + Assert.assertEquals("**,imei:123456789012345,H,080", encoder.encodeCommand(command)); + + } + } |