update 电单车协议

This commit is contained in:
Guoqs
2024-08-26 16:53:52 +08:00
parent 81dca24110
commit 613c6a74d8
5 changed files with 105 additions and 48 deletions

View File

@@ -40,7 +40,7 @@ public abstract class AbstractEBikeHandler implements InitializingBean {
byte[] head = dataProtocol.getHead();
// 长度 = 物理ID(4) + 消息ID(2) + 命令(1) + 数据(n) + 校验(2)每包最多256字节
byte[] length = BytesUtil.intToBytes(9 + messageBody.length);
byte[] length = BytesUtil.intToBytesLittle(9 + messageBody.length);
// 物理id
byte[] physicalId = dataProtocol.getPhysicalId();

View File

@@ -39,7 +39,7 @@ public class GetServerTimeHandler extends AbstractEBikeHandler {
// 获取当前服务器10位时间戳
byte[] timeBytes = BytesUtil.getIntBytes((int) (System.currentTimeMillis() / 1000));
System.out.println("data: " + BytesUtil.bytesToIntLittle(timeBytes));
// System.out.println("data: " + BytesUtil.bytesToIntLittle(timeBytes));
return getResult(dataProtocol, timeBytes);
}
}

View File

@@ -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 HeartbeatHandler extends AbstractEBikeHandler {
EBikeMessageCmd21 message = (EBikeMessageCmd21) AbsEBikeMessage.parseMessage(dataProtocol.getBytes());
EBikeMessageCmd21.DeviceHeartbeat deviceHeartbeat = message.getDeviceHeartbeat();
log.info("设备心跳包:{}", JSON.toJSONString(message));
return new byte[0];
return getResult(dataProtocol, Constants.zeroByteArray);
}
}