From eccecf2618f90e30d28d2e652389203556e39122 Mon Sep 17 00:00:00 2001 From: payton Date: Mon, 15 Jan 2024 09:53:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=88=E5=B9=B6=E4=BD=B3=E6=95=8Flpa?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sf_app/code/include/sf_4G_sms_lpa_cmd.h | 6 +- .../source/sf_app/code/source/4gMng/sf_ftp.c | 56 +++++ .../source/sf_app/code/source/4gMng/sf_sms.c | 205 ++++++++++++++++-- .../sf_app/code/source/app/sf_service.c | 18 +- 4 files changed, 258 insertions(+), 27 deletions(-) diff --git a/code/application/source/sf_app/code/include/sf_4G_sms_lpa_cmd.h b/code/application/source/sf_app/code/include/sf_4G_sms_lpa_cmd.h index 6a848dc9f..d672e26fa 100755 --- a/code/application/source/sf_app/code/include/sf_4G_sms_lpa_cmd.h +++ b/code/application/source/sf_app/code/include/sf_4G_sms_lpa_cmd.h @@ -54,11 +54,13 @@ #define SF_LPA_PROFILE_INFO_FILENEME (UINT8 *)"B:\\UDF\\profile_info.txt" #define SF_LPA_PROFILE_INFO_BACKUP_FILENEME (UINT8 *)"B:\\UDF\\profile_info_backup.txt" #else +// to do: save in flash #define SF_LPA_DOWNLOAD_PROFILE_AC_FILENEME "/tmp/download_ac.txt" #define SF_LPA_DOWNLOAD_ENABLE_PROFILE_AC_FILENEME "/tmp/download_enable_ac.txt" #define SF_LPA_PROFILE_INFO_FILENEME "/tmp/profile_info.txt" -#define SF_LPA_PROFILE_INFO_BACKUP_FILENEME "profile_info.txt" -#define SF_LPA_LOG_FILE_PATH "/mnt/sd/" //No use + +#define SF_LPA_PROFILE_INFO_BACKUP_FILENEME "/mnt/sd/profile_info.txt" +#define SF_LPA_LOG_FILE_PATH "/mnt/sd/" #endif typedef struct SF_SMS_LPA_CMD_S{ diff --git a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c index 10dc17a66..6b43c0bbf 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c @@ -1095,6 +1095,62 @@ SINT32 sf_video_send_ftp(void) return ret; } +SINT32 sf_ftp_lpa_log_send(void) +{ + SINT32 ret = SF_SUCCESS; + //UINT8 CamNameStr[20] = { 0 }; + UINT8 uploadFname[64] = { 0 }; + UINT8 lpaFile[64] = { 0 }; + UINT8 filePath[64] = { 0 }; + int timeout = 60000; + UIMenuStoreInfo *pPara = sf_app_ui_para_get(); + SF_PDT_PARAM_STATISTICS_S *pSifarPara = sf_statistics_param_get(); + + MLOGD("start\n"); + + printf("%s:%d filePath:%s\n", __FUNCTION__, __LINE__, filePath); + sprintf(lpaFile, "%s", sf_sms_lpa_log_file_name_get()); + sprintf(uploadFname, "%s/%s", SF_LPA_LOG_FILE_PATH, lpaFile); + + ret = SF_SUCCESS; + + if(SF_SUCCESS != ret) + { + printf("%s:%d upload err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + } + else + { + ret = sf_ftp_send(uploadFname, filePath, timeout); + + if(SF_SUCCESS != ret) + { + printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + }else { + DailyReportFtpSendSucess = 1; + pSifarPara->picSendCount = 0; + pSifarPara->sendThumbnailCount = 0; + pSifarPara->picSendSucessCount = 0; + pSifarPara->picSendTimeoutCount = 0; + pSifarPara->picSendFailCount = 0; + pSifarPara->sendThumbnailFailCount = 0; + pSifarPara->picSendTimeCount = 0; + pSifarPara->sendThumbnailTimeCount = 0; + pSifarPara->TirgNum=0; + pSifarPara->NewFlieCount=0; + pSifarPara->videoSendCount = 0; + pSifarPara->videoSendTimeCount = 0; + pSifarPara->videoSendFailCount = 0; + pSifarPara->videoSendSucessCount = 0; + pSifarPara->SendlowPowerWarnCnt = 0; + } + sf_dailyReport_set(); + } + MLOGD(" end ret:[0x%08X]\n", ret); + + return ret; +} + + SINT32 sf_ftp_dailyreport_send(void) { SINT32 ret = SF_SUCCESS; diff --git a/code/application/source/sf_app/code/source/4gMng/sf_sms.c b/code/application/source/sf_app/code/source/4gMng/sf_sms.c index f51e78bb5..06fc1d0a0 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_sms.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_sms.c @@ -42,6 +42,8 @@ #include "sf_fileMng.h" #include "sf_battery.h" #include "sf_system.h" +#include "sf_4G_sms_lpa_cmd.h" + /************************************************************************** * C O N S T A N T S * **************************************************************************/ @@ -1282,6 +1284,159 @@ UINT8 sf_message_data_processing(UINT8 strValue[30][32], UINT16 mm, UINT8 *sms_s return Readmmsok; } + + +UINT8 sf_poweroff_check_lpa_excute_cmd() +{ + //sf_mcu_watchdog_set(5); + sf_sms_lpa_download_command_add_to_list(); + sf_sms_lpa_command_execute(); + if(sf_sms_lpa_is_need_send_lpa_log() && (!sf_sms_lpa_is_need_enable_profile())) + { + sf_sms_lpa_set_send_lpa_log_flg(FALSE); + // to do: send lpa log + //sf_ftp_txt_file_send(FTP_FILE_LPA_LOG); + } + return 0; +} + +UINT8 sf_poweroff_check_lpa_enable_profile() +{ + if(sf_sms_lpa_is_need_enable_profile()) + { + sf_sms_lpa_command_enable_profile_handle(sf_sms_lpa_get_enable_profile_cmd_val()); + sf_sms_lpa_clean_need_enable_iccid(); + + if(!sf_sms_lpa_is_need_profile_switch_reboot() && sf_sms_lpa_is_need_send_lpa_log()) + { + sf_sms_lpa_set_send_lpa_log_flg(FALSE); + + // to do: send lpa log + //sf_ftp_txt_file_send(FTP_FILE_LPA_LOG); + printf("enter send LPA LOG\n"); + + } + else + { + printf("profile enable, reboot to re search net\n"); + ///sf_set_netsearch_step(SIM_NETSEARCH_STEP_IDLE); + + //to do: poweroff 4G MODELU power off, a reboot + //sf_set_poweroff_type(SF_POWEROFF_SYNC_PARAM); + return 0; + } + } +} + +UINT8 sf_sms_content_parse(SF_CHAR *smsStr) +{ + SF_CHAR strValue[32][32]= {0}; + SF_CHAR *temp = NULL; + SF_CHAR *lpaCmdStr = NULL; + UINT16 i = 0; + UINT16 smsCnt = 0; + UINT8 ret; + SF_SMS_LPA_CMD_T *pLpaCmd = NULL; + UIMenuStoreInfo *sfParam = sf_app_ui_para_get(); + SF_PDT_PARAM_STATISTICS_S *sfStat = sf_statistics_param_get(); + + if(strlen(smsStr) > 0) + { + + lpaCmdStr = SF_STRSTR(smsStr, "$R0e*"); + if(lpaCmdStr == NULL) + { + smsCnt = 0; + temp = strsep(&smsStr, "#"); + while(temp != 0) + { + strcpy(strValue[smsCnt], temp); + smsCnt++; + printf("---temp%d:%s\n", smsCnt, temp); + temp = strsep(&smsStr, "#"); + } + } + else + { + smsCnt = 1; + } + } + + if(smsCnt > 0) + { + i = 0; + + if(lpaCmdStr != NULL) + { + //printf("Error Format line-1\n", __LINE__); + //lpaCmdStr = SF_STRSTR(smsStr, "R0e*"); + //printf("Error Format line\n", __LINE__); + + pLpaCmd = malloc(sizeof(SF_SMS_LPA_CMD_T)); + memset(pLpaCmd, 0, sizeof(SF_SMS_LPA_CMD_T)); + + if(pLpaCmd != NULL) + { + if(sf_sms_lpa_command_info_extract((SINT8 *)lpaCmdStr, &pLpaCmd->CmdVal, pLpaCmd->Param1Buff, pLpaCmd->Param2Buff, pLpaCmd->Param3Buff) == SF_SUCCESS) + { + if((pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DOWNLOAD_PROFILE_1) || (pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DOWNLOAD_ENABLE_PROFILE_1)) + { + sf_sms_lpa_save_download_profile_activation_code(pLpaCmd->CmdVal, pLpaCmd->Param1Buff); + //sf_sms_lpa_command_log(pLpaCmd, SF_SMS_LPA_CMD_SUCCESS, LPA_NO_ERROR, SF_SMS_LPA_CMD_ERROR_SOURCE_OTHER); + } + else if((pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DOWNLOAD_PROFILE_2) || (pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DOWNLOAD_ENABLE_PROFILE_2)) + { + sf_sms_lpa_command_handle(pLpaCmd); + } + else if(pLpaCmd->CmdVal == SF_SMS_LPA_CMD_ENABLE_PROFILE) + { + sf_sms_lpa_command_handle(pLpaCmd); + //sf_sms_lpa_command_enable_profile_handle(sf_sms_lpa_get_enable_profile_cmd_val()); + } + else if((pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DELETE_PROFILE) || (pLpaCmd->CmdVal == SF_SMS_LPA_CMD_DELETE_PROFILE_NITIFY)) + { + sf_sms_lpa_command_handle(pLpaCmd); + } + else + { + /*cmd prase fail,need send lpa log*/ + //sf_sms_lpa_command_log(pLpaCmd, SF_SMS_LPA_CMD_FAIL, SF_LPA_CUSTOM_ERROR_CMD_UNKNOWN, SF_SMS_LPA_CMD_ERROR_SOURCE_OTHER); + printf("Error Parameter line:%d i=%d\n", __LINE__, i); + ret = SMS_STATUS_PARA_ERR; + } + } + else + { + /*cmd prase fail,need send lpa log*/ + //sf_sms_lpa_command_log(NULL, SF_SMS_LPA_CMD_FAIL, SF_LPA_CUSTOM_ERROR_CMD_UNKNOWN, SF_SMS_LPA_CMD_ERROR_SOURCE_OTHER); + printf("Error Format line:%d i=%d\n", __LINE__, i); + ret = SMS_STATUS_FORMAT_ERR; + } + + free(pLpaCmd); + } + else + { + /*cmd prase fail,need send lpa log*/ + //sf_sms_lpa_command_log(NULL, SF_SMS_LPA_CMD_FAIL, SF_LPA_CUSTOM_ERROR_MEMORY, SF_SMS_LPA_CMD_ERROR_SOURCE_OTHER); + printf("Error Memory line:%d i=%d\n", __LINE__, i); + ret = SMS_STATUS_FORMAT_ERR; + } + } + else + { + printf("Error Format2 line:%d i=%d\n", __LINE__, i); + ret = SMS_STATUS_FORMAT_ERR; + } + } + else + { + printf("Error Format3 line:%d i=%d\n", __LINE__, i); + ret = SMS_STATUS_NO_RESPONSE; + } + + return ret; +} /************************************************* Function: sf_sms_read_message Description: read message @@ -1526,35 +1681,41 @@ SINT32 sf_sms_read_message(void) break; } */ - - if(strstr((const char *)gsmPara, "$")) + if(strstr((const char *)gsmPara, "$R0e*"))//lpa cmd { - strtok((char *)gsmPara, "$"); - //strcpy((char *)strok, strtok(NULL, "$")); - snprintf((char *)strok, sizeof(strok), "%s", strtok(NULL, "$")); - //printf("strok:%s\n", strok); + Readmmsok = sf_sms_content_parse(gsmPara); } - - if(strlen((const char *)strok) > 0) + else { - mm = 0; - pStr = (char *)strok; - //printf("pStr:%s\n", pStr); - temp = (UINT8 *)strsep(&pStr, "#"); - - while(temp != 0) + if(strstr((const char *)gsmPara, "$")) { - //strcpy((char *)strValue[mm], (const char *)temp); - snprintf((char *)strValue[mm], sizeof(strValue[mm]), "%s", temp); - printf("strValue[%d]:%s\n", mm, strValue[mm]); - mm++; - temp = (UINT8 *)strsep(&pStr, "#"); + strtok((char *)gsmPara, "$"); + //strcpy((char *)strok, strtok(NULL, "$")); + snprintf((char *)strok, sizeof(strok), "%s", strtok(NULL, "$")); + //printf("strok:%s\n", strok); } + + if(strlen((const char *)strok) > 0) + { + mm = 0; + pStr = (char *)strok; + //printf("pStr:%s\n", pStr); + temp = (UINT8 *)strsep(&pStr, "#"); + + while(temp != 0) + { + //strcpy((char *)strValue[mm], (const char *)temp); + snprintf((char *)strValue[mm], sizeof(strValue[mm]), "%s", temp); + printf("strValue[%d]:%s\n", mm, strValue[mm]); + mm++; + temp = (UINT8 *)strsep(&pStr, "#"); + } + } + + Readmmsok = sf_message_data_processing(strValue, mm, &sms_send_mode); } - Readmmsok = sf_message_data_processing(strValue, mm, &sms_send_mode); - - printf("[%s:%d] getCmdFlag:%d Readmmsok:%d\n", __FUNCTION__, __LINE__, getCmdFlag, Readmmsok); + printf("[%s:%d] getCmdFlag:%d Readmmsok:%d\n", __FUNCTION__, __LINE__, getCmdFlag, Readmmsok); if(getCmdFlag) { eSmsLocation = SMS_SIM_CMGR; 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 2cac82bec..e0953ebed 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 @@ -1496,6 +1496,7 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) usleep(100*1000); } + // to do: 首次升级之后需要删除LPA log if(!sf_is_esim_card() || pCustomerParam->UpdateFlg) { if(pCustomerParam->UpdateFlg) @@ -1503,7 +1504,6 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) pCustomerParam->UpdateFlg = 0; //sf_set_param_save_flag(); } - sf_sms_lpa_delete_lpa_log(); } @@ -1757,6 +1757,7 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) usleep(100*1000); } + //to do:首次烧录后删除lpa log if(!sf_is_esim_card() || pCustomerParam->UpdateFlg) { if(pCustomerParam->UpdateFlg) @@ -1805,7 +1806,8 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) sf_lpa_get_esim_iccid(simIccidTmp); snprintf((char *)pCustomerParam->SimIccidV, sizeof(pCustomerParam->SimIccidV), (char *)simIccidTmp[0]); snprintf((char *)pCustomerParam->SimIccidA, sizeof(pCustomerParam->SimIccidA), (char *)simIccidTmp[1]); - + + // to do: 注网收到0,3的返回时,返回SF_SIM_ERROR_REG_NET_REFUSE s32ret = sf_4G_register_net_manual(pfnParam); if(pCustomerParam->ProfileSwitchFlg) @@ -1839,7 +1841,7 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) if(s32ret == SF_SUCCESS) sf_sms_lpa_set_send_lpa_log_flg(1); - // switch prlfile reboot in A reg net, reg 0,1 or reg 0,2, not need reboot again + // switch profile reboot in A reg net, reg 0,1 or reg 0,2, not need reboot again pCustomerParam->NetWorkNeedSearch = 0; } } @@ -1874,6 +1876,13 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) } } //sf_share_mem_customer_down(1); + + //to do :profile,reboot regnet,than send lpa log;log is exist + if(sf_sms_lpa_is_need_send_lpa_log()) + { + //tp_txt_file_send(FTP_FILE_LPA_LOG); + + } break; case SF_MCU_STARTUP_SYN_PARAM: @@ -1899,6 +1908,9 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) set_at_parament(); sf_USB_net_init(); + //to do : send lpa direct + //_ftp_txt_file_send(FTP_FILE_LPA_LOG); + if ((SF_ON == pCustomerParam->GpsSwitch) || (pCustomerParam->FristSendDailyAndGps)) { const int KEEP_SERACHING_TIMEOUT_MS = 2000;