app-starlock/star_lock/lib/blue/io_protocol/io_getPublicKey.dart

54 lines
1.2 KiB
Dart
Raw Normal View History

2023-08-08 09:42:35 +08:00
import 'dart:convert';
2023-08-09 15:42:26 +08:00
import 'dart:typed_data';
2023-08-08 09:42:35 +08:00
import 'package:get/get.dart';
2023-08-09 15:42:26 +08:00
import '../../tools/storage.dart';
import '../io_tool/io_manager.dart';
2023-08-08 09:42:35 +08:00
import '../io_tool/io_tool.dart';
2023-08-10 09:52:05 +08:00
import '../sender_manage.dart';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_type.dart';
2023-08-08 09:42:35 +08:00
class GetPublicKeyCommand extends SenderProtocol {
String? lockID;
GetPublicKeyCommand({
this.lockID,
}) : super(CommandType.getLockPublicKey);
@override
String toString() {
return 'GetPublicKeyCommand{lockID: $lockID}';
}
2023-08-08 09:42:35 +08:00
@override
List<int> messageDetail() {
List<int> data = [];
2023-08-10 18:56:29 +08:00
// 指令类型
int type = commandType!.typeValue;
double typeDouble = type / 256;
2023-08-10 18:56:29 +08:00
int type1 = typeDouble.toInt();
int type2 = type % 256;
2023-08-10 18:56:29 +08:00
data.add(type1);
data.add(type2);
2023-08-09 15:42:26 +08:00
int length = utf8.encode(lockID!).length;
2023-08-08 09:42:35 +08:00
data.addAll(utf8.encode(lockID!));
2023-08-09 15:42:26 +08:00
data = getFixedLengthList(data, 40 - length);
printLog(data);
2023-08-08 09:42:35 +08:00
return data;
}
}
class GetPublicKeyReply extends Reply {
GetPublicKeyReply.parseData(CommandType commandType, List<int> dataDetail)
2023-08-08 09:42:35 +08:00
: super.parseData(commandType, dataDetail) {
status = dataDetail[2];
data = dataDetail;
2023-08-08 09:42:35 +08:00
}
}