update 电单车协议

This commit is contained in:
Guoqs
2024-08-29 15:24:29 +08:00
parent 430a03ba7e
commit d60d50ed8a
4 changed files with 30 additions and 44 deletions

View File

@@ -236,35 +236,6 @@ public class BytesUtil {
return new String(temp);
}
/**
* 将byte数组转换为物理ID
* @param bytes 输入的byte数组
* @return 物理ID对象包含设备识别码和二维码下方的编号
*/
public static int convertToPhysicalId(byte[] bytes) {
// 检查输入是否合法
if (bytes == null || bytes.length != 4) {
throw new IllegalArgumentException("Input byte array must be of length 4.");
}
// 小端模式转大端模式
byte[] bigEndianBytes = new byte[4];
bigEndianBytes[0] = bytes[3];
bigEndianBytes[1] = bytes[2];
bigEndianBytes[2] = bytes[1];
bigEndianBytes[3] = bytes[0];
// 提取设备识别码
byte deviceId = bigEndianBytes[0];
// 剩余的三个字节转换为十进制
int deviceNumber = ((bigEndianBytes[1] & 0xFF) << 16) |
((bigEndianBytes[2] & 0xFF) << 8) |
(bigEndianBytes[3] & 0xFF);
log.debug("设备识别码:{}, 桩编号:{}", deviceId, deviceNumber);
return deviceNumber;
}
/**
* @函数功能: BCD码转为10进制串(阿拉伯数据) 小端模式
* @输入参数: BCD码