初步完成软件升级,模块升级,设备重置功能

This commit is contained in:
zyj 2023-10-26 14:39:53 +08:00
parent 3468be7600
commit 0c3672cafa
5 changed files with 120 additions and 5 deletions

View File

@ -1,4 +1,5 @@
#include "PrjInc.h"
#include "sf_param_common.h"
#include "sys_mempool.h"
#include "Dx.h"
#include "FileDB.h"
@ -94,6 +95,9 @@ static UINT32 BackgroundEthCamCheckPortReady(void);
static UINT32 BackgroundEthCamUpdateUIInfo(void);
static UINT32 BackgroundEthCamIperfTest(void);
#endif
static UINT32 BackgroundCameraFWUpgrade(void);
static UINT32 BackgroundModuleFWUpgrade(void);
static UINT32 BackgroundReset(void);
static UINT32 g_uiDpofOPMode = PLAYDPOF_SETONE;
static UINT32 g_uiDpofPrtNum = 0;
@ -187,6 +191,9 @@ BKG_JOB_ENTRY gBackgroundExtFuncTable[] = {
#endif
{NVTEVT_BKW_CAMERA_FW_UPGRADE, BackgroundCameraFWUpgrade},
{NVTEVT_BKW_MODULE_FW_UPGRADE, BackgroundModuleFWUpgrade},
{NVTEVT_BKW_RESET, BackgroundReset},
{0, 0},
};
@ -1896,6 +1903,26 @@ static UINT32 BackgroundEthCamIperfTest(void)
#endif
UINT32 BackgroundCameraFWUpgrade(void)
{
sf_do_upgrade_thread();
return TRUE;
}
UINT32 BackgroundModuleFWUpgrade(void)
{
sf_set_module_update(1);
return TRUE;
}
UINT32 BackgroundReset(void)
{
Reset_MenuInfo();
sf_sleep_ms(500);
Ux_PostEvent(NVTEVT_SYSTEM_SHUTDOWN, 1, APP_POWER_OFF_NORMAL);
return TRUE;
}
void AppBKW_SetData(BKW_DATA_SET attribute, UINT32 value)
{
switch (attribute) {

View File

@ -47,6 +47,10 @@ typedef enum {
NVTEVT_BKW_ETHCAM_UPDATE_UI,
NVTEVT_BKW_ETHCAM_IPERF_TEST,
NVTEVT_BKW_CAMERA_FW_UPGRADE,
NVTEVT_BKW_MODULE_FW_UPGRADE,
NVTEVT_BKW_RESET,
NVTEVT_BKW_END,
} NVT_BKW_CMD;
#define PLAYDPOF_SETONE 0x00000002

View File

@ -5,6 +5,7 @@
#include "UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h"
#include <kwrap/debug.h>
#include "sf_sd_common.h"
#include "sf_common.h"
static UINT32 gBKGEvt = 0;
static UINT32 gExeEvt = 0;
@ -105,6 +106,22 @@ void UIFlowMenuCommonConfirmAPI_Open(uint32_t itemID)
case IDM_DELETE_THIS:
strID = LV_PLUGIN_STRING_ID_STRID_ERASE_THIS;
break;
case IDM_FORMAT_SD:
strID = LV_PLUGIN_STRING_ID_STRING_FORMAT_SD;
gBKGEvt = NVTEVT_BKW_FORMAT_CARD;
break;
case IDM_CAMERA_FW_UPGRADE:
strID = LV_PLUGIN_STRING_ID_STRING_CAMERA_FW_UPGRADE;
gBKGEvt = NVTEVT_BKW_CAMERA_FW_UPGRADE;
break;
case IDM_MODULE_FW_UPGRADE:
strID = LV_PLUGIN_STRING_ID_STRING_MODE_FW_UPGRADE;
gBKGEvt = NVTEVT_BKW_MODULE_FW_UPGRADE;
break;
case IDM_RESET:
strID = LV_PLUGIN_STRING_ID_STRING_RESET_WARNING;
gBKGEvt = NVTEVT_BKW_RESET;
break;
default:
gBKGEvt = 0;
DBG_ERR("error itemID %d\r\n", gItemID);
@ -114,6 +131,15 @@ void UIFlowMenuCommonConfirmAPI_Open(uint32_t itemID)
/* set text by string id */
lv_plugin_msgbox_set_text(msgbox, strID);
// if(gItemID == IDM_RESET)
// {
// const lv_plugin_string_t* tmpstr1 = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRING_RESET_WARNING);
// const lv_plugin_string_t* tmpstr2 = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRING_RESET_RESTART);
// printf("%s\n%s",tmpstr1->ptr,tmpstr2->ptr);
// lv_msgbox_set_text_fmt(msgbox, "%s\n%s",tmpstr1->ptr,tmpstr2->ptr);
// }
/* update font of message part */
lv_plugin_msgbox_update_font(msgbox, LV_MSGBOX_PART_BG);
@ -178,7 +204,7 @@ void UIFlowMenuCommonConfirm_OnChildScrClose(lv_obj_t* obj, const LV_USER_EVENT_
const char* erase_text = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRID_ERASE_THIS)->ptr;
if(msg->event == NVTRET_WAITMOMENT ||
msg->event == NVTRET_FORMAT ||
msg->event == NVTRET_ENTER_MENU ||
strcmp(msgbox_text, erase_text) == 0)
{
UIFlowMenuCommonConfirm_CloseScr();
@ -273,6 +299,34 @@ static void UIFlowMenuCommonConfirm_MessageBox_ValueChanged(lv_obj_t* obj, uint3
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_NO_SD, 3000);
}
} else if (gBKGEvt == NVTEVT_BKW_CAMERA_FW_UPGRADE) {
if(sf_cardv_battery_value_get() < 40)
{
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_UPGRADE_ERR, 3000);
}
else
{
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_UPGRADING, 60000);
BKG_PostEvent(gBKGEvt);
}
} else if (gBKGEvt == NVTEVT_BKW_MODULE_FW_UPGRADE) {
if(sf_cardv_battery_value_get() < 40)
{
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_UPGRADE_LOWBAT, 3000);
}
else
{
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_UPGRADING, 60000);
BKG_PostEvent(gBKGEvt);
}
} else if (gBKGEvt == NVTEVT_BKW_RESET) {
lv_obj_set_hidden(msgbox, true);
UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRING_COMPLETED, 10000);
BKG_PostEvent(gBKGEvt);
} else if (gBKGEvt) {
DBG_FUNC("gBKGEvt=%d\r\n",gBKGEvt);
lv_plugin_scr_open(wait_moment_scr, &string_id_please_wait);

View File

@ -146,7 +146,7 @@ static int is_message_item(lv_obj_t* obj)
case IDM_FORMAT_SD:
{
printf("[is_message_item]IDM_FORMAT_SD\n");
UIFlowMenuCommonConfirmAPI_Open(IDM_FORMAT);
UIFlowMenuCommonConfirmAPI_Open(itemID);
return MESSAGE_ITEM_TRUE;
}
case IDM_DATE_AND_TIME:
@ -158,6 +158,15 @@ static int is_message_item(lv_obj_t* obj)
case IDM_CHECK_IN_PHOTO:
case IDM_GPS:
break;
case IDM_BATTERY_TYPE:
case IDM_SD_LOOP:
break;
case IDM_CAMERA_FW_UPGRADE:
case IDM_MODULE_FW_UPGRADE:
case IDM_RESET:
UIFlowMenuCommonConfirmAPI_Open(itemID);
return MESSAGE_ITEM_TRUE;
default:
break;
}
@ -648,7 +657,10 @@ static void UIFlowMenuCommonOption_ChildScrClose(lv_obj_t* obj)
pItem = &pPage->pItems[pPage->SelItem];
UINT16 itemID = pItem->ItemId;
if(itemID == IDM_FORMAT_SD)
if(itemID == IDM_FORMAT_SD ||
itemID == IDM_CAMERA_FW_UPGRADE ||
itemID == IDM_MODULE_FW_UPGRADE ||
itemID == IDM_RESET)
{
lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0));
}

