mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 18:09:54 +08:00
@@ -10,7 +10,7 @@
|
||||
#### 0x02 下行登录应答
|
||||
`68 0C 00 19 00 02 20 23 12 12 00 00 10 00 A1 55`
|
||||
#### 0x56 下行登录后对时
|
||||
`68 12 01 00 00 56 20 23 12 12 00 00 10 30 75 0F 11 12 0C 18 04 7D `
|
||||
`68 12 01 00 00 56 20 23 12 12 00 00 10 30 75 0F 11 12 0C 18 04 7D`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<artifactId>jcpp-protocol-yunkuaichong</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>JChargePointProtocol Yunkuaichong Protocol Module</name>
|
||||
<description>云快充1.5</description>
|
||||
<description>云快充全版本协议模块</description>
|
||||
|
||||
<properties>
|
||||
<main.dir>${basedir}/..</main.dir>
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AbstractYunKuaiChongCmdExe {
|
||||
|
||||
protected static byte[] encodePileCode(String pileCode) {
|
||||
if (StringUtils.length(pileCode) > 32) {
|
||||
throw new IllegalArgumentException("云快充1.5可接受最大桩编号为14位");
|
||||
throw new IllegalArgumentException("云快充可接受最大桩编号为14位");
|
||||
}
|
||||
|
||||
String pileCodeStr = StringUtils.leftPad(pileCode, 14, '0');
|
||||
@@ -81,7 +81,7 @@ public class AbstractYunKuaiChongCmdExe {
|
||||
|
||||
protected static byte[] encodeGunCode(String gunCode) {
|
||||
if (StringUtils.length(gunCode) > 2) {
|
||||
throw new IllegalArgumentException("云快充1.5可接受最大枪编号为2位");
|
||||
throw new IllegalArgumentException("云快充可接受最大枪编号为2位");
|
||||
}
|
||||
|
||||
String gunCodeStr = StringUtils.leftPad(gunCode, 2, '0');
|
||||
|
||||
@@ -8,6 +8,7 @@ package sanbing.jcpp.protocol.yunkuaichong;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.JCPPPair;
|
||||
@@ -100,6 +101,8 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
|
||||
// ================== 校验和双模式处理 ==================
|
||||
final int checkSumLE = in.getUnsignedShortLE(checksumPos);
|
||||
final int checkSumBE = in.getUnsignedShort(checksumPos);
|
||||
byte[] checkSumBytes = new byte[2];
|
||||
in.getBytes(checksumPos, checkSumBytes);
|
||||
|
||||
// ================== 校验数据智能拷贝 ==================
|
||||
final byte[] checkData = Arrays.copyOfRange(msg, 2, 2 + dataLength);
|
||||
@@ -108,16 +111,16 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
|
||||
JCPPPair<Boolean, Integer> checkResult = checkCrcSum(checkData, checkSumLE);
|
||||
if (!checkResult.getFirst()) {
|
||||
if (log.isDebugEnabled()) { // 日志惰性计算
|
||||
log.debug("{} 云快充校验域一次校验失败 CMD:{} 校验和:0x{} 期望校验和:0x{}",
|
||||
session, frameType, Integer.toHexString(checkSumLE), Integer.toHexString(checkResult.getSecond()));
|
||||
log.debug("{} 云快充校验域一次校验失败 CMD:{} 校验和:0x{} 期望校验和:{}",
|
||||
session, Integer.toHexString(frameType), ByteBufUtil.hexDump(checkSumBytes), checkResult.getSecond());
|
||||
}
|
||||
checkResult = checkCrcSum(checkData, checkSumBE);
|
||||
}
|
||||
|
||||
// ================== 最终校验失败处理 ==================
|
||||
if (!checkResult.getFirst()) {
|
||||
log.info("{} 云快充校验域二次校验失败 CMD:{} 校验和:0x{} 期望校验和:0x{}",
|
||||
session, frameType, Integer.toHexString(checkSumBE), Integer.toHexString(checkResult.getSecond()));
|
||||
log.info("{} 云快充校验域二次校验失败 CMD:{} 校验和:0x{} 期望校验和:{}",
|
||||
session, Integer.toHexString(frameType), ByteBufUtil.hexDump(checkSumBytes), checkResult.getSecond());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static sanbing.jcpp.infrastructure.util.config.ThreadPoolConfiguration.PROTOCOL_SESSION_SCHEDULED;
|
||||
import static sanbing.jcpp.protocol.domain.SessionCloseReason.MANUALLY;
|
||||
import static sanbing.jcpp.protocol.listener.tcp.TcpSession.SCHEDULE_KEY_AUTO_SYNC_TIME;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.FAILURE_BYTE;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.SUCCESS_BYTE;
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.enums.YunKuaiChongDownlinkCmdEnum.LOGIN_ACK;
|
||||
@@ -94,7 +95,7 @@ public class YunKuaiChongV150LoginAckDLCmd extends YunKuaiChongDownlinkCmdExe {
|
||||
}
|
||||
|
||||
private void registerSyncTimeTask(TcpSession tcpSession, byte[] pileCodeBytes, YunKuaiChongUplinkMessage requestData) {
|
||||
tcpSession.addSchedule("auto-sync-time", k -> {
|
||||
tcpSession.addSchedule(SCHEDULE_KEY_AUTO_SYNC_TIME, k -> {
|
||||
log.info("{} 云快充1.5.0开始注册定时对时任务", tcpSession);
|
||||
return PROTOCOL_SESSION_SCHEDULED.scheduleAtFixedRate(() ->
|
||||
syncTime(tcpSession, pileCodeBytes, requestData),
|
||||
|
||||
Reference in New Issue
Block a user