2022-04-13 23:50:25 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <m-string.h>
|
|
|
|
#include <storage/storage.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-05-06 19:26:25 +03:00
|
|
|
#define UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC 0
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
/*
|
|
|
|
* Checks if supplied full manifest path is valid
|
|
|
|
* @param full_path Full path to manifest file. Must be named UPDATE_MANIFEST_DEFAULT_NAME
|
|
|
|
* @param out_manifest_dir Directory to apply update from, if supplied path is valid.
|
|
|
|
* May be empty if update is in root update directory
|
|
|
|
* @return bool if supplied path is valid and out_manifest_dir contains dir to apply
|
|
|
|
*/
|
|
|
|
bool update_operation_get_package_dir_name(const char* full_path, string_t out_manifest_dir);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UpdatePrepareResultOK,
|
|
|
|
UpdatePrepareResultManifestPathInvalid,
|
|
|
|
UpdatePrepareResultManifestFolderNotFound,
|
|
|
|
UpdatePrepareResultManifestInvalid,
|
|
|
|
UpdatePrepareResultStageMissing,
|
|
|
|
UpdatePrepareResultStageIntegrityError,
|
|
|
|
} UpdatePrepareResult;
|
|
|
|
|
|
|
|
const char* update_operation_describe_preparation_result(const UpdatePrepareResult value);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validates next stage and sets up registers to apply update after restart
|
|
|
|
* @param manifest_dir_path Full path to manifest for update to apply
|
|
|
|
* @return UpdatePrepareResult validation & arm result
|
|
|
|
*/
|
|
|
|
UpdatePrepareResult update_operation_prepare(const char* manifest_file_path);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets update package index to pass in RTC registers
|
|
|
|
* @param storage Storage API
|
|
|
|
* @param update_package_dir Package directory name
|
2022-05-06 19:26:25 +03:00
|
|
|
* @return int32_t <=0 - error, >0 - update index value
|
2022-04-13 23:50:25 +03:00
|
|
|
*/
|
|
|
|
int32_t update_operation_get_package_index(Storage* storage, const char* update_package_dir);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets filesystem path for current update package
|
|
|
|
* @param storage Storage API
|
|
|
|
* @param out_path Path to directory with manifest & related files. Must be initialized
|
|
|
|
* @return true if path was restored successfully
|
|
|
|
*/
|
|
|
|
bool update_operation_get_current_package_path(Storage* storage, string_t out_path);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stores given update index in RTC registers
|
|
|
|
* @param index Value to store
|
|
|
|
*/
|
2022-05-06 19:26:25 +03:00
|
|
|
void update_operation_persist_package_index(int32_t index);
|
2022-04-13 23:50:25 +03:00
|
|
|
|
|
|
|
/*
|
2022-05-06 19:26:25 +03:00
|
|
|
* Checks if an update operation step is pending after reset
|
2022-04-13 23:50:25 +03:00
|
|
|
*/
|
|
|
|
bool update_operation_is_armed();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cancels pending update operation
|
|
|
|
*/
|
|
|
|
void update_operation_disarm();
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2022-05-06 16:37:10 +03:00
|
|
|
#endif
|