View File

@ -3,6 +3,7 @@
#include "UIFlowLVGL/UIFlowLVGL.h"
#include <kwrap/debug.h>
#include "sf_sd_common.h"
#include "sf_commu_mcu_reg.h"
/**************************************************************
* static variables
@ -91,6 +92,14 @@ void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_time
lv_plugin_msgbox_set_text(msgbox, id);
}
// if(LV_PLUGIN_STRING_ID_STRING_UPGRADING == msgID)
// {
// const lv_plugin_string_t* tmpstr1 = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRING_UPGRADING);
// const lv_plugin_string_t* tmpstr2 = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRING_UPGRADE_WARNING);
// printf("%s\n%s",tmpstr1->ptr,tmpstr2->ptr);
// lv_msgbox_set_text_fmt(msgbox, "%s\n%s",tmpstr1->ptr,tmpstr2->ptr);
// }
/* add button */
// btn_map[0] = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRID_OK)->ptr;
// lv_msgbox_add_btns(msgbox, btn_map);
@ -137,6 +146,7 @@ static void UIFlowWrnMsg_OnNVTMSG(lv_obj_t* obj, const LV_USER_EVENT_NVTMSG_DATA
{
case NVTEVT_BKW_FORMAT_CARD:
{
int ret = sf_get_card_statu();
if(ret == CMD_FORMAT_SD_OK)
{
@ -150,6 +160,13 @@ static void UIFlowWrnMsg_OnNVTMSG(lv_obj_t* obj, const LV_USER_EVENT_NVTMSG_DATA
printf("[%s]start auto close 3000ms", __FUNCTION__);
break;
}
case NVTEVT_BKW_CAMERA_FW_UPGRADE:
case NVTEVT_BKW_MODULE_FW_UPGRADE:
case NVTEVT_BKW_RESET:
{
break;
}
default:
break;
}
@ -262,9 +279,10 @@ void message_box_wrnmsg_event_callback(lv_obj_t* obj, lv_event_t event)
/* reset pointer of msgbox */
msgbox = NULL;
if(msgID == LV_PLUGIN_STRING_ID_STRING_NO_SD || msgID == LV_PLUGIN_STRING_ID_STRING_FORMATING)
if(msgID == LV_PLUGIN_STRING_ID_STRING_NO_SD ||
msgID == LV_PLUGIN_STRING_ID_STRING_FORMATING)
{
evt = NVTRET_FORMAT;
evt = NVTRET_ENTER_MENU;
}
/* parent is UIFlowWrnMsg */