2021-11-12 16:27:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
********************************************************************
|
|
|
|
|
|
* @file test_upgrade_platform_opt.c
|
2022-01-12 21:44:58 +08:00
|
|
|
|
* @version V1.0.0
|
|
|
|
|
|
* @date 2019/01/01
|
2021-11-12 16:27:03 +08:00
|
|
|
|
* @brief
|
|
|
|
|
|
*
|
2022-01-12 21:44:58 +08:00
|
|
|
|
* @copyright (c) 2017-2018 DJI. All rights reserved.
|
2021-11-12 16:27:03 +08:00
|
|
|
|
*
|
|
|
|
|
|
* All information contained herein is, and remains, the property of DJI.
|
|
|
|
|
|
* The intellectual and technical concepts contained herein are proprietary
|
|
|
|
|
|
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
|
|
|
|
|
* and protected by trade secret or copyright law. Dissemination of this
|
|
|
|
|
|
* information, including but not limited to data and other proprietary
|
|
|
|
|
|
* material(s) incorporated within the information, in any form, is strictly
|
|
|
|
|
|
* prohibited without the express written consent of DJI.
|
|
|
|
|
|
*
|
|
|
|
|
|
* If you receive this source code without DJI’s authorization, you may not
|
|
|
|
|
|
* further disseminate the information, and you must immediately remove the
|
|
|
|
|
|
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
|
|
|
|
|
* legal actions against you for any loss(es) or damage(s) caused by your
|
|
|
|
|
|
* failure to do so.
|
|
|
|
|
|
*
|
|
|
|
|
|
*********************************************************************
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
|
|
#include "test_upgrade_platform_opt.h"
|
2022-01-12 21:44:58 +08:00
|
|
|
|
#include <psdk_logger.h>
|
2021-11-12 16:27:03 +08:00
|
|
|
|
|
|
|
|
|
|
/* Private constants ---------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Private types -------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Private values -------------------------------------------------------------*/
|
2022-01-12 21:44:58 +08:00
|
|
|
|
static T_PsdkTestUpgradePlatformOpt s_upgradePlatformOpt = {0};
|
2021-11-12 16:27:03 +08:00
|
|
|
|
|
|
|
|
|
|
/* Private functions declaration ---------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported functions definition ---------------------------------------------*/
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_RegUpgradePlatformOpt(const T_PsdkTestUpgradePlatformOpt *upgradePlatformOpt)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (upgradePlatformOpt->rebootSystem == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("rebootSystem callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->cleanUpgradeProgramFileStoreArea == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("cleanUpgradeProgramFileStoreArea callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->createUpgradeProgramFile == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("createUpgradeProgramFile callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->readUpgradeProgramFile == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("readUpgradeProgramFile callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->writeUpgradeProgramFile == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("writeUpgradeProgramFile callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->closeUpgradeProgramFile == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("closeUpgradeProgramFile callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->replaceOldProgram == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("replaceOldProgram callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->setUpgradeRebootState == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("setUpgradeRebootState callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->getUpgradeRebootState == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("getUpgradeRebootState callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (upgradePlatformOpt->cleanUpgradeRebootState == NULL) {
|
2022-01-12 21:44:58 +08:00
|
|
|
|
PsdkLogger_UserLogError("cleanUpgradeRebootState callback can't be NULL");
|
|
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s_upgradePlatformOpt = *upgradePlatformOpt;
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
2021-11-12 16:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_RebootSystem(void)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.rebootSystem();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_CleanUpgradeProgramFileStoreArea(void)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.cleanUpgradeProgramFileStoreArea();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_CreateUpgradeProgramFile(const T_PsdkUpgradeFileInfo *fileInfo)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.createUpgradeProgramFile(fileInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_WriteUpgradeProgramFile(uint32_t offset, const uint8_t *data, uint16_t dataLen)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.writeUpgradeProgramFile(offset, data, dataLen);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_ReadUpgradeProgramFile(uint32_t offset, uint16_t readDataLen, uint8_t *data,
|
2021-11-12 16:27:03 +08:00
|
|
|
|
uint16_t *realLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.readUpgradeProgramFile(offset, readDataLen, data, realLen);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_CloseUpgradeProgramFile(void)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.closeUpgradeProgramFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_ReplaceOldProgram(void)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.replaceOldProgram();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_SetUpgradeRebootState(const T_PsdkUpgradeEndInfo *upgradeEndInfo)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.setUpgradeRebootState(upgradeEndInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_GetUpgradeRebootState(bool *isUpgradeReboot, T_PsdkUpgradeEndInfo *upgradeEndInfo)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.getUpgradeRebootState(isUpgradeReboot, upgradeEndInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-12 21:44:58 +08:00
|
|
|
|
T_PsdkReturnCode PsdkTest_CleanUpgradeRebootState(void)
|
2021-11-12 16:27:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
return s_upgradePlatformOpt.cleanUpgradeRebootState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|