1.优化代码,以免app崩溃

This commit is contained in:
payton 2023-08-11 10:39:24 +08:00
parent ff663b3226
commit de6ac0bbc4

View File

@ -2325,10 +2325,11 @@ SINT32 sf_module_complete_init(void)
UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
SLOGD(" s"); SLOGD(" s\n");
//needRecordLogFlag = 1; //needRecordLogFlag = 1;
puiPara->NetGeneration = SF_NET_NO; puiPara->NetGeneration = SF_NET_NO;
sf_gsm_para_buff_clear();
while(sf_app_while_flag()) while(sf_app_while_flag())
{ {
@ -2369,7 +2370,7 @@ SINT32 sf_module_complete_init(void)
sf_test_code_err(eNetRegLocation, "test"); sf_test_code_err(eNetRegLocation, "test");
#endif #endif
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "AT+GSN")))
{ {
delim = " \r\n"; delim = " \r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+GSN"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+GSN"), delim);
@ -2382,8 +2383,10 @@ SINT32 sf_module_complete_init(void)
mm++; mm++;
pTemp = strtok((char *)0, delim); pTemp = strtok((char *)0, delim);
} }
strcpy((char *)strNow, (const char *)strtmp[1]); snprintf((char *)strNow, sizeof(strNow), "%s", (const char *)strtmp[1]);
SLOGD("strNow=%s,strSave=%s", strNow, strSave);
//strcpy((char *)strNow, (const char *)strtmp[1]);
SLOGD("strNow=%s,strSave=%s\n", strNow, strSave);
if((strNow[0] != '\0') && (strncmp((char *)strNow, (char *)strSave, MODULE_IMEI_LEN) == 0)) if((strNow[0] != '\0') && (strncmp((char *)strNow, (char *)strSave, MODULE_IMEI_LEN) == 0))
{ {
@ -2394,7 +2397,7 @@ SINT32 sf_module_complete_init(void)
puiPara->DailyReportTime.Min = ((UINT16)(puiPara->ModuleImei[13]-48)*10+(puiPara->ModuleImei[14]-48))%60; puiPara->DailyReportTime.Min = ((UINT16)(puiPara->ModuleImei[13]-48)*10+(puiPara->ModuleImei[14]-48))%60;
SLOGI(puiPara->ModuleImei); SLOGI(puiPara->ModuleImei);
SF_DEBUG("ModuleImei=%s", puiPara->ModuleImei); SF_DEBUG("ModuleImei=%s\n", puiPara->ModuleImei);
} }
eNetRegLocation = QUECTEL_NETREG_ATI; eNetRegLocation = QUECTEL_NETREG_ATI;
@ -2431,7 +2434,7 @@ SINT32 sf_module_complete_init(void)
case QUECTEL_NETREG_ATI: case QUECTEL_NETREG_ATI:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "Revision")))
{ {
delim = " \r\n"; delim = " \r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "Revision"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "Revision"), delim);
@ -2446,7 +2449,7 @@ SINT32 sf_module_complete_init(void)
} }
strcpy((char *)puiPara->ModuleVer, (const char *)strtmp[1]); strcpy((char *)puiPara->ModuleVer, (const char *)strtmp[1]);
SF_DEBUG("ModuleVer=%s", puiPara->ModuleVer); SF_DEBUG("ModuleVer=%s\n", puiPara->ModuleVer);
if(strstr(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q)){ if(strstr(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q)){
at_manager_init(AT_MODULE_TYPE_EG915Q, sf_hal_ttyusb2_read, sf_hal_ttyusb2_write); at_manager_init(AT_MODULE_TYPE_EG915Q, sf_hal_ttyusb2_read, sf_hal_ttyusb2_write);
} }
@ -2950,7 +2953,7 @@ SINT32 sf_module_complete_init(void)
case QUECTEL_NETREG_QCCID: case QUECTEL_NETREG_QCCID:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "+QCCID:")))
{ {
delim = " \r\n"; delim = " \r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "+QCCID:"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "+QCCID:"), delim);
@ -2964,7 +2967,7 @@ SINT32 sf_module_complete_init(void)
pTemp = strtok((char *)0, delim); pTemp = strtok((char *)0, delim);
} }
strcpy((char *)strNow, (const char *)strtmp[1]); strcpy((char *)strNow, (const char *)strtmp[1]);
SLOGD("strNow=%s,strSave=%s", strNow, strSave); SLOGD("strNow=%s,strSave=%s\n", strNow, strSave);
if((strNow[0] != '\0') && (strncmp((char *)strNow, (char *)strSave, MODULE_ICCID_LEN) == 0)) if((strNow[0] != '\0') && (strncmp((char *)strNow, (char *)strSave, MODULE_ICCID_LEN) == 0))
{ {
@ -2972,7 +2975,7 @@ SINT32 sf_module_complete_init(void)
{ {
memset(puiPara->SimIccid, '\0', sizeof(puiPara->SimIccid)); memset(puiPara->SimIccid, '\0', sizeof(puiPara->SimIccid));
strncpy((char *)puiPara->SimIccid, (const char *)strNow, MODULE_ICCID_LEN); strncpy((char *)puiPara->SimIccid, (const char *)strNow, MODULE_ICCID_LEN);
SF_DEBUG("SimIccid=%s", puiPara->SimIccid); SF_DEBUG("SimIccid=%s\n", puiPara->SimIccid);
} }
goto SF_MODULE_END; goto SF_MODULE_END;
@ -3061,7 +3064,7 @@ SINT32 sf_net_regist_manual(void)
UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
SF_LOG(" s"); SF_LOG(" s\n");
#if MEGA_TEST #if MEGA_TEST
@ -3072,6 +3075,7 @@ SINT32 sf_net_regist_manual(void)
#endif #endif
sf_gsm_para_buff_clear();
while(sf_app_while_flag()) while(sf_app_while_flag())
{ {
@ -3404,7 +3408,7 @@ SINT32 sf_net_regist_manual(void)
case QUECTEL_NETREG_CIMI_2: case QUECTEL_NETREG_CIMI_2:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "AT+CIMI")))
{ {
delim = " \r\n"; delim = " \r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+CIMI"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+CIMI"), delim);
@ -3623,7 +3627,7 @@ SINT32 sf_net_regist_manual(void)
case QUECTEL_NETREG_CSQ: case QUECTEL_NETREG_CSQ:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "+CSQ:")))
{ {
delim = " ,\r\n"; delim = " ,\r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "+CSQ:"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "+CSQ:"), delim);
@ -3794,7 +3798,7 @@ SINT32 sf_auto_net_reg(void)
UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
SF_LOG(" s"); SF_LOG(" s\n");
//needRecordLogFlag = 1; //needRecordLogFlag = 1;
puiPara->NetGeneration = 0; puiPara->NetGeneration = 0;
@ -4035,7 +4039,7 @@ SINT32 sf_auto_net_reg(void)
case QUECTEL_NETREG_CIMI_2: case QUECTEL_NETREG_CIMI_2:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "AT+CIMI")))
{ {
delim = " \r\n"; delim = " \r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+CIMI"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "AT+CIMI"), delim);
@ -4215,7 +4219,7 @@ SINT32 sf_auto_net_reg(void)
case QUECTEL_NETREG_CSQ: case QUECTEL_NETREG_CSQ:
if(strstr((const char *)gsmPara, "OK")) if(strstr((const char *)gsmPara, "OK") && (strstr((const char *)gsmPara, "+CSQ:")))
{ {
delim = " ,\r\n"; delim = " ,\r\n";
pTemp = strtok((char *)strstr((const char *)gsmPara, "+CSQ:"), delim); pTemp = strtok((char *)strstr((const char *)gsmPara, "+CSQ:"), delim);