mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 电单车协议
This commit is contained in:
@@ -41,7 +41,7 @@ public class DeviceGetServerTimeHandler extends AbstractEBikeHandler {
|
||||
|
||||
// 获取当前服务器10位时间戳
|
||||
byte[] timeBytes = BytesUtil.getIntBytes((int) (System.currentTimeMillis() / 1000));
|
||||
// System.out.println("data: " + BytesUtil.bytesToIntLittle(timeBytes));
|
||||
|
||||
return getResult(dataProtocol, timeBytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,13 @@ public class HostGetServerTimeHandler extends AbstractEBikeHandler {
|
||||
// System.out.println("data: " + BytesUtil.bytesToIntLittle(timeBytes));
|
||||
return getResult(dataProtocol, timeBytes);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// DE 5C A9 5F,转小端模式,=0x5FA95CDE=1604934878=2020-11-09 23:14:38
|
||||
String str = "DE 5C A9 5F".replace(" ", "");
|
||||
byte[] bytes = BytesUtil.hexStringToByteArray(str);
|
||||
System.out.println("data: " + BytesUtil.binary(bytes, 16));
|
||||
System.out.println("time: " + BytesUtil.bytesToIntLittle(bytes));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.jsowell.netty.factory.EBikeOperateFactory;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import com.jsowell.pile.domain.ebike.EBikeCommandEnum;
|
||||
import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd20;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,9 @@ import org.springframework.stereotype.Component;
|
||||
public class RegistrationHandler extends AbstractEBikeHandler {
|
||||
private final String type = EBikeCommandEnum.REGISTRATION.getCode();
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
EBikeOperateFactory.register(type, this);
|
||||
@@ -39,6 +44,7 @@ public class RegistrationHandler extends AbstractEBikeHandler {
|
||||
saveLastTimeAndCheckChannel(message.getPhysicalId() + "", ctx);
|
||||
EBikeMessageCmd20.DeviceRegister deviceRegister = message.getDeviceRegister();
|
||||
log.info("设备注册包:{}", JSON.toJSONString(message));
|
||||
pileBasicInfoService.registrationEBikePile(message);
|
||||
return getResult(dataProtocol, Constants.zeroByteArray);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user