49 lines
1.2 KiB
Dart
49 lines
1.2 KiB
Dart
import 'dart:convert';
|
||
import 'dart:typed_data';
|
||
|
||
import '../../tools/storage.dart';
|
||
import '../io_tool/io_manager.dart';
|
||
import '../io_tool/io_tool.dart';
|
||
import '../sender_manage.dart';
|
||
import '../io_reply.dart';
|
||
import '../io_sender.dart';
|
||
import '../io_type.dart';
|
||
|
||
class GetPublicKeyCommand extends SenderProtocol {
|
||
String? lockID;
|
||
GetPublicKeyCommand({
|
||
this.lockID,
|
||
}) : super(CommandType.getLockPublicKey);
|
||
|
||
@override
|
||
List<int> messageDetail() {
|
||
List<int> data = [];
|
||
|
||
// 指令类型
|
||
int type = commandType!.typeValue;
|
||
double typeDouble = type / 256;
|
||
int type1 = typeDouble.toInt();
|
||
int type2 = type % 256;
|
||
data.add(type1);
|
||
data.add(type2);
|
||
// print("type:$type");
|
||
// print("type1:$type1");
|
||
// print("type2:$type2");
|
||
|
||
print("lockID:${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}");
|
||
int length = utf8.encode(lockID!).length;
|
||
data.addAll(utf8.encode(lockID!));
|
||
data = getFixedLengthList(data, 40 - length);
|
||
// print("dataaaaaa:$data");
|
||
return data;
|
||
}
|
||
}
|
||
|
||
class GetPublicKeyReply extends Reply {
|
||
GetPublicKeyReply.parseData(CommandType commandType, List<int> dataDetail)
|
||
: super.parseData(commandType, dataDetail) {
|
||
status = dataDetail[2];
|
||
data = dataDetail;
|
||
}
|
||
}
|