49 lines
1.1 KiB
Dart
49 lines
1.1 KiB
Dart
|
|
import 'dart:convert';
|
|
|
|
import '../io_reply.dart';
|
|
import '../io_sender.dart';
|
|
import '../io_tool/io_tool.dart';
|
|
import '../io_type.dart';
|
|
|
|
class GetDeviceModelCommand extends SenderProtocol {
|
|
GetDeviceModelCommand({
|
|
this.lockID,
|
|
}) : super(CommandType.getDeviceModel);
|
|
String? lockID;
|
|
|
|
|
|
@override
|
|
String toString() {
|
|
return 'GetDeviceModelCommand{lockID: $lockID}';
|
|
}
|
|
|
|
@override
|
|
List<int> messageDetail() {
|
|
List<int> data = [];
|
|
|
|
// 指令类型
|
|
final int type = commandType!.typeValue;
|
|
final double typeDouble = type / 256;
|
|
final int type1 = typeDouble.toInt();
|
|
final int type2 = type % 256;
|
|
data.add(type1);
|
|
data.add(type2);
|
|
|
|
final int length = utf8.encode(lockID!).length;
|
|
data.addAll(utf8.encode(lockID!));
|
|
data = getFixedLengthList(data, 40 - length);
|
|
|
|
printLog(data);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class GetDeviceModelReply extends Reply {
|
|
GetDeviceModelReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
: super.parseData(commandType, dataDetail) {
|
|
status = dataDetail[2];
|
|
data = dataDetail;
|
|
}
|
|
}
|