fix: 暂缓,改为sdk接入开发
This commit is contained in:
parent
b21fd12ca7
commit
59b972f864
@ -650,38 +650,38 @@ class BleService {
|
||||
|
||||
// 9. 检查是否需要重发(通用重发机制)
|
||||
// 只对实现了RetryableBleCommand接口的命令进行重发检查
|
||||
if (retryCount < maxRetries && command is RetryableBleCommand<T>) {
|
||||
// 明确转换类型以避免静态分析错误
|
||||
final retryableCommand = command as RetryableBleCommand<T>;
|
||||
if (retryableCommand.shouldRetry(response)) {
|
||||
AppLogger.info('🔄 命令${command.runtimeType}需要重发,准备创建重发命令 (重试次数: ${retryCount + 1}/${maxRetries})');
|
||||
|
||||
try {
|
||||
// 创建重发命令
|
||||
BaseBleCommand<T> retryCommand = retryableCommand.createRetryCommand(response);
|
||||
|
||||
// 重新发送命令,传递现有的命令键以确保响应正确处理
|
||||
AppLogger.info('🔄 使用重发机制重新发送命令');
|
||||
return await sendCommand<T>(
|
||||
command: retryCommand,
|
||||
targetDeviceId: targetDeviceId,
|
||||
targetDeviceName: targetDeviceName,
|
||||
timeout: timeout,
|
||||
autoConnectIfNeeded: true,
|
||||
// 重发时也需要自动连接
|
||||
maxRetries: maxRetries,
|
||||
retryCount: retryCount + 1,
|
||||
// 增加重试次数
|
||||
existingCommandKey: commandKey, // 传递现有的命令键
|
||||
);
|
||||
} catch (retryError, retryStackTrace) {
|
||||
AppLogger.error('❌ 创建或发送重发命令失败', error: retryError, stackTrace: retryStackTrace);
|
||||
// 如果创建重发命令失败,返回原始响应
|
||||
AppLogger.highlight('✨✨✨ ✅ 命令发送完成,收到应答: $response ✨✨✨');
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (retryCount < maxRetries && command is RetryableBleCommand<T>) {
|
||||
// // 明确转换类型以避免静态分析错误
|
||||
// final retryableCommand = command as RetryableBleCommand<T>;
|
||||
// if (retryableCommand.shouldRetry(response)) {
|
||||
// AppLogger.info('🔄 命令${command.runtimeType}需要重发,准备创建重发命令 (重试次数: ${retryCount + 1}/${maxRetries})');
|
||||
//
|
||||
// try {
|
||||
// // 创建重发命令
|
||||
// BaseBleCommand<T> retryCommand = retryableCommand.createRetryCommand(response);
|
||||
//
|
||||
// // 重新发送命令,传递现有的命令键以确保响应正确处理
|
||||
// AppLogger.info('🔄 使用重发机制重新发送命令');
|
||||
// return await sendCommand<T>(
|
||||
// command: retryCommand,
|
||||
// targetDeviceId: targetDeviceId,
|
||||
// targetDeviceName: targetDeviceName,
|
||||
// timeout: timeout,
|
||||
// autoConnectIfNeeded: true,
|
||||
// // 重发时也需要自动连接
|
||||
// maxRetries: maxRetries,
|
||||
// retryCount: retryCount + 1,
|
||||
// // 增加重试次数
|
||||
// existingCommandKey: commandKey, // 传递现有的命令键
|
||||
// );
|
||||
// } catch (retryError, retryStackTrace) {
|
||||
// AppLogger.error('❌ 创建或发送重发命令失败', error: retryError, stackTrace: retryStackTrace);
|
||||
// // 如果创建重发命令失败,返回原始响应
|
||||
// AppLogger.highlight('✨✨✨ ✅ 命令发送完成,收到应答: $response ✨✨✨');
|
||||
// return response;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
AppLogger.highlight('✨✨✨ ✅ 命令发送成功,收到应答: $response ✨✨✨');
|
||||
return response;
|
||||
|
||||
@ -3,14 +3,13 @@ import 'dart:convert';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:starwork_flutter/base/app_logger.dart';
|
||||
import 'package:starwork_flutter/ble/command/base/base_ble_command.dart';
|
||||
import 'package:starwork_flutter/ble/command/base/retryable_ble_command.dart';
|
||||
import 'package:starwork_flutter/ble/command/response/ble_cmd_get_private_key_parser.dart';
|
||||
import 'package:starwork_flutter/ble/command/response/model/ble_add_admin_response.dart';
|
||||
import 'package:starwork_flutter/ble/constant/lock_ble_constant.dart';
|
||||
import 'package:starwork_flutter/common/sm4_encipher/sm4.dart';
|
||||
|
||||
/// ✨✨✨ 增加超级管理员命令类 - 继承BaseBleCommand ✨✨✨
|
||||
class BleCmdAddAdmin extends BaseBleCommand<BleAddAdminResponse> implements RetryableBleCommand<BleAddAdminResponse> {
|
||||
class BleCmdAddAdmin extends BaseBleCommand<BleAddAdminResponse> {
|
||||
final String lockId;
|
||||
final String authUserId;
|
||||
final String keyId;
|
||||
@ -218,7 +217,8 @@ class BleCmdAddAdmin extends BaseBleCommand<BleAddAdminResponse> implements Retr
|
||||
endMin: this.endMin,
|
||||
role: this.role,
|
||||
password: this.password,
|
||||
token: token, // 使用从响应中获取的有效token
|
||||
token: token,
|
||||
// 使用从响应中获取的有效token
|
||||
publicKey: this.publicKey,
|
||||
privateKey: this.privateKey,
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user