From 09daf15be1a874a8880645d4595e1b57d4cf2eee Mon Sep 17 00:00:00 2001 From: seym45 Date: Mon, 24 Jul 2023 20:29:29 +0400 Subject: Add method to get calibration byte --- src/main/java/org/traccar/protocol/GatorProtocolEncoder.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/java/org') diff --git a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java index df85a712c..0d4353c8f 100644 --- a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java @@ -62,12 +62,24 @@ public class GatorProtocolEncoder extends BaseProtocolEncoder { return encodedId.toString(); } + private static String getCalibrationByteFromHexString(String data) { + String response = ""; + int calib = 0; + int length = data.length() / 2; + for (int i = 0; i < length; i++) { + calib = calib ^ Integer.parseInt(data.substring(i * 2, i * 2 + 2), 16); + } + response = Integer.toHexString(calib).toUpperCase(); + response = String.format("%2s", response).replace(' ', '0'); + return response; + } private ByteBuf encodeContent(long deviceId, String mainOrder, String content) { // FIXME: implement this method return null; } + @Override protected Object encodeCommand(Command command) { -- cgit v1.2.3