update 电单车协议

This commit is contained in:
Guoqs
2024-09-02 13:59:14 +08:00
parent 3221c9ae67
commit a41264d1b9
3 changed files with 105 additions and 9 deletions

View File

@@ -1,13 +1,34 @@
package com.jsowell.pile.service.impl;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import com.jsowell.pile.service.EBikeSendCommandService;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Slf4j
@Service
public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
@Override
public void send(String pileSn, AbsEBikeMessage msg) {
// 获取桩的channel
ChannelHandlerContext ctx = PileChannelEntity.getChannelByPileSn(pileSn);
if (Objects.isNull(ctx)) {
log.error("电单车send命令失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", pileSn);
throw new NullPointerException("channel");
}
if (Objects.isNull(msg)) {
log.error("电单车send命令失败, msg为空!");
throw new NullPointerException("msg");
}
String str = "44 4E 59 26 00 3B 37 AB 04 02 00 82 00 64 01 00 00 01 01 00 00 12 34 56 78 12 34 56 78 12 34 56 78 12 34 56 78 80 70 88 13 F8 08";
byte[] messageBytes = BytesUtil.hexStringToByteArray(str);
ctx.writeAndFlush(messageBytes);
}
}