update 电单车协议

This commit is contained in:
Guoqs
2024-08-29 16:58:21 +08:00
parent d8ff7c4361
commit 7db4ffaf37
7 changed files with 93 additions and 134 deletions

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}