2022-04-13 20:50:25 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <update_util/update_manifest.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2024-07-15 04:38:49 +00:00
|
|
|
#define UPDATE_DELAY_OPERATION_OK 10
|
2022-04-13 20:50:25 +00:00
|
|
|
#define UPDATE_DELAY_OPERATION_ERROR INT_MAX
|
|
|
|
|
|
|
|
typedef enum {
|
2022-05-06 16:26:25 +00:00
|
|
|
UpdateTaskStageProgress = 0,
|
|
|
|
|
2022-04-13 20:50:25 +00:00
|
|
|
UpdateTaskStageReadManifest,
|
2022-05-06 16:26:25 +00:00
|
|
|
UpdateTaskStageLfsBackup,
|
|
|
|
|
2022-04-27 15:53:48 +00:00
|
|
|
UpdateTaskStageRadioImageValidate,
|
|
|
|
UpdateTaskStageRadioErase,
|
2022-04-13 20:50:25 +00:00
|
|
|
UpdateTaskStageRadioWrite,
|
2022-04-27 15:53:48 +00:00
|
|
|
UpdateTaskStageRadioInstall,
|
|
|
|
UpdateTaskStageRadioBusy,
|
2022-05-06 16:26:25 +00:00
|
|
|
|
2022-04-27 15:53:48 +00:00
|
|
|
UpdateTaskStageOBValidation,
|
2022-05-06 16:26:25 +00:00
|
|
|
|
|
|
|
UpdateTaskStageValidateDFUImage,
|
|
|
|
UpdateTaskStageFlashWrite,
|
|
|
|
UpdateTaskStageFlashValidate,
|
|
|
|
|
2022-04-13 20:50:25 +00:00
|
|
|
UpdateTaskStageLfsRestore,
|
2024-06-30 10:38:48 +00:00
|
|
|
UpdateTaskStageResourcesFileCleanup,
|
|
|
|
UpdateTaskStageResourcesDirCleanup,
|
|
|
|
UpdateTaskStageResourcesFileUnpack,
|
2022-06-21 14:11:34 +00:00
|
|
|
UpdateTaskStageSplashscreenInstall,
|
2022-05-06 16:26:25 +00:00
|
|
|
|
2022-04-19 08:03:28 +00:00
|
|
|
UpdateTaskStageCompleted,
|
2022-04-13 20:50:25 +00:00
|
|
|
UpdateTaskStageError,
|
2022-05-06 16:26:25 +00:00
|
|
|
UpdateTaskStageOBError,
|
|
|
|
UpdateTaskStageMAX
|
2022-04-13 20:50:25 +00:00
|
|
|
} UpdateTaskStage;
|
|
|
|
|
2022-05-06 16:26:25 +00:00
|
|
|
inline bool update_stage_is_error(const UpdateTaskStage stage) {
|
|
|
|
return stage >= UpdateTaskStageError;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UpdateTaskStageGroupMisc = 0,
|
|
|
|
UpdateTaskStageGroupPreUpdate = 1 << 1,
|
|
|
|
UpdateTaskStageGroupFirmware = 1 << 2,
|
|
|
|
UpdateTaskStageGroupOptionBytes = 1 << 3,
|
|
|
|
UpdateTaskStageGroupRadio = 1 << 4,
|
|
|
|
UpdateTaskStageGroupPostUpdate = 1 << 5,
|
|
|
|
UpdateTaskStageGroupResources = 1 << 6,
|
2022-06-21 14:11:34 +00:00
|
|
|
UpdateTaskStageGroupSplashscreen = 1 << 7,
|
2022-05-06 16:26:25 +00:00
|
|
|
} UpdateTaskStageGroup;
|
|
|
|
|
2022-04-13 20:50:25 +00:00
|
|
|
typedef struct {
|
|
|
|
UpdateTaskStage stage;
|
2022-05-06 16:26:25 +00:00
|
|
|
uint8_t overall_progress, stage_progress;
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* status;
|
2022-05-06 16:26:25 +00:00
|
|
|
UpdateTaskStageGroup groups;
|
|
|
|
uint32_t total_progress_points;
|
|
|
|
uint32_t completed_stages_points;
|
2022-04-13 20:50:25 +00:00
|
|
|
} UpdateTaskState;
|
|
|
|
|
|
|
|
typedef struct UpdateTask UpdateTask;
|
|
|
|
|
2022-05-06 16:26:25 +00:00
|
|
|
typedef void (
|
|
|
|
*updateProgressCb)(const char* status, const uint8_t stage_pct, bool failed, void* state);
|
2022-04-13 20:50:25 +00:00
|
|
|
|
2024-03-19 14:43:52 +00:00
|
|
|
UpdateTask* update_task_alloc(void);
|
2022-04-13 20:50:25 +00:00
|
|
|
|
|
|
|
void update_task_free(UpdateTask* update_task);
|
|
|
|
|
|
|
|
void update_task_set_progress_cb(UpdateTask* update_task, updateProgressCb cb, void* state);
|
|
|
|
|
2022-06-20 14:54:48 +00:00
|
|
|
void update_task_start(UpdateTask* update_task);
|
2022-04-13 20:50:25 +00:00
|
|
|
|
|
|
|
bool update_task_is_running(UpdateTask* update_task);
|
|
|
|
|
|
|
|
UpdateTaskState const* update_task_get_state(UpdateTask* update_task);
|
|
|
|
|
|
|
|
UpdateManifest const* update_task_get_manifest(UpdateTask* update_task);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2022-05-06 13:37:10 +00:00
|
|
|
#endif
|