aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/CastelProtocolEncoder.java4
-rw-r--r--test/org/traccar/protocol/CastelProtocolEncoderTest.java2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/CastelProtocolEncoder.java b/src/org/traccar/protocol/CastelProtocolEncoder.java
index d69fc62cf..7ba33ca6d 100644
--- a/src/org/traccar/protocol/CastelProtocolEncoder.java
+++ b/src/org/traccar/protocol/CastelProtocolEncoder.java
@@ -28,7 +28,7 @@ import java.nio.charset.StandardCharsets;
public class CastelProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(long deviceId, int type, ChannelBuffer content) {
+ private ChannelBuffer encodeContent(long deviceId, short type, ChannelBuffer content) {
ChannelBuffer buf = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
String uniqueId = Context.getIdentityManager().getById(deviceId).getUniqueId();
@@ -42,7 +42,7 @@ public class CastelProtocolEncoder extends BaseProtocolEncoder {
buf.writeBytes(uniqueId.getBytes(StandardCharsets.US_ASCII));
buf.writeZero(20 - uniqueId.length());
- buf.writeShort(type);
+ buf.writeShort(ChannelBuffers.swapShort(type));
buf.writeBytes(content);
buf.writeShort(Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
diff --git a/test/org/traccar/protocol/CastelProtocolEncoderTest.java b/test/org/traccar/protocol/CastelProtocolEncoderTest.java
index 6e519363f..fc0a92c86 100644
--- a/test/org/traccar/protocol/CastelProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/CastelProtocolEncoderTest.java
@@ -15,7 +15,7 @@ public class CastelProtocolEncoderTest extends ProtocolTest {
command.setDeviceId(1);
command.setType(Command.TYPE_ENGINE_STOP);
- verifyCommand(encoder, command, binary("40401a00043132333435363738393031323334350000000000834501c7280d0a"));
+ verifyCommand(encoder, command, binary("40401a00043132333435363738393031323334350000000000458301fe6a0d0a"));
}