aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/handler/GeolocationHandler.java1
-rw-r--r--src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java32
-rw-r--r--src/main/java/org/traccar/protocol/PluginProtocolDecoder.java4
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java2
-rw-r--r--src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java3
-rw-r--r--src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java3
-rw-r--r--src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java3
-rw-r--r--swagger.json2
8 files changed, 41 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/handler/GeolocationHandler.java b/src/main/java/org/traccar/handler/GeolocationHandler.java
index c7b39e491..0e78322c8 100644
--- a/src/main/java/org/traccar/handler/GeolocationHandler.java
+++ b/src/main/java/org/traccar/handler/GeolocationHandler.java
@@ -65,7 +65,6 @@ public class GeolocationHandler extends ChannelInboundHandlerAdapter {
position.setAltitude(0);
position.setSpeed(0);
position.setCourse(0);
- position.set(Position.KEY_RSSI, 0);
ctx.fireChannelRead(position);
}
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
index 8a937a194..9449e2d5c 100644
--- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -83,7 +83,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
int subtype = buf.readUnsignedShort();
int length = buf.readUnsignedShort() - 4;
if (subtype == 0x0003) {
- String imei = buf.readSlice(length).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readCharSequence(length, StandardCharsets.US_ASCII).toString();
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
ByteBuf content = Unpooled.buffer();
@@ -117,7 +117,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, BitUtil.check(status, 14));
position.set(Position.KEY_EVENT, buf.readUnsignedShort());
- String time = buf.readSlice(12).toString(StandardCharsets.US_ASCII);
+ String time = buf.readCharSequence(12, StandardCharsets.US_ASCII).toString();
DateBuilder dateBuilder = new DateBuilder()
.setYear(Integer.parseInt(time.substring(0, 2)))
@@ -138,9 +138,33 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedShort() * 1000);
while (buf.readableBytes() > 4) {
- buf.readUnsignedShort(); // subtype
+ int subtype = buf.readUnsignedShort();
int length = buf.readUnsignedShort() - 4;
- buf.skipBytes(length);
+ switch (subtype) {
+ case 0x0001:
+ position.set(Position.KEY_COOLANT_TEMP, buf.readUnsignedByte() - 40);
+ position.set(Position.KEY_RPM, buf.readUnsignedShort());
+ position.set("averageSpeed", buf.readUnsignedByte());
+ buf.readUnsignedShort(); // interval fuel consumption
+ position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedShort());
+ position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte() * 0.4);
+ buf.readUnsignedInt(); // trip id
+ break;
+ case 0x0005:
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
+ position.set(Position.KEY_HDOP, buf.readUnsignedByte());
+ buf.readUnsignedInt(); // run time
+ break;
+ case 0x0009:
+ position.set(
+ Position.KEY_VIN, buf.readCharSequence(length, StandardCharsets.US_ASCII).toString());
+ break;
+ default:
+ buf.skipBytes(length);
+ break;
+ }
}
sendResponse(channel, MSG_POSITION_RSP, index, null);
diff --git a/src/main/java/org/traccar/protocol/PluginProtocolDecoder.java b/src/main/java/org/traccar/protocol/PluginProtocolDecoder.java
index 3f87a774b..106889ee0 100644
--- a/src/main/java/org/traccar/protocol/PluginProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PluginProtocolDecoder.java
@@ -34,8 +34,8 @@ public class PluginProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
- .expression("[^0-9]*")
- .number("(d+),") // device id
+ .expression("[^0-9,]*,?")
+ .number("([^,]+),") // device id
.number("(dddd)(dd)(dd)") // date (yyyymmdd)
.number("(dd)(dd)(dd),") // time (hhmmss)
.number("(-?d+.d+),") // longitude
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
index 903c37a8f..c469be442 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -421,7 +421,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
String type = values[index++];
- if (!type.equals("STT")) {
+ if (!type.equals("STT") && !type.equals("ALT")) {
return null;
}
diff --git a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
index 319d34e4c..6033bc744 100644
--- a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
@@ -17,6 +17,9 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest {
"c000000077aa0200000000000e000100143347315f48312e315f56312e30372e54000300133335353835353035303434303635380004000b3531323030303000050005010006000400070004000800050000090018383936313032353431343533333239313833360d000a000f796573696e7465726e6574c0"));
verifyPosition(decoder, binary(
+ "c000000060aa000000000000fa8000000031393037303431363434323700e9900affd61c1b00000000003a000000010015ffffff0000000000000004c2ffffffffff0005000a0d080000ca6a000900155741555a5a5a344730454e313133373233c0"));
+
+ verifyPosition(decoder, binary(
"c00000004baa0000000000000f8000000031363130323030373236333600e6d4f9ffcc78c700000022003600000001001500000000000000000000059bffffffffff0005000a040300000253c0"));
verifyPosition(decoder, binary(
diff --git a/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java
index df102a066..582ed9a5a 100644
--- a/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class PluginProtocolDecoderTest extends ProtocolTest {
PluginProtocolDecoder decoder = new PluginProtocolDecoder(null);
verifyPosition(decoder, text(
+ "$$STATUS,fleet40,20190704122622,26.259431,-29.027889,0,9,0,-1,2,19719,805315969,0,0,0"));
+
+ verifyPosition(decoder, text(
"$$ALARM801739,20190612121950,28.254067,-25.860494,0,0,0,-1,2,2,12595331,0,0,0,+,22,0,0,0,0,0,,0,0"));
verifyPosition(decoder, text(
diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
index ac46b6356..304bc0fed 100644
--- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -58,6 +58,9 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(null);
+ verifyPosition(decoder, text(
+ "ALT;0520000295;3FFFFF;52;1.0.2;0;20190703;01:03:24;00004697;732;101;0002;59;+4.682583;-74.128142;0.00;0.00;6;1;00000000;00000000;9;1;;4.1;12.92;103188"));
+
verifyAttribute(decoder, text(
"ST300UEX;109003241;08;1026;20190425;17:36:04;04402;+04.722553;-074.052583;000.020;000.00;10;1;0;12.04;010000;51;CabAVL\"CabMensaje,0,58.5,-1.0,,,FinMensaje\"FinAVL\r\n;B1;0000000000;4.1;1"),
"fuel1", 58.5);
diff --git a/swagger.json b/swagger.json
index 50231913e..41e54df17 100644
--- a/swagger.json
+++ b/swagger.json
@@ -1746,7 +1746,7 @@
"type": "integer"
},
"calendarId": {
- "description": "Geofence Id, can be second parameter only and only in combination with userId",
+ "description": "Calendar Id, can be second parameter only and only in combination with userId",
"type": "integer"
},
"attributeId": {