diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-16 19:58:26 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-16 19:58:26 +1300 |
commit | 34a5b8ceaff6617a8958ce04fb6c7f65d1d19979 (patch) | |
tree | c66c9280ca6be9ba4501beef7c8469026d1a25fd | |
parent | 0933f39774235641b1f4bdd1e1402b71bf9be9ed (diff) | |
download | trackermap-server-34a5b8ceaff6617a8958ce04fb6c7f65d1d19979.tar.gz trackermap-server-34a5b8ceaff6617a8958ce04fb6c7f65d1d19979.tar.bz2 trackermap-server-34a5b8ceaff6617a8958ce04fb6c7f65d1d19979.zip |
Fix Castel command encoding
-rw-r--r-- | src/org/traccar/protocol/CastelProtocolEncoder.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/CastelProtocolEncoderTest.java | 2 |
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")); } |