|
|
@@ -41,7 +41,13 @@ public class LoginFrame {
|
|
|
public void loginMsgSend(DeviceConnectionMsg deviceConnectionMsg,Device device){
|
|
|
byte[] send = new byte[0];
|
|
|
try {
|
|
|
- send = loginMsg(device);
|
|
|
+ System.out.println(device.getCommProtocolVer());
|
|
|
+ if(!device.getCommProtocolVer().startsWith("1.8")){
|
|
|
+ send = loginMsgNot18(device);
|
|
|
+ }else{
|
|
|
+ send = loginMsg18(device);
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
log.info("pileCode:"+device.getPileCode()+" login params Exception:");
|
|
|
e.printStackTrace();
|
|
|
@@ -66,8 +72,66 @@ public class LoginFrame {
|
|
|
log.info("pileCode:"+device.getPileCode()+" login over");
|
|
|
}
|
|
|
|
|
|
+ private byte[] loginMsgNot18( Device device) throws Exception {
|
|
|
+
|
|
|
+ byte[] msg = new byte[30];//消息体
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ //1.桩编码
|
|
|
+ byte[] pile_code = new byte[7];
|
|
|
+ byte[] bcd = DataConversion.bcdToBytes(device.getPileCode(), pile_code.length);
|
|
|
+ System.arraycopy(bcd, 0, pile_code, 0, bcd.length);
|
|
|
+ System.arraycopy(pile_code, 0, msg, index, pile_code.length);
|
|
|
+ index += pile_code.length;
|
|
|
+ //3. 充电桩类型,0:直流,1:交流
|
|
|
+ byte[] pile_type = new byte[]{device.getPileType()};
|
|
|
+ System.arraycopy(pile_type, 0, msg, index, pile_type.length);
|
|
|
+ index += pile_type.length;
|
|
|
+ // 4.充电枪连接数
|
|
|
+ byte[] charger_gun_num = new byte[]{device.getChargerGunNum()};
|
|
|
+ System.arraycopy(charger_gun_num, 0, msg, index, charger_gun_num.length);
|
|
|
+ index += charger_gun_num.length;
|
|
|
+ // 5.通讯协议版本
|
|
|
+ byte[] comm_protocol_ver = new byte[1]; // 通讯协议版本
|
|
|
+
|
|
|
+ // 提取前两位
|
|
|
+ String[] parts = device.getCommProtocolVer().split("\\.");
|
|
|
+ String firstTwoParts = parts[0] + "." + parts[1];
|
|
|
+ // 转换为数字并乘以 10
|
|
|
+ double number = Double.parseDouble(firstTwoParts);
|
|
|
+ double result = number * 10;
|
|
|
+ byte byteValue = (byte) result;
|
|
|
+ comm_protocol_ver[0] = byteValue;
|
|
|
+
|
|
|
+ System.arraycopy(comm_protocol_ver, 0, msg, index, comm_protocol_ver.length);
|
|
|
+ index += comm_protocol_ver.length;
|
|
|
+
|
|
|
+ //6.程序版本
|
|
|
+ byte[] program_version = new byte[8];
|
|
|
+ byte[] program_versions = device.getProgramVersion().getBytes();
|
|
|
+ System.arraycopy(program_versions, 0, program_version, 0, program_versions.length);
|
|
|
+
|
|
|
+ System.arraycopy(program_version, 0, msg, index, program_version.length);
|
|
|
+ index += program_version.length;
|
|
|
+ // 7.网络链接类型,0:sim 卡
|
|
|
+ byte[] net_link_type = new byte[]{device.getNetLinkType()};
|
|
|
+ System.arraycopy(net_link_type, 0, msg, index, net_link_type.length);
|
|
|
+ index += net_link_type.length;
|
|
|
+ //8.SIM卡
|
|
|
+ byte[] sim_card = new byte[10];
|
|
|
+ sim_card = DataConversion.bcdToBytes(device.getSimCard(), sim_card.length);
|
|
|
+ System.arraycopy(sim_card, 0, msg, index, sim_card.length);
|
|
|
+ index += sim_card.length;
|
|
|
+ // 9.运营商,0:移动
|
|
|
+ byte[] operators = new byte[]{device.getOperators()};
|
|
|
+ System.arraycopy(operators, 0, msg, index, operators.length);
|
|
|
+ index += operators.length;
|
|
|
+
|
|
|
+ return msg;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- private byte[] loginMsg( Device device) throws Exception {
|
|
|
+ private byte[] loginMsg18( Device device) throws Exception {
|
|
|
Random random = new Random();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (int i = 0; i < 16; i++) {
|