update 电单车协议

This commit is contained in:
Guoqs
2024-08-26 14:45:19 +08:00
parent f27773ba05
commit c091b6dea7
10 changed files with 144 additions and 83 deletions

View File

@@ -2,6 +2,7 @@ package com.jsowell.netty.handler.electricbicycles;
import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.core.redis.RedisCache;
@@ -9,7 +10,6 @@ import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.CRC16Util;
import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,23 +26,25 @@ public abstract class AbstractEBikeHandler implements InitializingBean {
* 执行逻辑
* 有应答
*/
public abstract byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx);
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
throw new UnsupportedOperationException();
}
/**
* 组装应答的结果
* @param ykcDataProtocol 请求数据
* @param dataProtocol 请求数据
* @param messageBody 消息体
* @return 应答结果
*/
protected byte[] getResult(YKCDataProtocol ykcDataProtocol, byte[] messageBody) {
protected byte[] getResult(EBikeDataProtocol dataProtocol, byte[] messageBody) {
// 起始标志
byte[] head = ykcDataProtocol.getHead();
byte[] head = dataProtocol.getHead();
// 序列号域
byte[] serialNumber = ykcDataProtocol.getSerialNumber();
byte[] serialNumber = dataProtocol.getPhysicalId();
// 加密标志
byte[] encryptFlag = ykcDataProtocol.getEncryptFlag();
byte[] encryptFlag = dataProtocol.getMessageId();
// 请求帧类型
byte[] requestFrameType = ykcDataProtocol.getFrameType();
byte[] requestFrameType = dataProtocol.getCommand();
// 应答帧类型
byte[] responseFrameType = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(requestFrameType);

View File

@@ -1,8 +1,8 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -28,7 +28,7 @@ public class GetServerTimeHandler extends AbstractEBikeHandler {
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,8 +1,8 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -24,11 +24,11 @@ public class HeartbeatHandler extends AbstractEBikeHandler {
* 执行逻辑
* 有应答
*
* @param msg
* @param dataProtocol
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,8 +1,8 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -28,7 +28,7 @@ public class RegistrationHandler extends AbstractEBikeHandler {
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
return new byte[0];
}
}

View File

@@ -1,8 +1,8 @@
package com.jsowell.netty.handler.electricbicycles;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import com.jsowell.common.core.domain.ebike.EBikeDataProtocol;
import com.jsowell.netty.factory.EBikeOperateFactory;
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -24,11 +24,12 @@ public class SettlementUploadHandler extends AbstractEBikeHandler {
* 执行逻辑
* 有应答
*
* @param msg
* @param dataProtocol
* @param ctx
*/
@Override
public byte[] supplyProcess(Class<? extends AbsEBikeMessage> msg, ChannelHandlerContext ctx) {
return new byte[0];
public byte[] supplyProcess(EBikeDataProtocol dataProtocol, ChannelHandlerContext ctx) {
return null;
}
}