fix: 完善读取锁状态接口
This commit is contained in:
parent
e07e30f598
commit
730cb9c5bb
@ -142,4 +142,12 @@ abstract class BaseBleResponseParser {
|
||||
uniqueList.reversed;
|
||||
return utf8.decode(uniqueList).toString();
|
||||
}
|
||||
|
||||
String asciiString(List<int> codeUnits) {
|
||||
String result = '';
|
||||
for (final int value in codeUnits) {
|
||||
result += String.fromCharCode(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,13 @@ class ReadLockStatusResponse {
|
||||
final int indate; // 有效时间(UNIX 时间戳)
|
||||
final String mac; // 蓝牙 MAC 地址
|
||||
final int featureValueLength; // 特征值字符串长度
|
||||
final List<int> featureValue; // 特征值
|
||||
final String featureValueHexStr; // 特征值16进制字符串
|
||||
final int featureEnValLength; // 启用功能长度
|
||||
final List<int> featureEnVal; // 启用功能
|
||||
final String featureEnValHexStr; // 启用功能16进制字符串
|
||||
final int featureParaTotal; // 支持的带参数特征值的总条目数
|
||||
final List<int> featureParaData; // 对应特征值的参数,从FeatureParaTotal开始,按照协议文档循环
|
||||
|
||||
ReadLockStatusResponse({
|
||||
required this.commandId,
|
||||
@ -45,6 +52,13 @@ class ReadLockStatusResponse {
|
||||
required this.indate,
|
||||
required this.mac,
|
||||
required this.featureValueLength,
|
||||
required this.featureValue,
|
||||
required this.featureValueHexStr,
|
||||
required this.featureEnValLength,
|
||||
required this.featureEnVal,
|
||||
required this.featureEnValHexStr,
|
||||
required this.featureParaTotal,
|
||||
required this.featureParaData,
|
||||
});
|
||||
|
||||
/// 是否成功
|
||||
@ -88,7 +102,13 @@ class ReadLockStatusResponse {
|
||||
'icPartNo: $icPartNo, '
|
||||
'indate: $indate (${DateTime.fromMillisecondsSinceEpoch(indate * 1000, isUtc: true)}), '
|
||||
'mac: $mac, '
|
||||
'featureValueLength: $featureValueLength)';
|
||||
'featureValueLength: $featureValueLength,'
|
||||
'featureValueHexStr: $featureValueHexStr,'
|
||||
'featureEnValLength: $featureEnValLength,'
|
||||
'featureEnValHexStr: $featureEnValHexStr,'
|
||||
'featureParaTotal: $featureParaTotal,'
|
||||
'featureParaData: $featureParaData'
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +157,13 @@ class BleCmdReadLockStatusParser extends BaseBleResponseParser {
|
||||
indate: 0,
|
||||
mac: '',
|
||||
featureValueLength: 0,
|
||||
featureValue: [],
|
||||
featureEnValLength: 0,
|
||||
featureValueHexStr: '',
|
||||
featureEnVal: [],
|
||||
featureEnValHexStr: '',
|
||||
featureParaTotal: -1,
|
||||
featureParaData: [],
|
||||
);
|
||||
}
|
||||
|
||||
@ -208,6 +235,26 @@ class BleCmdReadLockStatusParser extends BaseBleResponseParser {
|
||||
|
||||
// 18. 特征值长度 (1 byte)
|
||||
int featureValueLength = rawResponseData[offset++];
|
||||
|
||||
// 19. 锁特征值说明(本机能支持的功能)
|
||||
List<int> featureValue = BaseBleResponseParser.extractBytes(rawResponseData, offset, featureValueLength);
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
offset += featureValueLength;
|
||||
|
||||
// 20. 启用功能长度
|
||||
int featureEnValLength = rawResponseData[offset++];
|
||||
|
||||
// 21. 启用功能说明(本机启用的功能)
|
||||
List<int> featureEnVal = BaseBleResponseParser.extractBytes(rawResponseData, offset, featureEnValLength);
|
||||
String featureEnValStr = asciiString(featureValue);
|
||||
offset += featureEnValLength;
|
||||
|
||||
// 22. 支持的带参数特征值的总条目数
|
||||
int featureParaTotal = rawResponseData[offset++];
|
||||
|
||||
// 23. 支持特征值的参数设置
|
||||
List<int> featureParaData = rawResponseData.sublist(offset);
|
||||
|
||||
// ✅ 构造完整对象
|
||||
return ReadLockStatusResponse(
|
||||
commandId: commandId,
|
||||
@ -230,6 +277,13 @@ class BleCmdReadLockStatusParser extends BaseBleResponseParser {
|
||||
// 注意:UNIX 秒时间戳
|
||||
mac: mac,
|
||||
featureValueLength: featureValueLength,
|
||||
featureValue: featureValue,
|
||||
featureValueHexStr: featureValueStr,
|
||||
featureEnValLength: featureEnValLength,
|
||||
featureEnVal: featureEnVal,
|
||||
featureEnValHexStr: featureEnValStr,
|
||||
featureParaTotal: featureParaTotal,
|
||||
featureParaData: featureParaData,
|
||||
);
|
||||
} catch (e) {
|
||||
AppLogger.error('❌ 解析获取公钥应答数据异常', error: e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user