split firmware flashing from lwp3-bootloader

BLE won't always be the only way to flash firmware
This commit is contained in:
David Lechner
2020-06-09 23:51:32 -05:00
committed by David Lechner
parent 6d81da0df0
commit 07d0b5ef39
8 changed files with 376 additions and 371 deletions
-57
View File
@@ -463,60 +463,3 @@ export type BootloaderResponseAction =
| BootloaderChecksumResponseAction
| BootloaderStateResponseAction
| BootloaderErrorResponseAction;
/**
* High-level bootloader actions.
*/
export enum BootloaderActionType {
/**
* Flash new firmware to the device.
*/
FlashFirmware = 'bootloader.action.flash',
/**
* Firmware flash progress.
*/
FlashProgress = 'bootloader.action.flash.progress',
}
/**
* Action that flashes firmware to a hub.
*/
export interface BootloaderFlashFirmwareAction
extends Action<BootloaderActionType.FlashFirmware> {
/** The firmware zip file data or undefined to get firmware later. */
data?: ArrayBuffer;
}
/**
* Creates a new action to flash firmware to a hub.
* @param data The firmware zip file data or undefined to get firmware later.
*/
export function flashFirmware(data?: ArrayBuffer): BootloaderFlashFirmwareAction {
return { type: BootloaderActionType.FlashFirmware, data };
}
export interface BootloaderFlashProgressAction
extends Action<BootloaderActionType.FlashProgress> {
/**
* The number of bytes that have been flashed so far.
*/
complete: number;
/**
* The total number of bytes to be flashed.
*/
total: number;
}
export function progress(
complete: number,
total: number,
): BootloaderFlashProgressAction {
return { type: BootloaderActionType.FlashProgress, complete, total };
}
/**
* Common type for all high-level bootloader actions.
*/
export type BootloaderAction =
| BootloaderFlashFirmwareAction
| BootloaderFlashProgressAction;