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