feat: add bootloader DFU protocol validation
This commit is contained in:
@ -1,21 +1,29 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
class DfuV1FirmwareMetadata {
|
||||
const DfuV1FirmwareMetadata({
|
||||
class BootloaderDfuFirmwareMetadata {
|
||||
const BootloaderDfuFirmwareMetadata({
|
||||
required this.totalLength,
|
||||
required this.crc32,
|
||||
required this.appStart,
|
||||
required this.imageVersion,
|
||||
required this.sessionId,
|
||||
required this.flags,
|
||||
required this.vectorStackPointer,
|
||||
required this.vectorReset,
|
||||
});
|
||||
|
||||
final int totalLength;
|
||||
final int crc32;
|
||||
final int appStart;
|
||||
final int imageVersion;
|
||||
final int sessionId;
|
||||
final int flags;
|
||||
final int vectorStackPointer;
|
||||
final int vectorReset;
|
||||
}
|
||||
|
||||
class DfuV1PreparedFirmware {
|
||||
const DfuV1PreparedFirmware({
|
||||
class BootloaderDfuPreparedFirmware {
|
||||
const BootloaderDfuPreparedFirmware({
|
||||
required this.fileName,
|
||||
required this.fileBytes,
|
||||
required this.metadata,
|
||||
@ -25,7 +33,7 @@ class DfuV1PreparedFirmware {
|
||||
final String fileName;
|
||||
final String? filePath;
|
||||
final Uint8List fileBytes;
|
||||
final DfuV1FirmwareMetadata metadata;
|
||||
final BootloaderDfuFirmwareMetadata metadata;
|
||||
}
|
||||
|
||||
enum FirmwareSelectionFailureReason {
|
||||
@ -33,6 +41,9 @@ enum FirmwareSelectionFailureReason {
|
||||
malformedSelection,
|
||||
unsupportedExtension,
|
||||
emptyFile,
|
||||
imageTooSmall,
|
||||
imageTooLarge,
|
||||
invalidVectorTable,
|
||||
readFailed,
|
||||
}
|
||||
|
||||
@ -52,7 +63,7 @@ class FirmwareFileSelectionResult {
|
||||
this.failure,
|
||||
});
|
||||
|
||||
final DfuV1PreparedFirmware? firmware;
|
||||
final BootloaderDfuPreparedFirmware? firmware;
|
||||
final FirmwareSelectionFailure? failure;
|
||||
|
||||
bool get isSuccess => firmware != null;
|
||||
@ -60,7 +71,8 @@ class FirmwareFileSelectionResult {
|
||||
bool get isCanceled =>
|
||||
failure?.reason == FirmwareSelectionFailureReason.canceled;
|
||||
|
||||
static FirmwareFileSelectionResult success(DfuV1PreparedFirmware firmware) {
|
||||
static FirmwareFileSelectionResult success(
|
||||
BootloaderDfuPreparedFirmware firmware) {
|
||||
return FirmwareFileSelectionResult._(firmware: firmware);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user