aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Xt2400ProtocolDecoder.java15
-rw-r--r--swagger.json595
-rw-r--r--test/org/traccar/protocol/CarscopProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java5
4 files changed, 324 insertions, 294 deletions
diff --git a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
index a42c6175f..15e8558be 100644
--- a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.traccar.model.Position;
import javax.xml.bind.DatatypeConverter;
import java.net.SocketAddress;
+import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -77,8 +78,6 @@ public class Xt2400ProtocolDecoder extends BaseProtocolDecoder {
for (int i : l4) {
TAG_LENGTH_MAP.put(i, 4);
}
- TAG_LENGTH_MAP.put(0x65, 17);
- TAG_LENGTH_MAP.put(0x73, 16);
TAG_LENGTH_MAP.put(0x95, 24);
}
@@ -163,12 +162,24 @@ public class Xt2400ProtocolDecoder extends BaseProtocolDecoder {
case 0x13:
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
break;
+ case 0x14:
+ position.set(Position.KEY_RSSI, buf.readShort());
+ break;
case 0x16:
position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.1);
break;
case 0x17:
position.set(Position.KEY_POWER, buf.readUnsignedByte() * 0.1);
break;
+ case 0x57:
+ position.set(Position.KEY_OBD_SPEED, UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
+ break;
+ case 0x65:
+ position.set(Position.KEY_VIN, buf.readBytes(17).toString(StandardCharsets.US_ASCII));
+ break;
+ case 0x73:
+ position.set(Position.KEY_VERSION_FW, buf.readBytes(16).toString(StandardCharsets.US_ASCII).trim());
+ break;
default:
buf.skipBytes(getTagLength(tag));
break;
diff --git a/swagger.json b/swagger.json
index a82232f02..f4e816a5a 100644
--- a/swagger.json
+++ b/swagger.json
@@ -164,37 +164,6 @@
}
}
},
- "/devices/geofences": {
- "post": {
- "summary": "Link a Geofence to a Device",
- "parameters": [
- {
- "$ref": "#/parameters/DeviceGeofence"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/DeviceGeofence"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a Geofence from a Device",
- "parameters": [
- {
- "$ref": "#/parameters/DeviceGeofence"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
"/groups": {
"get": {
"summary": "Fetch a list of Groups",
@@ -273,50 +242,19 @@
}
}
},
- "/groups/geofences": {
+ "/permissions": {
"post": {
- "summary": "Link a Geofence to a Group",
+ "summary": "Link an Object to another Object",
"parameters": [
{
- "$ref": "#/parameters/GroupGeofence"
+ "$ref": "#/parameters/Permission"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/GroupGeofence"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a Geofence from a Group",
- "parameters": [
- {
- "$ref": "#/parameters/GroupGeofence"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
- "/permissions/devices": {
- "post": {
- "summary": "Link a Device to a User",
- "parameters": [
- {
- "$ref": "#/parameters/DevicePermission"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/DevicePermission"
+ "$ref": "#/definitions/Permission"
}
},
"400": {
@@ -325,134 +263,10 @@
}
},
"delete": {
- "summary": "Remove a Device from a User",
- "parameters": [
- {
- "$ref": "#/parameters/DevicePermission"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
- "/permissions/groups": {
- "post": {
- "summary": "Link a Group to a User",
- "parameters": [
- {
- "$ref": "#/parameters/GroupPermission"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/GroupPermission"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a Group from a User",
- "parameters": [
- {
- "$ref": "#/parameters/GroupPermission"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
- "/permissions/geofences": {
- "post": {
- "summary": "Link a Geofence to a User",
- "parameters": [
- {
- "$ref": "#/parameters/GeofencePermission"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/GeofencePermission"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a Geofence from a User",
- "parameters": [
- {
- "$ref": "#/parameters/GeofencePermission"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
- "/permissions/calendars": {
- "post": {
- "summary": "Link a Calendar to a User",
- "parameters": [
- {
- "$ref": "#/parameters/CalendarPermission"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/CalendarPermission"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a Calendar from a User",
+ "summary": "Unlink an Object from another Object",
"parameters": [
{
- "$ref": "#/parameters/CalendarPermission"
- }
- ],
- "responses": {
- "204": {
- "description": "No Content"
- }
- }
- }
- },
- "/permissions/users": {
- "post": {
- "summary": "Link a User to a manager User",
- "parameters": [
- {
- "$ref": "#/parameters/UserPermission"
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "$ref": "#/definitions/UserPermission"
- }
- }
- }
- },
- "delete": {
- "summary": "Remove a User from a manager User",
- "parameters": [
- {
- "$ref": "#/parameters/UserPermission"
+ "$ref": "#/parameters/Permission"
}
],
"responses": {
@@ -793,18 +607,13 @@
"$ref": "#/parameters/userId"
},
{
- "name": "groupId",
- "in": "query",
- "type": "integer"
+ "$ref": "#/parameters/deviceId"
},
{
- "$ref": "#/parameters/deviceId"
+ "$ref": "#/parameters/groupId"
},
{
- "name": "refresh",
- "in": "query",
- "required": false,
- "type": "boolean"
+ "$ref": "#/parameters/refresh"
}
],
"responses": {
@@ -1222,6 +1031,174 @@
}
}
}
+ },
+ "/attributes/computed": {
+ "get": {
+ "summary": "Fetch a list of Attributes",
+ "description": "Without params, it returns a list of Attributes the user has access to",
+ "parameters": [
+ {
+ "$ref": "#/parameters/all"
+ },
+ {
+ "$ref": "#/parameters/userId"
+ },
+ {
+ "$ref": "#/parameters/deviceId"
+ },
+ {
+ "$ref": "#/parameters/groupId"
+ },
+ {
+ "$ref": "#/parameters/refresh"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Attribute"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "summary": "Create an Attribute",
+ "parameters": [
+ {
+ "$ref": "#/parameters/Attribute"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Attribute"
+ }
+ }
+ }
+ }
+ },
+ "/attributes/computed/{id}": {
+ "put": {
+ "summary": "Update an Attribute",
+ "parameters": [
+ {
+ "$ref": "#/parameters/entityId"
+ },
+ {
+ "$ref": "#/parameters/Attribute"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Attribute"
+ }
+ }
+ }
+ },
+ "delete": {
+ "summary": "Delete an Attribute",
+ "parameters": [
+ {
+ "$ref": "#/parameters/entityId"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
+ },
+ "/drivers": {
+ "get": {
+ "summary": "Fetch a list of Drivers",
+ "description": "Without params, it returns a list of Drivers the user has access to",
+ "parameters": [
+ {
+ "$ref": "#/parameters/all"
+ },
+ {
+ "$ref": "#/parameters/userId"
+ },
+ {
+ "$ref": "#/parameters/deviceId"
+ },
+ {
+ "$ref": "#/parameters/groupId"
+ },
+ {
+ "$ref": "#/parameters/refresh"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Driver"
+ }
+ }
+ }
+ }
+ },
+ "post": {
+ "summary": "Create a Driver",
+ "parameters": [
+ {
+ "$ref": "#/parameters/Driver"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Driver"
+ }
+ }
+ }
+ }
+ },
+ "/drivers/{id}": {
+ "put": {
+ "summary": "Update a Driver",
+ "parameters": [
+ {
+ "$ref": "#/parameters/entityId"
+ },
+ {
+ "$ref": "#/parameters/Driver"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Driver"
+ }
+ }
+ }
+ },
+ "delete": {
+ "summary": "Delete a Driver",
+ "parameters": [
+ {
+ "$ref": "#/parameters/entityId"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No Content"
+ }
+ }
+ }
}
},
"definitions": {
@@ -1473,72 +1450,39 @@
"attributes": {}
}
},
- "DevicePermission": {
+ "Permission": {
+ "description": "This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 }",
"properties": {
"userId": {
+ "description": "User Id, can be only first parameter",
"type": "integer"
},
"deviceId": {
- "type": "integer"
- }
- }
- },
- "GroupPermission": {
- "properties": {
- "userId": {
+ "description": "Device Id, can be first parameter or second only in combination with userId",
"type": "integer"
},
"groupId": {
- "type": "integer"
- }
- }
- },
- "GeofencePermission": {
- "properties": {
- "userId": {
+ "description": "Group Id, can be first parameter or second only in combination with userId",
"type": "integer"
},
"geofenceId": {
- "type": "integer"
- }
- }
- },
- "CalendarPermission": {
- "properties": {
- "userId": {
+ "description": "Geofence Id, can be second parameter only",
"type": "integer"
},
"calendarId": {
- "type": "integer"
- }
- }
- },
- "UserPermission": {
- "properties": {
- "userId": {
+ "description": "Geofence Id, can be second parameter only and only in combination with userId",
"type": "integer"
},
- "managedUserId": {
- "type": "integer"
- }
- }
- },
- "GroupGeofence": {
- "properties": {
- "groupId": {
+ "attributeId": {
+ "description": "Computed Attribute Id, can be second parameter only",
"type": "integer"
},
- "geofenceId": {
- "type": "integer"
- }
- }
- },
- "DeviceGeofence": {
- "properties": {
- "deviceId": {
+ "driverId": {
+ "description": "Driver Id, can be second parameter only",
"type": "integer"
},
- "geofenceId": {
+ "managedUserId": {
+ "description": "User Id, can be second parameter only and only in combination with userId",
"type": "integer"
}
}
@@ -1635,6 +1579,10 @@
"type": "number",
"description": "in meters"
},
+ "spentFuel": {
+ "type": "number",
+ "description": "in liters"
+ },
"engineHours": {
"type": "integer"
}
@@ -1660,6 +1608,10 @@
"type": "number",
"description": "in meters"
},
+ "spentFuel": {
+ "type": "number",
+ "description": "in liters"
+ },
"duration": {
"type": "integer"
},
@@ -1690,6 +1642,51 @@
},
"endLon": {
"type": "number"
+ },
+ "driverUniqueId": {
+ "type": "integer"
+ },
+ "driverName": {
+ "type": "string"
+ }
+ }
+ },
+ "ReportStops": {
+ "properties": {
+ "deviceId": {
+ "type": "integer"
+ },
+ "deviceName": {
+ "type": "string"
+ },
+ "duration": {
+ "type": "integer"
+ },
+ "startTime": {
+ "type": "string",
+ "format": "date-time",
+ "description": "in IS0 8601 format. eg. `1963-11-22T18:30:00Z`"
+ },
+ "address": {
+ "type": "string"
+ },
+ "lat": {
+ "type": "number"
+ },
+ "lon": {
+ "type": "number"
+ },
+ "endTime": {
+ "type": "string",
+ "format": "date-time",
+ "description": "in IS0 8601 format. eg. `1963-11-22T18:30:00Z`"
+ },
+ "spentFuel": {
+ "type": "number",
+ "description": "in liters"
+ },
+ "engineHours": {
+ "type": "integer"
}
}
},
@@ -1758,6 +1755,40 @@
},
"atributes": {}
}
+ },
+ "Attribute": {
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "description": {
+ "type": "string"
+ },
+ "attribute": {
+ "type": "string"
+ },
+ "expression": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string",
+ "description": "String|Number|Boolean"
+ }
+ }
+ },
+ "Driver": {
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ },
+ "uniqueId": {
+ "type": "string"
+ },
+ "atributes": {}
+ }
}
},
"parameters": {
@@ -1773,6 +1804,12 @@
"description": "Can only be used by admins or managers to fetch all entities",
"type": "boolean"
},
+ "refresh": {
+ "name": "refresh",
+ "in": "query",
+ "required": false,
+ "type": "boolean"
+ },
"userId": {
"name": "userId",
"in": "query",
@@ -1785,6 +1822,12 @@
"description": "Standard users can use this only with _deviceId_s, they have access to",
"type": "integer"
},
+ "groupId": {
+ "name": "groupId",
+ "in": "query",
+ "description": "Standard users can use this only with _groupId_s, they have access to",
+ "type": "integer"
+ },
"Device": {
"name": "body",
"in": "body",
@@ -1793,12 +1836,12 @@
"$ref": "#/definitions/Device"
}
},
- "DeviceGeofence": {
+ "Permission": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/DeviceGeofence"
+ "$ref": "#/definitions/Permission"
}
},
"Group": {
@@ -1809,84 +1852,52 @@
"$ref": "#/definitions/Group"
}
},
- "GroupGeofence": {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/GroupGeofence"
- }
- },
- "DevicePermission": {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/DevicePermission"
- }
- },
- "GroupPermission": {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/GroupPermission"
- }
- },
- "GeofencePermission": {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/GeofencePermission"
- }
- },
- "CalendarPermission": {
+ "User": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/CalendarPermission"
+ "$ref": "#/definitions/User"
}
},
- "UserPermission": {
+ "Geofence": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/UserPermission"
+ "$ref": "#/definitions/Geofence"
}
},
- "User": {
+ "AttributeAlias": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/User"
+ "$ref": "#/definitions/AttributeAlias"
}
},
- "Geofence": {
+ "Calendar": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/Geofence"
+ "$ref": "#/definitions/Calendar"
}
},
- "AttributeAlias": {
+ "Attribute": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/AttributeAlias"
+ "$ref": "#/definitions/Attribute"
}
},
- "Calendar": {
+ "Driver": {
"name": "body",
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/Calendar"
+ "$ref": "#/definitions/Driver"
}
},
"deviceIdArray": {
diff --git a/test/org/traccar/protocol/CarscopProtocolDecoderTest.java b/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
index da3ac510f..2d6ea208f 100644
--- a/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class CarscopProtocolDecoderTest extends ProtocolTest {
CarscopProtocolDecoder decoder = new CarscopProtocolDecoder(new CarscopProtocol());
verifyNull(decoder, text(
+ "*170724163029UB05ORANGE000000010061825V0000.0000N00000.0000E000.0040331309.62"));
+
+ verifyNull(decoder, text(
"*160618233129UB00HSO"));
verifyNull(decoder, text(
diff --git a/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java b/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
index 3cc0c22ec..35ca282b2 100644
--- a/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
@@ -10,6 +10,11 @@ public class Xt2400ProtocolDecoderTest extends ProtocolTest {
Xt2400ProtocolDecoder decoder = new Xt2400ProtocolDecoder(new Xt2400Protocol());
+ decoder.setConfig("\n:wycfg pcr[0] 001001030406070809570a13121714100565\n");
+
+ verifyPosition(decoder, binary(
+ "000a344f1f0259766ae002074289f8f1c4b200e80000026712068000130000029300883559464255524845364650323433343235"));
+
decoder.setConfig("\n:wycfg pcr[0] 000f01030406070809570a131217141005\n");
verifyPosition(decoder, binary(