Skip to main content

Overview

The header file related to local upgrade functionality is uav_upgrade.h. This document describes the key information and usage methods for the structures and function prototypes in the uav_upgrade.h file.

Note:

  • Payload devices developed using PSDK can use uav_upgrade.h.

Table of Contents

  • Macro Definitions, Enumerations, and Structures
    typedef enum E_UAVUpgradeState
    typedef enum E_UAVDigestType
    typedef struct T_UAVModuleInfo
    typedef struct T_UAVUpgradeStatus
    typedef struct T_UAVUpgradeHandler

  • Function Prototypes
    function UAV_Upgrade_FirmwareDownload
    function UAV_Upgrade_FirmwareRequest
    function UAV_Upgrade_FirmwareVerify
    function UAV_Upgrade_FirmwareFinish

Macro Definitions, Enumerations, and Structures

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 Prototypes

function UAV_Upgrade_FirmwareDownload

  • Function: Request to download the corresponding module firmware package.
extern bool UAV_Upgrade_FirmwareDownload(const std::string &model, T_UAVFileDesc &desc);

function UAV_Upgrade_FirmwareRequest

  • Function: Download firmware package data in chunks.
extern bool UAV_Upgrade_FirmwareRequest(int64_t offset, int32_t length, const int msec, std::vector<uint8_t> &data);

function UAV_Upgrade_FirmwareVerify

  • Function: Verify the integrity of the downloaded firmware package file.
extern bool UAV_Upgrade_FirmwareVerify(const E_UAVDigestType type, const std::string &digest, const int msec);

function UAV_Upgrade_FirmwareFinish

  • Function: Notify the counterpart that the upgrade action is completed.
extern bool UAV_Upgrade_FirmwareFinish(const std::string &reason, const int msec);

function UAV_Upgrade_FirmwareCRC32

  • Function: Calculate data CRC32 checksum.
extern T_UAVReturnCode UAV_Upgrade_FirmwareCRC32(const std::string &filename, uint32_t &crc32);