update 电单车协议

This commit is contained in:
Guoqs
2024-09-04 14:42:44 +08:00
parent 0d26625b57
commit b4ba770136
3 changed files with 35 additions and 44 deletions

View File

@@ -116,30 +116,13 @@ public class YouDianUtils {
// return hexString;
// }
public static byte[] convertPortNumberToBytes(int portNumber) {
if (portNumber < 1 || portNumber > 16) {
throw new IllegalArgumentException("Port number must be between 1 and 16.");
}
// 端口号从1开始因此需要减去1
int hexValue = portNumber - 1;
// 转换为字节数组
byte[] bytes = new byte[2];
bytes[0] = (byte) 0x00; // 前缀0x
bytes[1] = (byte) hexValue;
return bytes;
}
/**
* 端口号转换
* 指充电桩的插口号端口号从0开始如0x00-0x0F则代表第1路-第16路0x00=第1路0x09=第十路0x0A=第十一路FF=设备智能选择端口(服务器下发);
* @param port
* @param portNumber
* @return
*/
public static byte[] convertPortNumberToBytes(String port) {
int portNumber = Integer.parseInt(port);
public static byte[] convertPortNumberToBytes(int portNumber) {
if (portNumber < 1 || portNumber > 16) {
throw new IllegalArgumentException("Port number must be between 1 and 16.");
}