feat: fw-update recovery flow
This commit is contained in:
@ -11,6 +11,7 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'
|
||||
class FirmwareUpdateService {
|
||||
FirmwareUpdateService({
|
||||
required FirmwareUpdateTransport transport,
|
||||
this.verifyAfterFinish = true,
|
||||
this.defaultStatusTimeout = const Duration(seconds: 2),
|
||||
this.defaultBootloaderConnectTimeout = const Duration(seconds: 60),
|
||||
this.defaultPostFinishResetTimeout = const Duration(seconds: 8),
|
||||
@ -22,6 +23,7 @@ class FirmwareUpdateService {
|
||||
}) : _transport = transport;
|
||||
|
||||
final FirmwareUpdateTransport _transport;
|
||||
final bool verifyAfterFinish;
|
||||
final Duration defaultStatusTimeout;
|
||||
final Duration defaultBootloaderConnectTimeout;
|
||||
final Duration defaultPostFinishResetTimeout;
|
||||
@ -220,6 +222,15 @@ class FirmwareUpdateService {
|
||||
);
|
||||
}
|
||||
|
||||
if (!verifyAfterFinish) {
|
||||
_emitProgress(
|
||||
state: DfuUpdateState.completed,
|
||||
sentBytes: imageBytes.length,
|
||||
expectedOffset: imageBytes.length,
|
||||
);
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
_emitProgress(state: DfuUpdateState.verifying);
|
||||
final reconnectResult = await _transport.reconnectForVerification(
|
||||
timeout: effectiveReconnectTimeout,
|
||||
@ -831,6 +842,14 @@ class ShifterFirmwareUpdateTransport implements FirmwareUpdateTransport {
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
if (shifterService == null) {
|
||||
_bootloaderDeviceId = buttonDeviceId;
|
||||
return bluetoothController.connectById(
|
||||
buttonDeviceId,
|
||||
timeout: timeout,
|
||||
);
|
||||
}
|
||||
|
||||
final scanResult = await _scanForBootloader(timeout: timeout);
|
||||
if (scanResult.isErr()) {
|
||||
return Err(scanResult.unwrapErr());
|
||||
|
||||
Reference in New Issue
Block a user