aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-11-02 17:57:22 -0700
committerAnton Tananaev <anton@traccar.org>2022-11-02 17:57:22 -0700
commit9280355123ee13f7f7d8bf7076a39dcab57ab1cd (patch)
treee2cd820dc11d75048dd89c2b4ad54c8e5188da74 /src/main/java/org/traccar/protocol
parent49646eccd5ec57013c78ea0a0776c206f812cb0b (diff)
downloadtrackermap-server-9280355123ee13f7f7d8bf7076a39dcab57ab1cd.tar.gz
trackermap-server-9280355123ee13f7f7d8bf7076a39dcab57ab1cd.tar.bz2
trackermap-server-9280355123ee13f7f7d8bf7076a39dcab57ab1cd.zip
Improve attribute type handling
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/KhdProtocolEncoder.java2
-rw-r--r--src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java6
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java4
-rw-r--r--src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java16
4 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java b/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java
index 8aeb9660d..12353b415 100644
--- a/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java
@@ -84,7 +84,7 @@ public class KhdProtocolEncoder extends BaseProtocolEncoder {
return encodeCommand(MSG_FACTORY_RESET, uniqueId, null);
case Command.TYPE_SET_SPEED_LIMIT:
ByteBuf content = Unpooled.buffer();
- content.writeByte(Integer.parseInt(command.getString(Command.KEY_DATA)));
+ content.writeByte(command.getInteger(Command.KEY_DATA));
return encodeCommand(MSG_RESUME_OIL, uniqueId, content);
case Command.TYPE_SET_ODOMETER:
return encodeCommand(MSG_DELETE_MILEAGE, uniqueId, null);
diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
index 03f0e7ecf..5859d91ce 100644
--- a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,8 +99,8 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
content.writeShort(command.getInteger(Command.KEY_FREQUENCY) / 10);
return encodeContent(command.getDeviceId(), MeiligaoProtocolDecoder.MSG_TRACK_BY_INTERVAL, content);
case Command.TYPE_OUTPUT_CONTROL:
- int index = Integer.parseInt(command.getString(Command.KEY_INDEX)) - 1;
- int value = Integer.parseInt(command.getString(Command.KEY_DATA));
+ int index = command.getInteger(Command.KEY_INDEX) - 1;
+ int value = command.getInteger(Command.KEY_DATA);
return encodeOutputCommand(command.getDeviceId(), index, value);
case Command.TYPE_ENGINE_STOP:
return encodeOutputCommand(command.getDeviceId(), 1, 1);
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
index 442961b19..5ec971a98 100644
--- a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
@@ -80,14 +80,14 @@ public class RuptelaProtocolEncoder extends BaseProtocolEncoder {
return encodeContent(RuptelaProtocolDecoder.MSG_FIRMWARE_UPDATE, content);
case Command.TYPE_OUTPUT_CONTROL:
content.writeInt(command.getInteger(Command.KEY_INDEX));
- content.writeInt(Integer.parseInt(command.getString(Command.KEY_DATA)));
+ content.writeInt(command.getInteger(Command.KEY_DATA));
return encodeContent(RuptelaProtocolDecoder.MSG_SET_IO, content);
case Command.TYPE_SET_CONNECTION:
String c = command.getString(Command.KEY_SERVER) + "," + command.getInteger(Command.KEY_PORT) + ",TCP";
content.writeBytes(c.getBytes(StandardCharsets.US_ASCII));
return encodeContent(RuptelaProtocolDecoder.MSG_SET_CONNECTION, content);
case Command.TYPE_SET_ODOMETER:
- content.writeInt(Integer.parseInt(command.getString(Command.KEY_DATA)));
+ content.writeInt(command.getInteger(Command.KEY_DATA));
return encodeContent(RuptelaProtocolDecoder.MSG_SET_ODOMETER, content);
default:
return null;
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
index 53308f968..b298adc5a 100644
--- a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java
@@ -59,23 +59,23 @@ public class SuntechProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, "CMD;%s;03;01\r", Command.KEY_UNIQUE_ID);
case Command.TYPE_OUTPUT_CONTROL:
if (command.getAttributes().get(Command.KEY_DATA).equals("1")) {
- switch (command.getString(Command.KEY_INDEX)) {
- case "1":
+ switch (command.getInteger(Command.KEY_INDEX)) {
+ case 1:
return formatCommand(command, "CMD;%s;04;01\r", Command.KEY_UNIQUE_ID);
- case "2":
+ case 2:
return formatCommand(command, "CMD;%s;04;03\r", Command.KEY_UNIQUE_ID);
- case "3":
+ case 3:
return formatCommand(command, "CMD;%s;04;09\r", Command.KEY_UNIQUE_ID);
default:
return null;
}
} else {
- switch (command.getString(Command.KEY_INDEX)) {
- case "1":
+ switch (command.getInteger(Command.KEY_INDEX)) {
+ case 1:
return formatCommand(command, "CMD;%s;04;02\r", Command.KEY_UNIQUE_ID);
- case "2":
+ case 2:
return formatCommand(command, "CMD;%s;04;04\r", Command.KEY_UNIQUE_ID);
- case "3":
+ case 3:
return formatCommand(command, "CMD;%s;04;10\r", Command.KEY_UNIQUE_ID);
default:
return null;