61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
// 获取网关状态
|
|
import 'dart:convert';
|
|
|
|
import '../io_reply.dart';
|
|
import '../io_sender.dart';
|
|
import '../io_tool/io_tool.dart';
|
|
import '../io_type.dart';
|
|
|
|
class GatewayGetStatusCommand extends SenderProtocol {
|
|
GatewayGetStatusCommand({
|
|
this.lockID,
|
|
this.userID,
|
|
}) : super(CommandType.gatewayGetStatus);
|
|
|
|
String? lockID;
|
|
String? userID;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'GatewayGetStatusCommand{lockID: $lockID, userID: $userID}';
|
|
}
|
|
|
|
@override
|
|
List<int> messageDetail() {
|
|
final List<int> data = <int>[];
|
|
List<int> subData = <int>[];
|
|
|
|
// 指令类型
|
|
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);
|
|
|
|
//lockID 40
|
|
final int ssidLength = utf8.encode(lockID!).length;
|
|
subData.addAll(utf8.encode(lockID!));
|
|
subData = getFixedLengthList(subData, 40 - ssidLength);
|
|
|
|
//userID 20
|
|
final int passwordLength = utf8.encode(userID!).length;
|
|
subData.addAll(utf8.encode(userID!));
|
|
subData = getFixedLengthList(subData, 20 - passwordLength);
|
|
|
|
data.addAll(subData);
|
|
|
|
printLog(data);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class GatewayGetStatusReply extends Reply {
|
|
GatewayGetStatusReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
: super.parseData(commandType, dataDetail) {
|
|
data = dataDetail;
|
|
final int status = data[2];
|
|
errorWithStstus(status);
|
|
}
|
|
}
|