/************************************************************************** | |
* | |
* Copyright (c) 2012 ZTE Corporation. | |
* | |
*************************************************************************** | |
* Ä£ ¿é Ãû : AT_SERVER | |
* ÎÄ ¼þ Ãû : sms_proc.c | |
* Ïà¹ØÎļþ : | |
* ʵÏÖ¹¦ÄÜ : AtServerÄ£¿ésmsÁ÷³Ì¿ØÖÆÎļþ | |
* ×÷ Õß : G.F | |
* °æ ±¾ : V1.0 | |
* Íê³ÉÈÕÆÚ : 2013-09-29 | |
* ÆäËü˵Ã÷ : | |
**************************************************************************/ | |
/************************************************************************** | |
* Ð޸ļǼ1: | |
***************************************************************************/ | |
/************************************************************************** | |
* Ð޸ıàºÅ : EC:617002775301, EC617002775301 | |
* ÐÞ ¸Ä ÈË : chenjie10092374 | |
* ÐÞ¸ÄÈÕÆÚ : 2014.5.30 | |
* ÐÞ¸ÄÄÚÈÝ : (´úÂë×ß²é)ÐÞ¸ÄÏà¹ØSMS½ÓÊÕ¶ÌÐÅÁ÷³Ì´¦Àí | |
**************************************************************************/ | |
/************************************************************************** | |
* Ð޸ıàºÅ : й¦ÄÜ | |
* ÐÞ ¸Ä ÈË : chenjie10092374 | |
* ÐÞ¸ÄÈÕÆÚ : 2014.6.24 | |
* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë | |
**************************************************************************/ | |
/************************************************************************** | |
* Ð޸ıàºÅ : й¦ÄÜ | |
* ÐÞ ¸Ä ÈË : chenjie10092374 | |
* ÐÞ¸ÄÈÕÆÚ : 2014.08.07 | |
* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÏòMMI·¢ËͶÌÐÅ״̬µÄ´úÂë | |
**************************************************************************/ | |
/************************************************************************** | |
* #includeÇø | |
**************************************************************************/ | |
#include <limits.h> | |
#include "sms_code.h" | |
#include <sys/msg.h> | |
/************************************************************************** | |
* ³£Á¿¶¨ÒåÇø | |
**************************************************************************/ | |
/* **********È«¾Ö³£Á¿ **************/ | |
// ³¤¶ÌÐŵļ¶ÁªÐÅÏ¢ | |
T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms; | |
// Ⱥ·¢ÐÅÏ¢ | |
T_zUfiSms_GroupInfo g_zUfiSms_GroupSms; | |
//Êý¾Ý¿âÖд洢µÄÐÅÏ¢£¬ÓÃÓÚ´æ´¢ÒÑ·¢ÐÅÏ¢ | |
T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX]; | |
/* ¿¨ÖÐÊÇ·ñ´æ´¢ÒÑÂú, 0--¿¨, 1--nv */ | |
UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX] = {FALSE,FALSE}; | |
// ¶ÌÐÅɾ³ýÐÅÏ¢ | |
T_zUfiSms_DelSms g_zUfiSms_DelMsg; | |
T_zUfiSms_DelIndexInfo g_deleteIndex={0}; | |
//¶ÌÐÅδ¶Á±êÖ¾ÐÞ¸Ä | |
T_zUfiSms_ModifySms g_zUfiSms_modifyMsg={0}; | |
T_zUfiSms_ModifyIndexInfo g_modifyIndex={0}; | |
// ³¤¶ÌÐŵĵ¥Î»·¢Ëͳ¤¶È | |
int g_zUfiSms_UnitLen = 0; | |
// ³¤¶ÌÐŵÄ×Ü·Ö¶ÎÊý,ÓÃÓÚÅж϶ÌÐÅ·Ö¶ÎÊÇ·ñ·¢ËÍÍê±Ï | |
int g_zUfiSms_ConcatTotalNum = 0; | |
//µ±Ç°·¢Ë͵ij¤¶ÌÐÅÆ¬¶ÎºÅ£¬ÓÃÓڼǼÿ¶ÎµÄ·¢Ëͽá¹ûºÍÅжÏÊÇ·ñ·¢ËͽáÊø | |
int g_zUfiSms_CurConcatSegNo = 0; | |
//³¤¶ÌÐÅÊÇ·ñ·¢Ëͳɹ¦£¬Ä¬ÈÏ·¢Ëͳɹ¦ | |
UINT8 g_zUfiSms_IsConcatSendSuc = TRUE; | |
// ¶ÌÐÅ·¢ËÍʧ°ÜµÄÌõÊý£¬ÓÃÓÚ³¤¶ÌÐŵķ¢ËͼÆÊý | |
int g_zUfiSms_SendFailedCount = 0; | |
//¶ÌÐŲÎÕÕÊý¾Ý£¬¸ø×é×°¼¶Áª¶ÌÐŵĶÌÐÅͷʱÓà | |
int g_zUfiSms_MsgRefer = 0; | |
// ¶ÌÐÅ·¢ËÍʧ°ÜºóÖØÊÔ´ÎÊý | |
int g_zUfiSms_SendFailedRetry = 0; | |
//¼Ç¼µ±Ç°×´Ì¬£¬ÓÃÓÚWebserverÏÔʾ | |
//T_zUfiSms_StatusInfo g_zUfiSms_StatusInfo; | |
char g_Zmena_value[2] = {0}; | |
//Êý¾Ý¿âÖÐָʾһÌõ¶ÌÐżÇ¼ÊÇ·ñ±»WEBUIÏÔʾ | |
//0:ÏÔʾ£»1:²»ÏÔʾ | |
int g_displaymode = 0; | |
extern SMS_LOCATION g_zUfiSms_CurLocation; | |
extern T_zUfiSms_CmdStatus zUfiSms_HandleReport( unsigned char* ptPduData); | |
extern void zUfiSms_GetReportStatus(char *pdu_tmp,int *stat); | |
extern VOID zUfiSms_ResendAtCmdZmena(int cid); | |
extern int zUfiSms_DecodeSmsData | |
( | |
T_zUfiSms_DbStoreData *pDb_Data, | |
int msg_index, | |
zUfiSms_StoreType iStorePos, | |
T_SmsStatus bSms_Status, | |
wms_message_format_enum_v01 format, | |
long iPdu_Len, | |
unsigned char *pPdu_Received | |
); | |
typedef struct{ | |
long mtype; | |
char mtext[12]; | |
}FOTA_MSG_BUF; | |
#define WEBUI_NOTIFY_PUSH_MSG_ 3 | |
/* ºê´¦Àí */ | |
/************************************************************************** | |
* Êý¾Ý½á¹¹¶¨ÒåÇø | |
**************************************************************************/ | |
typedef struct | |
{ | |
unsigned int isread_record; | |
unsigned int inbox_full; | |
}T_zUfiMmi_SmsRecord; | |
/************************************************************************** | |
* staticº¯ÊýÉùÃ÷Çø | |
**************************************************************************/ | |
/************************************************************************** | |
* È«¾Ö±äÁ¿¶¨ÒåÇø | |
**************************************************************************/ | |
/************************************************************************** | |
* º¯ÊýʵÏÖÇø | |
**************************************************************************/ | |
//ËùÓÐsmsÏà¹ØµÄ¹¦Äܳõʼ»¯ | |
void zUfiMmi_SendSmsStatus(void) | |
{ | |
int iSmsNum = 0; | |
T_zUfiMmi_SmsRecord tRecord = { 0 }; | |
CHAR smsNum[50]={0}; | |
sc_cfg_get(NV_SMS_IN_NUM,smsNum,sizeof(smsNum)); | |
iSmsNum = atoi(smsNum); | |
// *G.F* | |
tRecord.isread_record = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_MAX); | |
if(iSmsNum >= ZSMS_NUM_MAX_CPE) | |
{ | |
tRecord.inbox_full = 1; | |
} | |
else | |
{ | |
tRecord.inbox_full = 0; | |
} | |
//zUfi_SendMsgToAp(MODULE_ID_MMI,MSG_MMICHANNEL_MESSAGE, sizeof(tRecord), (CHAR*)&tRecord); | |
} | |
VOID zUfiSms_Init(VOID) | |
{ | |
zUfiSms_CfgInit(); | |
zUfiSms_ChangeMainState(SMS_STATE_INITING); /* ÉèÖÃ״̬Ϊiniting, ÒÔ¹©Ò³ÃæÆÁ±Î²Ù×÷*/ | |
//zUfiSms_InitDb(); | |
//zUfiMmi_SendSmsStatus(); | |
} | |
VOID zSvr_Zpbic_Sms_Init(VOID) | |
{ | |
int atRes = 0; | |
T_zUfiSms_StatusInfo tStatus = {0}; | |
CHAR outDate[50]={0}; | |
zUfiSms_Init(); | |
zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_INIT); | |
//zSvr_Sms_At_Init(cid); | |
zSms_SendSmsInitReq(); | |
at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send init req\n"); | |
//atUnsoli_Report_Zmena("0", cid); | |
zSms_SendZmenaReq(0); | |
at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send zmena req\n"); | |
sc_cfg_get(NV_OUTDATE_DELETE,outDate,sizeof(outDate)); | |
at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init outdate check %s\n", outDate); | |
if(0 == strcmp(outDate, "1")) | |
{ | |
atWeb_OutdateSmsCheck(ZUFI_NULL); | |
} | |
} | |
VOID zUfiSms_DeleteAllSimSms(VOID) | |
{ | |
zUfiSms_DeleteAllSimSmsInDb(); | |
} | |
#if 0 | |
VOID zUfiSms_ResendAtCmdZmena(int cid) | |
{ | |
CHAR netType[50]={0}; | |
sc_cfg_get(NV_NETWORK_TYPE,netType,sizeof(netType)); | |
if(!g_Zmena_rsp && | |
(0!=strcmp("No Service",netType)&&0!=strcmp("Limited Service",netType))) | |
{ | |
atUnsoli_Report_Zmena(NULL,cid); | |
} | |
} | |
#endif | |
void zUfiSms_Ack_new_msg(BOOL needAck) | |
{ | |
#if 0 | |
CHAR ackPduStr[400] = {0}; | |
SMS_PARAM reportParam = {0}; | |
int total_length = 0; | |
UINT8 TP_FCS = 0; | |
CHAR strValue[2] = {0}; | |
if(needAck) | |
{ | |
TP_FCS = 0x00; | |
sprintf(strValue, "%d", 1); | |
} | |
else | |
{ | |
TP_FCS = 0xD3; | |
sprintf(strValue, "%d", 2); | |
} | |
sprintf(reportParam.SCA, "%s", cfg_get("sms_center_num")); | |
total_length = zUfiSms_EncodePdu_DeliverReport(&reportParam, ackPduStr, TP_FCS); | |
memset(&g_zUfiSms_ackPdu, 0, sizeof(g_zUfiSms_ackPdu)); | |
g_zUfiSms_ackPdu.length = String2Bytes(ackPduStr, g_zUfiSms_ackPdu.pdu, strlen(ackPduStr)); | |
memset(g_zUfiSms_ackPdu.pdu, 0, sizeof(g_zUfiSms_ackPdu.pdu)); | |
memcpy(&g_zUfiSms_ackPdu.pdu, &ackPduStr, sizeof(ackPduStr)); | |
atBase_SendMsgToSelf(ZAT_CNMA_CMD, strValue, sizeof(strValue)); | |
#endif | |
#if 0//zhangfen for platform | |
CHAR strValue[2] = {0}; | |
if(needAck) | |
{ | |
snprintf(strValue, sizeof(strValue),"%d", 1); | |
} | |
else | |
{ | |
snprintf(strValue, sizeof(strValue),"%d", 2); | |
} | |
zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_CNMA,strlen(strValue),strValue); | |
#endif | |
if(needAck) | |
{ | |
zSms_SendCnmaReq(1); | |
} | |
else | |
{ | |
zSms_SendCnmaReq(2); | |
} | |
} | |
/* ·¢ËͶÌÐÅ */ | |
T_zUfiSms_CmdStatus zUfiSms_SendRawSms(T_zUfiSms_SendReq *ptSendMsg) | |
{ | |
if(NULL == ptSendMsg || 0 == ptSendMsg->receiver_count) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_SendRawSms receiver_count:%d/dest_num:%s/msg_len:%d/id:%d.\n",ptSendMsg->receiver_count,ptSendMsg->dest_num[0],ptSendMsg->msg_len,ptSendMsg->id); | |
#if 1//corem for debug | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_SendRawSms dcs:%d\n",ptSendMsg->dcs); | |
#endif | |
sc_cfg_set(NV_SMS_SEND_RESULT, ""); | |
g_zUfiSms_SendFailedCount = 0; | |
// Ö¸¶¨ÒªÉ¾³ý£¬»òÕßÊǴӲݸåÏäÖлñÈ¡(idÓÐЧ)£¬ÏÈɾ³ýÔ¶ÌÐÅ¡£*/ | |
if (ptSendMsg->isDelete == TRUE || -1 != ptSendMsg->id) | |
{ | |
(void)zUfiSms_DeleteDraftSms(ptSendMsg->id); | |
} | |
//¼Ç¼±àÂë¸ñʽºÍÓïÑÔ£¬ºóÐøÄÚÈÝת»»Ê±Ê¹Óà | |
zUfiSms_SetGlobalDcsLang(ptSendMsg->dcs); | |
// Ìî³äȺ·¢¼Ç¼ | |
memset(&g_zUfiSms_GroupSms,0,sizeof(g_zUfiSms_GroupSms)); | |
if(ZUFI_FAIL == zUfiSms_FillGroupSms(ptSendMsg, &g_zUfiSms_GroupSms))//kw 3 | |
{ | |
return WMS_CMD_FAILED; | |
} | |
// ²ð·Ö¼¶Áª¶ÌÐÅ£¬ÄÚÈÝÌîµ½g_zUfiSms_ConcatSmsÖУ¬·µ»Ø¶ÌÐŵĵ¥Î»³¤¶È | |
memset(&g_zUfiSms_ConcatSms,0,sizeof(g_zUfiSms_ConcatSms)); | |
g_zUfiSms_UnitLen = zUfiSms_FillConcatSms(ptSendMsg,&g_zUfiSms_ConcatSms); | |
g_zUfiSms_IsConcatSendSuc = TRUE; | |
g_zUfiSms_CurConcatSegNo = 0; | |
memset(g_zUfiSms_DbStoreData,0,sizeof(g_zUfiSms_DbStoreData)); | |
//for traffic | |
//Á÷Á¿Ð£×¼¹¦ÄÜ·¢Ë͵ĶÌÐŲ»ÐèÒªÏÔʾ¸øWEBUI | |
if(ptSendMsg->mem_store == 10) | |
{ | |
g_displaymode = 1; | |
at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 1\n"); | |
} | |
else | |
{ | |
g_displaymode = 0; | |
at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 0\n"); | |
} | |
return zUfiSms_SendSms(); | |
} | |
T_zUfiSms_CmdStatus zUfiSms_WriteRawSms(T_zUfiSms_SaveReq *pSaveBuff) | |
{ | |
T_zUfiSms_ConcatInfo tConcatSms; | |
T_zUfiSms_GroupInfo tGroupSms; | |
int iSmsLen = 0; | |
T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS; | |
if(NULL == pSaveBuff) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
if (g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV]) | |
{ | |
// NVÒÑÂú | |
at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms nv memory is full,return\n"); | |
//g_zUfiSms_StatusInfo.err_code = ZTE_SMS_CMS_MEM_FULL; | |
return WMS_CMD_FAILED; | |
} | |
if (pSaveBuff->isDelete == TRUE) | |
{ | |
(void)zUfiSms_DeleteDraftSms(pSaveBuff->id); | |
} | |
zUfiSms_SetGlobalDcsLang(pSaveBuff->dcs); | |
memset(&tConcatSms,0,sizeof(T_zUfiSms_ConcatInfo)); | |
memset(&tGroupSms,0,sizeof(T_zUfiSms_GroupInfo)); | |
(void)zUfiSms_FillGroupSms(pSaveBuff,&tGroupSms); | |
iSmsLen = zUfiSms_FillConcatSms(pSaveBuff,&tConcatSms); | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms total_receiver=%d,iSmsLen=%d\n",tGroupSms.total_receiver,iSmsLen); | |
//°´ÕÕ·¢¼þÈË£¬Öð¸ö½øÐжÌÐű£´æ | |
for(tGroupSms.current_receiver = 0; tGroupSms.current_receiver < tGroupSms.total_receiver; tGroupSms.current_receiver++) | |
{ | |
tConcatSms.current_sending = 0; | |
result = zUfiSms_SaveSmsToDb(pSaveBuff,&tConcatSms,&tGroupSms,iSmsLen); | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms current_receiver=%d,result=%d\n",tGroupSms.current_receiver,result); | |
} | |
sc_cfg_set(NV_SMS_DB_CHANGE,"1"); | |
zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]) | |
{ | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT); | |
} | |
at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms end and result=%d\n",result); | |
return result; | |
} | |
T_zUfiSms_CmdStatus zUfiSms_DeleteSms(T_zUfiSms_DelReq *ptDelBuff) | |
{ | |
T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS; | |
BOOL memoryFullbeforeDelete = FALSE; | |
BOOL unreadBeforeDelete = FALSE; | |
if(NULL == ptDelBuff) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
at_print(LOG_DEBUG, "[SMS] !!!!!zUfiSms_DeleteSms!!count:%d/id[%d].\n",ptDelBuff->all_or_count,ptDelBuff->id[0]); | |
(void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
zUfiSms_ChangeMainState(SMS_STATE_DELING); | |
// ¹¹Ôì¶ÌÐŵÄÏêϸɾ³ýÐÅÏ¢ | |
memset(&g_zUfiSms_DelMsg,0,sizeof(T_zUfiSms_DelSms)); | |
if(ZUFI_FAIL == zUfiSms_SetDeleteInfo(ptDelBuff)) | |
{ | |
at_print(LOG_DEBUG,"[SMS] !!!zUfiSms_SetDeleteInfo fail.\n"); | |
zUfiSms_ChangeMainState(SMS_STATE_DELED); | |
return WMS_CMD_FAILED; | |
} | |
at_print(LOG_DEBUG, "[SMS] !!!zUfiSms_SetDeleteInfo Read to Delete:nv_count:%d/sim_count:%d.\n",g_zUfiSms_DelMsg.nv_count,g_zUfiSms_DelMsg.sim_count); | |
if(0 < g_zUfiSms_DelMsg.nv_count) /* delete nv sms*/ | |
{ | |
if(g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]) | |
{ | |
memoryFullbeforeDelete = TRUE; | |
} | |
unreadBeforeDelete = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV); | |
result = (T_zUfiSms_CmdStatus)zUfiSms_DeleteNvSms(); | |
(void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
zUfiSms_ChangeMainState(SMS_STATE_DELED); | |
sc_cfg_set(NV_SMS_DB_CHANGE,"1"); | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_DeleteNvSms memoryFullbeforeDelete=%d,MemFullFlag(NV)=%d\n",memoryFullbeforeDelete,g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]); | |
if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]) | |
{ | |
//memset(g_Zmena_value,0,sizeof(g_Zmena_value)); | |
//sat_print(LOG_DEBUGg_Zmena_value, "%d", 0); | |
//atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value)); | |
at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteNvSms: send AT+ZMENA=0\n"); | |
//atUnsoli_Report_Zmena("0", cid); | |
zSms_SendZmenaReq(0); | |
} | |
if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01] | |
|| unreadBeforeDelete && !zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)) | |
{ | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT); | |
} | |
} | |
if(0 < g_zUfiSms_DelMsg.sim_count) /*delete sim sms*/ | |
{ | |
result = zUfiSms_DeleteSimSms(); | |
(void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_SIM); | |
} | |
at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteSms result=%d\n",result); | |
return result; | |
} | |
// δ¶Á±äÒѶÁ | |
T_zUfiSms_CmdStatus zUfiSms_ModifySmsTag(T_zUfiSms_ModifyFlag *ptModifyBuff) | |
{ | |
unsigned long i = 0; | |
T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS; | |
char acStorePos[50] = {0}; | |
if(NULL == ptModifyBuff) | |
{ | |
at_print(LOG_ERR,"inputs is null."); | |
return WMS_CMD_FAILED; | |
} | |
for(i = 0; i < ptModifyBuff->total_id; i++) | |
{ | |
if(ptModifyBuff->id[i] < 1 || ZUFI_FAIL == zUfiSms_UpdateSmsTagInDb(ptModifyBuff->id[i],ptModifyBuff->tags)) | |
{ | |
result = WMS_CMD_FAILED; | |
} | |
else | |
{ | |
result = WMS_CMD_SUCCESS; | |
} | |
} | |
if(ZUFI_FAIL == zUfiSms_GetStorePosById("Mem_Store",acStorePos,sizeof(acStorePos),ptModifyBuff->id[0])) | |
{ | |
return ZUFI_FAIL; | |
} | |
if(0 == strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE)) //!zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV) && | |
{ | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_READING); | |
} | |
if(0 == strcmp(acStorePos,ZTE_WMS_DB_SIM_TABLE) && ptModifyBuff->total_id > 0)/*sim sms*/ | |
{ | |
zUfiSms_ModifyModemSms(ptModifyBuff); | |
} | |
return result; | |
} | |
//ÉèÖöÌÐŲÎÊý | |
T_zUfiSms_CmdStatus zUfiSms_SetSmsPara(T_zUfiSms_ParaInfo *ptParaBuff) | |
{ | |
int atRes = 0; | |
CHAR sca[ZTE_WMS_ADDRESS_DIGIT_MAX_V01 + 1] = {0}; | |
CHAR store[20] = {0}; | |
CHAR defaultStore[50]={0}; | |
if (ptParaBuff == ZUFI_NULL) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
if (strlen(ptParaBuff->sca) != 0) | |
{ | |
strncpy(sca, ptParaBuff->sca,sizeof(sca)-1); | |
at_print(LOG_DEBUG, "send ZAT_CSCA_SET_CMD message csca is %s.\n", sca); | |
//atBase_SendMsgToSelf(ZAT_CSCA_SET_CMD, (CHAR *)&tCscaPara, sizeof(tCscaPara)); | |
//zhangfen for platform | |
atRes = zSms_SetCscaReq(ptParaBuff->sca); | |
if(atRes != ZSMS_RESULT_OK) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
} | |
sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore)); | |
if((*(ptParaBuff->default_store) != '\0') && | |
(0 != strcmp(defaultStore, ptParaBuff->default_store))) | |
{ | |
//atBase_SendMsgToSelf(ZAT_CNMI_CMD, NULL, 0); | |
//zhangfen for platform | |
//kw 3 | |
//if(ptParaBuff->default_store == NULL) | |
//{ | |
// sc_cfg_get(NV_DEFAULT_STORE,store,sizeof(store)); | |
//} | |
//else | |
{ | |
strncpy(store, ptParaBuff->default_store,sizeof(store)-1); | |
} | |
atRes = zSms_SendCnmiReq(store); | |
if(atRes != ZSMS_RESULT_OK) | |
{ | |
return WMS_CMD_FAILED; | |
} | |
} | |
if(-1 == zUfiSms_SetDbParameters(ptParaBuff)) | |
{ | |
at_print(LOG_ERR,"set parameters to table failed."); | |
return WMS_CMD_FAILED; | |
} | |
//memcpy((VOID *)&g_zUfiSms_CurSmsPara, (VOID *)ptParaBuff, sizeof(T_zUfiSms_ParaInfo)); | |
return WMS_CMD_SUCCESS; | |
} | |
void zUfiSms_CmgrNvSet(void) | |
{ | |
char sms_rec_flag[5] = {0}; | |
char remind_flag[5]; | |
int sms_count = 0; | |
int remind_count =0; | |
//NVÖжÌÐÅÊýÁ¿¼ÓÒ» | |
memset(sms_rec_flag,0,sizeof(sms_rec_flag)); | |
sc_cfg_get(ZTE_WMS_NVCONFIG_RECEVIED,sms_rec_flag,sizeof(sms_rec_flag)); | |
sms_count = atoi(sms_rec_flag); | |
if(sms_count < 0 || sms_count > INT_MAX-1) { //kw 3 | |
at_print(LOG_ERR,"[SMS]sms_count err:%d\n", sms_count); | |
return; | |
} | |
memset(sms_rec_flag,0,sizeof(sms_rec_flag)); | |
snprintf(sms_rec_flag,sizeof(sms_rec_flag),"%d",sms_count + 1); | |
sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED, sms_rec_flag); | |
sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_LED, sms_rec_flag); | |
memset(remind_flag,0,sizeof(remind_flag)); | |
snprintf(remind_flag,sizeof(remind_flag),"%d",remind_count+1); | |
sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_REMIND, remind_flag); | |
sc_cfg_set(NV_SMS_RECV_RESULT, "ok"); | |
sc_cfg_set(NV_SMS_DB_CHANGE,"1"); | |
} | |
void zUfiSms_CdsRespProc(T_zSms_SmsInd *ptRespData) | |
{ | |
unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 }; | |
T_zUfiSms_DbStoreData tDbStoreData = { 0 }; | |
int isPushSms = 0; | |
// ¶ÌÐÅÄÚÈÝΪ¿Õ | |
if (strcmp(ptRespData->pdu,"") == 0) | |
{ | |
CHAR srState[50]={0}; | |
sc_cfg_get(NV_SR_STATE,srState,sizeof(srState)); | |
if(0 != strcmp(srState, "sr_receiving")) | |
{ | |
//²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í | |
sc_cfg_set(NV_SMS_RECV_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
} | |
else | |
{ | |
// ±¨¸æÊÕµ½ | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
} | |
return; | |
} | |
zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat); | |
(void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu)); | |
/* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ */ | |
if(5 == ptRespData->stat) | |
{ | |
(void)zUfiSms_HandleReport(acFormatPdu); | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
zUfiSms_Ack_new_msg(TRUE); | |
return ; | |
} | |
return; | |
} | |
int zUfiSms_CheckIfWholeSms(T_zUfiSms_DbStoreData *data, SMS_MSG_INFO *pmsg) | |
{ | |
if(data->concat_sms != 1) | |
{ | |
return 0; | |
} | |
zUfiSms_GetCurrentRecvTotalSeq(data, pmsg); | |
at_print(LOG_DEBUG, "[SMS][traffic] zUfiSms_CheckIfWholeSms id = %s, totalSeq = %d,ref =%d,total =%d, seq=%d\n", pmsg->id, atoi(pmsg->total_seq),data->concat_info[0],data->concat_info[1],data->concat_info[2]); | |
if(data->concat_info[1] == atoi(pmsg->total_seq)) | |
{ | |
return 0; | |
} | |
return -1; | |
} | |
void zUfiSms_TrafficChangeSmsTag(T_zUfiSms_DbStoreData *data) | |
{ | |
CHAR smsNumber[50]={0}; | |
sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber)); | |
if(0 == strcmp(smsNumber, data->number)) | |
{ | |
data->tag = WMS_TAG_TYPE_MT_READ_V01; | |
data->msg_displaymode = 1; | |
} | |
} | |
void zUfiSms_HandleTrafficSms(T_zUfiSms_DbStoreData *data) | |
{ | |
int iSmsId = 0; | |
SMS_MSG_INFO msg = {0}; | |
CHAR smsNumber[50]={0}; | |
sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber)); | |
at_print(LOG_DEBUG, "[SMS][traffic] tDbStoreData.number = %s, traffic_sms_number = %s\n", data->number,smsNumber); | |
if(0 == strcmp(smsNumber, data->number)) | |
{ | |
if(0 != zUfiSms_CheckIfWholeSms(data, &msg)) | |
{ | |
at_print(LOG_DEBUG,"[SMS][traffic] cmt ind, recv sms, but not whole sms, wait to recv next seg\n"); | |
return; | |
} | |
sc_cfg_set(NV_TRAFFIC_RECV_SMS_ID, msg.id); | |
sc_cfg_set(NV_TRAFFIC_SMS_NUMBER, "0"); | |
at_print(LOG_DEBUG, "[SMS][traffic] zUfiSms_HandleTrafficSms traffic_recv_sms_id = %s\n", msg.id); | |
} | |
} | |
void zUfiSms_CmtRespProc(T_zSms_SmsInd *ptRespData) | |
{ | |
zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01; | |
unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 }; | |
T_zUfiSms_DbStoreData tDbStoreData; | |
int isPushSms = 0; | |
SMS_PARAM one_sms = { 0 }; | |
int unread_sms_before_recv_new_sms = 0; | |
memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData)); | |
at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu); | |
// ¶ÌÐÅÄÚÈÝΪ¿Õ | |
if (strcmp(ptRespData->pdu,"") == 0 ) | |
{ | |
CHAR srState[50]={0}; | |
sc_cfg_get(NV_SR_STATE,srState,sizeof(srState)); | |
if(0 != strcmp(srState, "sr_receiving")) | |
{ | |
//²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í | |
sc_cfg_set(NV_SMS_RECV_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
} | |
else | |
{ | |
// ±¨¸æÊÕµ½ | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
} | |
return; | |
} | |
//sleep(1); | |
isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms); | |
at_print(LOG_DEBUG, "[sms]zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms); | |
if(SMS_NOTIFICATION == isPushSms) //notification | |
{ | |
BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD)); | |
zte_fota_notifyPushMsg(0); | |
} | |
if(SMS_NO_PUSH != isPushSms) | |
{ | |
/*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/ | |
at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index); | |
at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum); | |
at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum); | |
at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum); | |
//zUfiSms_DelModemSms(one_sms.index); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
zUfiSms_Ack_new_msg(TRUE); | |
return; | |
} | |
//»ñȡ״̬ | |
zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat); | |
(void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu)); | |
/* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */ | |
if(5 == ptRespData->stat) | |
{ | |
(void)zUfiSms_HandleReport(acFormatPdu); | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
zUfiSms_Ack_new_msg(TRUE); | |
return ; | |
} | |
// ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ | |
(void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat, | |
WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu); | |
if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2) | |
{ | |
iStorePos = WMS_STORAGE_TYPE_UIM_V01; | |
} | |
if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)) | |
{ | |
unread_sms_before_recv_new_sms = 1; | |
} | |
else | |
{ | |
unread_sms_before_recv_new_sms = 0; | |
} | |
zUfiSms_TrafficChangeSmsTag(&tDbStoreData); | |
//дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg | |
if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1)) | |
{ | |
zUfiSms_Ack_new_msg(FALSE); | |
//memset(g_Zmena_value,0,sizeof(g_Zmena_value)); | |
//sat_print(LOG_DEBUGg_Zmena_value, "%d", 1); | |
//atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value)); | |
//zhangfen for platform | |
//zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMENA,1,"1"); | |
zSms_SendZmenaReq(1); | |
return; | |
} | |
if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2) | |
{ | |
zUfiSms_Ack_new_msg(TRUE); | |
} | |
zUfiSms_CmgrNvSet(); | |
zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_NEW); | |
//for traffic sms | |
zUfiSms_HandleTrafficSms(&tDbStoreData); | |
return; | |
} | |
void zUfiSms_ZmgrRespProc(T_zSms_SmsInd *ptRespData) | |
{ | |
zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01; | |
unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 }; | |
T_zUfiSms_DbStoreData tDbStoreData; | |
int isPushSms = 0; | |
SMS_PARAM one_sms = { 0 }; | |
CHAR defaultStore[50]={0}; | |
memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData)); | |
at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu); | |
// ¶ÌÐÅÄÚÈÝΪ¿Õ | |
if (strcmp(ptRespData->pdu,"") == 0 ) | |
{ | |
CHAR srState[50]={0}; | |
sc_cfg_get(NV_SR_STATE,srState,sizeof(srState)); | |
if(0 != strcmp(srState, "sr_receiving")) | |
{ | |
//²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í | |
sc_cfg_set(NV_SMS_RECV_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
} | |
else | |
{ | |
// ±¨¸æÊÕµ½ | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
} | |
return; | |
} | |
//sleep(1); | |
isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms); | |
at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms); | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms); | |
if(SMS_NOTIFICATION == isPushSms) //notification | |
{ | |
BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD)); | |
zte_fota_notifyPushMsg(0); | |
} | |
if(SMS_NO_PUSH != isPushSms) | |
{ | |
/*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/ | |
at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index); | |
at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum); | |
at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum); | |
at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum); | |
//zUfiSms_DelModemSms(one_sms.index); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
//zUfiSms_Ack_new_msg(TRUE); | |
return; | |
} | |
//»ñȡ״̬ | |
zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat); | |
(void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu)); | |
/* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */ | |
if(5 == ptRespData->stat) | |
{ | |
(void)zUfiSms_HandleReport(acFormatPdu); | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
//zUfiSms_Ack_new_msg(TRUE); | |
return ; | |
} | |
sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore)); | |
if(0 == strcmp(defaultStore, "sim")) | |
{ | |
iStorePos = WMS_STORAGE_TYPE_UIM_V01; | |
} | |
// ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ | |
(void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat, | |
WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu); | |
if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2) | |
{ | |
iStorePos = WMS_STORAGE_TYPE_UIM_V01; | |
} | |
zUfiSms_TrafficChangeSmsTag(&tDbStoreData); | |
//дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg | |
if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1)) | |
{ | |
//zUfiSms_Ack_new_msg(FALSE); | |
//memset(g_Zmena_value,0,sizeof(g_Zmena_value)); | |
//sat_print(LOG_DEBUGg_Zmena_value, "%d", 1); | |
//atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value)); | |
//zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1"); | |
return; | |
} | |
if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2) | |
{ | |
//zUfiSms_Ack_new_msg(TRUE); | |
} | |
zUfiSms_CmgrNvSet(); | |
zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
//for traffic sms | |
zUfiSms_HandleTrafficSms(&tDbStoreData); | |
return; | |
} | |
//unused | |
void zUfiSms_CmgrRespProc(T_zSms_SmsInd *ptRespData) | |
{ | |
zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01; | |
unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 }; | |
T_zUfiSms_DbStoreData tDbStoreData; | |
int isPushSms = 0; | |
SMS_PARAM one_sms = { 0 }; | |
int unread_sms_before_recv_new_sms = 0; | |
memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData)); | |
at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu); | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_READING); | |
// ¶ÌÐÅÄÚÈÝΪ¿Õ | |
if (strcmp(ptRespData->pdu,"") == 0 ) | |
{ | |
CHAR srState[50]={0}; | |
sc_cfg_get(NV_SR_STATE,srState,sizeof(srState)); | |
if(0 != strcmp(srState, "sr_receiving")) | |
{ | |
//²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í | |
sc_cfg_set(NV_SMS_RECV_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
} | |
else | |
{ | |
// ±¨¸æÊÕµ½ | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
} | |
return; | |
} | |
//sleep(1); | |
isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms); | |
at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms); | |
at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms); | |
if(SMS_NOTIFICATION == isPushSms) //notification | |
{ | |
BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD)); | |
zte_fota_notifyPushMsg(0); | |
} | |
if(SMS_NO_PUSH != isPushSms) | |
{ | |
/*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/ | |
at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index); | |
at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum); | |
at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum); | |
at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum); | |
//zUfiSms_DelModemSms(one_sms.index); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
//zUfiSms_Ack_new_msg(TRUE); | |
return; | |
} | |
//»ñȡ״̬ | |
zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat); | |
(void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu)); | |
/* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */ | |
if(5 == ptRespData->stat) | |
{ | |
(void)zUfiSms_HandleReport(acFormatPdu); | |
sc_cfg_set(NV_SR_STATE, "sr_received"); | |
//zUfiSms_Ack_new_msg(TRUE); | |
return ; | |
} | |
// ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ | |
(void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat, | |
WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu); | |
if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2) | |
{ | |
iStorePos = WMS_STORAGE_TYPE_UIM_V01; | |
} | |
if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)) | |
{ | |
unread_sms_before_recv_new_sms = 1; | |
} | |
else | |
{ | |
unread_sms_before_recv_new_sms = 0; | |
} | |
//дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg | |
if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1)) | |
{ | |
//zUfiSms_Ack_new_msg(FALSE); | |
//memset(g_Zmena_value,0,sizeof(g_Zmena_value)); | |
//sprintf(g_Zmena_value, "%d", 1); | |
//atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value)); | |
//zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1"); | |
return; | |
} | |
if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2) | |
{ | |
//zUfiSms_Ack_new_msg(TRUE); | |
} | |
zUfiSms_CmgrNvSet(); | |
zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
return; | |
} | |
void zUfiSms_CmgsRespProc(VOID) | |
{ | |
T_zUfiSms_StatusInfo tStatusInfo = {0}; | |
g_zUfiSms_DbStoreData->msg_displaymode = g_displaymode; | |
if(g_zUfiSms_DbStoreData->msg_displaymode != 1) | |
{ | |
//²»¹Üʧ°ÜÓë·ñ£¬´æÈë·¢¼þÏ䣬²¢ÉèÖñê¼Ç | |
if(0 == zUfiSms_WriteSmsToDb(&g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1],WMS_STORAGE_TYPE_NV_V01,-1)) | |
{ | |
g_zUfiSms_MsgRefer++; | |
(void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer); | |
} | |
} | |
printf("[SMS] atSms_RecvCmgsRsp segNo:%d/TotalNum:%d/FailNum:%d.\n",g_zUfiSms_CurConcatSegNo,g_zUfiSms_ConcatTotalNum,g_zUfiSms_SendFailedCount); | |
// ¶ÌÐÅ·¢ËͽáÊø | |
if(g_zUfiSms_CurConcatSegNo == g_zUfiSms_ConcatTotalNum ) | |
{ | |
g_zUfiSms_CurConcatSegNo = 0; | |
memset((void*)&tStatusInfo,0,sizeof(T_zUfiSms_StatusInfo)); | |
tStatusInfo.err_code = ZTE_SMS_CMS_NONE; | |
tStatusInfo.send_failed_count = g_zUfiSms_SendFailedCount; | |
tStatusInfo.delete_failed_count = 0; | |
if(g_zUfiSms_SendFailedCount == 0) | |
{ | |
tStatusInfo.cmd_status = WMS_CMD_SUCCESS; | |
sc_cfg_set(NV_SMS_SEND_RESULT, "ok"); | |
} | |
else | |
{ | |
tStatusInfo.cmd_status = WMS_CMD_FAILED; | |
sc_cfg_set(NV_SMS_SEND_RESULT, "fail"); | |
} | |
tStatusInfo.cmd = WMS_SMS_CMD_MSG_SEND; | |
(void)zUfiSms_SetCmdStatus(&tStatusInfo); | |
sc_cfg_set(NV_SMS_DB_CHANGE,"1"); | |
zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV); | |
if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]) | |
{ | |
zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT); | |
} | |
} | |
else | |
{ | |
//¼ÌÐø·¢ËÍÏÂÒ»¸öseg | |
//zUfiSms_SendConcatSms(cid); | |
} | |
} | |
int zte_fota_notifyPushMsg(int cmd) | |
{ | |
FOTA_MSG_BUF msg = {0}; | |
int errs = 0; | |
key_t req_id = ftok("/media/zte/zte_socket/fota_dmapp_msg",1); | |
int msgid=msgget(req_id,0); | |
if (msgid != -1) { //kw 3 | |
msg.mtype = 1; | |
msg.mtext[0] = WEBUI_NOTIFY_PUSH_MSG_; | |
errs = msgsnd(msgid, &msg, sizeof(msg)-sizeof(long),0); | |
} | |
return (errs<0?0:1); | |
} | |
#if 0 //ÎÞÓôúÂë | |
int atSms_SendCmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
return zSvr_SendAtSyn(ZAT_CMGL_CMD,"AT+CMGL=0\r\n",cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvCmglRsp(T_zAt_AtRes *pResLine) | |
{ | |
return; | |
} | |
#endif | |
#if 0 //zhangfen for platform | |
int atSms_SendZmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
int res = 0; | |
pthread_mutex_lock(&smsdb_mutex); | |
res = zSvr_SendAtSyn(ZAT_ZMGL_CMD,"AT+ZMGL=4\r\n",cid,pAtRst,atRstSize); | |
pthread_mutex_unlock(&smsdb_mutex); | |
return res; | |
} | |
VOID atSms_initAtOk(VOID) | |
{ | |
T_zUfiSms_StatusInfo tStatus = {0}; | |
//´Ë´¦»áµ¼ÖÂcmglÔÙ·¢Ò»´Î¼ÓÔØµ½ME´¦ | |
//zUfiSms_ChangeMainState(SMS_STATE_LOADED); | |
sc_cfg_set(NV_SMS_LOAD_RESULT, "ok"); | |
tStatus.cmd_status = WMS_CMD_SUCCESS; | |
tStatus.cmd = WMS_SMS_CMD_INIT; | |
(void)zUfiSms_SetCmdStatus(&tStatus); | |
zUfiSms_ChangeMainState(SMS_STATE_LOADED); | |
} | |
int atSms_initAtErr(UINT8 *pErrCode) | |
{ | |
T_zUfiSms_StatusInfo tStatus = {0}; | |
sc_cfg_set(NV_SMS_LOAD_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_LOADED); | |
tStatus.cmd_status = WMS_CMD_FAILED; | |
tStatus.cmd = WMS_SMS_CMD_INIT; | |
(void)zUfiSms_SetCmdStatus(&tStatus); | |
return FALSE; | |
} | |
VOID atSms_RecvZmglRsp(T_zAt_AtRes *pResLine) | |
{ | |
static T_zUfiSms_SmsItem tSmsPara = {0}; | |
printf("[SMS] atSms_RecvZmglRsp Enter pduFlag:%d/result:%d.\n",pResLine->pduFlag,pResLine->result); | |
if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG) | |
{ | |
zUfiSms_CmglRespProc(pResLine, &tSmsPara); | |
} | |
else | |
{ | |
//ÊÕµ½Ò»ÌõÐÂcmglºó£¬½«+cmgl:1,2,"",152¸ñʽ»¯²¢´æ´¢IndexºÍstatus¡¢length | |
memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem)); | |
(void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,1); | |
printf("[SMS] Zmgl Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length); | |
} | |
} | |
int atSms_SendCmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
CHAR pAtcmdStr[20] = {0}; | |
iSmsIndex = atoi(pAtCmdPara); | |
printf("[SMS] atSms_SendCmgrReq Get index:%d.\n",iSmsIndex); | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGR=%s\r\n", pAtCmdPara); | |
return zSvr_SendAtSyn(ZAT_CMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvCmgrRsp(T_zAt_AtRes *pResLine) | |
{ | |
#if 0 | |
static T_zUfiSms_SmsItem tSmsPara = {0}; | |
T_zUfiSms_CmgrSetRsp tCmgrRsp = {0}; | |
printf("atSms_RecvCmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result); | |
if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG) | |
{ | |
if(ZAT_RESULT_AUTOREPORT != pResLine->result) | |
{ | |
printf("!!!!!!!!!atSms_RecvCmgrRsp get result Error.\n"); | |
return; | |
} | |
tCmgrRsp.index = tSmsPara.index; | |
tCmgrRsp.length = tSmsPara.length; | |
tCmgrRsp.stat = tSmsPara.stat; | |
sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu); | |
//strcpy(tCmgrRsp.pdu, pResLine->resParas); | |
zUfiSms_CmgrRespProc(&tCmgrRsp); | |
zUfiMmi_SendSmsStatus(); | |
sc_cfg_set("sms_recv_result", "ok"); | |
} | |
else | |
{ | |
//ÊÕµ½Ò»ÌõÐÂcmgrºó£¬½«+cmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ | |
memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem)); | |
(void)zUfiSms_FormatSms(pResLine->resParas, &tSmsPara,2); | |
tSmsPara.index = iSmsIndex; | |
printf("======Cmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length); | |
} | |
#endif | |
} | |
int atSms_SendZmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
CHAR pAtcmdStr[20] = {0}; | |
iSmsIndex = atoi(pAtCmdPara); | |
printf("[SMS] atSms_SendZmgrReq Get index:%d.\n",iSmsIndex); | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMGR=%s\r\n", pAtCmdPara); | |
return zSvr_SendAtSyn(ZAT_ZMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvZmgrOk(T_zAt_AtRes *pResLine, UINT8 *nextAt) | |
{ | |
return; | |
} | |
VOID atSms_RecvZmgrErr(T_zAt_AtRes *pResLine, UINT8 *nextAt) | |
{ | |
at_print(LOG_DEBUG,"SMS zmgr is fail\n"); | |
at_print(LOG_DEBUG"[SMS] atSms_RecvZmgrErr SMS zmgr is fail\n"); | |
//if(0 != strcmp(cfg_safe_get("sr_state"), "sr_receiving")) | |
{ | |
//¶ÌÐŽÓÊÕʧ°Ü£¬ÓÖ·Ç״̬±¨¸æ×´Ì¬ | |
sc_cfg_set(NV_SMS_RECV_RESULT, "fail"); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVED); | |
} | |
} | |
VOID atSms_RecvZmgrRsp(T_zAt_AtRes *pResLine) | |
{ | |
static T_zUfiSms_SmsItem tSmsPara = {0}; | |
T_zUfiSms_CmgrSetRsp tCmgrRsp = {0}; | |
printf("[SMS] atSms_RecvZmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result); | |
if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG) | |
{ | |
if(ZAT_RESULT_AUTOREPORT != pResLine->result) | |
{ | |
printf("[SMS] atSms_RecvZmgrRsp get result Error.\n"); | |
return; | |
} | |
tCmgrRsp.index = tSmsPara.index; | |
tCmgrRsp.length = tSmsPara.length; | |
tCmgrRsp.stat = tSmsPara.stat; | |
sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu); | |
//strcpy(tCmgrRsp.pdu, pResLine->resParas); | |
zUfiSms_ZmgrRespProc(&tCmgrRsp); | |
zUfiMmi_SendSmsStatus(); | |
sc_cfg_set(NV_SMS_RECV_RESULT, "ok"); | |
} | |
else | |
{ | |
//ÊÕµ½Ò»ÌõÐÂzmgrºó£¬½«+zmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ | |
memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem)); | |
(void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,2); | |
tSmsPara.index = iSmsIndex; | |
printf("[SMS] Zmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length); | |
} | |
} | |
int atSms_SendCmgdReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
CHAR pAtcmdStr[20] = {0}; | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGD=%s\r\n", pAtCmdPara); | |
return zSvr_SendAtSyn(ZAT_CMGD_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvCmgdOk(VOID) | |
{ | |
CHAR strUsed[10] = {0}; | |
int used = 0; | |
sc_cfg_set(NV_SMS_DEL_RESULT, "ok"); | |
printf("[SMS] set sim_del_result to OK. \n"); | |
sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed)); | |
used = atoi(strUsed)-1; | |
if(used < 0) | |
{ | |
used = 0; | |
} | |
memset(&strUsed, 0, 10); | |
snprintf(strUsed,sizeof(strUsed),"%d", used); | |
sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED, strUsed); | |
} | |
VOID atSms_RecvCmgdErr(VOID) | |
{ | |
sc_cfg_set(NV_SMS_DEL_RESULT, "fail"); | |
printf("[SMS] set sim_del_result to fail. \n"); | |
} | |
VOID atSms_RecvCmgdFinish(VOID) | |
{ | |
char StrValue[10] = {0}; | |
CHAR strTotal[10] = {0}; | |
CHAR strUsed[10] = {0}; | |
int total = 0; | |
int used = 0; | |
int remain = 0; | |
sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed)); | |
used = atoi(strUsed); | |
sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strTotal,sizeof(strTotal)); | |
total = atoi(strTotal); | |
remain = total - used; | |
if(remain < 0) | |
{ | |
remain = 0; | |
} | |
memset(&StrValue, 0, 10); | |
snprintf(StrValue,sizeof(StrValue),"%d", remain); | |
sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue); | |
printf("[SMS] zUfiSms_DeleteSimSms used=%d,remain=%d,total=%d\n",used,remain,total); | |
zUfiSms_ChangeMainState(SMS_STATE_DELED); | |
sc_cfg_set(NV_SMS_DB_CHANGE,"1"); | |
} | |
int atSms_SendCmgsReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
int atRes = 0; | |
CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0}; | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGS=%d\r\n", g_zUfiSms_FinalCmgsBuf.length); | |
atRes = zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
if(atRes != ZAT_RESULT_SMS) | |
{ | |
return atRes; | |
} | |
memset(pAtcmdStr, 0, ZSMS_PDU_SIZE); | |
//assert(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE); | |
//Áôһλ¸ø½áβ·û | |
if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE-1) | |
{ | |
memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, strlen(g_zUfiSms_FinalCmgsBuf.pdu)); | |
} | |
else | |
{ | |
printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",g_zUfiSms_FinalCmgsBuf.pdu); | |
memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, ZSMS_PDU_SIZE-2); | |
} | |
// Ìí¼Ó½áβ·û | |
*(pAtcmdStr + strlen(g_zUfiSms_FinalCmgsBuf.pdu)) = ZSMS_CTRL_Z_CHAR; | |
memset(pAtRst, 0, atRstSize); | |
return zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvCmgsOk(UINT8 *pResLine, int cid) | |
{ | |
at_print(LOG_DEBUG,"sms sended success. \n"); | |
g_zUfiSms_CurConcatSegNo++; | |
if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX) | |
{ | |
return; | |
} | |
//·¢Ëͳɹ¦Ò»½Ú | |
g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_SENT_V01; | |
zUfiSms_CmgsRespProc(cid); | |
} | |
VOID atSms_RecvCmgsErr(UINT8 *pResLine, int cid) | |
{ | |
at_print(LOG_DEBUG,"sms sended fail. \n"); | |
g_zUfiSms_CurConcatSegNo++; | |
if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX) | |
{ | |
return; | |
} | |
//ʧ°ÜÊýÁ¿£¬×îÖÕдÈëÊý¾Ý¿â | |
g_zUfiSms_SendFailedCount++; | |
at_print(LOG_DEBUG,"send sms failed,so write sms to draftbox.\n"); | |
g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_NOT_SENT_V01; | |
if(g_zUfiSms_ConcatTotalNum > 1) | |
{ | |
// ³¤¶ÌÐÅ·¢ËÍʧ°Ü£¬ÖÃΪfalse | |
g_zUfiSms_IsConcatSendSuc = FALSE; | |
} | |
zUfiSms_CmgsRespProc(cid); | |
} | |
VOID atSms_RecvCmgsRsp(T_zAt_AtRes *pResLine) | |
{ | |
return; | |
} | |
VOID atSms_RecvCmtRsp(T_zAt_AtRes *pResLine) | |
{ | |
//ÅжÏÊÇ·ñÖ§³ÖSMS | |
//added by wenqin 2016-5-18 | |
CHAR needSMS[50] = {0}; | |
sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS)); | |
if(0 == strcmp(needSMS, "no")) | |
{ | |
printf("[SMS]atSms_RecvCmtRsp needSMS=no!"); | |
return; | |
} | |
static T_zUfiSms_SmsItem tSmsPara = {0}; | |
T_zUfiSms_CmtSetRsp tCmtRsp = {0}; | |
if(NULL == pResLine) | |
{ | |
return; | |
} | |
printf("[SMS] atSms_RecvCmtRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result); | |
if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG) | |
{ | |
if(ZAT_RESULT_AUTOREPORT != pResLine->result) | |
{ | |
printf("[SMS] atSms_RecvCmtRsp get result Error.\n"); | |
return; | |
} | |
tCmtRsp.length = tSmsPara.length; | |
sscanf(pResLine->resParas,"%500s", tCmtRsp.pdu); | |
pthread_mutex_lock(&smsdb_mutex); | |
zUfiSms_CmtRespProc(&tCmtRsp); | |
zUfiMmi_SendSmsStatus(); | |
pthread_mutex_unlock(&smsdb_mutex); | |
sc_cfg_set(NV_SMS_RECV_RESULT, "ok"); | |
} | |
else | |
{ | |
memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem)); | |
atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas)); | |
printf("[SMS] cmt ind! pResLine->resParas:%s.\n", pResLine->resParas); | |
sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length); | |
printf("[SMS] cmt ind! length:%d.\n", tSmsPara.length); | |
} | |
} | |
VOID atSms_RecvCmtiRsp(T_zAt_AtRes *pResLine) | |
{ | |
//ÅжÏÊÇ·ñÖ§³ÖSMS | |
//added by wenqin 2016-5-18 | |
CHAR needSMS[50] = {0}; | |
sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS)); | |
if(0 == strcmp(needSMS, "no")) | |
{ | |
printf("[SMS]atSms_RecvCmtRsp needSMS=no!"); | |
return; | |
} | |
char sms_Main_state[30]={0}; | |
char * memory = NULL; | |
printf("[SMS] atSms_RecvCmtiRsp enter %s.\n",pResLine->resParas); | |
if(NULL == pResLine) | |
{ | |
return; | |
} | |
if(ZAT_CMTI_CMD != pResLine->atCmdId) | |
{ | |
return; | |
} | |
//ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ | |
sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state)); | |
if(strcmp(sms_Main_state,"sms_deling")==0) | |
{ | |
printf("[SMS] atSms_RecvCmtiRsp: sms_deling\n"); | |
return; | |
} | |
// ÉèÖöÌÐÅ´æ´¢ÇøÓò£¬ZMGRÈ¥¶ÁÈ¡ | |
memory = strstr(pResLine->resParas,"\""); | |
if(NULL != memory) | |
{ | |
memory++; | |
} | |
if(0 == strncmp("SM", memory, 2)) | |
{ | |
zUfiSms_SetSmsLocation(SMS_LOCATION_SIM); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVING); | |
memory += 4; | |
printf("[SMS] send cmgr: %s\n",memory); | |
zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory); | |
} | |
else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö | |
{ | |
printf("[SMS] atSms_RecvCmtiRsp :store location not SM.\n"); | |
} | |
sc_cfg_set(NV_SMS_RECV_RESULT, ""); | |
} | |
VOID atSms_RecvCdsRsp(T_zAt_AtRes *pResLine) | |
{ | |
//ÅжÏÊÇ·ñÖ§³ÖSMS | |
//added by wenqin 2016-5-18 | |
CHAR needSMS[50] = {0}; | |
sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS)); | |
if(0 == strcmp(needSMS, "no")) | |
{ | |
printf("[SMS]atSms_RecvCmtRsp needSMS=no!"); | |
return; | |
} | |
static T_zUfiSms_SmsItem tSmsPara = {0}; | |
T_zUfiSms_CmgrSetRsp tCmgrRsp = {0}; | |
if(NULL == pResLine) | |
{ | |
return; | |
} | |
if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG) | |
{ | |
if(ZAT_RESULT_AUTOREPORT != pResLine->result) | |
{ | |
printf("[SMS] atSms_RecvCdsRsp get result Error.\n"); | |
return; | |
} | |
tCmgrRsp.length = tSmsPara.length; | |
sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu); | |
pthread_mutex_lock(&smsdb_mutex); | |
zUfiSms_CdsRespProc(&tCmgrRsp); | |
zUfiMmi_SendSmsStatus(); | |
pthread_mutex_unlock(&smsdb_mutex); | |
sc_cfg_set(NV_SMS_RECV_RESULT, "ok"); | |
} | |
else | |
{ | |
memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem)); | |
atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas)); | |
printf("[SMS] cds ind! pResLine->resParas:%s.\n", pResLine->resParas); | |
sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length); | |
printf("[SMS] atSms_RecvCdsRsp cds ind! length:%d.\n", tSmsPara.length); | |
} | |
} | |
VOID atSms_RecvCdsiRsp(T_zAt_AtRes *pResLine) | |
{ | |
//ÅжÏÊÇ·ñÖ§³ÖSMS | |
//added by wenqin 2016-5-18 | |
CHAR needSMS[50] = {0}; | |
sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS)); | |
if(0 == strcmp(needSMS, "no")) | |
{ | |
printf("[SMS]atSms_RecvCmtRsp needSMS=no!"); | |
return; | |
} | |
char sms_Main_state[30]={0}; | |
char * memory = NULL; | |
printf("[SMS] atSms_RecvCdsiRsp enter %s.\n",pResLine->resParas); | |
if(NULL == pResLine) | |
{ | |
return; | |
} | |
if(ZAT_CDSI_CMD != pResLine->atCmdId) | |
{ | |
return; | |
} | |
//ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ | |
sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state)); | |
if(strcmp(sms_Main_state,"sms_deling")==0) | |
{ | |
printf("[SMS] atSms_RecvCdsiRsp: sms_deling\n"); | |
return; | |
} | |
memory = strstr(pResLine->resParas,"\""); | |
if(NULL != memory) | |
{ | |
memory++; | |
} | |
printf("[SMS] atSms_RecvCdsiRsp: memory = %s\n", memory); | |
if(0 == strncmp("SM", memory, 2)) | |
{ | |
zUfiSms_SetSmsLocation(SMS_LOCATION_SIM); | |
zUfiSms_ChangeMainState(SMS_STATE_RECVING); | |
memory += 4; | |
printf("[SMS] send cmgr: %s\n",memory); | |
zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory); | |
} | |
else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö | |
{ | |
printf("[SMS] atSms_RecvCdsiRsp :store location not SM.\n"); | |
} | |
sc_cfg_set(NV_SMS_RECV_RESULT, ""); | |
} | |
int atSms_SendZmenaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
CHAR pAtcmdStr[20] = {0}; | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMENA=%s\r\n", pAtCmdPara); | |
return zSvr_SendAtSyn(ZAT_ZMENA_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
VOID atSms_RecvZmenaOk(VOID) | |
{ | |
g_Zmena_rsp = TRUE; | |
return; | |
} | |
VOID atSms_RecvZmenaErr(VOID) | |
{ | |
g_Zmena_rsp = FALSE; | |
return; | |
} | |
int atSms_SendCnmaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize) | |
{ | |
int atRes = 0; | |
CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0}; | |
CHAR ackPduStr[50] = {0}; | |
if(atoi(pAtCmdPara) == 1) | |
{ | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s\r\n", pAtCmdPara); | |
atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
printf("[SMS] atSms_SendCnmaReq 111111 ack ok = %s.\n", pAtcmdStr); | |
return 0; | |
} | |
else | |
{ | |
zUfiSms_EncodePdu_DeliverReport(ackPduStr, 0xD3); | |
snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s,%d\r\n", pAtCmdPara, strlen(ackPduStr)/2); | |
atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
if(atRes != ZAT_RESULT_SMS) | |
{ | |
return atRes; | |
} | |
printf("[SMS] atSms_SendCnmaReq = %s.\n", pAtcmdStr); | |
memset(pAtcmdStr, 0, ZSMS_PDU_SIZE); | |
if(strlen(ackPduStr)< ZSMS_PDU_SIZE-1) | |
{ | |
memcpy(pAtcmdStr, ackPduStr, strlen(ackPduStr)); | |
} | |
else | |
{ | |
printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",ackPduStr); | |
memcpy(pAtcmdStr, ackPduStr, ZSMS_PDU_SIZE-2); | |
} | |
// Ìí¼Ó½áβ·û | |
*(pAtcmdStr + strlen(ackPduStr)) = ZSMS_CTRL_Z_CHAR; | |
printf("[SMS] atSms_SendCnmaReq. pdu= %s\n", pAtcmdStr); | |
memset(pAtRst, 0, atRstSize); | |
return zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize); | |
} | |
} | |
VOID atSms_RecvCnmaRsp(T_zAt_AtRes *pResLine) | |
{ | |
return; | |
} | |
VOID atUnsoli_Delete_Sim_Sms(UINT8 *pDatabuf, int cid) | |
{ | |
CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0}; | |
int atRes = 0; | |
if(pDatabuf == NULL) | |
{ | |
return; | |
} | |
atRes = atSms_SendCmgdReq(pDatabuf, cid, errCode, ZSVR_AT_RES_CODE_LEN); | |
if(atRes == ZSMS_RESULT_OK) | |
{ | |
atSms_RecvCmgdOk(); | |
} | |
else | |
{ | |
atSms_RecvCmgdErr(); | |
} | |
atSms_RecvCmgdFinish(); | |
} | |
VOID atUnsoli_Report_Cnma(UINT8 *pDatabuf, int cid) | |
{ | |
CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0}; | |
if(pDatabuf == NULL) | |
{ | |
printf("[SMS] atUnsoli_Report_Cnma null"); | |
return; | |
} | |
atSms_SendCnmaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN); | |
} | |
VOID atUnsoli_Report_Zmena(UINT8 *pDatabuf, int cid) | |
{ | |
CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0}; | |
int atRes = 0; | |
if(pDatabuf == NULL) | |
{ | |
printf("[SMS] atUnsoli_Report_Zmena null"); | |
return; | |
} | |
atRes = atSms_SendZmenaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN); | |
if(atRes == ZSMS_RESULT_OK) | |
{ | |
atSms_RecvZmenaOk(); | |
} | |
else | |
{ | |
atSms_RecvZmenaErr(); | |
} | |
} | |
VOID atUnsoli_Report_Zmgr(UINT8 *pDatabuf, int cid) | |
{ | |
CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0}; | |
if(pDatabuf == NULL) | |
{ | |
printf("[SMS] atUnsoli_Report_Zmgr null"); | |
return; | |
} | |
atSms_SendZmgrReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN); | |
} | |
#endif | |