Skip to content

Commit

Permalink
Merge pull request traccar#4206 from flocsy/message-encoding
Browse files Browse the repository at this point in the history
fixed message encoding
  • Loading branch information
tananaev authored Jan 30, 2019
2 parents 91dc8da + 61eb285 commit ccbb289
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/org/traccar/protocol/WatchProtocolEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public String formatValue(String key, Object value) {
DecimalFormat fmt = new DecimalFormat("+#.##;-#.##", DecimalFormatSymbols.getInstance(Locale.US));
return fmt.format(offset);
} else if (key.equals(Command.KEY_MESSAGE)) {
return DataConverter.printHex(value.toString().getBytes());
return DataConverter.printHex(value.toString().getBytes(StandardCharsets.UTF_16BE));
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion test/org/traccar/protocol/WatchProtocolEncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testEncode() throws Exception {
command.setDeviceId(1);
command.setType(Command.TYPE_MESSAGE);
command.set(Command.KEY_MESSAGE, "text");
assertEquals("[CS*123456789012345*0010*MESSAGE,74657874]", encoder.encodeCommand(null, command));
assertEquals("[CS*123456789012345*0018*MESSAGE,0074006500780074]", encoder.encodeCommand(null, command));

command = new Command();
command.setDeviceId(1);
Expand Down

0 comments on commit ccbb289

Please sign in to comment.