76 lines
1.6 KiB
Dart
76 lines
1.6 KiB
Dart
|
|
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<int>? data;
|
|
|
|
UDPMainProtocolCommand({
|
|
this.command,
|
|
this.commandTypeIsCalling,
|
|
this.subCommand,
|
|
this.lockID,
|
|
this.lockIP,
|
|
this.userMobile,
|
|
this.userMobileIP,
|
|
this.data,
|
|
}) : super(CommandUDPType.heart);
|
|
|
|
@override
|
|
List<int> messageDetail() {
|
|
List<int> data = [];
|
|
|
|
// 命令
|
|
data.add(command!);
|
|
|
|
// 命令类型
|
|
data.add(commandTypeIsCalling!);
|
|
|
|
// 子命令
|
|
data.add(subCommand!);
|
|
|
|
// lockID
|
|
data.addAll(utf8.encode(lockID!));
|
|
data = getFixedLengthList(data, 20 - utf8.encode(lockID!).length);
|
|
|
|
// lockIP
|
|
var lockIPList = lockIP!.split(".");
|
|
lockIPList.forEach((element) {
|
|
data.add(int.parse(element));
|
|
});
|
|
|
|
// userMobile
|
|
data.addAll(utf8.encode(userMobile!));
|
|
data = getFixedLengthList(data, 20 - utf8.encode(userMobile!).length);
|
|
|
|
// userMobileIP
|
|
var userMobileIPList = lockIP!.split(".");
|
|
userMobileIPList.forEach((element) {
|
|
data.add(int.parse(element));
|
|
});
|
|
|
|
// print("datadatadata:$data");
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class UDPMainProtocolReply extends UDPReply {
|
|
UDPMainProtocolReply.parseData(CommandUDPType commandType, List<int> dataDetail)
|
|
: super.parseData(commandType, dataDetail) {
|
|
data = dataDetail;
|
|
}
|
|
}
|