概述
本地升级相关功能的头文件为 uav_upgrade.h
,本文档描述了 uav_upgrade.h
文件中结构体和函数原型的关键信息和使用方法。
说明:
- 使用 PSDK 开发的负载设备可使用
uav_upgrade.h
。
目录
宏定义、枚举与结构体
typedef enum E_UAVUpgradeState
typedef enum E_UAVDigestType
typedef struct T_UAVModuleInfo
typedef struct T_UAVUpgradeStatus
typedef struct T_UAVUpgradeHandler函数原型
function UAV_Upgrade_FirmwareDownload
function UAV_Upgrade_FirmwareRequest
function UAV_Upgrade_FirmwareVerify
function UAV_Upgrade_FirmwareFinish
目宏定义、枚举与结构体
typedef enum E_UAVUpgradeState
typedef enum {
UAV_UPGRADE_STATE_IDLE = 0,
UAV_UPGRADE_STATE_DOING = 1,
UAV_UPGRADE_STATE_FINISH = 2,
UAV_UPGRADE_STATE_FAILED = 3
}E_UAVUpgradeState;
typedef enum E_UAVDigestType
typedef enum {
DIGEST_TYPE_MD5 = 0,
DIGEST_TYPE_SHA1 = 1,
DIGEST_TYPE_CRC32 = 2,
DIGEST_TYPE_SHA224 = 3,
DIGEST_TYPE_SHA256 = 4,
DIGEST_TYPE_SHA384 = 5,
DIGEST_TYPE_SHA512 = 6,
}E_UAVDigestType;
typedef struct T_UAVModuleInfo
typedef struct {
std::string model;
std::string app_version;
std::string boot_version;
std::string hard_version;
}T_UAVModuleInfo;
typedef struct T_UAVUpgradeStatus
typedef struct {
int32_t state;
int32_t progress;
int32_t error_code;
std::string module;
std::string error_desc;
}T_UAVUpgradeStatus;
typedef struct T_UAVUpgradeHandler
typedef struct {
bool (*UAV_Upgrade_GetModuleInfo)(T_UAVModuleInfo &info);
bool (*UAV_Upgrade_ConditionCheck)(void);
int (*UAV_Upgrade_Excute)(bool force, const std::string &model, const std::string &filename);
bool (*UAV_Upgrade_Query)(T_UAVUpgradeStatus &status);
}T_UAVUpgradeHandler;
函数原型
function UAV_Upgrade_FirmwareDownload
- 功能: 请求下载对应的模块固件包。
extern bool UAV_Upgrade_FirmwareDownload(const std::string &model, T_UAVFileDesc &desc);
function UAV_Upgrade_FirmwareRequest
- 功能: 分包下载对应的模块固件包数据。
extern bool UAV_Upgrade_FirmwareRequest(int64_t offset, int32_t length, const int msec, std::vector<uint8_t> &data);
function UAV_Upgrade_FirmwareVerify
- 功能: 下载完成对应的模块固件包文件完整性效验。
extern bool UAV_Upgrade_FirmwareVerify(const E_UAVDigestType type, const std::string &digest, const int msec);
function UAV_Upgrade_FirmwareFinish
- 功能: 通知对端升级动作完成。
extern bool UAV_Upgrade_FirmwareFinish(const std::string &reason, const int msec);
function UAV_Upgrade_FirmwareCRC32
- 功能: 数据 CRC32 校验计算。
extern T_UAVReturnCode UAV_Upgrade_FirmwareCRC32(const std::string &filename, uint32_t &crc32);