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 a06bbd7ad..715dd463a 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 @@ -1,10 +1,14 @@ // #include "MenuQR.h" +#include #include "PrjInc.h" #include "UIWnd/UIFlow.h" #include "UIFlowLVGL/UIFlowLVGL.h" #include "lvgl/src/lv_lib_qrcode/lv_qrcode.h" +#include "sf_param_struct.h" +#include "sf_message_queue.h" +#include "sf_fileMng.h" +#include "sf_common.h" TMDEF_BEGIN_OPTIONS(NETWORK_SELECTION) -TMDEF_OPTION_TEXT_S(END, TM_OPTION_ENABLE) TMDEF_END_OPTIONS() TMDEF_BEGIN_OPTIONS(QR_PICTURE) TMDEF_OPTION_TEXT_S(END, TM_OPTION_ENABLE) @@ -201,6 +205,250 @@ static void init_Matrix_style(void) isinitialized = 1; } +// printf("[%s]%d\n",__FUNCTION__,__LINE__); + +// -------------------------------------------------------------------------- +// Network Selection +// -------------------------------------------------------------------------- +#define NETMSGPATH "/tmp/wifiData.txt" +#define OPERATOR_INFO_SIZE 18 +#define PROFILE_INFO_SIZE 17 +#define PROFILE_NAME_SIZE 16 +#define PROFILE_MAX 20 +static lv_task_t* checkfile_task = NULL; +static lv_obj_t* pMenu = NULL; +static lv_obj_t *plabel = NULL; +static int ProfileTotal = 0; +static int ProfileSelected = 0; +static unsigned char ProfileNameList[PROFILE_MAX][PROFILE_NAME_SIZE] = {0}; + +static void update_Network_Selection_msg(lv_obj_t* obj) +{ + // int UISelected = 0; + + // //显示 + // lv_plugin_menu_set_item_string_id(pMenu, 0, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, LV_PLUGIN_STRING_ID_STRID_1); + // lv_plugin_menu_set_item_string_id(pMenu, 1, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, LV_PLUGIN_STRING_ID_STRID_2); + // lv_plugin_menu_set_item_hidden(pMenu, 0, false); + // lv_plugin_menu_set_item_hidden(pMenu, 1, false); + // // lv_label_set_text(plabel, ""); + +// itemIndex = 0; +// #if 1 +// for (i = 0; i < pItem->Count; i++) { +// DBG_DUMP("%s enableIndex=%d :%d\r\n", __func__,i,enableIndex[i]); +// //check option if disable +// TM_CheckOptionStatus(pMenu, &itemIndex, TRUE); +// if(itemIndex > pItem->Count){ +// break; +// } +// enableIndex[i] = itemIndex; +// OptionEN_Num = i; +// if(enableIndex[i] == SelOption){ +// Selindex = i; +// } +// itemIndex++; +// } +// printf("Selindex:%d OptionEN_Num:%d pItem->Count:%d\n",Selindex,OptionEN_Num,pItem->Count); +// if(Selindex){ +// if((Selindex / OPTION_PAGE_NUM) == 0){ +// Selindex = 0; +// }else{ +// Selindex = (Selindex / OPTION_PAGE_NUM); + +// } +// } +// for(i = 0; i < OPTION_PAGE_NUM; i++){ +// pOption = &pItem->pOptions[enableIndex[i + (Selindex * OPTION_PAGE_NUM)]]; +// if (((enableIndex[i + (Selindex * OPTION_PAGE_NUM)]) > (pItem->Count -1)) && (i < OPTION_PAGE_NUM)) { +// printf("\033[33m[LV_MenuCommonOption_UpdateContent] 1 \033[0m\n"); +// lv_plugin_menu_set_item_string_id(menu_option, i, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, pOption->TextId); +// lv_plugin_menu_set_item_img_id(menu_option, i, LV_PLUGIN_MENU_ITEM_STATE_DISABLED, pOption->IconId); +// lv_plugin_menu_set_item_hidden(menu_option, i, true); +// ui_hidden = true; + +// }else if((i + (Selindex * OPTION_PAGE_NUM)) > OptionEN_Num){ +// printf("\033[33m[LV_MenuCommonOption_UpdateContent] 2 \033[0m\n"); +// lv_plugin_menu_set_item_string_id(menu_option, i, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, pOption->TextId); +// lv_plugin_menu_set_item_img_id(menu_option, i, LV_PLUGIN_MENU_ITEM_STATE_DISABLED, pOption->IconId); +// lv_plugin_menu_set_item_hidden(menu_option, i, true); +// ui_hidden = true; +// }else{ +// printf("\033[33m[LV_MenuCommonOption_UpdateContent] 3 \033[0m\n"); +// lv_plugin_menu_set_item_string_id(menu_option, i, LV_PLUGIN_MENU_ITEM_VISIBLE_STATE_NUM, pOption->TextId); +// lv_plugin_menu_set_item_img_id(menu_option, i, LV_PLUGIN_MENU_ITEM_STATE_DISABLED, pOption->IconId); +// lv_plugin_menu_set_item_hidden(menu_option, i, false); +// ui_hidden = true; +// if(enableIndex[i+(Selindex * OPTION_PAGE_NUM)] == SelOption){ +// printf("\033[33m[LV_MenuCommonOption_UpdateContent] 4 %d %d \033[0m\n", i, Selindex); +// s_SelOption = i + (Selindex * OPTION_PAGE_NUM); +// lv_plugin_menu_select_item(menu_option, i); +// ui_hidden = false; +// } +// } + +// DBG_DUMP("%s ui_hidden=%d\r\n", __func__,ui_hidden); +// if(i==0){ +// lv_obj_set_hidden(image_option1_scr_uiflowmenucommonoption, ui_hidden); +// }else if(i == 1){ +// lv_obj_set_hidden(image_option2_scr_uiflowmenucommonoption, ui_hidden); +// }else if(i == 2){ +// lv_obj_set_hidden(image_option3_scr_uiflowmenucommonoption, ui_hidden); +// }else if(i == 3){ +// lv_obj_set_hidden(image_option4_scr_uiflowmenucommonoption, ui_hidden); +// }else if(i == 4){ +// lv_obj_set_hidden(image_option5_scr_uiflowmenucommonoption, ui_hidden); +// } + +// } + + // lv_plugin_string_t*test = (lv_plugin_string_t*)lv_plugin_get_string(IDS_MOVIE_MJPG); + // char* str = (char*)test->ptr; + // snprintf(str, test->size, "6565"); + +} + +static void checkfile_task_end(void) +{ + if(checkfile_task) + { + lv_task_del(checkfile_task); + checkfile_task = NULL; + } +} + +static void checkfile_task_cb(lv_task_t* task) +{ + struct stat statBuf; + int fd = -1; + int BuffLen; + unsigned char Buff[1024] = { 0 }; + + lv_obj_t* obj = (lv_obj_t*)task->user_data; + + if(sf_cardv_4G_status_get() == SF_4G_SEARCHING) + { + printf("[%s]Searching...\n", __FUNCTION__); + lv_label_set_text(plabel, "\n\nSearching..."); + return; + } + + if(sf_cardv_get_sim_insert() == 0) + { + checkfile_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(); + return; + } + else if(sf_cardv_get_is_esim() == 0) + { + checkfile_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(); + return; + } + else + { + if(!sf_file_IsExsit(NETMSGPATH)) + { + SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SCAN; + stMessageBuf.arg2 = SF_CONTROL_TYPE_LOCAL; + stMessageBuf.arg3 = 1; + stMessageBuf.cmdId = CMD_DEV; + sf_com_message_send_to_app(&stMessageBuf); + usleep(100); + } + + if(sf_file_IsExsit(NETMSGPATH)) + { + fd = open(NETMSGPATH, O_RDWR, 0777); + if(fd >= 0) + { + fstat(fd, &statBuf); + BuffLen = statBuf.st_size; + printf("fSize=%d\n", BuffLen); + read(fd, Buff, BuffLen); + close(fd); + remove(NETMSGPATH); + + for(int i = 0; i < BuffLen; i++) + { + printf("%x ", Buff[i]); + } + + if(Buff[5] == 0x3b/*WIFI_CONTROL_CAMERA_Network_Scan*/ && Buff[8] == 0x00/*CMD_SUCCESS*/) + { + int OperatorTotal = Buff[9]; + int ProfileOffset = 11 + OPERATOR_INFO_SIZE*OperatorTotal; + ProfileTotal = Buff[ProfileOffset]; + ProfileSelected = Buff[ProfileOffset + 1]; + + printf("\nOperatorTotal:%d ProfileOffset:%d ProfileTotal:%d ProfileSelected:%d\n", OperatorTotal, ProfileOffset, ProfileTotal, ProfileSelected); + + for(int i = 0; i < ProfileTotal; i++) + { + printf("Profile %d ",Buff[ProfileOffset + 2 + (i * PROFILE_INFO_SIZE)]); + memcpy(ProfileNameList[i], Buff + (ProfileOffset + 3 + (i * PROFILE_INFO_SIZE)), PROFILE_NAME_SIZE); + printf("%s\n", ProfileNameList[i]); + } + + checkfile_task_end(); + lv_label_set_text(plabel, ""); + + update_Network_Selection_msg(obj); + } + return; + } + } + } +} + +void show_Network_Selection_page(lv_obj_t* obj, lv_obj_t* menu_obj) +{ + pMenu = menu_obj; + // sf_cardv_set_operationSelectResp(0xff); + init_Matrix_style(); + + plabel = lv_label_create(obj, NULL); + lv_label_set_long_mode(plabel, LV_LABEL_LONG_BREAK); + // lv_label_set_align(plabel, LV_LABEL_ALIGN_CENTER); + lv_label_set_text(plabel, "1\n2\nSearching..."); + lv_obj_set_pos(plabel, 32, 55); + lv_obj_set_width(plabel, 256); + lv_obj_add_style(plabel, 0, &gMatrixStylebtn); + + if(checkfile_task == NULL){ + checkfile_task = lv_task_create(checkfile_task_cb, 1000, LV_TASK_PRIO_MID, (void*)obj); + } +} + +void hidde_Network_Selection_page(void) +{ + checkfile_task_end(); + + pMenu = NULL; + + if(plabel) + { + lv_obj_del(plabel); + } +} + +void Option_Network_Selection_Key(lv_obj_t* obj, uint32_t key) +{ + +} // -------------------------------------------------------------------------- // QR CODE diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.h b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.h index 3c0608d92..95e619b6c 100644 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.h +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuQR.h @@ -4,6 +4,8 @@ extern TM_MENU gQrMenu; extern TM_ITEM gTM_ITEMS_QR[]; +extern void show_Network_Selection_page(lv_obj_t* obj, lv_obj_t* menu_obj); +extern void hidde_Network_Selection_page(void); extern void show_qr_picture_page(lv_obj_t* obj); extern void hidde_qr_picture_page(void); extern void show_Password_page(lv_obj_t* obj); @@ -13,6 +15,7 @@ extern void hidde_Camera_Info_page(void); extern void show_Camera_Name_page(lv_obj_t* obj); extern void hidde_Camera_Name_page(void); +extern void Option_Network_Selection_Key(lv_obj_t* obj, uint32_t key); extern void Option_Password_Key(lv_obj_t* obj, uint32_t key); extern void Option_CAMERA_INFO_Key(lv_obj_t* obj, uint32_t key); extern void Option_Camera_Name_Key(lv_obj_t* obj, uint32_t key); diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c index a55722374..fa1fc78b0 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c @@ -8,6 +8,7 @@ #if HUNTING_CAMERA_MCU == ENABLE #include #endif +// #include "sf_4g_lpa.h" #define OPTION_PAGE_NUM 5 @@ -84,7 +85,7 @@ static void UIFlowMenuCommonOption_CloseScr(lv_obj_t* obj) #endif // -------------------------------------------------------------------------- -// Secondary interface is other display +// Secondary // -------------------------------------------------------------------------- #define MESSAGE_ITEM_TRUE 1 #define MESSAGE_ITEM_FALSE 0 @@ -97,11 +98,12 @@ static int is_message_item(lv_obj_t* obj) pItem = &pPage->pItems[pPage->SelItem]; UINT16 itemID = pItem->ItemId; switch (itemID) { - // case IDM_NETWORK_SELECTION: - // { - // printf("[is_message_item]IDM_NETWORK_SELECTION\n"); - // return; - // } + case IDM_NETWORK_SELECTION: + { + printf("[is_message_item]IDM_NETWORK_SELECTION\n"); + show_Network_Selection_page(obj, menu_option); + return MESSAGE_ITEM_TRUE; + } case IDM_QR_PICTURE: { printf("[is_message_item]IDM_QR_PICTURE\n"); @@ -589,7 +591,7 @@ static void LV_MenuOption_OnSelected(lv_obj_t* obj) } // -------------------------------------------------------------------------- - // 3th interface is other display + // 3th // -------------------------------------------------------------------------- if((pItem->ItemId == IDM_PASSWORD || pItem->ItemId == IDM_CAMERA_NAME || @@ -842,6 +844,7 @@ void UIFlowMenuCommonOptionEventCallback(lv_obj_t* obj, lv_event_t event) switch(itemID) { case IDM_NETWORK_SELECTION: + UIFlowMenuCommonOption_Key(obj, *key); break; case IDM_QR_PICTURE: UIFlowMenuCommonOption_Key(obj, *key); diff --git a/code/application/source/sf_app/code/include/sf_4g_lpa.h b/code/application/source/sf_app/code/include/sf_4g_lpa.h index 977527176..3a3e7151a 100755 --- a/code/application/source/sf_app/code/include/sf_4g_lpa.h +++ b/code/application/source/sf_app/code/include/sf_4g_lpa.h @@ -71,8 +71,8 @@ void sf_set_wifi_socket(int fd); int sf_get_wifi_socket(void); void sf_set_wifi_cmd(UINT8 cmd); UINT8 sf_get_wifi_cmd(void); -void sf_network_select(UINT8* profileId); -void sf_4g_operator_scan(UINT8 mode); +void sf_network_select(UINT8 profileId, UINT8 ctlType); //SF_CONTROL_TYPE_e ctlType +void sf_4g_operator_scan(UINT8 mode, UINT8 ctlType); //SF_CONTROL_TYPE_e ctlType SINT32 sf_lpa_get_esim_iccid(SF_CHAR iccid[][22]); diff --git a/code/application/source/sf_app/code/include/sf_module.h b/code/application/source/sf_app/code/include/sf_module.h index b74de8b2f..63932cace 100644 --- a/code/application/source/sf_app/code/include/sf_module.h +++ b/code/application/source/sf_app/code/include/sf_module.h @@ -46,16 +46,16 @@ extern "C" { -typedef enum sf4G_STATUS_E -{ - SF_4G_OK = 0x01, - SF_4G_FAIL = 0x02, - SF_4G_FREE = 0x03, - SF_4G_SENDING = 0x04, - SF_4G_SEARCHING = 0X05, - SF_4G_REBOOT = 0x06, - SF_4G_BUTT = 0x07, -} SF_4G_STATUS_E; +// typedef enum sf4G_STATUS_E +// { +// SF_4G_OK = 0x01, +// SF_4G_FAIL = 0x02, +// SF_4G_FREE = 0x03, +// SF_4G_SENDING = 0x04, +// SF_4G_SEARCHING = 0X05, +// SF_4G_REBOOT = 0x06, +// SF_4G_BUTT = 0x07, +// } SF_4G_STATUS_E; //SINT32 sf_4G_cfun_set(); diff --git a/code/application/source/sf_app/code/include/sf_param_enum.h b/code/application/source/sf_app/code/include/sf_param_enum.h index 179d37b27..443d0b090 100755 --- a/code/application/source/sf_app/code/include/sf_param_enum.h +++ b/code/application/source/sf_app/code/include/sf_param_enum.h @@ -482,6 +482,8 @@ typedef enum sf_PARA_MESSAGE_TYPE_E SF_PARA_CMD_BATTERY_LEVEL = 0x1F02, SF_PARA_CMD_WAIT = 0x1F03, SF_PARA_CMD_SIG = 0x1F04, + SF_PARA_CMD_SIMISINSERT = 0x1F05, + SF_PARA_CMD_ISESIM = 0x1F06, }SF_PARA_MESSAGE_TYPE_E; typedef enum sf_WIFI_MESSAGE_TYPE_E @@ -521,9 +523,29 @@ typedef enum _SF_DEV_CMD_STEP_e{ SF_DEV_CMD_ESIM_OPERATION_SWTICH = 0x5, SF_DEV_CMD_OTA = 0x6, SF_DEV_CMD_BLU_START = 0x7, + SF_DEV_CMD_ESIM_OPERATION_SELECT_RESP = 0x8, SF_DEV_CMD_BUTT } SF_DEV_CMD_STEP_e; +typedef enum _SF_CONTROL_TYPE_e{ + SF_CONTROL_TYPE_NONE, + SF_CONTROL_TYPE_BLUETOOTH, + SF_CONTROL_TYPE_WIFI, + SF_CONTROL_TYPE_SMS, + SF_CONTROL_TYPE_LOCAL +}SF_CONTROL_TYPE_e; + +typedef enum sf4G_STATUS_E +{ + SF_4G_OK = 0x01, + SF_4G_FAIL = 0x02, + SF_4G_FREE = 0x03, + SF_4G_SENDING = 0x04, + SF_4G_SEARCHING = 0X05, + SF_4G_REBOOT = 0x06, + SF_4G_BUTT = 0x07, +} SF_4G_STATUS_E; + #ifdef __cplusplus #if __cplusplus } 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 9f06a23b2..7fec838d8 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 @@ -28,6 +28,7 @@ //#define SAMPLE__USE_MODEM_CONNECTIVITY +#include "sf_param_enum.h" #include #include #if !SIFAR_PLATFORM_ICATCH @@ -1915,6 +1916,14 @@ SINT32 sf_lpa_get_download_profile_iccid(SINT8* iccid) static UINT8 g_esim_flag=0; //adjust insert esim or not void sf_set_esim_card(UINT8 flag) { + if(g_esim_flag != flag) + { + SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.arg2 = flag; + stMessageBuf.arg1 = SF_PARA_CMD_ISESIM; + stMessageBuf.cmdId = CMD_PARA; + sf_com_message_send_to_cardv(&stMessageBuf); + } g_esim_flag = flag; } @@ -2798,16 +2807,23 @@ UINT8 sf_check_network_status(void) return errCode; } +struct ThreadArgs +{ + UINT8 arg1; + UINT8 arg2; +}; -void sf_operator_scan_thread(UINT32 *tmp) +void sf_operator_scan_thread(void* args) { printf("scan network.\n"); - + struct ThreadArgs* myArgs = (struct ThreadArgs*)args; + UINT8 totalOperator = 0; UINT8 totalProfile = 0; UINT8 i = 0; UINT8 errCode = CMD_SUCCESS; - UINT8 mode = (UINT8)*tmp; + UINT8 mode = myArgs->arg1; + SF_CONTROL_TYPE_e controlType = myArgs->arg2; UINT8 *sendBuff = NULL; UINT16 sendBuffLen = 0; APP_SVR_PACKET_T *pMsgParse = NULL; @@ -2822,7 +2838,7 @@ void sf_operator_scan_thread(UINT32 *tmp) memset((void *)&profileItem, 0, sizeof(LPA_PROFILE_INFO)); memset((void *)&operatorInfo, 0, sizeof(SF_OPERATORS_LIST_T)); - printf("mode=%d\n", mode); + printf("mode=%d controlType:%d\n", mode, controlType); errCode = sf_check_network_status(); @@ -2945,21 +2961,24 @@ void sf_operator_scan_thread(UINT32 *tmp) } printf("\n[sendBuff-1] e\n"); free(sendBuff); - sf_share_mem_wifi_down(1); + + if(controlType == SF_CONTROL_TYPE_WIFI) + sf_share_mem_wifi_down(1); } } - - - -void sf_4g_operator_scan(UINT8 mode) +void sf_4g_operator_scan(UINT8 mode, UINT8 ctlType) { pthread_t tOperScanTask; + + static struct ThreadArgs args = {0}; + args.arg1 = mode; + args.arg2 = ctlType; - pthread_create(&tOperScanTask,NULL,sf_operator_scan_thread,(void *)&mode); + pthread_create(&tOperScanTask,NULL,sf_operator_scan_thread,(void *)&args); } UINT8 sf_wifi_server_network_select_finish(UINT8 errCode) @@ -3059,14 +3078,17 @@ SF_BOOL sf_get_active_profile_next_index(UINT8 *index) return TRUE; } -void sf_network_select_thread(UINT8 * tmp) +void sf_network_select_thread(void* args) { - printf("select network, PID:%d\n", *tmp); + struct ThreadArgs* myArgs = (struct ThreadArgs*)args; + printf("select network, PID:%d\n", myArgs->arg1); + UINT32 ret = SF_LPA_SUCCESS; UINT32 sts = 0; UINT32 retryTime=0; UINT8 errCode = CMD_SUCCESS; - UINT8 profileId = *tmp; + UINT8 profileId = myArgs->arg1; + SF_CONTROL_TYPE_e controlType = myArgs->arg2; UINT8 curActiveProfileId = 0; UINT32 totalProfile = 0; LPA_API_ERROR lpaErrCode = LPA_NO_ERROR; @@ -3269,7 +3291,17 @@ void sf_network_select_thread(UINT8 * tmp) } - sf_wifi_server_network_select_finish(errCode); + if(controlType == SF_CONTROL_TYPE_WIFI) + sf_wifi_server_network_select_finish(errCode); + else 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); + } #if ((!SF_IQ_DEBUG)&&(!SF_4G_TEST)) if(errCode == CMD_SUCCESS) @@ -3293,11 +3325,16 @@ void sf_network_select_thread(UINT8 * tmp) } -void sf_network_select(UINT8* profileId) +void sf_network_select(UINT8 profileId, UINT8 ctlType) { pthread_t tNetWorkSeclectTask; - SLOGD("sf_network_select,Pid:%d\n", *profileId); - pthread_create(&tNetWorkSeclectTask, NULL, sf_network_select_thread, profileId); + SLOGD("sf_network_select,Pid:%d ctlType:%d\n", profileId, ctlType); + + static struct ThreadArgs args = {0}; + args.arg1 = profileId; + args.arg2 = ctlType; + + pthread_create(&tNetWorkSeclectTask, NULL, sf_network_select_thread, (void *)&args); } diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index c975f30eb..d2aaacf99 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -911,18 +911,18 @@ static SINT32 sf_app_proccess_cmd_dev(SF_MESSAGE_BUF_S *pMessageBuf) break; case SF_DEV_CMD_ESIM_OPERATION_SCAN: - MLOGI("SF_DEV_CMD_ESIM_OPERATION_SCAN: arg3:%d\n", pMessageBuf->arg3); + MLOGI("SF_DEV_CMD_ESIM_OPERATION_SCAN: arg2:%d arg3:%d\n", pMessageBuf->arg2, pMessageBuf->arg3); //sf_set_wifi_socket(pMessageBuf->arg2); sf_set_wifi_cmd(0x3b);//WIFI_CONTROL_CAMERA_Network_Scan - sf_4g_operator_scan(pMessageBuf->arg3); + sf_4g_operator_scan(pMessageBuf->arg3, pMessageBuf->arg2); break; case SF_DEV_CMD_ESIM_OPERATION_SELECT: - MLOGI("SF_DEV_CMD_ESIM_OPERATION_SELECT:arg3:%d\n", pMessageBuf->arg3); + MLOGI("SF_DEV_CMD_ESIM_OPERATION_SCAN: arg2:%d arg3:%d\n", pMessageBuf->arg2, pMessageBuf->arg3); //sf_set_wifi_socket(pMessageBuf->arg2); sf_set_wifi_cmd(0x3c);//WIFI_CONTROL_CAMERA_Network_Select - sf_network_select((UINT8 *)&pMessageBuf->arg3); + sf_network_select(pMessageBuf->arg3, pMessageBuf->arg2); break; case SF_DEV_CMD_ESIM_OPERATION_SWTICH: diff --git a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu_reg.c b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu_reg.c index 06c8d0c2a..65d6b2696 100755 --- a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu_reg.c +++ b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu_reg.c @@ -33,6 +33,7 @@ #include "sf_param_common.h" #include "sf_sms.h" #include "sf_system.h" +#include "sf_message_queue.h" #ifdef __cplusplus #if __cplusplus extern "C" { @@ -1211,6 +1212,15 @@ int sf_app_while_flag(void) } void sf_set_sim_insert(UINT32 sim) { + if(simCardInsert != sim) + { + SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.arg2 = sim; + stMessageBuf.arg1 = SF_PARA_CMD_SIMISINSERT; + stMessageBuf.cmdId = CMD_PARA; + sf_com_message_send_to_cardv(&stMessageBuf); + } + simCardInsert = sim; } diff --git a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c index 9d8c5bb10..70dde0eec 100755 --- a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c +++ b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c @@ -2044,7 +2044,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) printf("[WIFI_CONTROL_CAMERA_Network_Scan] fd:%d\n", fd); //SF_MESSAGE_BUF_S stMessageBuf = {0}; stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SCAN; - stMessageBuf.arg2 = fd; + stMessageBuf.arg2 = SF_CONTROL_TYPE_WIFI; stMessageBuf.arg3 = pMsgStruct->msgBuf.ctrlNetworkScan.networkCtrl; stMessageBuf.cmdId = CMD_DEV; sf_com_message_send_to_app(&stMessageBuf); @@ -2057,7 +2057,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) printf("[WIFI_CONTROL_CAMERA_Network_Select] fd:%d, pID:%d\n", fd, \ pMsgStruct->msgBuf.ctrlNetworkSelect.profileId); stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SELECT; - stMessageBuf.arg2 = fd; + stMessageBuf.arg2 = SF_CONTROL_TYPE_WIFI; stMessageBuf.arg3 = pMsgStruct->msgBuf.ctrlNetworkSelect.profileId; stMessageBuf.cmdId = CMD_DEV; sf_com_message_send_to_app(&stMessageBuf); diff --git a/code/lib/source/sifar/code/include/sf_common.h b/code/lib/source/sifar/code/include/sf_common.h index c1a7116d6..e48c35b6e 100755 --- a/code/lib/source/sifar/code/include/sf_common.h +++ b/code/lib/source/sifar/code/include/sf_common.h @@ -93,6 +93,14 @@ BOOL sf_is_movie_preview(void); BOOL sf_is_cap_preview(void); BOOL sf_is_preview(void); short sf_cardv_get_cq_signal(void); +void sf_cardv_4G_status_set(UINT8 status); +UINT8 sf_cardv_4G_status_get(void); +void sf_cardv_set_sim_insert(UINT8 sim); +UINT8 sf_cardv_get_sim_insert(void); +void sf_cardv_set_is_esim(UINT8 flag); +UINT8 sf_cardv_get_is_esim(void); +void sf_cardv_set_operationSelectResp(UINT8 resp); +UINT8 sf_cardv_get_operationSelectResp(void); void sf_set_send_statu(BOOL is); BOOL sf_get_send_statu(void); void sf_cardv_set_mcu_rtc_flag(void); diff --git a/code/lib/source/sifar/code/source/common/sf_common.c b/code/lib/source/sifar/code/source/common/sf_common.c index 4e2144af7..bfbf80180 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -59,6 +59,7 @@ #include #include #include "UIAppNetwork.h" +#include "kwrap/nvt_type.h" #include "sf_common.h" #include "sf_mcu.h" #include "sf_4g_lpa.h" @@ -68,7 +69,10 @@ BOOL isGoing2PowerOff = FALSE; UINT16 AutoOfftime = 0; BOOL isGoing2Pir = FALSE; -UINT8 NetWorkFlag = 0; +static UINT8 NetWorkFlag = 0; //SF_4G_STATUS_E +static UINT8 simCardInsert = 0; +static UINT8 g_esim_flag = 0; +static UINT8 operationSelectResp = 0; //WIFICameraErrCode_t UINT8 RespFlag = 0; static BOOL IsMenu = FALSE; static BOOL IsCap = FALSE; @@ -1691,13 +1695,19 @@ static SINT32 sf_cardv_proccess_cmd_para_update(SF_MESSAGE_BUF_S *pMessageBuf) ModuleUpdating = pMessageBuf->arg2; break; case SF_PARA_CMD_NET_STATUS: - NetWorkFlag = pMessageBuf->arg2; + sf_cardv_4G_status_set(pMessageBuf->arg2); break; case SF_PARA_CMD_WAIT: sf_cardv_set_wait_shared_condition(0); break; case SF_PARA_CMD_SIG: sf_cardv_para_signaling_start(); + break; + case SF_PARA_CMD_SIMISINSERT: + sf_cardv_set_sim_insert(pMessageBuf->arg2); + break; + case SF_PARA_CMD_ISESIM: + sf_cardv_set_is_esim(pMessageBuf->arg2); break; default: break; @@ -1798,7 +1808,10 @@ static SINT32 sf_cardv_proccess_cmd_dev(SF_MESSAGE_BUF_S *pMessageBuf) MLOGI("batteryVal:%d batteryType:%d powerVal:%d p:%d\n",batteryVal, batteryType, powerVal,pMessageBuf->arg3); break; - + case SF_DEV_CMD_ESIM_OPERATION_SELECT_RESP: + sf_cardv_set_operationSelectResp(pMessageBuf->arg2); + MLOGI("operationSelectResp:%d\n", pMessageBuf->arg2); + break; default: break; } @@ -2450,7 +2463,7 @@ BOOL sf_cmd_fs_ro_check(unsigned char argc, char **argv) BOOL sf_check_net_work_flag(void) { - if((0x04 == NetWorkFlag/*SF_4G_SENDING*/) || (0x05 == NetWorkFlag/*SF_4G_SEARCHING*/)){ + if((SF_4G_SENDING == NetWorkFlag/*SF_4G_SENDING*/) || (SF_4G_SEARCHING == NetWorkFlag/*SF_4G_SEARCHING*/)){ return TRUE; } else{ @@ -2459,6 +2472,51 @@ BOOL sf_check_net_work_flag(void) } +void sf_cardv_4G_status_set(UINT8 status) +{ + NetWorkFlag = status; + printf("cardv NetWorkFlag:%d\n",NetWorkFlag); +} + +UINT8 sf_cardv_4G_status_get(void) +{ + return NetWorkFlag; +} + +void sf_cardv_set_sim_insert(UINT8 sim) +{ + simCardInsert = sim; + printf("cardv simCardInsert:%d\n",simCardInsert); +} + +UINT8 sf_cardv_get_sim_insert(void) +{ + return simCardInsert; +} + +void sf_cardv_set_is_esim(UINT8 flag) +{ + g_esim_flag = flag; + printf("cardv g_esim_flag:%d\n",g_esim_flag); +} + +UINT8 sf_cardv_get_is_esim(void) +{ + return g_esim_flag; +} + +void sf_cardv_set_operationSelectResp(UINT8 resp) +{ + operationSelectResp = resp; +} + +UINT8 sf_cardv_get_operationSelectResp(void) +{ + return operationSelectResp; +} + + + /************************************************* Function: sf_save_camera_info Description: save camera info to sd