diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.c index 90df5e263..d6d44176b 100644 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.c @@ -303,11 +303,10 @@ static lv_obj_t* pMenu = NULL; static lv_obj_t *plabel = NULL; static int ProfileTotal = 0; static int ProfileSelected = 0; +static int ProfileFocused = 0; static unsigned char ProfileNameList[PROFILE_MAX][PROFILE_NAME_SIZE] = {0}; -//优化需要的点 -//按键加锁 -//回调取消延时 +static int Countdown = 0; static void update_Network_Selection_msg(lv_obj_t* obj) { @@ -317,31 +316,33 @@ static void update_Network_Selection_msg(lv_obj_t* obj) return; } - if(ProfileSelected > PROFILE_MAX) + if(ProfileFocused > PROFILE_MAX) { - printf("[error]ProfileSelected exceed the limit\n"); - ProfileSelected = 0; + printf("[error]ProfileFocused exceed the limit\n"); + ProfileFocused = 0; } - // int selectedIndex = ProfileSelected % ITEMS_PER_PAGE; - int selectedPage = ProfileSelected / ITEMS_PER_PAGE; + int selectedPage = ProfileFocused / ITEMS_PER_PAGE; int ishidden = 0; for(int i = 0; i < ITEMS_PER_PAGE; i++) { - printf("i:%d data:%d\n", i, (IDS_NETWORK_SELECTION_1 + (ITEMS_PER_PAGE * selectedPage) + i)); - // lv_plugin_menu_set_item_string_id(pMenu, i, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, (IDS_NETWORK_SELECTION_1 + (ITEMS_PER_PAGE * selectedPage) + i)); + // printf("i:%d data:%d\n", i, (IDS_NETWORK_SELECTION_1 + (ITEMS_PER_PAGE * selectedPage) + i)); lv_plugin_menu_set_item_string_id(pMenu, i, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, - (IDS_NETWORK_SELECTION_1 + (ITEMS_PER_PAGE * selectedPage) + i)); + (IDS_NETWORK_SELECTION_1 + (ITEMS_PER_PAGE * selectedPage) + i)); lv_plugin_menu_set_item_img_id(pMenu, i, LV_PLUGIN_MENU_ITEM_STATE_DISABLED, LV_PLUGIN_IMG_ID_ICON_OK); + ishidden = true; if((ITEMS_PER_PAGE * selectedPage) + i < ProfileTotal) { lv_plugin_menu_set_item_hidden(pMenu, i, false);//整项 + if((ITEMS_PER_PAGE * selectedPage) + i == ProfileFocused) + { + lv_plugin_menu_select_item(pMenu, i);//白条 + } if((ITEMS_PER_PAGE * selectedPage) + i == ProfileSelected) { ishidden = false; - lv_plugin_menu_select_item(pMenu, i);//白条 } } else @@ -381,6 +382,23 @@ static void network_scan_task_cb(lv_task_t* task) lv_obj_t* obj = (lv_obj_t*)task->user_data; + if(Countdown) + { + printf("[%s]Countdown:%d\n", __FUNCTION__, Countdown); + Countdown--; + if(Countdown <= 0) + { + network_scan_task_end(); + lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); + hidde_Network_Selection_page(); + return; + } + else + { + return; + } + } + if(sf_cardv_4G_status_get() == SF_4G_SEARCHING) { printf("[%s]Searching...\n", __FUNCTION__); @@ -390,26 +408,14 @@ static void network_scan_task_cb(lv_task_t* task) if(sf_cardv_get_sim_insert() == 0) { - network_scan_task_end(); - lv_label_set_text(plabel, "\n\nCheck SIM"); - - sleep(3); - - lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); - hidde_Network_Selection_page(); + Countdown = 3; return; } else if(sf_cardv_get_is_esim() == 0) { - network_scan_task_end(); - lv_label_set_text(plabel, "\n\nNetwork selection is only available with SIM cards that have multiple networks."); - - sleep(3); - - lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); - hidde_Network_Selection_page(); + Countdown = 3; return; } else @@ -422,7 +428,6 @@ static void network_scan_task_cb(lv_task_t* task) stMessageBuf.arg3 = 1; stMessageBuf.cmdId = CMD_DEV; sf_com_message_send_to_app(&stMessageBuf); - // usleep(100); } if(sf_file_IsExsit(NETMSGPATH)) @@ -448,6 +453,7 @@ static void network_scan_task_cb(lv_task_t* task) int ProfileOffset = 11 + OPERATOR_INFO_SIZE*OperatorTotal; ProfileTotal = Buff[ProfileOffset]; ProfileSelected = Buff[ProfileOffset + 1]; + ProfileFocused = ProfileSelected; printf("\nOperatorTotal:%d ProfileOffset:%d ProfileTotal:%d ProfileSelected:%d\n", OperatorTotal, ProfileOffset, ProfileTotal, ProfileSelected); @@ -468,35 +474,9 @@ static void network_scan_task_cb(lv_task_t* task) tmpPluginStr = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_1 + i); tmpstr = (char*)tmpPluginStr->ptr; snprintf(tmpstr, PROFILE_NAME_SIZE, "%s", ProfileNameList[i]); - printf("i:%d tmpstr:%s len:%d p:%p\n", i, tmpstr, tmpPluginStr->size, tmpstr); + // printf("i:%d tmpstr:%s len:%d p:%p\n", i, tmpstr, tmpPluginStr->size, tmpstr); } -// lv_plugin_string_t*test = (lv_plugin_string_t*)lv_plugin_get_string(8); -// char* str = (char*)test->ptr; -// snprintf(str, test->size, ""); - -// printf("//////////////////////\n\n"); - -// lv_plugin_string_t* tmpPluginStr1 = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_1); -// lv_plugin_string_t* tmpPluginStr2 = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_2); -// lv_plugin_string_t* tmpPluginStr3 = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_3); -// lv_plugin_string_t* tmpPluginStr4 = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_4); -// lv_plugin_string_t* tmpPluginStr5 = (lv_plugin_string_t*)lv_plugin_get_string(IDS_NETWORK_SELECTION_5); - -// printf("%p\n%p\n%p\n%p\n%p\n\n", tmpPluginStr1, tmpPluginStr2, tmpPluginStr3, tmpPluginStr4, tmpPluginStr5); - -// printf("%p\n%p\n%p\n%p\n%p\n\n", tmpPluginStr1->ptr, tmpPluginStr2->ptr, tmpPluginStr3->ptr, tmpPluginStr4->ptr, tmpPluginStr5->ptr); - -// char* tmpstr1 = (char*)tmpPluginStr1->ptr; -// char* tmpstr2 = (char*)tmpPluginStr2->ptr; -// char* tmpstr3 = (char*)tmpPluginStr3->ptr; -// char* tmpstr4 = (char*)tmpPluginStr4->ptr; -// char* tmpstr5 = (char*)tmpPluginStr5->ptr; - -// printf("%p\n%p\n%p\n%p\n%p\n\n", tmpstr1, tmpstr2, tmpstr3, tmpstr4, tmpstr5); - -// printf("//////////////////////\n\n"); - update_Network_Selection_msg(obj); lv_obj_set_hidden(container_main_menu_scr_uiflowmenucommonoption, false); } @@ -519,32 +499,40 @@ static void network_select_task_cb(lv_task_t* task) { lv_obj_t* obj = (lv_obj_t*)task->user_data; + if(Countdown) + { + printf("[%s]Countdown:%d\n", __FUNCTION__, Countdown); + Countdown--; + if(Countdown <= 0) + { + network_select_task_end(); + lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); + hidde_Network_Selection_page(); + return; + } + else + { + return; + } + } + int resp = sf_cardv_get_operationSelectResp(); printf("network_select_task_cb:%d\n",resp); switch (resp) { case 0x00:/*CMD_SUCCESS*/ - network_select_task_end(); lv_label_set_text(plabel, "\n\nCompleted"); - sleep(3); - lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); - hidde_Network_Selection_page(); + Countdown = 3; break; case 0x34:/*NETWORK_NOT_NEED_SET*/ - network_select_task_end(); lv_label_set_text(plabel, "\n\nProfile is enabled"); - sleep(3); - lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); - hidde_Network_Selection_page(); + Countdown = 3; break; case 0xff: break; default: - network_select_task_end(); lv_label_set_text(plabel, "\n\nCurrently network is busy, Please try it later"); - sleep(3); - lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); - hidde_Network_Selection_page(); + Countdown = 3; break; } } @@ -564,6 +552,7 @@ void show_Network_Selection_page(lv_obj_t* obj, lv_obj_t* menu_obj) lv_obj_add_style(plabel, 0, &gMatrixStylebtn); if(network_scan_task == NULL){ + Countdown = 0; network_scan_task = lv_task_create(network_scan_task_cb, 1000, LV_TASK_PRIO_MID, (void*)obj); } } @@ -578,40 +567,43 @@ void hidde_Network_Selection_page(void) if(plabel) { lv_obj_del(plabel); + plabel = NULL; } } void Option_Network_Selection_Key(lv_obj_t* obj, uint32_t key) { - // UIMenuStoreInfo *puiPara = sf_ui_para_get(); - // char result[2]; - // char tmpchar; - // char* p; printf("key:%d\n",key); switch(key) { case LV_USER_KEY_NEXT: - if(ProfileSelected >= 0 && ProfileSelected < (ProfileTotal - 1)) + if(network_scan_task == NULL && network_select_task == NULL) { - ProfileSelected++; + if(ProfileFocused >= 0 && ProfileFocused < (ProfileTotal - 1)) + { + ProfileFocused++; + } + else + { + ProfileFocused = 0; + } + update_Network_Selection_msg(obj); } - else - { - ProfileSelected = 0; - } - update_Network_Selection_msg(obj); break; case LV_USER_KEY_PREV: - if(ProfileSelected > 0 && ProfileSelected < ProfileTotal) + if(network_scan_task == NULL && network_select_task == NULL) { - ProfileSelected--; + if(ProfileFocused > 0 && ProfileFocused < ProfileTotal) + { + ProfileFocused--; + } + else + { + ProfileFocused = 0; + } + update_Network_Selection_msg(obj); } - else - { - ProfileSelected = 0; - } - update_Network_Selection_msg(obj); break; case LV_USER_KEY_LEFT: lv_plugin_scr_close(obj, gen_nvtmsg_data(NVTRET_ENTER_MENU, 0)); @@ -620,17 +612,21 @@ void Option_Network_Selection_Key(lv_obj_t* obj, uint32_t key) case LV_USER_KEY_RIGHT: break; case LV_KEY_ENTER: - lv_obj_set_hidden(container_main_menu_scr_uiflowmenucommonoption, true); - lv_label_set_text(plabel, "\n\nNetwork Switching..."); - sf_cardv_set_operationSelectResp(0xff); - SF_MESSAGE_BUF_S stMessageBuf = {0}; - stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SELECT; - stMessageBuf.arg2 = SF_CONTROL_TYPE_LOCAL; - stMessageBuf.arg3 = ProfileSelected; - stMessageBuf.cmdId = CMD_DEV; - sf_com_message_send_to_app(&stMessageBuf); - if(network_select_task == NULL){ - network_select_task = lv_task_create(network_select_task_cb, 1000, LV_TASK_PRIO_MID, (void*)obj); + if(network_scan_task == NULL && network_select_task == NULL) + { + lv_obj_set_hidden(container_main_menu_scr_uiflowmenucommonoption, true); + lv_label_set_text(plabel, "\n\nNetwork Switching..."); + sf_cardv_set_operationSelectResp(0xff); + SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SELECT; + stMessageBuf.arg2 = SF_CONTROL_TYPE_LOCAL; + stMessageBuf.arg3 = ProfileFocused; + stMessageBuf.cmdId = CMD_DEV; + sf_com_message_send_to_app(&stMessageBuf); + if(network_select_task == NULL){ + Countdown = 0; + network_select_task = lv_task_create(network_select_task_cb, 1000, LV_TASK_PRIO_MID, (void*)obj); + } } break; default: diff --git a/code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c b/code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c index 7fec838d8..5651bb3f9 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c @@ -3208,9 +3208,10 @@ void sf_network_select_thread(void* args) //clear lpa switch flag. sf_set_lpa_switch_flag(0); - + //SF_POWEROFF_REBOOT if(errCode == CMD_SUCCESS) { + #if 0 SLOGE("Reboot module,try again!\n"); int retryTime = 0; int rebootTime=0; @@ -3223,7 +3224,6 @@ void sf_network_select_thread(void* args) sleep(SF_MODULE_RESET_WAIT_TIME); sf_set_module_reset_flag(0); - #if 0 while(sf_get_ttyfd() < 0) { sf_ttyfd_init_tryother(); @@ -3238,13 +3238,28 @@ void sf_network_select_thread(void* args) sf_set_module_reset_flag(0); sf_ttyfd_init_tryother(); } - #endif //if(sf_get_ttyfd() < 0) { errCode = NETWORK_CMD_READ_SIM_FAIL; } + #endif + if(controlType == SF_CONTROL_TYPE_LOCAL) + { + SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.cmdId = CMD_DEV; + stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SELECT_RESP; + stMessageBuf.arg2 = errCode; + stMessageBuf.arg3 = 0; + sf_com_message_send_to_cardv(&stMessageBuf); + } + + // sf_mcu_reg_set(SF_MCU_RESET_MODULE, 0); + // sleep(2); + // sf_mcu_reg_set(SF_MCU_POWEROFF, 0); + sf_mcu_reg_set(SF_MCU_POWER_RESTART, 0); + } else {