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 7a72e61a3..b5f5b1f53 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,12 +71,13 @@ 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 sf_network_select(UINT8 profileId); +void sf_network_select(UINT8* profileId); void sf_4g_operator_scan(UINT8 mode); + //UINT32 sf_sample_lpa_init(UINT8 refreshNetworkFlg); diff --git a/code/application/source/sf_app/code/include/sf_common.h b/code/application/source/sf_app/code/include/sf_common.h old mode 100644 new mode 100755 index 568bd2234..208fc1da4 --- a/code/application/source/sf_app/code/include/sf_common.h +++ b/code/application/source/sf_app/code/include/sf_common.h @@ -82,7 +82,6 @@ UINT8 sf_get_fw_update(void); void sf_set_fw_update(UINT8 flag); UINT8 sf_app_get_night_led_flag(void); -void sf_set_key_fw_update(UINT8 flag); #ifdef __cplusplus #if __cplusplus } diff --git a/code/application/source/sf_app/code/include/sf_eg91_sim.h b/code/application/source/sf_app/code/include/sf_eg91_sim.h index 238115849..fc3be4feb 100755 --- a/code/application/source/sf_app/code/include/sf_eg91_sim.h +++ b/code/application/source/sf_app/code/include/sf_eg91_sim.h @@ -325,6 +325,7 @@ SINT32 sf_net_regist_manual(void); SINT32 sf_auto_net_reg(void); int sf_get_operatorname(char *strname); +SINT32 sf_4g_test_esim(void); SINT32 eg915q_set_usbnet(SF_FN_PARAM_S *pfnParam); diff --git a/code/application/source/sf_app/code/include/sf_fileMng.h b/code/application/source/sf_app/code/include/sf_fileMng.h old mode 100644 new mode 100755 index bef5db8ca..2624de5de --- a/code/application/source/sf_app/code/include/sf_fileMng.h +++ b/code/application/source/sf_app/code/include/sf_fileMng.h @@ -80,6 +80,11 @@ SF_HDFILE_ATTR_S* sf_file_hd_cfg_get(void); void sf_file_hd_cfg_set_down(SF_HDFILE_ATTR_S *pSfHdPara); void sf_hd_param_set(SF_HDFILE_ATTR_S *pSfHdPara); SF_HDFILE_ATTR_S* sf_file_video_cfg_get(void); +void sf_set_key_fw_update(UINT8 flag); +SF_REPORT_WIFI_ATTR_S* sf_wifi_cfg_get(void); +void sf_wifi_cfg_set_down(SF_REPORT_WIFI_ATTR_S *pSfWifiPara); +void sf_wifi_param_set(SF_REPORT_WIFI_ATTR_S *pSfWifiPara); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/application/source/sf_app/code/include/sf_hal_ttyusb.h b/code/application/source/sf_app/code/include/sf_hal_ttyusb.h index 03fddc650..1038d1368 100755 --- a/code/application/source/sf_app/code/include/sf_hal_ttyusb.h +++ b/code/application/source/sf_app/code/include/sf_hal_ttyusb.h @@ -37,8 +37,8 @@ extern "C" { #define GPRS_MODULE_TYPE_EG91_V "EG91VX" #define GPRS_MODULE_TYPE_EG95_V "EG95VX" -#define GPRS_MODULE_TYPE_EG91_NAXD "EG91NAXD" -#define GPRS_MODULE_TYPE_EG95_NAXD "EG95NAXD" +#define GPRS_MODULE_TYPE_EG91_NAXD "EG91NA" +#define GPRS_MODULE_TYPE_EG95_NAXD "EG95NA" #define GPRS_MODULE_TYPE_EG915Q "EG915Q" @@ -47,7 +47,7 @@ extern "C" { #define E_PDP_INDEX 7 -#define V_PDP_INDEX 3 +#define V_PDP_INDEX 7 #define A_PDP_INDEX 1 typedef struct sf_SERIAL_DATA_FRAME_TYPE_S { 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 68f361eaa..d02529a4c 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 @@ -491,6 +491,7 @@ typedef enum sf_WIFI_MESSAGE_TYPE_E SF_WIFI_CMD_RESTART = 0x1C00, SF_WIFI_CMD_CAPTURE = 0x1D00, SF_WIFI_CMD_HD_TURE = 0x1E00, + SF_WIFI_CMD_SEND = 0x1F00, }SF_WIFI_MESSAGE_TYPE_E; diff --git a/code/application/source/sf_app/code/include/sf_param_struct.h b/code/application/source/sf_app/code/include/sf_param_struct.h old mode 100644 new mode 100755 index 8f4b3c971..a5e837d17 --- a/code/application/source/sf_app/code/include/sf_param_struct.h +++ b/code/application/source/sf_app/code/include/sf_param_struct.h @@ -311,6 +311,11 @@ typedef struct sf_REPORT_FILE_ATTR_S { SF_SEND_FILE_ATTR_S stSendFileAttr[100]; }SF_REPORT_FILE_ATTR_S; +typedef struct sf_REPORT_WIFI_ATTR_S { + UINT8 Lenth; + UINT8 WifiParam[1024]; +}SF_REPORT_WIFI_ATTR_S; + typedef struct sf_MESSAGE_Buf_S { long mtype; 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 37b5b9cfe..8a7e1e4a8 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 @@ -63,6 +63,8 @@ static int fd; + + bool Modem_OpenAndConfigurePort() { #if !SIFAR_PLATFORM_ICATCH @@ -324,7 +326,6 @@ static UINT32 ScanfVal[SCANF_MAX_ARGC] = {0}; static UINT32 IsEsimFlag = TRUE; static UINT32 EsimInitFinish = FALSE; static UINT8 SimEid[40] = {0}; -static SINT32 WifiSocket=0; static UINT8 DownLoadProfileIccid[2*LPA_PROFILE_ICCID_BUFFER_MAX_SIZE+1] = {0}; static UINT8 WifiCurrentCmd=0; @@ -332,16 +333,6 @@ LPA_GET_PROFILES_INFO getProfilesInfo; LPA_PROFILE_INFO *ProfileData = NULL; LPA_PROFILE_INFO ProfileActive; -void sf_set_wifi_socket(int fd) -{ - WifiSocket = fd; -} - -int sf_get_wifi_socket(void) -{ - return WifiSocket; -} - void sf_set_wifi_cmd(UINT8 cmd) { WifiCurrentCmd = cmd; @@ -2826,6 +2817,7 @@ void sf_operator_scan_thread(UINT32 *tmp) LPA_PROFILE_INFO profileItem; UINT16 profileListBase = 0; UINT8 OperatorNameL[20] = {0}; + SF_REPORT_WIFI_ATTR_S* wifiCfg = sf_wifi_cfg_get(); memset((void *)&profileItem, 0, sizeof(LPA_PROFILE_INFO)); memset((void *)&operatorInfo, 0, sizeof(SF_OPERATORS_LIST_T)); @@ -2865,10 +2857,9 @@ void sf_operator_scan_thread(UINT32 *tmp) - int fd = sf_get_wifi_socket(); + //int fd = sf_get_wifi_socket(); UINT8 currentCmd = sf_get_wifi_cmd(); - if(fd > 0) { sendBuffLen = 10/*Magic+MsgLen+CMD+ACK+EndFlag*/ + 5/*Operator/Profile Total,ID*/ + totalOperator * sizeof(Operator_Info_T) + totalProfile * sizeof(Profile_Info_T); printf("sendBuffLen=%d totalOperator=%d totalProfile=%d\n", sendBuffLen, totalOperator, totalProfile); @@ -2926,14 +2917,37 @@ void sf_operator_scan_thread(UINT32 *tmp) sendBuff[sendBuffLen - 1] = 0xee; //memdump(sendBuff, sendBuffLen); - send(fd,(void *)sendBuff, sendBuffLen, 0); + //send(fd,(void *)sendBuff, sendBuffLen, 0); + wifiCfg->Lenth = sendBuffLen; + memset(wifiCfg->WifiParam, '\0', sizeof(wifiCfg->WifiParam)); + memcpy(wifiCfg->WifiParam, sendBuff, sendBuffLen); + + SF_CHAR filePath[64] = { 0 }; + SINT32 fdWifi = -1; + SF_SPRINTF(filePath, "/tmp/wifiData.txt"); + SLOGD("filePath:%s\n", filePath); + + fdWifi = SF_OPEN(filePath, O_WRONLY | O_CREAT, 0777); + if(fdWifi >= 0) + { + SF_WRITE(fdWifi, sendBuff, sendBuffLen); + SF_CLOSE(fdWifi); + } + + for(i = 0; i < wifiCfg->Lenth; i++) + { + printf("[%x]-", wifiCfg->WifiParam[i]); + } + printf("\n[scan-1] e\n"); + for(i = 0; i < wifiCfg->Lenth; i++) + { + printf("[%x]-", sendBuff[i]); + } + printf("\n[sendBuff-1] e\n"); free(sendBuff); + sf_share_mem_wifi_down(1); - } - else - { - printf("%s(%d)socket error\n",__FUNCTION__,__LINE__); - } + } } @@ -2951,15 +2965,19 @@ void sf_4g_operator_scan(UINT8 mode) UINT8 sf_wifi_server_network_select_finish(UINT8 errCode) { APP_SVR_PACKET_T msgParse; + UINT8 *sendBuff = NULL; + UINT16 sendBuffLen = 0;; UINT32 tmp = 0; + UINT32 i = 0; + SF_REPORT_WIFI_ATTR_S* wifiCfg = sf_wifi_cfg_get(); memset((void *)&msgParse, 0, sizeof(msgParse)); - int fd = sf_get_wifi_socket(); + //int fd = sf_get_wifi_socket(); UINT8 currentCmd = sf_get_wifi_cmd(); - if(fd > 0) { + sendBuff = (UINT8 *)&msgParse; msgParse.msgBuf.rctrlNetworkSelect.cmdRet = errCode; msgParse.msgBuf.rctrlNetworkSelect.suffix = htons(MSG_END_FIX); msgParse.msglen = htons(sizeof(MSG_DEV_NetworkSelect_Ctrl_Rsp_T) + 2*sizeof(UINT16)); @@ -2969,11 +2987,42 @@ UINT8 sf_wifi_server_network_select_finish(UINT8 errCode) msgParse.rsp = htons(MSG_WIFI_2_APP); /* add the magic + len total 2*2 bytes; */ tmp=ntohs(msgParse.msglen); - send( fd,(void *)(&msgParse), (tmp + sizeof(UINT16)*2), 0); -#if 0 + + wifiCfg->Lenth = tmp + sizeof(UINT16)*2; + sendBuffLen = wifiCfg->Lenth; + memset(wifiCfg->WifiParam, '\0', sizeof(wifiCfg->WifiParam)); + memcpy(wifiCfg->WifiParam, sendBuff, wifiCfg->Lenth); +#if 1 printf("[app_agent]:send msg OK, msg_len[%d],data_len:[%d],cmd:[0x%x],rsp[0x%x]\n", (tmp+4), tmp, ntohs(msgParse.cmd), ntohs(msgParse.rsp) ); + for(i= 0; i < wifiCfg->Lenth; i++) + printf("[%x]-", wifiCfg->WifiParam[i]); + + printf("\n"); #endif + SF_CHAR filePath[64] = { 0 }; + SINT32 fdWifi = -1; + SF_SPRINTF(filePath, "/tmp/wifiData.txt"); + SLOGD("filePath:%s\n", filePath); + + fdWifi = SF_OPEN(filePath, O_WRONLY | O_CREAT, 0777); + if(fdWifi >= 0) + { + SF_WRITE(fdWifi, sendBuff, sendBuffLen); + SF_CLOSE(fdWifi); + } + + for(i = 0; i < wifiCfg->Lenth; i++) + { + printf("[%x]-", wifiCfg->WifiParam[i]); + } + printf("\n[scan-1] e\n"); + for(i = 0; i < sendBuffLen; i++) + { + printf("[%x]-", sendBuff[i]); + } + printf("\n[sendBuff-1] e\n"); + sf_share_mem_wifi_down(1); } return 0; @@ -3010,14 +3059,14 @@ SF_BOOL sf_get_active_profile_next_index(UINT8 *index) return TRUE; } -void sf_network_select_thread(UINT32 * tmp) +void sf_network_select_thread(UINT8 * tmp) { - printf("select network.\n"); + printf("select network, PID:%d\n", *tmp); UINT32 ret = SF_LPA_SUCCESS; UINT32 sts = 0; UINT32 retryTime=0; UINT8 errCode = CMD_SUCCESS; - UINT8 profileId = (UINT8)*tmp; + UINT8 profileId = *tmp; UINT8 curActiveProfileId = 0; UINT32 totalProfile = 0; LPA_API_ERROR lpaErrCode = LPA_NO_ERROR; @@ -3086,6 +3135,17 @@ void sf_network_select_thread(UINT32 * tmp) sleep(10); continue; } + else if (lpaErrCode == LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR) + { + retryTime++; + if(retryTime>6) + { + errCode = NETWORK_PROFILE_SELECT_BUSY; + sts = 1; + } + sleep(10); + continue; + } else { if(lpaErrCode == SF_LPA_ERROR_PROFILE_NOT_FOUND) @@ -3233,10 +3293,11 @@ void sf_network_select_thread(UINT32 * tmp) } -void sf_network_select(UINT8 profileId) +void sf_network_select(UINT8* profileId) { pthread_t tNetWorkSeclectTask; - pthread_create(&tNetWorkSeclectTask,NULL,sf_network_select_thread,(void *)&profileId); + SLOGD("sf_network_select,Pid:%d\n", *profileId); + pthread_create(&tNetWorkSeclectTask, NULL, sf_network_select_thread, profileId); } @@ -3304,6 +3365,17 @@ void sf_network_switch_thread() sleep(10); continue; } + else if (lpaErrCode == LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR) + { + retryTime++; + if(retryTime>6) + { + errCode = NETWORK_PROFILE_SELECT_BUSY; + sts = 1; + } + sleep(10); + continue; + } else { if(lpaErrCode == SF_LPA_ERROR_PROFILE_NOT_FOUND) @@ -3392,7 +3464,6 @@ void sf_network_switch(void) pthread_create(&tNetWorkSeclectTask,NULL,sf_network_switch_thread,NULL); } - #endif diff --git a/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c b/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c index 0d6e39e61..189060c47 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c @@ -2661,7 +2661,7 @@ SINT32 sf_module_complete_init(void) //SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE); //break; } - else if(strstr((const char *)gsmPara, "+QSIMSTAT: 0,1")) + else if(strstr((const char *)gsmPara, "+QSIMSTAT: 0,1") || (strstr((const char *)gsmPara, "+QSIMSTAT: 0,2"))) { eNetRegLocation = QUECTEL_NETREG_DBGCTL; sf_set_sim_insert(1); @@ -2962,22 +2962,45 @@ SINT32 sf_module_complete_init(void) } else if(strstr((const char *)gsmPara, "NOT")) { - sf_set_sim_insert(0); - sf_set_sim_pin_flag(1, 1, 1); + if(time > 200) + { + sf_set_sim_insert(0); + sf_set_sim_pin_flag(1, 1, 1); - ret = SF_SIM_ERROR_PIN; - SLOGE(gsmPara); - sprintf((char *)logStr, "Error Code:0x%08X\n", ret); - SLOGE(logStr); - goto SF_MODULE_END; + ret = SF_SIM_ERROR_PIN; + SLOGE(gsmPara); + sprintf((char *)logStr, "Error Code:0x%08X\n", ret); + SLOGE(logStr); + goto SF_MODULE_END; + } + else if(time % 10 == 0) + { + SLOGD("--------tempi:%d--------", time); + sprintf((char *)gsmPara, "AT+CPIN?\r"); + ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen(gsmPara)); + SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE); + } + } else if(strstr((const char *)gsmPara, "ERROR")) { - ret = SF_SIM_ERROR_AT_TIMEOUT; - SLOGE(gsmPara); - sprintf((char *)logStr, "Error Code:0x%08X\n", ret); - SLOGE(logStr); - goto SF_MODULE_END; + + if(time > 200) + { + ret = SF_SIM_ERROR_AT_TIMEOUT; + SLOGE(gsmPara); + sprintf((char *)logStr, "Error Code:0x%08X\n", ret); + SLOGE(logStr); + goto SF_MODULE_END; + } + else if(time % 10 == 0) + { + SLOGD("--------tempi:%d--------", time); + sprintf((char *)gsmPara, "AT+CPIN?\r"); + ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen(gsmPara)); + SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE); + } + } else { @@ -3265,8 +3288,8 @@ SINT32 sf_net_regist_manual(void) SF_LOG("operation info manual set,default success.\n"); } SF_LOG("puiPara->ModuleVer:%s\n",puiPara->ModuleVer); - if((strstr((const char *)puiPara->Sim4gApn, APN_4G_VERIZON)) && ((SF_STRNCMP(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG91_V, 6) == 0)) \ - && ((SF_STRNCMP(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG95_V, 6) == 0))) + if((strstr((const char *)puiPara->Sim4gApn, APN_4G_VERIZON)) \ + && (((SF_STRNCMP(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG91_NAXD, 6) == 0))|| ((SF_STRNCMP(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG95_NAXD, 6) == 0)))) { eNetRegLocation = QUECTEL_NETREG_QNVFW; sprintf((char *)gsmPara, "%s", "at+qnvfr=\"/nv/item_files/modem/uim/gstk/feature_bmsk\"\r"); @@ -5185,6 +5208,106 @@ void sf_4g_module_sleep(void) return; } + +/************************************************* + Function: sf_4g_test_esim + Description: 4g module enter minimun fun + Input: N/A + Output: N/A + Return: N/A + Others: N/A +*************************************************/ +SINT32 sf_4g_test_esim(void) +{ + SINT32 ret = 0; //0:start; 1:success; 2:timeout; 3:fail; + UINT8 time = 0; + UINT8 calltime = 0; + SF_SIM_E eSmsLocation = SMS_SIM_INIT_DTRUP; + int ttyRet = 0; + UIMenuStoreInfo *pPara = sf_app_ui_para_get(); + + printf("%s\n", __FUNCTION__); + + if(/*(pPara->GpsSwitch) && */(pPara->NeedTimeSyncStartUp == 1) || pPara->FristSendDailyAndGps) + { + return ret; + } + + sf_gsm_para_buff_clear(); + + strcpy((char *)gsmPara, "AT$QCSIMSLEEP=0\r"); + ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen(gsmPara)); + + while(sf_app_while_flag()) + { + time++; + + if(time >= 100) + { + ret = SF_SIM_ERROR_AT_TIMEOUT; + sprintf((char *)logStr, "ReadMsg Wait Init Timeout.\n[ERROR]eSmsLocation=%d", eSmsLocation); + SLOGE(logStr); + time = 0; + return ret; + } + + sf_gsm_para_buff_clear(); + + sf_hal_ttyusb2_read(gsmPara, 200); + if(gsmPara[0] != '\0') + { + printf("[%s:%d]eSmsLocation:%d\ngsmPara:%s\n", __FUNCTION__, __LINE__, eSmsLocation, gsmPara); + } + switch(eSmsLocation) + { + case SMS_SIM_INIT_DTRUP: + + if(strstr((const char *)gsmPara, "OK")) + { + strcpy((char *)gsmPara, "AT\r"); //sleep + ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen(gsmPara)); + SF_CHECK_RETURN(ttyRet, SF_SIM_ERROR_AT_TIMEOUT); + eSmsLocation = SMS_SIM_INIT_EXIT; + } + else if(strstr((const char *)gsmPara, "ERROR")) + { + goto SF_FUN_RETURN; + } + + break; + + case SMS_SIM_INIT_EXIT: + + if(strstr((const char *)gsmPara, "OK")) + { + goto SF_FUN_RETURN; + } + else + { + calltime++; + + if(calltime > 20) + { + ret = SF_SIM_ERROR_AT_TIMEOUT; + sprintf((char *)logStr, "[%s:%d]ErrorCode=0x%08x,AT+QSCLK Timeout.", __FUNCTION__, __LINE__, ret); + SLOGE(logStr); + goto SF_FUN_RETURN; + } + } + + break; + + default: + break; + } + } + + SF_FUN_RETURN: + + printf("[%s:%d] ret:%d\n", __FUNCTION__, __LINE__, ret); + return ret; +} + /************************************************* Function: sf_4g_set_module_minimun_fun Description: 4g module enter minimun fun diff --git a/code/application/source/sf_app/code/source/app/sf_app.c b/code/application/source/sf_app/code/source/app/sf_app.c index 4f167fb5e..40c3b8f67 100755 --- a/code/application/source/sf_app/code/source/app/sf_app.c +++ b/code/application/source/sf_app/code/source/app/sf_app.c @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) { printf("*********************************************\n"); printf("* *\n"); - printf("* sf_app-v3 *\n"); + printf("* sf_app-v5 *\n"); printf("* *\n"); printf("*********************************************\n"); //gpio_direction_input(C_GPIO(10)); 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 96093035a..fc1783bbb 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 @@ -899,18 +899,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\n"); - sf_set_wifi_socket(pMessageBuf->arg2); + MLOGI("SF_DEV_CMD_ESIM_OPERATION_SCAN: arg3:%d\n", pMessageBuf->arg3); + //sf_set_wifi_socket(pMessageBuf->arg2); sf_set_wifi_cmd(0x3b);//WIFI_CONTROL_CAMERA_Network_Scan sf_4g_operator_scan(pMessageBuf->arg3); break; case SF_DEV_CMD_ESIM_OPERATION_SELECT: - MLOGI("SF_DEV_CMD_ESIM_OPERATION_SELECT\n"); - sf_set_wifi_socket(pMessageBuf->arg2); + MLOGI("SF_DEV_CMD_ESIM_OPERATION_SELECT:arg3:%d\n", pMessageBuf->arg3); + //sf_set_wifi_socket(pMessageBuf->arg2); sf_set_wifi_cmd(0x3c);//WIFI_CONTROL_CAMERA_Network_Select - sf_network_select(pMessageBuf->arg3); + sf_network_select(&pMessageBuf->arg3); break; case SF_DEV_CMD_ESIM_OPERATION_SWTICH: diff --git a/code/application/source/sf_app/code/source/app/sf_service.c b/code/application/source/sf_app/code/source/app/sf_service.c index 01beefc39..e29c8845a 100755 --- a/code/application/source/sf_app/code/source/app/sf_service.c +++ b/code/application/source/sf_app/code/source/app/sf_service.c @@ -1632,7 +1632,7 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) { sf_sms_lpa_command_recombination_log(SF_SMS_LPA_CMD_FAIL, SF_LPA_CUSTOM_ERROR_NETWORK_REJECTED); - if(pCustomerParam->PreActiveProfileIccid != '\0') + if(pCustomerParam->PreActiveProfileIccid[0] != '\0') { sf_sms_lpa_profile_rool_back((const SINT8 *)pCustomerParam->PreActiveProfileIccid); memset(pCustomerParam->PreActiveProfileIccid, '\0', sizeof(pCustomerParam->PreActiveProfileIccid)); diff --git a/code/application/source/sf_app/code/source/commMng/sf_share_mem.c b/code/application/source/sf_app/code/source/commMng/sf_share_mem.c old mode 100644 new mode 100755 index c64086c26..c06fae119 --- a/code/application/source/sf_app/code/source/commMng/sf_share_mem.c +++ b/code/application/source/sf_app/code/source/commMng/sf_share_mem.c @@ -23,11 +23,15 @@ extern "C" { #include "sf_param_common.h" #include "sf_fileMng.h" #include "sf_message_queue.h" +#include "sf_4g_lpa.h" + int sf_semId = -1; int sf_sharMemId = -1; int sf_sharMemfileId = -1; int sf_hdMemId = -1; +int sf_wifiMemId = -1; + union semun { int val; struct semid_ds *buf; @@ -363,6 +367,73 @@ SINT32 sf_share_mem_hd_down(UINT32 to) } +SINT32 sf_share_mem_wifi_update(void)//cardv get data from share mem +{ + SF_REPORT_WIFI_ATTR_S *pSfWifiPara = 0; + if(SF_SUCCESS == sf_share_mem_init((char*)"/tmp/sf_wifi",sizeof(SF_REPORT_WIFI_ATTR_S),&sf_wifiMemId)) + { + pSfWifiPara = (SF_REPORT_WIFI_ATTR_S *)sf_share_mem_get(sf_wifiMemId); + if(pSfWifiPara <= 0) + { + printf("[%s:%d] creat share mem failed!!!\n", __FUNCTION__, __LINE__); + return SF_FAILURE; + } + else + { + sf_wifi_param_set(pSfWifiPara); + shmdt(pSfWifiPara); + printf("[%s:%d] creat share mem succeed ID:%d!!!\n", __FUNCTION__, __LINE__, sf_wifiMemId); + return SF_SUCCESS; + } + + } + return SF_FAILURE; + +} + +SINT32 sf_share_mem_wifi_down(UINT32 to)//sf_app upload data to share mem +{ + SF_REPORT_WIFI_ATTR_S *pSfWifiPara = 0; + + printf("[%s:%d] s\n", __FUNCTION__, __LINE__); + if(SF_SUCCESS == sf_share_mem_init((char*)"/tmp/sf_wifi",sizeof(SF_REPORT_WIFI_ATTR_S),&sf_wifiMemId)) + { + pSfWifiPara = (SF_REPORT_WIFI_ATTR_S *)sf_share_mem_get(sf_wifiMemId); + if(pSfWifiPara <= 0) + { + printf("[%s:%d] creat share mem failed!!!\n", __FUNCTION__, __LINE__); + return SF_FAILURE; + } + else + { + sf_wifi_cfg_set_down(pSfWifiPara); + shmdt(pSfWifiPara); + SF_MESSAGE_BUF_S stMessageBuf = {0}; + if(to)//to cardv + { + stMessageBuf.arg1 = SF_WIFI_CMD_SEND; + stMessageBuf.cmdId = CMD_WIFI; + MLOGI("PARA UPDATE to cardv ID:%d\n",sf_wifiMemId); + sf_com_message_send_to_cardv(&stMessageBuf); + } + else //to sf app + { + stMessageBuf.arg1 = SF_PARA_CMD_UPDATE; + stMessageBuf.cmdId = CMD_FILE; + MLOGI("PARA UPDATE to app ID:%d\n",sf_wifiMemId); + sf_com_message_send_to_app(&stMessageBuf); + } + + //printf("[%s:%d] to:%d creat share mem succeed ID:%d!!!\n", __FUNCTION__, __LINE__, to, sf_hdMemId); + return SF_SUCCESS; + } + + } + return SF_FAILURE; + +} + + #ifdef __cplusplus #if __cplusplus diff --git a/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c b/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c index e04826dab..61cf1f1b8 100755 --- a/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c +++ b/code/application/source/sf_app/code/source/fileMng/sf_fileMng.c @@ -25,6 +25,8 @@ SF_SRCFILE_ATTR_S *pThumbFileCfg = 0; static SF_HDFILE_ATTR_S HDFileCfg = {0}; static SF_HDFILE_ATTR_S VideoFileCfg = {0}; +static SF_REPORT_WIFI_ATTR_S stWifiParam = {0}; + //"^HRT[0-9]{5}.txt$" //"^W[0-9]{7}.txt$" @@ -692,6 +694,24 @@ SF_HDFILE_ATTR_S* sf_file_video_cfg_get(void) { return &VideoFileCfg; } + +SF_REPORT_WIFI_ATTR_S* sf_wifi_cfg_get(void) +{ + return &stWifiParam; +} + +void sf_wifi_cfg_set_down(SF_REPORT_WIFI_ATTR_S *pSfWifiPara) +{ + //currentInfo = *pSfCustomerPara; + memcpy(pSfWifiPara, &stWifiParam, sizeof(SF_REPORT_WIFI_ATTR_S)); +} + +void sf_wifi_param_set(SF_REPORT_WIFI_ATTR_S *pSfWifiPara) +{ + //currentInfo = *pSfCustomerPara; + memcpy(&stWifiParam, pSfWifiPara, sizeof(SF_REPORT_WIFI_ATTR_S)); +} + #ifdef __cplusplus #if __cplusplus } 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 b364f45cf..696c1ca4d 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 @@ -2035,7 +2035,8 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_CONTROL_CAMERA_Network_Scan: - //sf_set_wifi_socket(fd); + sf_set_wifi_socket(fd); + 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; @@ -2047,6 +2048,9 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_CONTROL_CAMERA_Network_Select: //SF_MESSAGE_BUF_S stMessageBuf = {0}; + sf_set_wifi_socket(fd); + 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.arg3 = pMsgStruct->msgBuf.ctrlNetworkSelect.profileId; @@ -2138,6 +2142,12 @@ void appSvrResponseSocketSet(SINT32 socket) gSendSocket = socket; } +SINT32 appSvrResponseSocketGet( ) +{ + //printf("appSvrResponseSocketSet socket=%d\n", socket); + return gSendSocket; +} + UINT8 sf_wifi_server_stop_shoot_respond(UINT8 errCode) { APP_SVR_PACKET_T msgParse; diff --git a/code/lib/source/sifar/code/include/sf_common.h b/code/lib/source/sifar/code/include/sf_common.h index 1525d0273..041edd218 100755 --- a/code/lib/source/sifar/code/include/sf_common.h +++ b/code/lib/source/sifar/code/include/sf_common.h @@ -122,4 +122,6 @@ UINT32 sf_cardv_cap_start(void); UINT32 sf_cardv_hd_cap_start(void); void sf_cardv_set_wait_shared_condition(int in); int sf_cardv_para_signaling_start(void); +UINT32 sf_cardv_wifi_send(); + #endif 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 c8cf6efeb..6f77e5f7e 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -88,7 +88,7 @@ static SINT16 cTemper = 0; static pthread_cond_t condition; static pthread_mutex_t Param_mutexLock; static int shared_condition = 1; - +static SINT32 WifiSocket = 0; static SF_THREAD_S UpgradeTskParam = { .IsRun = 0, @@ -156,6 +156,15 @@ void sf_set_auto_off_time(UINT16 time) AutoOfftime = time; } +void sf_set_wifi_socket(int fd) +{ + WifiSocket = fd; +} + +int sf_get_wifi_socket(void) +{ + return WifiSocket; +} void sf_mode_detect(void) { static UINT8 state = 0; @@ -287,7 +296,7 @@ void sf_mode_detect(void) { AutoOfftime=0; } - + AutoOfftime=0; //if(((System_GetState(SYS_STATE_CURRMODE) == PRIMARY_MODE_PHOTO)&& (gPhotoData.State == PHOTO_ST_VIEW)) // || ((System_GetState(SYS_STATE_CURRMODE) == PRIMARY_MODE_MOVIE) && (FlowMovie_GetMovDataState() == MOV_ST_VIEW))) if(sf_is_preview()) @@ -1666,6 +1675,11 @@ static SINT32 sf_cardv_proccess_cmd_wifi(SF_MESSAGE_BUF_S *pMessageBuf) case SF_WIFI_CMD_HD_TURE: sf_cardv_hd_cap_start(); break; + + case SF_WIFI_CMD_SEND: + sf_cardv_wifi_send(); + break; + default: break; } @@ -2578,4 +2592,43 @@ UINT32 sf_cardv_hd_cap_start(void) HdCapTskCfg.IsRun = 1; return SF_SUCCESS; +} + +UINT32 sf_cardv_wifi_send() +{ + SINT32 fd = 0; + SINT32 sendBuffLen = 0; + SINT8 sendBuff[1024] = { 0 }; + SINT32 i = 0; + struct stat statBuf; + + if(SF_SUCCESS == sf_share_mem_hd_update()) + { + SF_REPORT_WIFI_ATTR_S* wifiCfg = sf_wifi_cfg_get(); + fd = sf_get_wifi_socket(); + + SF_CHAR filePath[64] = { 0 }; + SINT32 fdWifi = -1; + sprintf(filePath, "/tmp/wifiData.txt"); + printf("filePath:%s\n", filePath); + + fdWifi = open(filePath, O_RDWR, 0777); + if(fdWifi >= 0) + { + fstat(fdWifi, &statBuf); + sendBuffLen = statBuf.st_size; + printf("fSize=%d\n", sendBuffLen); + read(fdWifi, sendBuff, sendBuffLen); + close(fdWifi); + + for(i = 0; i < sendBuffLen; i++) + { + printf("[%x]-", sendBuff[i]); + } + printf("\n[cardv-sendBuff-1] e\n"); + + send(fd, sendBuff, sendBuffLen, 0); + remove("/tmp/wifiData.txt"); + } + } } \ No newline at end of file