mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
update 电单车协议
This commit is contained in:
@@ -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码
|
||||
|
||||
Reference in New Issue
Block a user