mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 电单车协议
This commit is contained in:
@@ -38,21 +38,17 @@ public abstract class AbstractEBikeHandler implements InitializingBean {
|
||||
protected byte[] getResult(EBikeDataProtocol dataProtocol, byte[] messageBody) {
|
||||
// 起始标志
|
||||
byte[] head = dataProtocol.getHead();
|
||||
|
||||
// 长度 = 物理ID(4) + 消息ID(2) + 命令(1) + 数据(n) + 校验(2),每包最多256字节
|
||||
byte[] length = BytesUtil.intToBytesLittle(9 + messageBody.length);
|
||||
|
||||
// 物理id
|
||||
byte[] physicalId = dataProtocol.getPhysicalId();
|
||||
// 加密标志
|
||||
byte[] messageId = dataProtocol.getMessageId();
|
||||
// 请求帧类型
|
||||
byte[] command = dataProtocol.getCommand();
|
||||
|
||||
// 整个数据包中的每个字节(不包括校验字段本身)
|
||||
byte[] dataFields = Bytes.concat(head, length, physicalId, messageId, command, messageBody);
|
||||
byte[] checkFieldBytes = YouDianUtils.getCheckFieldBytes(dataFields);
|
||||
|
||||
return Bytes.concat(dataFields, checkFieldBytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.netty.handler.electricbicycles;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
|
||||
import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
@@ -36,6 +37,6 @@ public class RegistrationHandler extends AbstractEBikeHandler {
|
||||
EBikeMessageCmd20 message = (EBikeMessageCmd20) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
|
||||
EBikeMessageCmd20.DeviceRegister deviceRegister = message.getDeviceRegister();
|
||||
log.info("设备注册包:{}", JSON.toJSONString(message));
|
||||
return new byte[0];
|
||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public class EBikeMessageCmd20 extends AbsEBikeMessage {
|
||||
private String powerBoardVersion;
|
||||
|
||||
public DeviceRegister(byte[] dataBytes) {
|
||||
this.firmwareVersion = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.firmwareVersion = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) * 0.01 + "";
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3)) + "";
|
||||
this.virtualId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 3, 4)) + "";
|
||||
this.deviceType = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 4, 5));
|
||||
this.deviceType = BytesUtil.printHexBinary(Arrays.copyOfRange(dataBytes, 4, 5));
|
||||
this.workMode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 5, 6));
|
||||
this.powerBoardVersion = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 6, 8));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user