diff options
4 files changed, 33 insertions, 6 deletions
diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index 3e47ada70..a8e20c698 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -24,6 +24,7 @@ import org.traccar.database.IdentityManager; import org.traccar.helper.Checksum; import org.traccar.model.Device; import org.traccar.model.Position; +import org.traccar.model.Group; import javax.inject.Inject; import javax.ws.rs.client.Client; @@ -139,6 +140,18 @@ public class WebDataHandler extends BaseDataHandler { request = request.replace("{gprmc}", formatSentence(position)); } + if (request.contains("{group}")) { + String deviceGroupName = ""; + if (device.getGroupId() != 0) { + Group group = Context.getGroupsManager().getById(device.getGroupId()); + if (group != null) { + deviceGroupName = group.getName(); + } + } + + request = request.replace("{group}", URLEncoder.encode(deviceGroupName, StandardCharsets.UTF_8.name())); + } + return request; } diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index c0f485349..1fbae15ce 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -73,9 +73,11 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { .number(",(d+.?d*)?").optional() // altitude .number(",([01])?").optional() // ignition .number(",([01])?").optional() // door - .number(",(?:(d+.d+)%)?").optional() // fuel 1 - .number(",(?:(d+.d+)%)?").optional() // fuel 2 - .number("(-?d+)?") // temperature + .groupBegin() + .number(",(?:(d+.d+)%)?") // fuel 1 + .number(",(?:(d+.d+)%|d+)?") // fuel 2 + .groupEnd("?") + .number(",([-+]?d+)?") // temperature .groupEnd() .any() .compile(); @@ -193,7 +195,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } else if (alarm.equals("acc off")) { position.set(Position.KEY_IGNITION, false); } else if (alarm.startsWith("T:")) { - position.set(Position.PREFIX_TEMP + 1, alarm.substring(2)); + position.set(Position.PREFIX_TEMP + 1, Double.parseDouble(alarm.substring(2))); } else if (alarm.startsWith("oil ")) { position.set(Position.KEY_FUEL_LEVEL, Double.parseDouble(alarm.substring(4))); } else if (!position.getAttributes().containsKey(Position.KEY_ALARM) && !alarm.equals("tracker")) { diff --git a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index f6264b7e3..d68479097 100644 --- a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(null); + verifyPositions(decoder, buffer( + "+RESP:GTFRI,1A0900,860599000306845,G3-313,0,0,4,1,2.1,0,426.7,8.611466,47.681639,20181214134603,0228,0001,077F,4812,25.2,1,5.7,34,437.3,8.611600,47.681846,20181214134619,0228,0001,077F,4812,25.2,1,4.4,62,438.2,8.611893,47.681983,20181214134633,0228,0001,077F,4812,25.2,1,4.8,78,436.6,8.612236,47.682040,20181214134648,0228,0001,077F,4812,25.2,83,20181214134702,0654$")); + verifyPosition(decoder, buffer( "+RESP:GTCAN,270703,867162025056839,gv300w,0,1,E07FFFFF,,2,H9307659,368713.50,1291,90,91,,P82.40,,61,10.10,6.76,3.34,524.08,,,0000,,00,,,007FFFFF,,,,,,,,,,,,,,,,,,,,,0000,2,0,,,0,88.6,104,117.6,-116.886007,32.543697,20181031202959,0334,0020,5234,7FCC3D0,00,20181031203002,9F50$")); diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java index 7dc1d36f4..00e85f5e3 100644 --- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class Gps103ProtocolDecoderTest extends ProtocolTest { @@ -11,6 +12,13 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest { Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(null); verifyPosition(decoder, text( + "imei:868683026321020,T:+11,181217080050,,F,080047.000,A,3227.3057,N,11649.4754,W,0.00,0,,0,0,0.00%,,+11;")); + + verifyAttribute(decoder, text( + "imei:868683026321020,tracker,181217080106,,F,080102.000,A,3227.3057,N,11649.4754,W,0.00,0,,0,0,0.00%,0,+11;"), + Position.PREFIX_TEMP + 1, 11); + + verifyPosition(decoder, text( "imei:861359038609986,Equipo 1,---,------,----,214734,241018,26,1,-33.42317,-70.61930,067,229,0674,1.00,08,0,1,---,*")); verifyPosition(decoder, text( @@ -22,8 +30,9 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest { verifyAttributes(decoder, text( "imei:868683027758113,OBD,180905200218,,,,0,0,0.39%,70,9.41%,494,0.00,P0137,P0430,,;")); - verifyPosition(decoder, text( - "imei:353451044508750,001,0809231929,13554900601,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,30.1,65.43,1,0,10.5%,0.0%,28;")); + verifyAttribute(decoder, text( + "imei:353451044508750,001,0809231929,13554900601,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,30.1,65.43,1,0,10.5%,0.0%,28;"), + "fuel1", 10.5); verifyPosition(decoder, text( "imei:864180036029895,acc on,180508145653,,F,065645.000,A,4729.1497,N,01904.2342,E,0.00,0,,1,,0.00%,,;")); |