import 'dart:convert'; import '../../../blue/io_tool/io_tool.dart'; import '../io_udpSender.dart'; import '../io_udpType.dart'; import '../udp_reply.dart'; class UDPMainProtocolCommand extends UDPSenderProtocol { int? command; int? commandTypeIsCalling; int? subCommand; String? lockID; String? lockIP; String? userMobile; String? userMobileIP; List? endData; UDPMainProtocolCommand({ this.command, this.commandTypeIsCalling, this.subCommand, this.lockID, this.lockIP, this.userMobile, this.userMobileIP, this.endData, }) : super(CommandUDPType.heart); @override List messageDetail() { List data = []; // 命令 data.add(command!); // 命令类型 data.add(commandTypeIsCalling!); // 子命令 data.add(subCommand!); // lockID List lockIDData = utf8.encode(lockID!); data.addAll(lockIDData); // topBytes = getFixedLengthList(lockIDData, 20 - lockIDData.length); for (int i = 0; i < 20 - lockIDData.length; i++) { data.add(0); } // lockIP var lockIPList = lockIP!.split("."); lockIPList.forEach((element) { data.add(int.parse(element)); }); // userMobile List userMobileData = utf8.encode(userMobile!); data.addAll(userMobileData); // topBytes = getFixedLengthList(topBytes, 20 - userMobileData.length); for (int i = 0; i < 20 - userMobileData.length; i++) { data.add(0); } // userMobileIP var userMobileIPList = lockIP!.split("."); userMobileIPList.forEach((element) { data.add(int.parse(element)); }); data.addAll(endData!); // AppLog.log("datadatadata:$data"); return data; } } class UDPMainProtocolReply extends UDPReply { UDPMainProtocolReply.parseData(CommandUDPType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; } }