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 0aeb030bc..66929bf47 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 @@ -1332,7 +1332,7 @@ SINT32 sf_sms_read_message(void) break; case SMS_SIM_CMGR: - + TO_SMS_SIM_CMGR: if(number > 254) { number = 0; @@ -1442,6 +1442,8 @@ SINT32 sf_sms_read_message(void) eSmsLocation = SMS_SIM_CMGR; msmll--; number = msmtmp[msmmb++]; + printf("\n[%s:%d] pSifarPara->SmsFlag:%d\n", __FUNCTION__, __LINE__, pSifarPara->SmsFlag); + goto TO_SMS_SIM_CMGR; } else { @@ -1454,9 +1456,10 @@ SINT32 sf_sms_read_message(void) printf("read msg null, delete REC READ\n"); eSmsLocation = SMS_SIM_CMGD2; + printf("\n[%s:%d] pSifarPara->SmsFlag:%d\n", __FUNCTION__, __LINE__, pSifarPara->SmsFlag); + goto TO_SMS_SIM_CMGD2; } - printf("\n[%s:%d] pSifarPara->SmsFlag:%d\n", __FUNCTION__, __LINE__, pSifarPara->SmsFlag); break; } else if((strstr((const char *)gsmPara, "+CMGR:")) && (number < 255)) @@ -1469,7 +1472,17 @@ SINT32 sf_sms_read_message(void) { //no sms command,exit; getCmdFlag = 0; - eSmsLocation = SMS_SIM_CMDFLAG; + printf("[%s:%d] getCmdFlag:%d\n", __FUNCTION__, __LINE__, getCmdFlag); + if(getCmdFlag) + { + eSmsLocation = SMS_SIM_CMGR; + goto TO_SMS_SIM_CMGR; + } + else + { + eSmsLocation = SMS_SIM_CMGD2; + goto TO_SMS_SIM_CMGD2; + } break; } @@ -1509,214 +1522,24 @@ SINT32 sf_sms_read_message(void) Readmmsok = sf_message_data_processing(strValue, mm, &sms_send_mode); - if((Readmmsok == SMS_STATUS_NO_RESPONSE) || (Readmmsok == SMS_STATUS_IDLE)) - { - eSmsLocation = SMS_SIM_CMDFLAG; - } - else - { - eSmsLocation = SMS_SIM_CMDFLAG; - } + printf("[%s:%d] getCmdFlag:%d Readmmsok:%d\n", __FUNCTION__, __LINE__, getCmdFlag, Readmmsok); + if(getCmdFlag) + { + eSmsLocation = SMS_SIM_CMGR; + goto TO_SMS_SIM_CMGR; + } + else + { + eSmsLocation = SMS_SIM_CMGD2; + goto TO_SMS_SIM_CMGD2; + } //add = 0; - break; - #if 0 - case SMS_SIM_CMGS: - printf("%s:%d getCmdFlag:%d\n", __FUNCTION__, __LINE__, getCmdFlag); - - - if(((pPara->Phone1[0] == '\0') && (pPara->Phone2[0] == '\0') && (pPara->Phone3[0] == '\0') && (pPara->Phone4[0] == '\0')) || (!Readmmsok)) - { - if(getCmdFlag) - { - eSmsLocation = SMS_SIM_CMGR; //no send,but need continue read. - } - else - { - eSmsLocation = SMS_SIM_CMGD2; //no send,no read,exit. - } - } - else - { - /*if(getCmdFlag) - { - eSmsLocation = SMS_SIM_CMGR; //no send,continue read. - break; - } - else - { - //read all message,then send. - }*/ - - if(pPara->Phone1[0] != '\0') - { - sprintf((char *)gsmPara, "AT+CMGS=\"%s\"\r", pPara->Phone1); - } - else if(pPara->Phone2[0] != '\0') - { - sprintf((char *)gsmPara, "AT+CMGS=\"%s\"\r", pPara->Phone2); - } - else if(pPara->Phone3[0] != '\0') - { - sprintf((char *)gsmPara, "AT+CMGS=\"%s\"\r", pPara->Phone3); - } - else if(pPara->Phone4[0] != '\0') - { - sprintf((char *)gsmPara, "AT+CMGS=\"%s\"\r", pPara->Phone4); - } - - ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara)); - SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE); - eSmsLocation = SMS_SIM_CONTENT; - } - - break; - - case SMS_SIM_CONTENT: - - if(strstr((const char *)gsmPara, ">")) - { - if(sms_send_mode == 0) - { - if(Readmmsok == SMS_STATUS_RECIEV) - { - sprintf((char *)gsmPara, "SMS commands executed successfully!\x1a\r"); - } - else if(Readmmsok == SMS_STATUS_FORMAT_ERR) - { - sprintf((char *)gsmPara, "SMS command format error!\x1a\r"); - } - else if(Readmmsok == SMS_STATUS_PARA_ERR) - { - sprintf((char *)gsmPara, "SMS command parameter error!\x1a\r"); - } - else - { - sprintf((char *)gsmPara, "SMS command unknown error!\x1a\r"); - } - } - else if(sms_send_mode == 1) - { - if(Readmmsok == SMS_STATUS_RECIEV) - { - if(IS_CARD_EXIST) - { - sp5kDiskInfoGet(SP5K_DRIVE_SD, SP5K_DISK_SIZE_BY_MEGA_BYTE, &totalSize); - sp5kDiskInfoGet(SP5K_DRIVE_SD, SP5K_DISK_FREE_SIZE_BY_KBYTE, &dskfree); - dskfree = dskfree / 1024; - sprintf((char *)dskfreeStr, "%dM/%dM", dskfree, totalSize); - } - else - { - sprintf((char *)dskfreeStr, "NO CARD"); - } - - sf_versionGet(localver, localfea); - sf_mcu_version_get(mcuVersion); - sprintf((char *)gsmPara, "ModuleImei:%s VER:%s MCU VER:%s CSQ:%d SD:%s Bat:%d%%\x1a\r", \ - pPara->ModuleImei, localver, mcuVersion, cq_Signal, dskfreeStr, sf_battery_value_get(0)); - } - else if(Readmmsok == SMS_STATUS_PARA_ERR) - { - sprintf((char *)gsmPara, "SMS command parameter error!\x1a\r"); - } - else - { - sprintf((char *)gsmPara, "SMS command unknown error!\x1a\r"); - } - } - else if(sms_send_mode == 2) - { - if(Readmmsok == SMS_STATUS_RECIEV) - { - sprintf((char *)gsmPara, "SMS commands executed successfully!\x1a\r"); - } - else if(Readmmsok == SMS_STATUS_FORMAT_ERR) - { - sprintf((char *)gsmPara, "SMS command format error!\x1a\r"); - } - else if(Readmmsok == SMS_STATUS_PARA_ERR) - { - sprintf((char *)gsmPara, "SMS command parameter error!\x1a\r"); - } - else - { - sprintf((char *)gsmPara, "SMS command unknown error!\x1a\r"); - } - } - else - { - sprintf((char *)gsmPara, "SMS unknown error!\x1a\r"); - } - - SLOGE((SINT8 *)gsmPara); - - ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara)); - SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE); - eSmsLocation = SMS_SIM_REPLY; - } - else - { - eSmsLocation = SMS_SIM_CMGD2; - } - - break; - - case SMS_SIM_REPLY: - - if(strstr((const char *)gsmPara, "OK")) - { - eSmsLocation = SMS_SIM_CMDFLAG; - Readmmsok = 0; - } - else if(strstr((const char *)gsmPara, "ERROR: 350")) - { - add++; - - if(add < 3) - { - eSmsLocation = SMS_SIM_CMGS; //retry send two times. - } - else - { - Readmmsok = 0; - eSmsLocation = SMS_SIM_CMDFLAG; - sts = SF_SMS_ERROR_SEND_MSG; - add = 0; - - SLOGE((SINT8 *)gsmPara); - sprintf((char *)errMsg, "[%s:%d]Send SMS Three Times,Error Code:0x%08X", __FUNCTION__, __LINE__, sts); - SLOGE((SINT8 *)errMsg); - } - } - else if(strstr((const char *)gsmPara, "ERROR")) - { - eSmsLocation = SMS_SIM_CMDFLAG; - Readmmsok = 0; - sts = SF_SMS_ERROR_SEND_MSG; - SLOGE((SINT8 *)gsmPara); - sprintf((char *)errMsg, "[%s:%d]Send SMS Fail,Error Code:0x%08X", __FUNCTION__, __LINE__, sts); - SLOGE((SINT8 *)errMsg); - } - - break; -#endif - case SMS_SIM_CMDFLAG: - printf("getCmdFlag:%d\n", getCmdFlag); - - if(getCmdFlag) - { - eSmsLocation = SMS_SIM_CMGR; - } - else - { - eSmsLocation = SMS_SIM_CMGD2; - } - break; case SMS_SIM_CMGD2: + TO_SMS_SIM_CMGD2: strcpy((char *)gsmPara, "AT+CMGD=1,3\r"); printf("[%s:%d] %s\n", __FUNCTION__, __LINE__,gsmPara);