2022-04-13 23:50:25 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <update_util/update_manifest.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-09-28 20:13:12 +03:00
|
|
|
#define UPDATE_DELAY_OPERATION_OK 10
|
2022-04-13 23:50:25 +03:00
|
|
|
#define UPDATE_DELAY_OPERATION_ERROR INT_MAX
|
|
|
|
|
|
|
|
typedef enum {
|
2022-05-06 19:26:25 +03:00
|
|
|
UpdateTaskStageProgress = 0,
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
UpdateTaskStageReadManifest,
|
2022-05-06 19:26:25 +03:00
|
|
|
UpdateTaskStageLfsBackup,
|
|
|
|
|
2022-04-27 18:53:48 +03:00
|
|
|
UpdateTaskStageRadioImageValidate,
|
|
|
|
UpdateTaskStageRadioErase,
|
2022-04-13 23:50:25 +03:00
|
|
|
UpdateTaskStageRadioWrite,
|
2022-04-27 18:53:48 +03:00
|
|
|
UpdateTaskStageRadioInstall,
|
|
|
|
UpdateTaskStageRadioBusy,
|
2022-05-06 19:26:25 +03:00
|
|
|
|
2022-04-27 18:53:48 +03:00
|
|
|
UpdateTaskStageOBValidation,
|
2022-05-06 19:26:25 +03:00
|
|
|
|
|
|
|
UpdateTaskStageValidateDFUImage,
|
|
|
|
UpdateTaskStageFlashWrite,
|
|
|
|
UpdateTaskStageFlashValidate,
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
UpdateTaskStageLfsRestore,
|
2022-04-19 22:02:37 +03:00
|
|
|
UpdateTaskStageResourcesUpdate,
|
2022-06-21 17:11:34 +03:00
|
|
|
UpdateTaskStageSplashscreenInstall,
|
2022-05-06 19:26:25 +03:00
|
|
|
|
2022-04-19 11:03:28 +03:00
|
|
|
UpdateTaskStageCompleted,
|
2022-04-13 23:50:25 +03:00
|
|
|
UpdateTaskStageError,
|
2022-05-06 19:26:25 +03:00
|
|
|
UpdateTaskStageOBError,
|
|
|
|
UpdateTaskStageMAX
|
2022-04-13 23:50:25 +03:00
|
|
|
} UpdateTaskStage;
|
|
|
|
|
2022-05-06 19:26:25 +03: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 17:11:34 +03:00
|
|
|
UpdateTaskStageGroupSplashscreen = 1 << 7,
|
2022-05-06 19:26:25 +03:00
|
|
|
} UpdateTaskStageGroup;
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
typedef struct {
|
|
|
|
UpdateTaskStage stage;
|
2022-05-06 19:26:25 +03:00
|
|
|
uint8_t overall_progress, stage_progress;
|
2022-10-05 18:15:23 +03:00
|
|
|
FuriString* status;
|
2022-05-06 19:26:25 +03:00
|
|
|
UpdateTaskStageGroup groups;
|
|
|
|
uint32_t total_progress_points;
|
|
|
|
uint32_t completed_stages_points;
|
2022-04-13 23:50:25 +03:00
|
|
|
} UpdateTaskState;
|
|
|
|
|
|
|
|
typedef struct UpdateTask UpdateTask;
|
|
|
|
|
2022-05-06 19:26:25 +03:00
|
|
|
typedef void (
|
|
|
|
*updateProgressCb)(const char* status, const uint8_t stage_pct, bool failed, void* state);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
|
|
|
UpdateTask* update_task_alloc();
|
|
|
|
|
|
|
|
void update_task_free(UpdateTask* update_task);
|
|
|
|
|
|
|
|
void update_task_set_progress_cb(UpdateTask* update_task, updateProgressCb cb, void* state);
|
|
|
|
|
2022-06-20 17:54:48 +03:00
|
|
|
void update_task_start(UpdateTask* update_task);
|
2022-04-13 23:50:25 +03: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 16:37:10 +03:00
|
|
|
#endif
|