From b1ec28e97939dea4090b6acc2727f527ebd34991 Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 6 Sep 2023 21:09:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8E=BB=E9=99=A4=E7=BC=96=E8=AF=91=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/sf_app/code/include/sf_4g_lpa.h | 20 +- .../sf_app/code/source/4gMng/sf_4g_lpa.c | 302 +++++++++--------- 2 files changed, 161 insertions(+), 161 deletions(-) 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 b5f5b1f53..f01d8b7b1 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 @@ -9,13 +9,13 @@ #define INPUT_SUBFOLDER "mnt/sd/config" #define OUTPUT_SUBFOLDER "mnt/sd/logs" -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif +#ifndef true +#define true 1 +#endif + +#ifndef false +#define false 0 +#endif #define PROFILE_STATE_DISABLED 0 @@ -48,8 +48,8 @@ LPA_API_ERROR sf_enable_profile(UINT8 indexProfiles); UINT32 sf_profile_name_paired(UINT8 *profileName, UINT8 *operatorName); void sf_lpa_profile_active_change(void); -UINT8 sf_is_esim_card(); -UINT8 sf_is_esim_init_finish(); +UINT8 sf_is_esim_card(void); +UINT8 sf_is_esim_init_finish(void); UINT32 sf_get_profile_total(void); UINT32 sf_is_profile_index_enable(UINT8 index); @@ -70,7 +70,7 @@ SINT32 sf_lpa_set_download_profile_iccid(SINT8* iccid); 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(); +UINT8 sf_get_wifi_cmd(void); void sf_network_select(UINT8* profileId); void sf_4g_operator_scan(UINT8 mode); 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 8a7e1e4a8..9f99652a9 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 @@ -1918,7 +1918,7 @@ void sf_set_esim_card(UINT8 flag) g_esim_flag = flag; } -UINT8 sf_is_esim_card() +UINT8 sf_is_esim_card(void) { return g_esim_flag; } @@ -1930,7 +1930,7 @@ void sf_set_esim_init_finish(UINT8 flag) { g_esim_init_finish_flag = flag; } -UINT8 sf_is_esim_init_finish() +UINT8 sf_is_esim_init_finish(void) { return g_esim_init_finish_flag; } @@ -1971,7 +1971,7 @@ void sf_lpa_profile_info_refresh(void) -void sf_sample_lpa_thread() +void sf_sample_lpa_thread(void) { bool res; const LPA_API_VERSION* lpaApiVersion; @@ -2346,7 +2346,7 @@ void sf_sample_lpa_init(void) if(!SfLpaTskParam.IsRun) { - pthread_create(&SfLpaTskParam.TskId, NULL, sf_sample_lpa_thread, NULL); + pthread_create(&SfLpaTskParam.TskId, NULL, (void *)sf_sample_lpa_thread, NULL); SfLpaTskParam.IsRun = 1; } } @@ -2369,7 +2369,7 @@ void sf_profile_active_change_thread(ULONG tmp) void sf_lpa_profile_active_change(void) { pthread_t tLpaProfileActiveTask; - pthread_create(&tLpaProfileActiveTask,NULL,sf_profile_active_change_thread,(void *)NULL); + pthread_create(&tLpaProfileActiveTask,NULL,(void *)sf_profile_active_change_thread,(void *)NULL); } @@ -2803,42 +2803,42 @@ void sf_operator_scan_thread(UINT32 *tmp) { printf("scan network.\n"); - UINT8 totalOperator = 0; - UINT8 totalProfile = 0; - UINT8 i = 0; - UINT8 errCode = CMD_SUCCESS; - UINT8 mode = (UINT8)*tmp; - UINT8 *sendBuff = NULL; - UINT16 sendBuffLen = 0; - APP_SVR_PACKET_T *pMsgParse = NULL; - SF_OPERATORS_LIST_T operatorInfo; - Operator_Info_T *pOperatorInfo = NULL; - Profile_Info_T *pProfileInfo = NULL; - LPA_PROFILE_INFO profileItem; - UINT16 profileListBase = 0; + UINT8 totalOperator = 0; + UINT8 totalProfile = 0; + UINT8 i = 0; + UINT8 errCode = CMD_SUCCESS; + UINT8 mode = (UINT8)*tmp; + UINT8 *sendBuff = NULL; + UINT16 sendBuffLen = 0; + APP_SVR_PACKET_T *pMsgParse = NULL; + SF_OPERATORS_LIST_T operatorInfo; + Operator_Info_T *pOperatorInfo = NULL; + Profile_Info_T *pProfileInfo = NULL; + 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)); - - printf("mode=%d\n", mode); - - errCode = sf_check_network_status(); - - if(errCode == CMD_SUCCESS) - { - totalOperator = sf_get_operator_total(); - - if(mode == 0) //scan - { + + memset((void *)&profileItem, 0, sizeof(LPA_PROFILE_INFO)); + memset((void *)&operatorInfo, 0, sizeof(SF_OPERATORS_LIST_T)); + + printf("mode=%d\n", mode); + + errCode = sf_check_network_status(); + + if(errCode == CMD_SUCCESS) + { + totalOperator = sf_get_operator_total(); + + if(mode == 0) //scan + { errCode = NETWORK_CMD_NOT_SUPPORT; #if 0 - sf_operator_delete_to_list(); - sf_operator_scan(); - totalOperator = sf_get_operator_total(); + sf_operator_delete_to_list(); + sf_operator_scan(); + totalOperator = sf_get_operator_total(); #endif - } + } else if(mode == 1) //not scan and return esim info { @@ -2851,71 +2851,71 @@ void sf_operator_scan_thread(UINT32 *tmp) { errCode = NETWORK_CMD_NOT_SUPPORT; } - - totalProfile = sf_get_profile_total(); - } + + totalProfile = sf_get_profile_total(); + } //int fd = sf_get_wifi_socket(); UINT8 currentCmd = sf_get_wifi_cmd(); - { - 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); - sendBuff = malloc(sendBuffLen); - memset((void *)sendBuff, 0, sendBuffLen); - pMsgParse = (APP_SVR_PACKET_T *)sendBuff; - pMsgParse->magicNum = htons(MSG_PRE_FIX); - pMsgParse->cmd = htons(currentCmd); - pMsgParse->rsp = htons(MSG_WIFI_2_APP); - pMsgParse->msglen = htons(sendBuffLen - 2*sizeof(UINT16)); - pMsgParse->msgBuf.rctrlNetworkScan.cmdRet = errCode; - - pMsgParse->msgBuf.rctrlNetworkScan.buff[0] = totalOperator; - pMsgParse->msgBuf.rctrlNetworkScan.buff[1] = 0xff; - pOperatorInfo = (Operator_Info_T *)&(pMsgParse->msgBuf.rctrlNetworkScan.buff[2]); - + { + 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); + sendBuff = malloc(sendBuffLen); + memset((void *)sendBuff, 0, sendBuffLen); + pMsgParse = (APP_SVR_PACKET_T *)sendBuff; + pMsgParse->magicNum = htons(MSG_PRE_FIX); + pMsgParse->cmd = htons(currentCmd); + pMsgParse->rsp = htons(MSG_WIFI_2_APP); + pMsgParse->msglen = htons(sendBuffLen - 2*sizeof(UINT16)); + pMsgParse->msgBuf.rctrlNetworkScan.cmdRet = errCode; + + pMsgParse->msgBuf.rctrlNetworkScan.buff[0] = totalOperator; + pMsgParse->msgBuf.rctrlNetworkScan.buff[1] = 0xff; + pOperatorInfo = (Operator_Info_T *)&(pMsgParse->msgBuf.rctrlNetworkScan.buff[2]); + sf_get_operatorname(OperatorNameL); - for(i = 0; i < totalOperator; i++) - { - if(sf_get_operator_item(i, &operatorInfo) == SUCCESS) - { - pOperatorInfo[i].operatorId = operatorInfo.Index; - SF_STRNCPY(&(pOperatorInfo[i].operatorName), &(operatorInfo.OperatorNameLong), 16); - pOperatorInfo[i].signalVal = operatorInfo.SignalVal; - - if(SF_STRNCMP(operatorInfo.OperatorNameLong, OperatorNameL, sizeof(operatorInfo.OperatorNameLong)) == 0) - { - pMsgParse->msgBuf.rctrlNetworkScan.buff[1] = operatorInfo.Index; - } - } - } - - profileListBase = 2 + totalOperator * sizeof(Operator_Info_T); - printf("profileListBase=%d\n", profileListBase); - pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase] = totalProfile; //htons(totalProfile); - pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 1] = 0xff; - pProfileInfo = (Profile_Info_T *)&(pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 2]); - - for(i = 0; i < totalProfile; i++) - { - if(sf_get_profile_item(i, &profileItem) == SUCCESS) - { - pProfileInfo[i].profileId = i; - SF_STRNCPY(&pProfileInfo[i].profileName, profileItem.profileName, 16); - - if(profileItem.profileState[0] == PROFILE_STATE_ENABLED) - { - pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 1] = i; - } - } - } - - sendBuff[sendBuffLen - 2] = 0xff; - sendBuff[sendBuffLen - 1] = 0xee; - + for(i = 0; i < totalOperator; i++) + { + if(sf_get_operator_item(i, &operatorInfo) == SUCCESS) + { + pOperatorInfo[i].operatorId = operatorInfo.Index; + SF_STRNCPY(&(pOperatorInfo[i].operatorName), &(operatorInfo.OperatorNameLong), 16); + pOperatorInfo[i].signalVal = operatorInfo.SignalVal; + + if(SF_STRNCMP(operatorInfo.OperatorNameLong, OperatorNameL, sizeof(operatorInfo.OperatorNameLong)) == 0) + { + pMsgParse->msgBuf.rctrlNetworkScan.buff[1] = operatorInfo.Index; + } + } + } + + profileListBase = 2 + totalOperator * sizeof(Operator_Info_T); + printf("profileListBase=%d\n", profileListBase); + pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase] = totalProfile; //htons(totalProfile); + pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 1] = 0xff; + pProfileInfo = (Profile_Info_T *)&(pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 2]); + + for(i = 0; i < totalProfile; i++) + { + if(sf_get_profile_item(i, &profileItem) == SUCCESS) + { + pProfileInfo[i].profileId = i; + SF_STRNCPY(&pProfileInfo[i].profileName, profileItem.profileName, 16); + + if(profileItem.profileState[0] == PROFILE_STATE_ENABLED) + { + pMsgParse->msgBuf.rctrlNetworkScan.buff[profileListBase + 1] = i; + } + } + } + + sendBuff[sendBuffLen - 2] = 0xff; + sendBuff[sendBuffLen - 1] = 0xee; + //memdump(sendBuff, sendBuffLen); //send(fd,(void *)sendBuff, sendBuffLen, 0); wifiCfg->Lenth = sendBuffLen; @@ -2948,7 +2948,7 @@ void sf_operator_scan_thread(UINT32 *tmp) sf_share_mem_wifi_down(1); } - + } @@ -3065,16 +3065,16 @@ void sf_network_select_thread(UINT8 * tmp) UINT32 ret = SF_LPA_SUCCESS; UINT32 sts = 0; UINT32 retryTime=0; - UINT8 errCode = CMD_SUCCESS; + UINT8 errCode = CMD_SUCCESS; UINT8 profileId = *tmp; UINT8 curActiveProfileId = 0; UINT32 totalProfile = 0; LPA_API_ERROR lpaErrCode = LPA_NO_ERROR; - - errCode = sf_check_network_status(); - - if(errCode == CMD_SUCCESS) - { + + errCode = sf_check_network_status(); + + if(errCode == CMD_SUCCESS) + { sf_get_profile_active_index(&curActiveProfileId); @@ -3108,11 +3108,11 @@ void sf_network_select_thread(UINT8 * tmp) //LOG_DM_RS("Swich Result:0x%02x\n", lpaErrCode); if(lpaErrCode == LPA_NO_ERROR) - { + { sf_lpa_profile_info_refresh(); - errCode = CMD_SUCCESS; + errCode = CMD_SUCCESS; sts = 1; - } + } else if (lpaErrCode == LPA_ERROR_LOCAL_PROFILE_CAT_BUSY) { retryTime++; @@ -3147,24 +3147,24 @@ void sf_network_select_thread(UINT8 * tmp) continue; } else - { + { if(lpaErrCode == SF_LPA_ERROR_PROFILE_NOT_FOUND) - { - printf("status:PROFILE_NOT_FOUND\n"); - errCode = NETWORK_PROFILE_NOT_FOUND; - } + { + printf("status:PROFILE_NOT_FOUND\n"); + errCode = NETWORK_PROFILE_NOT_FOUND; + } else if(lpaErrCode == SF_LPA_ERROR_PROFILE_IS_ENABLE) - { - printf("status:PROFILE_IS_ENABLE\n"); - errCode = NETWORK_NOT_NEED_SET; - } - else - { - printf("status:SELECT_FAILED\n"); - errCode = NETWORK_PROFILE_SELECT_FAILED; - } + { + printf("status:PROFILE_IS_ENABLE\n"); + errCode = NETWORK_NOT_NEED_SET; + } + else + { + printf("status:SELECT_FAILED\n"); + errCode = NETWORK_PROFILE_SELECT_FAILED; + } sts = 1; - } + } } if(lpaErrCode == LPA_ERROR_LOCAL_PROFILE_CAT_BUSY) @@ -3267,9 +3267,9 @@ void sf_network_select_thread(UINT8 * tmp) } - } + } - sf_wifi_server_network_select_finish(errCode); + sf_wifi_server_network_select_finish(errCode); #if ((!SF_IQ_DEBUG)&&(!SF_4G_TEST)) if(errCode == CMD_SUCCESS) @@ -3281,14 +3281,14 @@ void sf_network_select_thread(UINT8 * tmp) #endif -#if 0 - if((errCode == CMD_SUCCESS) || (errCode == NETWORK_PROFILE_SELECT_FAILED)) - { - sleep(3); - sf_send_poweroff_msg(); - printf("[power off] %s(%d)\n",__FUNCTION__,__LINE__); - } - +#if 0 + if((errCode == CMD_SUCCESS) || (errCode == NETWORK_PROFILE_SELECT_FAILED)) + { + sleep(3); + sf_send_poweroff_msg(); + printf("[power off] %s(%d)\n",__FUNCTION__,__LINE__); + } + #endif } @@ -3307,15 +3307,15 @@ void sf_network_switch_thread() UINT32 ret = SF_LPA_SUCCESS; UINT32 sts = 0; UINT32 retryTime=0; - UINT8 errCode = CMD_SUCCESS; - UINT8 profileId = 0; + UINT8 errCode = CMD_SUCCESS; + UINT8 profileId = 0; UINT8 curActiveProfileId = 0; LPA_API_ERROR lpaErrCode = LPA_NO_ERROR; - - errCode = sf_check_network_status(); + + errCode = sf_check_network_status(); SLOGE("errCode:%x\n", errCode); - if(errCode == CMD_SUCCESS) + if(errCode == CMD_SUCCESS) { if(sf_get_active_profile_next_index(&profileId) == FALSE) { @@ -3338,11 +3338,11 @@ void sf_network_switch_thread() //LOG_DM_RS("Swich Result:0x%02x\n", lpaErrCode); if(lpaErrCode == LPA_NO_ERROR) - { + { sf_lpa_profile_info_refresh(); - errCode = CMD_SUCCESS; + errCode = CMD_SUCCESS; sts = 1; - } + } else if (lpaErrCode == LPA_ERROR_LOCAL_PROFILE_CAT_BUSY) { retryTime++; @@ -3377,24 +3377,24 @@ void sf_network_switch_thread() continue; } else - { + { if(lpaErrCode == SF_LPA_ERROR_PROFILE_NOT_FOUND) - { - printf("status:PROFILE_NOT_FOUND\n"); - errCode = NETWORK_PROFILE_NOT_FOUND; - } + { + printf("status:PROFILE_NOT_FOUND\n"); + errCode = NETWORK_PROFILE_NOT_FOUND; + } else if(lpaErrCode == SF_LPA_ERROR_PROFILE_IS_ENABLE) - { - printf("status:PROFILE_IS_ENABLE\n"); - errCode = NETWORK_NOT_NEED_SET; - } - else - { - printf("status:SELECT_FAILED\n"); - errCode = NETWORK_PROFILE_SELECT_FAILED; - } + { + printf("status:PROFILE_IS_ENABLE\n"); + errCode = NETWORK_NOT_NEED_SET; + } + else + { + printf("status:SELECT_FAILED\n"); + errCode = NETWORK_PROFILE_SELECT_FAILED; + } sts = 1; - } + } } if(lpaErrCode == LPA_ERROR_LOCAL_PROFILE_CAT_BUSY)