mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-28 15:05:18 +08:00
update 电单车协议
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
|
||||
/**
|
||||
* 电单车发送命令服务
|
||||
*/
|
||||
public interface EBikeSendCommandService {
|
||||
void send(String pileSn, AbsEBikeMessage msg);
|
||||
// void send(String pileSn, AbsEBikeMessage msg);
|
||||
|
||||
void startCharging(String pileSn);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.jsowell.common.enums.ykc.PileChannelEntity;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.RandomUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import com.jsowell.pile.domain.ebike.serversend.EBikeMessageCmd82;
|
||||
import com.jsowell.pile.service.EBikeSendCommandService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -14,21 +16,49 @@ import java.util.Objects;
|
||||
@Service
|
||||
public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
|
||||
@Override
|
||||
public void send(String pileSn, AbsEBikeMessage msg) {
|
||||
public void startCharging(String pileSn) {
|
||||
EBikeMessageCmd82 message = new EBikeMessageCmd82();
|
||||
message.setHeader("DNY");
|
||||
message.setPhysicalId(Integer.parseInt(pileSn));
|
||||
message.setMessageId(RandomUtil.getRandomNumber(4));
|
||||
message.setCommand("82");
|
||||
EBikeMessageCmd82.SpecificData data = new EBikeMessageCmd82.SpecificData();
|
||||
data.setRateMode("3");
|
||||
data.setBalanceOrValidity("0");
|
||||
data.setPortNumber("0");
|
||||
data.setChargeCommand("1");
|
||||
data.setChargeDurationOrPower("0");
|
||||
data.setOrderNumber("0");
|
||||
data.setMaxChargeDuration("0");
|
||||
data.setOverloadPower("0");
|
||||
data.setQrCodeLight("0");
|
||||
data.setLongChargeMode("0");
|
||||
data.setExtraFloatChargeTime("0");
|
||||
data.setSkipShortCircuitDetection("0");
|
||||
data.setNoUserPullOutCheck("0");
|
||||
data.setForceAutoStopWhenFull("0");
|
||||
data.setFullChargePower("0");
|
||||
data.setMaxFullChargePowerCheckTime("0");
|
||||
message.setData(data);
|
||||
this.send(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共方法, 发送指令
|
||||
* @param msg
|
||||
*/
|
||||
private void send(AbsEBikeMessage msg) {
|
||||
String pileSn = msg.getPhysicalId() + "";
|
||||
byte[] messageBytes = msg.getMessageBytes();
|
||||
PileChannelEntity.output();
|
||||
log.info("发送电单车命令, pileSn:{}, messageBytes:{}", pileSn, BytesUtil.binary(messageBytes, 16));
|
||||
// 获取桩的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);
|
||||
|
||||
|
||||
// ctx.writeAndFlush(messageBytes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user