xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 1 | /**************************************************************************
|
| 2 | *
|
| 3 | * Copyright (c) 2012 ZTE Corporation.
|
| 4 | *
|
| 5 | ***************************************************************************
|
| 6 | * Ä£ ¿é Ãû : AT_SERVER
|
| 7 | * ÎÄ ¼þ Ãû : sms_proc.c
|
| 8 | * Ïà¹ØÎļþ :
|
| 9 | * ʵÏÖ¹¦ÄÜ : AtServerÄ£¿ésmsÁ÷³Ì¿ØÖÆÎļþ
|
| 10 | * ×÷ Õß : G.F
|
| 11 | * °æ ±¾ : V1.0
|
| 12 | * Íê³ÉÈÕÆÚ : 2013-09-29
|
| 13 | * ÆäËü˵Ã÷ :
|
| 14 | **************************************************************************/
|
| 15 |
|
| 16 | /**************************************************************************
|
| 17 | * Ð޸ļǼ1:
|
| 18 | ***************************************************************************/
|
| 19 | /**************************************************************************
|
| 20 | * Ð޸ıàºÅ : EC:617002775301, EC617002775301
|
| 21 | * ÐÞ ¸Ä ÈË : chenjie10092374
|
| 22 | * ÐÞ¸ÄÈÕÆÚ : 2014.5.30
|
| 23 | * ÐÞ¸ÄÄÚÈÝ : (´úÂë×ß²é)ÐÞ¸ÄÏà¹ØSMS½ÓÊÕ¶ÌÐÅÁ÷³Ì´¦Àí
|
| 24 | **************************************************************************/
|
| 25 | /**************************************************************************
|
| 26 | * Ð޸ıàºÅ : й¦ÄÜ
|
| 27 | * ÐÞ ¸Ä ÈË : chenjie10092374
|
| 28 | * ÐÞ¸ÄÈÕÆÚ : 2014.6.24
|
| 29 | * ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
|
| 30 | **************************************************************************/
|
| 31 | /**************************************************************************
|
| 32 | * Ð޸ıàºÅ : й¦ÄÜ
|
| 33 | * ÐÞ ¸Ä ÈË : chenjie10092374
|
| 34 | * ÐÞ¸ÄÈÕÆÚ : 2014.08.07
|
| 35 | * ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÏòMMI·¢ËͶÌÐÅ״̬µÄ´úÂë
|
| 36 | **************************************************************************/
|
| 37 | /**************************************************************************
|
| 38 | * #includeÇø
|
| 39 | **************************************************************************/
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 40 | #include <limits.h>
|
| 41 | #include "sms_code.h"
|
| 42 | #include <sys/msg.h>
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 43 |
|
| 44 | /**************************************************************************
|
| 45 | * ³£Á¿¶¨ÒåÇø
|
| 46 | **************************************************************************/
|
| 47 |
|
| 48 | /* **********È«¾Ö³£Á¿ **************/
|
| 49 |
|
| 50 | // ³¤¶ÌÐŵļ¶ÁªÐÅÏ¢
|
| 51 | T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;
|
| 52 |
|
| 53 | // Ⱥ·¢ÐÅÏ¢
|
| 54 | T_zUfiSms_GroupInfo g_zUfiSms_GroupSms;
|
| 55 |
|
| 56 | //Êý¾Ý¿âÖд洢µÄÐÅÏ¢£¬ÓÃÓÚ´æ´¢ÒÑ·¢ÐÅÏ¢
|
| 57 | T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];
|
| 58 |
|
| 59 | /* ¿¨ÖÐÊÇ·ñ´æ´¢ÒÑÂú, 0--¿¨, 1--nv */
|
| 60 | UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX] = {FALSE,FALSE};
|
| 61 |
|
| 62 | // ¶ÌÐÅɾ³ýÐÅÏ¢
|
| 63 | T_zUfiSms_DelSms g_zUfiSms_DelMsg;
|
| 64 | T_zUfiSms_DelIndexInfo g_deleteIndex={0};
|
| 65 |
|
| 66 | //¶ÌÐÅδ¶Á±êÖ¾ÐÞ¸Ä
|
| 67 | T_zUfiSms_ModifySms g_zUfiSms_modifyMsg={0};
|
| 68 | T_zUfiSms_ModifyIndexInfo g_modifyIndex={0};
|
| 69 |
|
| 70 | // ³¤¶ÌÐŵĵ¥Î»·¢Ëͳ¤¶È
|
| 71 | int g_zUfiSms_UnitLen = 0;
|
| 72 |
|
| 73 | // ³¤¶ÌÐŵÄ×Ü·Ö¶ÎÊý,ÓÃÓÚÅж϶ÌÐÅ·Ö¶ÎÊÇ·ñ·¢ËÍÍê±Ï
|
| 74 | int g_zUfiSms_ConcatTotalNum = 0;
|
| 75 |
|
| 76 | //µ±Ç°·¢Ë͵ij¤¶ÌÐÅÆ¬¶ÎºÅ£¬ÓÃÓڼǼÿ¶ÎµÄ·¢Ëͽá¹ûºÍÅжÏÊÇ·ñ·¢ËͽáÊø
|
| 77 | int g_zUfiSms_CurConcatSegNo = 0;
|
| 78 |
|
| 79 | //³¤¶ÌÐÅÊÇ·ñ·¢Ëͳɹ¦£¬Ä¬ÈÏ·¢Ëͳɹ¦
|
| 80 | UINT8 g_zUfiSms_IsConcatSendSuc = TRUE;
|
| 81 |
|
| 82 | // ¶ÌÐÅ·¢ËÍʧ°ÜµÄÌõÊý£¬ÓÃÓÚ³¤¶ÌÐŵķ¢ËͼÆÊý
|
| 83 | int g_zUfiSms_SendFailedCount = 0;
|
| 84 |
|
| 85 | //¶ÌÐŲÎÕÕÊý¾Ý£¬¸ø×é×°¼¶Áª¶ÌÐŵĶÌÐÅͷʱÓÃ
|
| 86 | int g_zUfiSms_MsgRefer = 0;
|
| 87 |
|
| 88 | // ¶ÌÐÅ·¢ËÍʧ°ÜºóÖØÊÔ´ÎÊý
|
| 89 | int g_zUfiSms_SendFailedRetry = 0;
|
| 90 |
|
| 91 | //¼Ç¼µ±Ç°×´Ì¬£¬ÓÃÓÚWebserverÏÔʾ
|
| 92 | //T_zUfiSms_StatusInfo g_zUfiSms_StatusInfo;
|
| 93 |
|
| 94 | char g_Zmena_value[2] = {0};
|
| 95 | //Êý¾Ý¿âÖÐָʾһÌõ¶ÌÐżÇ¼ÊÇ·ñ±»WEBUIÏÔʾ
|
| 96 | //0:ÏÔʾ£»1:²»ÏÔʾ
|
| 97 | int g_displaymode = 0;
|
| 98 |
|
| 99 |
|
| 100 | extern SMS_LOCATION g_zUfiSms_CurLocation;
|
| 101 | extern T_zUfiSms_CmdStatus zUfiSms_HandleReport( unsigned char* ptPduData);
|
| 102 | extern void zUfiSms_GetReportStatus(char *pdu_tmp,int *stat);
|
| 103 | extern VOID zUfiSms_ResendAtCmdZmena(int cid);
|
| 104 | extern int zUfiSms_DecodeSmsData
|
| 105 | (
|
| 106 | T_zUfiSms_DbStoreData *pDb_Data,
|
| 107 | int msg_index,
|
| 108 | zUfiSms_StoreType iStorePos,
|
| 109 | T_SmsStatus bSms_Status,
|
| 110 | wms_message_format_enum_v01 format,
|
| 111 | long iPdu_Len,
|
| 112 | unsigned char *pPdu_Received
|
| 113 | );
|
| 114 |
|
| 115 | typedef struct{
|
| 116 | long mtype;
|
| 117 | char mtext[12];
|
| 118 | }FOTA_MSG_BUF;
|
| 119 |
|
| 120 | #define WEBUI_NOTIFY_PUSH_MSG_ 3
|
| 121 |
|
| 122 | /* ºê´¦Àí */
|
| 123 |
|
| 124 | /**************************************************************************
|
| 125 | * Êý¾Ý½á¹¹¶¨ÒåÇø
|
| 126 | **************************************************************************/
|
| 127 | typedef struct
|
| 128 | {
|
| 129 | unsigned int isread_record;
|
| 130 | unsigned int inbox_full;
|
| 131 | }T_zUfiMmi_SmsRecord;
|
| 132 | /**************************************************************************
|
| 133 | * staticº¯ÊýÉùÃ÷Çø
|
| 134 | **************************************************************************/
|
| 135 |
|
| 136 | /**************************************************************************
|
| 137 | * È«¾Ö±äÁ¿¶¨ÒåÇø
|
| 138 | **************************************************************************/
|
| 139 |
|
| 140 |
|
| 141 | /**************************************************************************
|
| 142 | * º¯ÊýʵÏÖÇø
|
| 143 | **************************************************************************/
|
| 144 | //ËùÓÐsmsÏà¹ØµÄ¹¦Äܳõʼ»¯
|
| 145 | void zUfiMmi_SendSmsStatus(void)
|
| 146 | {
|
| 147 | int iSmsNum = 0;
|
| 148 | T_zUfiMmi_SmsRecord tRecord = { 0 };
|
| 149 | CHAR smsNum[50]={0};
|
| 150 | sc_cfg_get(NV_SMS_IN_NUM,smsNum,sizeof(smsNum));
|
| 151 |
|
| 152 | iSmsNum = atoi(smsNum);
|
| 153 | // *G.F*
|
| 154 | tRecord.isread_record = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_MAX);
|
| 155 | if(iSmsNum >= ZSMS_NUM_MAX_CPE)
|
| 156 | {
|
| 157 | tRecord.inbox_full = 1;
|
| 158 | }
|
| 159 | else
|
| 160 | {
|
| 161 | tRecord.inbox_full = 0;
|
| 162 | }
|
| 163 | //zUfi_SendMsgToAp(MODULE_ID_MMI,MSG_MMICHANNEL_MESSAGE, sizeof(tRecord), (CHAR*)&tRecord);
|
| 164 | }
|
| 165 |
|
| 166 | VOID zUfiSms_Init(VOID)
|
| 167 | {
|
| 168 | zUfiSms_CfgInit();
|
| 169 | zUfiSms_ChangeMainState(SMS_STATE_INITING); /* ÉèÖÃ״̬Ϊiniting, ÒÔ¹©Ò³ÃæÆÁ±Î²Ù×÷*/
|
| 170 | //zUfiSms_InitDb();
|
| 171 |
|
| 172 | //zUfiMmi_SendSmsStatus();
|
| 173 | }
|
| 174 |
|
| 175 | VOID zSvr_Zpbic_Sms_Init(VOID)
|
| 176 | {
|
| 177 | int atRes = 0;
|
| 178 | T_zUfiSms_StatusInfo tStatus = {0};
|
| 179 | CHAR outDate[50]={0};
|
| 180 |
|
| 181 | zUfiSms_Init();
|
| 182 | zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_INIT);
|
| 183 |
|
| 184 | //zSvr_Sms_At_Init(cid);
|
| 185 | zSms_SendSmsInitReq();
|
| 186 | at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send init req\n");
|
| 187 | //atUnsoli_Report_Zmena("0", cid);
|
| 188 | zSms_SendZmenaReq(0);
|
| 189 | at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send zmena req\n");
|
| 190 | sc_cfg_get(NV_OUTDATE_DELETE,outDate,sizeof(outDate));
|
| 191 | at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init outdate check %s\n", outDate);
|
| 192 | if(0 == strcmp(outDate, "1"))
|
| 193 | {
|
| 194 | atWeb_OutdateSmsCheck(ZUFI_NULL);
|
| 195 | }
|
| 196 | }
|
| 197 |
|
| 198 |
|
| 199 | VOID zUfiSms_DeleteAllSimSms(VOID)
|
| 200 | {
|
| 201 | zUfiSms_DeleteAllSimSmsInDb();
|
| 202 | }
|
| 203 |
|
| 204 | #if 0
|
| 205 | VOID zUfiSms_ResendAtCmdZmena(int cid)
|
| 206 | {
|
| 207 | CHAR netType[50]={0};
|
| 208 | sc_cfg_get(NV_NETWORK_TYPE,netType,sizeof(netType));
|
| 209 |
|
| 210 | if(!g_Zmena_rsp &&
|
| 211 | (0!=strcmp("No Service",netType)&&0!=strcmp("Limited Service",netType)))
|
| 212 | {
|
| 213 | atUnsoli_Report_Zmena(NULL,cid);
|
| 214 | }
|
| 215 | }
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 216 | #endif
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 217 |
|
| 218 | void zUfiSms_Ack_new_msg(BOOL needAck)
|
| 219 | {
|
| 220 | #if 0
|
| 221 | CHAR ackPduStr[400] = {0};
|
| 222 | SMS_PARAM reportParam = {0};
|
| 223 | int total_length = 0;
|
| 224 | UINT8 TP_FCS = 0;
|
| 225 | CHAR strValue[2] = {0};
|
| 226 |
|
| 227 | if(needAck)
|
| 228 | {
|
| 229 | TP_FCS = 0x00;
|
| 230 | sprintf(strValue, "%d", 1);
|
| 231 | }
|
| 232 | else
|
| 233 | {
|
| 234 | TP_FCS = 0xD3;
|
| 235 | sprintf(strValue, "%d", 2);
|
| 236 | }
|
| 237 |
|
| 238 | sprintf(reportParam.SCA, "%s", cfg_get("sms_center_num"));
|
| 239 | total_length = zUfiSms_EncodePdu_DeliverReport(&reportParam, ackPduStr, TP_FCS);
|
| 240 |
|
| 241 | memset(&g_zUfiSms_ackPdu, 0, sizeof(g_zUfiSms_ackPdu));
|
| 242 | g_zUfiSms_ackPdu.length = String2Bytes(ackPduStr, g_zUfiSms_ackPdu.pdu, strlen(ackPduStr));
|
| 243 |
|
| 244 | memset(g_zUfiSms_ackPdu.pdu, 0, sizeof(g_zUfiSms_ackPdu.pdu));
|
| 245 | memcpy(&g_zUfiSms_ackPdu.pdu, &ackPduStr, sizeof(ackPduStr));
|
| 246 |
|
| 247 | atBase_SendMsgToSelf(ZAT_CNMA_CMD, strValue, sizeof(strValue));
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 248 | #endif
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 249 | #if 0//zhangfen for platform
|
| 250 | CHAR strValue[2] = {0};
|
| 251 |
|
| 252 | if(needAck)
|
| 253 | {
|
| 254 | snprintf(strValue, sizeof(strValue),"%d", 1);
|
| 255 | }
|
| 256 | else
|
| 257 | {
|
| 258 | snprintf(strValue, sizeof(strValue),"%d", 2);
|
| 259 | }
|
| 260 | zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_CNMA,strlen(strValue),strValue);
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 261 | #endif
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 262 | if(needAck)
|
| 263 | {
|
| 264 | zSms_SendCnmaReq(1);
|
| 265 | }
|
| 266 | else
|
| 267 | {
|
| 268 | zSms_SendCnmaReq(2);
|
| 269 | }
|
| 270 | }
|
| 271 |
|
| 272 |
|
| 273 | /* ·¢ËͶÌÐÅ */
|
| 274 | T_zUfiSms_CmdStatus zUfiSms_SendRawSms(T_zUfiSms_SendReq *ptSendMsg)
|
| 275 | {
|
| 276 | if(NULL == ptSendMsg || 0 == ptSendMsg->receiver_count)
|
| 277 | {
|
| 278 | return WMS_CMD_FAILED;
|
| 279 | }
|
| 280 | 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);
|
| 281 | #if 1//corem for debug
|
| 282 | at_print(LOG_DEBUG, "[SMS] zUfiSms_SendRawSms dcs:%d\n",ptSendMsg->dcs);
|
| 283 | #endif
|
| 284 |
|
| 285 | sc_cfg_set(NV_SMS_SEND_RESULT, "");
|
| 286 | g_zUfiSms_SendFailedCount = 0;
|
| 287 |
|
| 288 | // Ö¸¶¨ÒªÉ¾³ý£¬»òÕßÊǴӲݸåÏäÖлñÈ¡(idÓÐЧ)£¬ÏÈɾ³ýÔ¶ÌÐÅ¡£*/
|
| 289 | if (ptSendMsg->isDelete == TRUE || -1 != ptSendMsg->id)
|
| 290 | {
|
| 291 | (void)zUfiSms_DeleteDraftSms(ptSendMsg->id);
|
| 292 | }
|
| 293 |
|
| 294 | //¼Ç¼±àÂë¸ñʽºÍÓïÑÔ£¬ºóÐøÄÚÈÝת»»Ê±Ê¹ÓÃ
|
| 295 | zUfiSms_SetGlobalDcsLang(ptSendMsg->dcs);
|
| 296 |
|
| 297 | // Ìî³äȺ·¢¼Ç¼
|
| 298 | memset(&g_zUfiSms_GroupSms,0,sizeof(g_zUfiSms_GroupSms));
|
| 299 | if(ZUFI_FAIL == zUfiSms_FillGroupSms(ptSendMsg, &g_zUfiSms_GroupSms))//kw 3
|
| 300 | {
|
| 301 | return WMS_CMD_FAILED;
|
| 302 | }
|
| 303 |
|
| 304 | // ²ð·Ö¼¶Áª¶ÌÐÅ£¬ÄÚÈÝÌîµ½g_zUfiSms_ConcatSmsÖУ¬·µ»Ø¶ÌÐŵĵ¥Î»³¤¶È
|
| 305 | memset(&g_zUfiSms_ConcatSms,0,sizeof(g_zUfiSms_ConcatSms));
|
| 306 | g_zUfiSms_UnitLen = zUfiSms_FillConcatSms(ptSendMsg,&g_zUfiSms_ConcatSms);
|
| 307 |
|
| 308 | g_zUfiSms_IsConcatSendSuc = TRUE;
|
| 309 | g_zUfiSms_CurConcatSegNo = 0;
|
| 310 | memset(g_zUfiSms_DbStoreData,0,sizeof(g_zUfiSms_DbStoreData));
|
| 311 |
|
| 312 | //for traffic
|
| 313 | //Á÷Á¿Ð£×¼¹¦ÄÜ·¢Ë͵ĶÌÐŲ»ÐèÒªÏÔʾ¸øWEBUI
|
| 314 | if(ptSendMsg->mem_store == 10)
|
| 315 | {
|
| 316 | g_displaymode = 1;
|
| 317 | at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 1\n");
|
| 318 | }
|
| 319 | else
|
| 320 | {
|
| 321 | g_displaymode = 0;
|
| 322 | at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 0\n");
|
| 323 | }
|
| 324 | return zUfiSms_SendSms();
|
| 325 | }
|
| 326 |
|
| 327 | T_zUfiSms_CmdStatus zUfiSms_WriteRawSms(T_zUfiSms_SaveReq *pSaveBuff)
|
| 328 | {
|
| 329 | T_zUfiSms_ConcatInfo tConcatSms;
|
| 330 | T_zUfiSms_GroupInfo tGroupSms;
|
| 331 | int iSmsLen = 0;
|
| 332 | T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
|
| 333 |
|
| 334 | if(NULL == pSaveBuff)
|
| 335 | {
|
| 336 | return WMS_CMD_FAILED;
|
| 337 | }
|
| 338 |
|
| 339 | if (g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV])
|
| 340 | {
|
| 341 | // NVÒÑÂú
|
| 342 | at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms nv memory is full,return\n");
|
| 343 | //g_zUfiSms_StatusInfo.err_code = ZTE_SMS_CMS_MEM_FULL;
|
| 344 | return WMS_CMD_FAILED;
|
| 345 | }
|
| 346 |
|
| 347 | if (pSaveBuff->isDelete == TRUE)
|
| 348 | {
|
| 349 | (void)zUfiSms_DeleteDraftSms(pSaveBuff->id);
|
| 350 | }
|
| 351 | zUfiSms_SetGlobalDcsLang(pSaveBuff->dcs);
|
| 352 |
|
| 353 | memset(&tConcatSms,0,sizeof(T_zUfiSms_ConcatInfo));
|
| 354 | memset(&tGroupSms,0,sizeof(T_zUfiSms_GroupInfo));
|
| 355 | (void)zUfiSms_FillGroupSms(pSaveBuff,&tGroupSms);
|
| 356 | iSmsLen = zUfiSms_FillConcatSms(pSaveBuff,&tConcatSms);
|
| 357 |
|
| 358 | at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms total_receiver=%d,iSmsLen=%d\n",tGroupSms.total_receiver,iSmsLen);
|
| 359 | //°´ÕÕ·¢¼þÈË£¬Öð¸ö½øÐжÌÐű£´æ
|
| 360 | for(tGroupSms.current_receiver = 0; tGroupSms.current_receiver < tGroupSms.total_receiver; tGroupSms.current_receiver++)
|
| 361 | {
|
| 362 | tConcatSms.current_sending = 0;
|
| 363 | result = zUfiSms_SaveSmsToDb(pSaveBuff,&tConcatSms,&tGroupSms,iSmsLen);
|
| 364 | at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms current_receiver=%d,result=%d\n",tGroupSms.current_receiver,result);
|
| 365 | }
|
| 366 | sc_cfg_set(NV_SMS_DB_CHANGE,"1");
|
| 367 |
|
| 368 | zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 369 | if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
|
| 370 | {
|
| 371 | zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
|
| 372 | }
|
| 373 |
|
| 374 | at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms end and result=%d\n",result);
|
| 375 | return result;
|
| 376 |
|
| 377 | }
|
| 378 |
|
| 379 | T_zUfiSms_CmdStatus zUfiSms_DeleteSms(T_zUfiSms_DelReq *ptDelBuff)
|
| 380 | {
|
| 381 | T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
|
| 382 | BOOL memoryFullbeforeDelete = FALSE;
|
| 383 | BOOL unreadBeforeDelete = FALSE;
|
| 384 |
|
| 385 | if(NULL == ptDelBuff)
|
| 386 | {
|
| 387 | return WMS_CMD_FAILED;
|
| 388 | }
|
| 389 | at_print(LOG_DEBUG, "[SMS] !!!!!zUfiSms_DeleteSms!!count:%d/id[%d].\n",ptDelBuff->all_or_count,ptDelBuff->id[0]);
|
| 390 | (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 391 | zUfiSms_ChangeMainState(SMS_STATE_DELING);
|
| 392 |
|
| 393 | // ¹¹Ôì¶ÌÐŵÄÏêϸɾ³ýÐÅÏ¢
|
| 394 | memset(&g_zUfiSms_DelMsg,0,sizeof(T_zUfiSms_DelSms));
|
| 395 | if(ZUFI_FAIL == zUfiSms_SetDeleteInfo(ptDelBuff))
|
| 396 | {
|
| 397 | at_print(LOG_DEBUG,"[SMS] !!!zUfiSms_SetDeleteInfo fail.\n");
|
| 398 | zUfiSms_ChangeMainState(SMS_STATE_DELED);
|
| 399 | return WMS_CMD_FAILED;
|
| 400 | }
|
| 401 | 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);
|
| 402 |
|
| 403 | if(0 < g_zUfiSms_DelMsg.nv_count) /* delete nv sms*/
|
| 404 | {
|
| 405 | if(g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
|
| 406 | {
|
| 407 | memoryFullbeforeDelete = TRUE;
|
| 408 | }
|
| 409 |
|
| 410 | unreadBeforeDelete = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV);
|
| 411 |
|
| 412 | result = (T_zUfiSms_CmdStatus)zUfiSms_DeleteNvSms();
|
| 413 | (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 414 | zUfiSms_ChangeMainState(SMS_STATE_DELED);
|
| 415 | sc_cfg_set(NV_SMS_DB_CHANGE,"1");
|
| 416 | at_print(LOG_DEBUG, "[SMS] zUfiSms_DeleteNvSms memoryFullbeforeDelete=%d,MemFullFlag(NV)=%d\n",memoryFullbeforeDelete,g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]);
|
| 417 | if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
|
| 418 | {
|
| 419 | //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
|
| 420 | //sat_print(LOG_DEBUGg_Zmena_value, "%d", 0);
|
| 421 | //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
|
| 422 | at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteNvSms: send AT+ZMENA=0\n");
|
| 423 | //atUnsoli_Report_Zmena("0", cid);
|
| 424 | zSms_SendZmenaReq(0);
|
| 425 | }
|
| 426 |
|
| 427 | if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]
|
| 428 | || unreadBeforeDelete && !zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
|
| 429 | {
|
| 430 | zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
|
| 431 | }
|
| 432 | }
|
| 433 | if(0 < g_zUfiSms_DelMsg.sim_count) /*delete sim sms*/
|
| 434 | {
|
| 435 | result = zUfiSms_DeleteSimSms();
|
| 436 | (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_SIM);
|
| 437 | }
|
| 438 | at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteSms result=%d\n",result);
|
| 439 | return result;
|
| 440 | }
|
| 441 |
|
| 442 |
|
| 443 | // δ¶Á±äÒѶÁ
|
| 444 | T_zUfiSms_CmdStatus zUfiSms_ModifySmsTag(T_zUfiSms_ModifyFlag *ptModifyBuff)
|
| 445 | {
|
| 446 | unsigned long i = 0;
|
| 447 | T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
|
| 448 | char acStorePos[50] = {0};
|
| 449 |
|
| 450 | if(NULL == ptModifyBuff)
|
| 451 | {
|
| 452 | at_print(LOG_ERR,"inputs is null.");
|
| 453 | return WMS_CMD_FAILED;
|
| 454 | }
|
| 455 |
|
| 456 | for(i = 0; i < ptModifyBuff->total_id; i++)
|
| 457 | {
|
| 458 | if(ptModifyBuff->id[i] < 1 || ZUFI_FAIL == zUfiSms_UpdateSmsTagInDb(ptModifyBuff->id[i],ptModifyBuff->tags))
|
| 459 | {
|
| 460 | result = WMS_CMD_FAILED;
|
| 461 | }
|
| 462 | else
|
| 463 | {
|
| 464 | result = WMS_CMD_SUCCESS;
|
| 465 | }
|
| 466 | }
|
| 467 |
|
| 468 | if(ZUFI_FAIL == zUfiSms_GetStorePosById("Mem_Store",acStorePos,sizeof(acStorePos),ptModifyBuff->id[0]))
|
| 469 | {
|
| 470 | return ZUFI_FAIL;
|
| 471 | }
|
| 472 |
|
| 473 | if(0 == strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE)) //!zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV) &&
|
| 474 | {
|
| 475 | zUfiSms_SendSmsStatusInfo(MSG_SMS_READING);
|
| 476 | }
|
| 477 |
|
| 478 | if(0 == strcmp(acStorePos,ZTE_WMS_DB_SIM_TABLE) && ptModifyBuff->total_id > 0)/*sim sms*/
|
| 479 | {
|
| 480 | zUfiSms_ModifyModemSms(ptModifyBuff);
|
| 481 | }
|
| 482 | return result;
|
| 483 | }
|
| 484 |
|
| 485 | //ÉèÖöÌÐŲÎÊý
|
| 486 | T_zUfiSms_CmdStatus zUfiSms_SetSmsPara(T_zUfiSms_ParaInfo *ptParaBuff)
|
| 487 | {
|
| 488 | int atRes = 0;
|
| 489 | CHAR sca[ZTE_WMS_ADDRESS_DIGIT_MAX_V01 + 1] = {0};
|
| 490 | CHAR store[20] = {0};
|
| 491 | CHAR defaultStore[50]={0};
|
| 492 |
|
| 493 | if (ptParaBuff == ZUFI_NULL)
|
| 494 | {
|
| 495 | return WMS_CMD_FAILED;
|
| 496 | }
|
| 497 |
|
| 498 | if (strlen(ptParaBuff->sca) != 0)
|
| 499 | {
|
| 500 | strncpy(sca, ptParaBuff->sca,sizeof(sca)-1);
|
| 501 | at_print(LOG_DEBUG, "send ZAT_CSCA_SET_CMD message csca is %s.\n", sca);
|
| 502 | //atBase_SendMsgToSelf(ZAT_CSCA_SET_CMD, (CHAR *)&tCscaPara, sizeof(tCscaPara));
|
| 503 | //zhangfen for platform
|
| 504 | atRes = zSms_SetCscaReq(ptParaBuff->sca);
|
| 505 | if(atRes != ZSMS_RESULT_OK)
|
| 506 | {
|
| 507 | return WMS_CMD_FAILED;
|
| 508 | }
|
| 509 | }
|
| 510 |
|
| 511 | sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
|
| 512 | if((*(ptParaBuff->default_store) != '\0') &&
|
| 513 | (0 != strcmp(defaultStore, ptParaBuff->default_store)))
|
| 514 | {
|
| 515 |
|
| 516 | //atBase_SendMsgToSelf(ZAT_CNMI_CMD, NULL, 0);
|
| 517 | //zhangfen for platform
|
| 518 | //kw 3
|
| 519 | //if(ptParaBuff->default_store == NULL)
|
| 520 | //{
|
| 521 | // sc_cfg_get(NV_DEFAULT_STORE,store,sizeof(store));
|
| 522 | //}
|
| 523 | //else
|
| 524 | {
|
| 525 | strncpy(store, ptParaBuff->default_store,sizeof(store)-1);
|
| 526 | }
|
| 527 | atRes = zSms_SendCnmiReq(store);
|
| 528 | if(atRes != ZSMS_RESULT_OK)
|
| 529 | {
|
| 530 | return WMS_CMD_FAILED;
|
| 531 | }
|
| 532 | }
|
| 533 |
|
| 534 | if(-1 == zUfiSms_SetDbParameters(ptParaBuff))
|
| 535 | {
|
| 536 | at_print(LOG_ERR,"set parameters to table failed.");
|
| 537 | return WMS_CMD_FAILED;
|
| 538 | }
|
| 539 |
|
| 540 | //memcpy((VOID *)&g_zUfiSms_CurSmsPara, (VOID *)ptParaBuff, sizeof(T_zUfiSms_ParaInfo));
|
| 541 |
|
| 542 | return WMS_CMD_SUCCESS;
|
| 543 | }
|
| 544 |
|
| 545 | void zUfiSms_CmgrNvSet(void)
|
| 546 | {
|
| 547 | char sms_rec_flag[5] = {0};
|
| 548 | char remind_flag[5];
|
| 549 | int sms_count = 0;
|
| 550 | int remind_count =0;
|
| 551 |
|
| 552 | //NVÖжÌÐÅÊýÁ¿¼ÓÒ»
|
| 553 | memset(sms_rec_flag,0,sizeof(sms_rec_flag));
|
| 554 | sc_cfg_get(ZTE_WMS_NVCONFIG_RECEVIED,sms_rec_flag,sizeof(sms_rec_flag));
|
| 555 | sms_count = atoi(sms_rec_flag);
|
| 556 | if(sms_count < 0 || sms_count > INT_MAX-1) { //kw 3
|
| 557 | at_print(LOG_ERR,"[SMS]sms_count err:%d\n", sms_count);
|
| 558 | return;
|
| 559 | }
|
| 560 |
|
| 561 | memset(sms_rec_flag,0,sizeof(sms_rec_flag));
|
| 562 | snprintf(sms_rec_flag,sizeof(sms_rec_flag),"%d",sms_count + 1);
|
| 563 |
|
| 564 | sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED, sms_rec_flag);
|
| 565 | sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_LED, sms_rec_flag);
|
| 566 |
|
| 567 | memset(remind_flag,0,sizeof(remind_flag));
|
| 568 | snprintf(remind_flag,sizeof(remind_flag),"%d",remind_count+1);
|
| 569 | sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_REMIND, remind_flag);
|
| 570 | sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
|
| 571 | sc_cfg_set(NV_SMS_DB_CHANGE,"1");
|
| 572 | }
|
| 573 |
|
| 574 | void zUfiSms_CdsRespProc(T_zSms_SmsInd *ptRespData)
|
| 575 | {
|
| 576 | unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
|
| 577 | T_zUfiSms_DbStoreData tDbStoreData = { 0 };
|
| 578 | int isPushSms = 0;
|
| 579 |
|
| 580 | // ¶ÌÐÅÄÚÈÝΪ¿Õ
|
| 581 | if (strcmp(ptRespData->pdu,"") == 0)
|
| 582 | {
|
| 583 | CHAR srState[50]={0};
|
| 584 | sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
|
| 585 | if(0 != strcmp(srState, "sr_receiving"))
|
| 586 | {
|
| 587 | //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
|
| 588 | sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
|
| 589 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 590 | }
|
| 591 | else
|
| 592 | {
|
| 593 | // ±¨¸æÊÕµ½
|
| 594 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 595 | }
|
| 596 | return;
|
| 597 | }
|
| 598 |
|
| 599 | zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
|
| 600 | (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
|
| 601 |
|
| 602 | /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ */
|
| 603 | if(5 == ptRespData->stat)
|
| 604 | {
|
| 605 | (void)zUfiSms_HandleReport(acFormatPdu);
|
| 606 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 607 | zUfiSms_Ack_new_msg(TRUE);
|
| 608 | return ;
|
| 609 | }
|
| 610 |
|
| 611 | return;
|
| 612 | }
|
| 613 |
|
| 614 | int zUfiSms_CheckIfWholeSms(T_zUfiSms_DbStoreData *data, SMS_MSG_INFO *pmsg)
|
| 615 | {
|
| 616 | if(data->concat_sms != 1)
|
| 617 | {
|
| 618 | return 0;
|
| 619 | }
|
| 620 |
|
| 621 | zUfiSms_GetCurrentRecvTotalSeq(data, pmsg);
|
| 622 |
|
| 623 | 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]);
|
| 624 | if(data->concat_info[1] == atoi(pmsg->total_seq))
|
| 625 | {
|
| 626 | return 0;
|
| 627 | }
|
| 628 |
|
| 629 | return -1;
|
| 630 | }
|
| 631 |
|
| 632 | void zUfiSms_TrafficChangeSmsTag(T_zUfiSms_DbStoreData *data)
|
| 633 | {
|
| 634 | CHAR smsNumber[50]={0};
|
| 635 | sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber));
|
| 636 | if(0 == strcmp(smsNumber, data->number))
|
| 637 | {
|
| 638 | data->tag = WMS_TAG_TYPE_MT_READ_V01;
|
| 639 | data->msg_displaymode = 1;
|
| 640 | }
|
| 641 | }
|
| 642 |
|
| 643 | void zUfiSms_HandleTrafficSms(T_zUfiSms_DbStoreData *data)
|
| 644 | {
|
| 645 | int iSmsId = 0;
|
| 646 | SMS_MSG_INFO msg = {0};
|
| 647 | CHAR smsNumber[50]={0};
|
| 648 | sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber));
|
| 649 |
|
| 650 | at_print(LOG_DEBUG, "[SMS][traffic] tDbStoreData.number = %s, traffic_sms_number = %s\n", data->number,smsNumber);
|
| 651 | if(0 == strcmp(smsNumber, data->number))
|
| 652 | {
|
| 653 | if(0 != zUfiSms_CheckIfWholeSms(data, &msg))
|
| 654 | {
|
| 655 | at_print(LOG_DEBUG,"[SMS][traffic] cmt ind, recv sms, but not whole sms, wait to recv next seg\n");
|
| 656 | return;
|
| 657 | }
|
| 658 |
|
| 659 | sc_cfg_set(NV_TRAFFIC_RECV_SMS_ID, msg.id);
|
| 660 | sc_cfg_set(NV_TRAFFIC_SMS_NUMBER, "0");
|
| 661 | at_print(LOG_DEBUG, "[SMS][traffic] zUfiSms_HandleTrafficSms traffic_recv_sms_id = %s\n", msg.id);
|
| 662 | }
|
| 663 |
|
| 664 | }
|
| 665 |
|
| 666 | void zUfiSms_CmtRespProc(T_zSms_SmsInd *ptRespData)
|
| 667 | {
|
| 668 | zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
|
| 669 | unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
|
| 670 | T_zUfiSms_DbStoreData tDbStoreData;
|
| 671 | int isPushSms = 0;
|
| 672 | SMS_PARAM one_sms = { 0 };
|
| 673 | int unread_sms_before_recv_new_sms = 0;
|
| 674 |
|
| 675 | memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
|
| 676 | 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);
|
| 677 |
|
| 678 | // ¶ÌÐÅÄÚÈÝΪ¿Õ
|
| 679 | if (strcmp(ptRespData->pdu,"") == 0 )
|
| 680 | {
|
| 681 | CHAR srState[50]={0};
|
| 682 | sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
|
| 683 | if(0 != strcmp(srState, "sr_receiving"))
|
| 684 | {
|
| 685 | //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
|
| 686 | sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
|
| 687 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 688 | }
|
| 689 | else
|
| 690 | {
|
| 691 | // ±¨¸æÊÕµ½
|
| 692 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 693 | }
|
| 694 | return;
|
| 695 | }
|
| 696 |
|
| 697 | //sleep(1);
|
| 698 | isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
|
| 699 | at_print(LOG_DEBUG, "[sms]zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
|
| 700 | if(SMS_NOTIFICATION == isPushSms) //notification
|
| 701 | {
|
| 702 | BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
|
| 703 | zte_fota_notifyPushMsg(0);
|
| 704 | }
|
| 705 |
|
| 706 | if(SMS_NO_PUSH != isPushSms)
|
| 707 | {
|
| 708 | /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
|
| 709 | at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
|
| 710 | at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
|
| 711 | at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
|
| 712 | at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
|
| 713 |
|
| 714 | //zUfiSms_DelModemSms(one_sms.index);
|
| 715 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 716 | zUfiSms_Ack_new_msg(TRUE);
|
| 717 | return;
|
| 718 | }
|
| 719 |
|
| 720 | //»ñȡ״̬
|
| 721 | zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
|
| 722 | (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
|
| 723 |
|
| 724 | /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
|
| 725 | if(5 == ptRespData->stat)
|
| 726 | {
|
| 727 | (void)zUfiSms_HandleReport(acFormatPdu);
|
| 728 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 729 | zUfiSms_Ack_new_msg(TRUE);
|
| 730 | return ;
|
| 731 | }
|
| 732 |
|
| 733 | // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
|
| 734 | (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
|
| 735 | WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
|
| 736 |
|
| 737 | if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
|
| 738 | {
|
| 739 | iStorePos = WMS_STORAGE_TYPE_UIM_V01;
|
| 740 | }
|
| 741 |
|
| 742 | if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
|
| 743 | {
|
| 744 | unread_sms_before_recv_new_sms = 1;
|
| 745 | }
|
| 746 | else
|
| 747 | {
|
| 748 | unread_sms_before_recv_new_sms = 0;
|
| 749 | }
|
| 750 |
|
| 751 | zUfiSms_TrafficChangeSmsTag(&tDbStoreData);
|
| 752 |
|
| 753 | //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
|
| 754 | if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
|
| 755 | {
|
| 756 | zUfiSms_Ack_new_msg(FALSE);
|
| 757 | //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
|
| 758 | //sat_print(LOG_DEBUGg_Zmena_value, "%d", 1);
|
| 759 | //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
|
| 760 | //zhangfen for platform
|
| 761 | //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMENA,1,"1");
|
| 762 | zSms_SendZmenaReq(1);
|
| 763 | return;
|
| 764 | }
|
| 765 |
|
| 766 | if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
|
| 767 | {
|
| 768 | zUfiSms_Ack_new_msg(TRUE);
|
| 769 | }
|
| 770 |
|
| 771 | zUfiSms_CmgrNvSet();
|
| 772 |
|
| 773 | zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 774 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 775 |
|
| 776 | zUfiSms_SendSmsStatusInfo(MSG_SMS_NEW);
|
| 777 |
|
| 778 | //for traffic sms
|
| 779 | zUfiSms_HandleTrafficSms(&tDbStoreData);
|
| 780 | return;
|
| 781 | }
|
| 782 |
|
| 783 | void zUfiSms_ZmgrRespProc(T_zSms_SmsInd *ptRespData)
|
| 784 | {
|
| 785 | zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
|
| 786 | unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
|
| 787 | T_zUfiSms_DbStoreData tDbStoreData;
|
| 788 | int isPushSms = 0;
|
| 789 | SMS_PARAM one_sms = { 0 };
|
| 790 | CHAR defaultStore[50]={0};
|
| 791 |
|
| 792 | memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
|
| 793 | 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);
|
| 794 |
|
| 795 | // ¶ÌÐÅÄÚÈÝΪ¿Õ
|
| 796 | if (strcmp(ptRespData->pdu,"") == 0 )
|
| 797 | {
|
| 798 | CHAR srState[50]={0};
|
| 799 | sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
|
| 800 | if(0 != strcmp(srState, "sr_receiving"))
|
| 801 | {
|
| 802 | //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
|
| 803 | sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
|
| 804 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 805 | }
|
| 806 | else
|
| 807 | {
|
| 808 | // ±¨¸æÊÕµ½
|
| 809 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 810 | }
|
| 811 | return;
|
| 812 | }
|
| 813 |
|
| 814 | //sleep(1);
|
| 815 | isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
|
| 816 | at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
|
| 817 | at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms);
|
| 818 | if(SMS_NOTIFICATION == isPushSms) //notification
|
| 819 | {
|
| 820 | BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
|
| 821 | zte_fota_notifyPushMsg(0);
|
| 822 | }
|
| 823 |
|
| 824 | if(SMS_NO_PUSH != isPushSms)
|
| 825 | {
|
| 826 | /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
|
| 827 | at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
|
| 828 | at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
|
| 829 | at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
|
| 830 | at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
|
| 831 |
|
| 832 | //zUfiSms_DelModemSms(one_sms.index);
|
| 833 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 834 | //zUfiSms_Ack_new_msg(TRUE);
|
| 835 | return;
|
| 836 | }
|
| 837 |
|
| 838 | //»ñȡ״̬
|
| 839 | zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
|
| 840 | (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
|
| 841 |
|
| 842 | /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
|
| 843 | if(5 == ptRespData->stat)
|
| 844 | {
|
| 845 | (void)zUfiSms_HandleReport(acFormatPdu);
|
| 846 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 847 | //zUfiSms_Ack_new_msg(TRUE);
|
| 848 | return ;
|
| 849 | }
|
| 850 |
|
| 851 | sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
|
| 852 | if(0 == strcmp(defaultStore, "sim"))
|
| 853 | {
|
| 854 | iStorePos = WMS_STORAGE_TYPE_UIM_V01;
|
| 855 | }
|
| 856 |
|
| 857 | // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
|
| 858 | (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
|
| 859 | WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
|
| 860 |
|
| 861 | if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
|
| 862 | {
|
| 863 | iStorePos = WMS_STORAGE_TYPE_UIM_V01;
|
| 864 | }
|
| 865 |
|
| 866 | zUfiSms_TrafficChangeSmsTag(&tDbStoreData);
|
| 867 |
|
| 868 | //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
|
| 869 | if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
|
| 870 | {
|
| 871 | //zUfiSms_Ack_new_msg(FALSE);
|
| 872 | //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
|
| 873 | //sat_print(LOG_DEBUGg_Zmena_value, "%d", 1);
|
| 874 | //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
|
| 875 | //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1");
|
| 876 | return;
|
| 877 | }
|
| 878 |
|
| 879 | if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
|
| 880 | {
|
| 881 | //zUfiSms_Ack_new_msg(TRUE);
|
| 882 | }
|
| 883 |
|
| 884 | zUfiSms_CmgrNvSet();
|
| 885 |
|
| 886 | zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 887 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 888 |
|
| 889 | //for traffic sms
|
| 890 | zUfiSms_HandleTrafficSms(&tDbStoreData);
|
| 891 |
|
| 892 | return;
|
| 893 | }
|
| 894 |
|
| 895 | //unused
|
| 896 | void zUfiSms_CmgrRespProc(T_zSms_SmsInd *ptRespData)
|
| 897 | {
|
| 898 | zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
|
| 899 | unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
|
| 900 | T_zUfiSms_DbStoreData tDbStoreData;
|
| 901 | int isPushSms = 0;
|
| 902 | SMS_PARAM one_sms = { 0 };
|
| 903 | int unread_sms_before_recv_new_sms = 0;
|
| 904 |
|
| 905 | memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
|
| 906 | 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);
|
| 907 | zUfiSms_SendSmsStatusInfo(MSG_SMS_READING);
|
| 908 | // ¶ÌÐÅÄÚÈÝΪ¿Õ
|
| 909 | if (strcmp(ptRespData->pdu,"") == 0 )
|
| 910 | {
|
| 911 | CHAR srState[50]={0};
|
| 912 | sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
|
| 913 | if(0 != strcmp(srState, "sr_receiving"))
|
| 914 | {
|
| 915 | //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
|
| 916 | sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
|
| 917 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 918 | }
|
| 919 | else
|
| 920 | {
|
| 921 | // ±¨¸æÊÕµ½
|
| 922 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 923 | }
|
| 924 | return;
|
| 925 | }
|
| 926 |
|
| 927 | //sleep(1);
|
| 928 | isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
|
| 929 | at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
|
| 930 | at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms);
|
| 931 | if(SMS_NOTIFICATION == isPushSms) //notification
|
| 932 | {
|
| 933 | BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
|
| 934 | zte_fota_notifyPushMsg(0);
|
| 935 | }
|
| 936 |
|
| 937 | if(SMS_NO_PUSH != isPushSms)
|
| 938 | {
|
| 939 | /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
|
| 940 | at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
|
| 941 | at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
|
| 942 | at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
|
| 943 | at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
|
| 944 |
|
| 945 | //zUfiSms_DelModemSms(one_sms.index);
|
| 946 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 947 | //zUfiSms_Ack_new_msg(TRUE);
|
| 948 | return;
|
| 949 | }
|
| 950 |
|
| 951 | //»ñȡ״̬
|
| 952 | zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
|
| 953 | (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
|
| 954 |
|
| 955 | /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
|
| 956 | if(5 == ptRespData->stat)
|
| 957 | {
|
| 958 | (void)zUfiSms_HandleReport(acFormatPdu);
|
| 959 | sc_cfg_set(NV_SR_STATE, "sr_received");
|
| 960 | //zUfiSms_Ack_new_msg(TRUE);
|
| 961 | return ;
|
| 962 | }
|
| 963 |
|
| 964 | // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
|
| 965 | (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
|
| 966 | WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
|
| 967 |
|
| 968 | if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
|
| 969 | {
|
| 970 | iStorePos = WMS_STORAGE_TYPE_UIM_V01;
|
| 971 | }
|
| 972 |
|
| 973 | if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
|
| 974 | {
|
| 975 | unread_sms_before_recv_new_sms = 1;
|
| 976 | }
|
| 977 | else
|
| 978 | {
|
| 979 | unread_sms_before_recv_new_sms = 0;
|
| 980 | }
|
| 981 |
|
| 982 | //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
|
| 983 | if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
|
| 984 | {
|
| 985 | //zUfiSms_Ack_new_msg(FALSE);
|
| 986 | //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
|
| 987 | //sprintf(g_Zmena_value, "%d", 1);
|
| 988 | //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
|
| 989 | //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1");
|
| 990 | return;
|
| 991 | }
|
| 992 |
|
| 993 | if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
|
| 994 | {
|
| 995 | //zUfiSms_Ack_new_msg(TRUE);
|
| 996 | }
|
| 997 |
|
| 998 | zUfiSms_CmgrNvSet();
|
| 999 |
|
| 1000 | zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 1001 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 1002 |
|
| 1003 | return;
|
| 1004 | }
|
| 1005 |
|
| 1006 |
|
| 1007 | void zUfiSms_CmgsRespProc(VOID)
|
| 1008 | {
|
| 1009 | T_zUfiSms_StatusInfo tStatusInfo = {0};
|
| 1010 |
|
| 1011 | g_zUfiSms_DbStoreData->msg_displaymode = g_displaymode;
|
| 1012 |
|
| 1013 | if(g_zUfiSms_DbStoreData->msg_displaymode != 1)
|
| 1014 | {
|
| 1015 | //²»¹Üʧ°ÜÓë·ñ£¬´æÈë·¢¼þÏ䣬²¢ÉèÖñê¼Ç
|
| 1016 | if(0 == zUfiSms_WriteSmsToDb(&g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1],WMS_STORAGE_TYPE_NV_V01,-1))
|
| 1017 | {
|
| 1018 | g_zUfiSms_MsgRefer++;
|
| 1019 | (void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);
|
| 1020 | }
|
| 1021 | }
|
| 1022 |
|
| 1023 | printf("[SMS] atSms_RecvCmgsRsp segNo:%d/TotalNum:%d/FailNum:%d.\n",g_zUfiSms_CurConcatSegNo,g_zUfiSms_ConcatTotalNum,g_zUfiSms_SendFailedCount);
|
| 1024 |
|
| 1025 | // ¶ÌÐÅ·¢ËͽáÊø
|
| 1026 | if(g_zUfiSms_CurConcatSegNo == g_zUfiSms_ConcatTotalNum )
|
| 1027 | {
|
| 1028 | g_zUfiSms_CurConcatSegNo = 0;
|
| 1029 |
|
| 1030 | memset((void*)&tStatusInfo,0,sizeof(T_zUfiSms_StatusInfo));
|
| 1031 | tStatusInfo.err_code = ZTE_SMS_CMS_NONE;
|
| 1032 | tStatusInfo.send_failed_count = g_zUfiSms_SendFailedCount;
|
| 1033 | tStatusInfo.delete_failed_count = 0;
|
| 1034 | if(g_zUfiSms_SendFailedCount == 0)
|
| 1035 | {
|
| 1036 | tStatusInfo.cmd_status = WMS_CMD_SUCCESS;
|
| 1037 | sc_cfg_set(NV_SMS_SEND_RESULT, "ok");
|
| 1038 | }
|
| 1039 | else
|
| 1040 | {
|
| 1041 | tStatusInfo.cmd_status = WMS_CMD_FAILED;
|
| 1042 | sc_cfg_set(NV_SMS_SEND_RESULT, "fail");
|
| 1043 | }
|
| 1044 | tStatusInfo.cmd = WMS_SMS_CMD_MSG_SEND;
|
| 1045 | (void)zUfiSms_SetCmdStatus(&tStatusInfo);
|
| 1046 | sc_cfg_set(NV_SMS_DB_CHANGE,"1");
|
| 1047 | zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
|
| 1048 | if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
|
| 1049 | {
|
| 1050 | zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
|
| 1051 | }
|
| 1052 | }
|
| 1053 | else
|
| 1054 | {
|
| 1055 | //¼ÌÐø·¢ËÍÏÂÒ»¸öseg
|
| 1056 | //zUfiSms_SendConcatSms(cid);
|
| 1057 | }
|
| 1058 | }
|
| 1059 |
|
| 1060 | int zte_fota_notifyPushMsg(int cmd)
|
| 1061 | {
|
| 1062 | FOTA_MSG_BUF msg = {0};
|
| 1063 | int errs = 0;
|
| 1064 | key_t req_id = ftok("/media/zte/zte_socket/fota_dmapp_msg",1);
|
| 1065 | int msgid=msgget(req_id,0);
|
| 1066 | if (msgid != -1) { //kw 3
|
| 1067 | msg.mtype = 1;
|
| 1068 | msg.mtext[0] = WEBUI_NOTIFY_PUSH_MSG_;
|
| 1069 | errs = msgsnd(msgid, &msg, sizeof(msg)-sizeof(long),0);
|
| 1070 | }
|
| 1071 | return (errs<0?0:1);
|
| 1072 | }
|
| 1073 |
|
| 1074 | #if 0 //ÎÞÓôúÂë
|
| 1075 | int atSms_SendCmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1076 | {
|
| 1077 | return zSvr_SendAtSyn(ZAT_CMGL_CMD,"AT+CMGL=0\r\n",cid,pAtRst,atRstSize);
|
| 1078 | }
|
| 1079 |
|
| 1080 | VOID atSms_RecvCmglRsp(T_zAt_AtRes *pResLine)
|
| 1081 | {
|
| 1082 | return;
|
| 1083 | }
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 1084 | #endif
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 1085 |
|
| 1086 | #if 0 //zhangfen for platform
|
| 1087 | int atSms_SendZmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1088 | {
|
| 1089 | int res = 0;
|
| 1090 | pthread_mutex_lock(&smsdb_mutex);
|
| 1091 | res = zSvr_SendAtSyn(ZAT_ZMGL_CMD,"AT+ZMGL=4\r\n",cid,pAtRst,atRstSize);
|
| 1092 | pthread_mutex_unlock(&smsdb_mutex);
|
| 1093 | return res;
|
| 1094 | }
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 | VOID atSms_initAtOk(VOID)
|
| 1099 | {
|
| 1100 | T_zUfiSms_StatusInfo tStatus = {0};
|
| 1101 | //´Ë´¦»áµ¼ÖÂcmglÔÙ·¢Ò»´Î¼ÓÔØµ½ME´¦
|
| 1102 | //zUfiSms_ChangeMainState(SMS_STATE_LOADED);
|
| 1103 | sc_cfg_set(NV_SMS_LOAD_RESULT, "ok");
|
| 1104 | tStatus.cmd_status = WMS_CMD_SUCCESS;
|
| 1105 | tStatus.cmd = WMS_SMS_CMD_INIT;
|
| 1106 | (void)zUfiSms_SetCmdStatus(&tStatus);
|
| 1107 | zUfiSms_ChangeMainState(SMS_STATE_LOADED);
|
| 1108 | }
|
| 1109 |
|
| 1110 | int atSms_initAtErr(UINT8 *pErrCode)
|
| 1111 | {
|
| 1112 | T_zUfiSms_StatusInfo tStatus = {0};
|
| 1113 |
|
| 1114 | sc_cfg_set(NV_SMS_LOAD_RESULT, "fail");
|
| 1115 | zUfiSms_ChangeMainState(SMS_STATE_LOADED);
|
| 1116 |
|
| 1117 | tStatus.cmd_status = WMS_CMD_FAILED;
|
| 1118 | tStatus.cmd = WMS_SMS_CMD_INIT;
|
| 1119 | (void)zUfiSms_SetCmdStatus(&tStatus);
|
| 1120 | return FALSE;
|
| 1121 | }
|
| 1122 |
|
| 1123 | VOID atSms_RecvZmglRsp(T_zAt_AtRes *pResLine)
|
| 1124 | {
|
| 1125 | static T_zUfiSms_SmsItem tSmsPara = {0};
|
| 1126 |
|
| 1127 | printf("[SMS] atSms_RecvZmglRsp Enter pduFlag:%d/result:%d.\n",pResLine->pduFlag,pResLine->result);
|
| 1128 | if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
|
| 1129 | {
|
| 1130 | zUfiSms_CmglRespProc(pResLine, &tSmsPara);
|
| 1131 | }
|
| 1132 | else
|
| 1133 | {
|
| 1134 | //ÊÕµ½Ò»ÌõÐÂcmglºó£¬½«+cmgl:1,2,"",152¸ñʽ»¯²¢´æ´¢IndexºÍstatus¡¢length
|
| 1135 | memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
|
| 1136 | (void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,1);
|
| 1137 | printf("[SMS] Zmgl Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
|
| 1138 | }
|
| 1139 | }
|
| 1140 |
|
| 1141 | int atSms_SendCmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1142 | {
|
| 1143 | CHAR pAtcmdStr[20] = {0};
|
| 1144 |
|
| 1145 | iSmsIndex = atoi(pAtCmdPara);
|
| 1146 | printf("[SMS] atSms_SendCmgrReq Get index:%d.\n",iSmsIndex);
|
| 1147 |
|
| 1148 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGR=%s\r\n", pAtCmdPara);
|
| 1149 | return zSvr_SendAtSyn(ZAT_CMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1150 | }
|
| 1151 |
|
| 1152 | VOID atSms_RecvCmgrRsp(T_zAt_AtRes *pResLine)
|
| 1153 | {
|
| 1154 | #if 0
|
| 1155 | static T_zUfiSms_SmsItem tSmsPara = {0};
|
| 1156 | T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
|
| 1157 |
|
| 1158 | printf("atSms_RecvCmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
|
| 1159 |
|
| 1160 | if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
|
| 1161 | {
|
| 1162 |
|
| 1163 | if(ZAT_RESULT_AUTOREPORT != pResLine->result)
|
| 1164 | {
|
| 1165 | printf("!!!!!!!!!atSms_RecvCmgrRsp get result Error.\n");
|
| 1166 | return;
|
| 1167 | }
|
| 1168 |
|
| 1169 | tCmgrRsp.index = tSmsPara.index;
|
| 1170 | tCmgrRsp.length = tSmsPara.length;
|
| 1171 | tCmgrRsp.stat = tSmsPara.stat;
|
| 1172 | sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
|
| 1173 | //strcpy(tCmgrRsp.pdu, pResLine->resParas);
|
| 1174 |
|
| 1175 | zUfiSms_CmgrRespProc(&tCmgrRsp);
|
| 1176 | zUfiMmi_SendSmsStatus();
|
| 1177 | sc_cfg_set("sms_recv_result", "ok");
|
| 1178 | }
|
| 1179 | else
|
| 1180 | {
|
| 1181 | //ÊÕµ½Ò»ÌõÐÂcmgrºó£¬½«+cmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ
|
| 1182 | memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
|
| 1183 |
|
| 1184 | (void)zUfiSms_FormatSms(pResLine->resParas, &tSmsPara,2);
|
| 1185 | tSmsPara.index = iSmsIndex;
|
| 1186 | printf("======Cmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
|
| 1187 | }
|
| 1188 | #endif
|
| 1189 | }
|
| 1190 |
|
| 1191 | int atSms_SendZmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1192 | {
|
| 1193 | CHAR pAtcmdStr[20] = {0};
|
| 1194 |
|
| 1195 | iSmsIndex = atoi(pAtCmdPara);
|
| 1196 | printf("[SMS] atSms_SendZmgrReq Get index:%d.\n",iSmsIndex);
|
| 1197 |
|
| 1198 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMGR=%s\r\n", pAtCmdPara);
|
| 1199 | return zSvr_SendAtSyn(ZAT_ZMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1200 | }
|
| 1201 |
|
| 1202 | VOID atSms_RecvZmgrOk(T_zAt_AtRes *pResLine, UINT8 *nextAt)
|
| 1203 | {
|
| 1204 | return;
|
| 1205 | }
|
| 1206 |
|
| 1207 | VOID atSms_RecvZmgrErr(T_zAt_AtRes *pResLine, UINT8 *nextAt)
|
| 1208 | {
|
| 1209 | at_print(LOG_DEBUG,"SMS zmgr is fail\n");
|
| 1210 | at_print(LOG_DEBUG"[SMS] atSms_RecvZmgrErr SMS zmgr is fail\n");
|
| 1211 | //if(0 != strcmp(cfg_safe_get("sr_state"), "sr_receiving"))
|
| 1212 | {
|
| 1213 | //¶ÌÐŽÓÊÕʧ°Ü£¬ÓÖ·Ç״̬±¨¸æ×´Ì¬
|
| 1214 | sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
|
| 1215 | zUfiSms_ChangeMainState(SMS_STATE_RECVED);
|
| 1216 | }
|
| 1217 | }
|
| 1218 |
|
| 1219 | VOID atSms_RecvZmgrRsp(T_zAt_AtRes *pResLine)
|
| 1220 | {
|
| 1221 | static T_zUfiSms_SmsItem tSmsPara = {0};
|
| 1222 | T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
|
| 1223 |
|
| 1224 | printf("[SMS] atSms_RecvZmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
|
| 1225 |
|
| 1226 | if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
|
| 1227 | {
|
| 1228 |
|
| 1229 | if(ZAT_RESULT_AUTOREPORT != pResLine->result)
|
| 1230 | {
|
| 1231 | printf("[SMS] atSms_RecvZmgrRsp get result Error.\n");
|
| 1232 | return;
|
| 1233 | }
|
| 1234 |
|
| 1235 | tCmgrRsp.index = tSmsPara.index;
|
| 1236 | tCmgrRsp.length = tSmsPara.length;
|
| 1237 | tCmgrRsp.stat = tSmsPara.stat;
|
| 1238 | sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
|
| 1239 | //strcpy(tCmgrRsp.pdu, pResLine->resParas);
|
| 1240 |
|
| 1241 | zUfiSms_ZmgrRespProc(&tCmgrRsp);
|
| 1242 | zUfiMmi_SendSmsStatus();
|
| 1243 | sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
|
| 1244 | }
|
| 1245 | else
|
| 1246 | {
|
| 1247 | //ÊÕµ½Ò»ÌõÐÂzmgrºó£¬½«+zmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ
|
| 1248 | memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
|
| 1249 |
|
| 1250 | (void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,2);
|
| 1251 | tSmsPara.index = iSmsIndex;
|
| 1252 | printf("[SMS] Zmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
|
| 1253 | }
|
| 1254 | }
|
| 1255 |
|
| 1256 |
|
| 1257 | int atSms_SendCmgdReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1258 | {
|
| 1259 | CHAR pAtcmdStr[20] = {0};
|
| 1260 |
|
| 1261 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGD=%s\r\n", pAtCmdPara);
|
| 1262 | return zSvr_SendAtSyn(ZAT_CMGD_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1263 | }
|
| 1264 |
|
| 1265 | VOID atSms_RecvCmgdOk(VOID)
|
| 1266 | {
|
| 1267 | CHAR strUsed[10] = {0};
|
| 1268 | int used = 0;
|
| 1269 |
|
| 1270 | sc_cfg_set(NV_SMS_DEL_RESULT, "ok");
|
| 1271 | printf("[SMS] set sim_del_result to OK. \n");
|
| 1272 |
|
| 1273 | sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
|
| 1274 | used = atoi(strUsed)-1;
|
| 1275 | if(used < 0)
|
| 1276 | {
|
| 1277 | used = 0;
|
| 1278 | }
|
| 1279 | memset(&strUsed, 0, 10);
|
| 1280 | snprintf(strUsed,sizeof(strUsed),"%d", used);
|
| 1281 | sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED, strUsed);
|
| 1282 | }
|
| 1283 |
|
| 1284 | VOID atSms_RecvCmgdErr(VOID)
|
| 1285 | {
|
| 1286 |
|
| 1287 | sc_cfg_set(NV_SMS_DEL_RESULT, "fail");
|
| 1288 | printf("[SMS] set sim_del_result to fail. \n");
|
| 1289 | }
|
| 1290 |
|
| 1291 | VOID atSms_RecvCmgdFinish(VOID)
|
| 1292 | {
|
| 1293 | char StrValue[10] = {0};
|
| 1294 | CHAR strTotal[10] = {0};
|
| 1295 | CHAR strUsed[10] = {0};
|
| 1296 | int total = 0;
|
| 1297 | int used = 0;
|
| 1298 | int remain = 0;
|
| 1299 |
|
| 1300 | sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
|
| 1301 | used = atoi(strUsed);
|
| 1302 | sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strTotal,sizeof(strTotal));
|
| 1303 | total = atoi(strTotal);
|
| 1304 | remain = total - used;
|
| 1305 | if(remain < 0)
|
| 1306 | {
|
| 1307 | remain = 0;
|
| 1308 | }
|
| 1309 |
|
| 1310 | memset(&StrValue, 0, 10);
|
| 1311 | snprintf(StrValue,sizeof(StrValue),"%d", remain);
|
| 1312 | sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue);
|
| 1313 | printf("[SMS] zUfiSms_DeleteSimSms used=%d,remain=%d,total=%d\n",used,remain,total);
|
| 1314 | zUfiSms_ChangeMainState(SMS_STATE_DELED);
|
| 1315 | sc_cfg_set(NV_SMS_DB_CHANGE,"1");
|
| 1316 | }
|
| 1317 |
|
| 1318 |
|
| 1319 | int atSms_SendCmgsReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1320 | {
|
| 1321 | int atRes = 0;
|
| 1322 | CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0};
|
| 1323 |
|
| 1324 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGS=%d\r\n", g_zUfiSms_FinalCmgsBuf.length);
|
| 1325 | atRes = zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1326 | if(atRes != ZAT_RESULT_SMS)
|
| 1327 | {
|
| 1328 | return atRes;
|
| 1329 | }
|
| 1330 |
|
| 1331 | memset(pAtcmdStr, 0, ZSMS_PDU_SIZE);
|
| 1332 | //assert(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE);
|
| 1333 | //Áôһλ¸ø½áβ·û
|
| 1334 | if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE-1)
|
| 1335 | {
|
| 1336 | memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, strlen(g_zUfiSms_FinalCmgsBuf.pdu));
|
| 1337 | }
|
| 1338 | else
|
| 1339 | {
|
| 1340 | printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",g_zUfiSms_FinalCmgsBuf.pdu);
|
| 1341 | memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, ZSMS_PDU_SIZE-2);
|
| 1342 | }
|
| 1343 | // Ìí¼Ó½áβ·û
|
| 1344 | *(pAtcmdStr + strlen(g_zUfiSms_FinalCmgsBuf.pdu)) = ZSMS_CTRL_Z_CHAR;
|
| 1345 | memset(pAtRst, 0, atRstSize);
|
| 1346 | return zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1347 | }
|
| 1348 |
|
| 1349 |
|
| 1350 | VOID atSms_RecvCmgsOk(UINT8 *pResLine, int cid)
|
| 1351 | {
|
| 1352 | at_print(LOG_DEBUG,"sms sended success. \n");
|
| 1353 | g_zUfiSms_CurConcatSegNo++;
|
| 1354 |
|
| 1355 | if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
|
| 1356 | {
|
| 1357 | return;
|
| 1358 | }
|
| 1359 |
|
| 1360 | //·¢Ëͳɹ¦Ò»½Ú
|
| 1361 | g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_SENT_V01;
|
| 1362 |
|
| 1363 | zUfiSms_CmgsRespProc(cid);
|
| 1364 | }
|
| 1365 |
|
| 1366 | VOID atSms_RecvCmgsErr(UINT8 *pResLine, int cid)
|
| 1367 | {
|
| 1368 | at_print(LOG_DEBUG,"sms sended fail. \n");
|
| 1369 | g_zUfiSms_CurConcatSegNo++;
|
| 1370 | if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
|
| 1371 | {
|
| 1372 | return;
|
| 1373 | }
|
| 1374 |
|
| 1375 | //ʧ°ÜÊýÁ¿£¬×îÖÕдÈëÊý¾Ý¿â
|
| 1376 | g_zUfiSms_SendFailedCount++;
|
| 1377 |
|
| 1378 | at_print(LOG_DEBUG,"send sms failed,so write sms to draftbox.\n");
|
| 1379 | g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
|
| 1380 | if(g_zUfiSms_ConcatTotalNum > 1)
|
| 1381 | {
|
| 1382 | // ³¤¶ÌÐÅ·¢ËÍʧ°Ü£¬ÖÃΪfalse
|
| 1383 | g_zUfiSms_IsConcatSendSuc = FALSE;
|
| 1384 | }
|
| 1385 |
|
| 1386 | zUfiSms_CmgsRespProc(cid);
|
| 1387 | }
|
| 1388 |
|
| 1389 |
|
| 1390 | VOID atSms_RecvCmgsRsp(T_zAt_AtRes *pResLine)
|
| 1391 | {
|
| 1392 | return;
|
| 1393 | }
|
| 1394 |
|
| 1395 |
|
| 1396 | VOID atSms_RecvCmtRsp(T_zAt_AtRes *pResLine)
|
| 1397 | {
|
| 1398 | //ÅжÏÊÇ·ñÖ§³ÖSMS
|
| 1399 | //added by wenqin 2016-5-18
|
| 1400 | CHAR needSMS[50] = {0};
|
| 1401 | sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
|
| 1402 | if(0 == strcmp(needSMS, "no"))
|
| 1403 | {
|
| 1404 | printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
|
| 1405 | return;
|
| 1406 | }
|
| 1407 |
|
| 1408 |
|
| 1409 | static T_zUfiSms_SmsItem tSmsPara = {0};
|
| 1410 | T_zUfiSms_CmtSetRsp tCmtRsp = {0};
|
| 1411 |
|
| 1412 | if(NULL == pResLine)
|
| 1413 | {
|
| 1414 | return;
|
| 1415 | }
|
| 1416 |
|
| 1417 | printf("[SMS] atSms_RecvCmtRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
|
| 1418 |
|
| 1419 | if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
|
| 1420 | {
|
| 1421 |
|
| 1422 | if(ZAT_RESULT_AUTOREPORT != pResLine->result)
|
| 1423 | {
|
| 1424 | printf("[SMS] atSms_RecvCmtRsp get result Error.\n");
|
| 1425 | return;
|
| 1426 | }
|
| 1427 |
|
| 1428 | tCmtRsp.length = tSmsPara.length;
|
| 1429 | sscanf(pResLine->resParas,"%500s", tCmtRsp.pdu);
|
| 1430 |
|
| 1431 | pthread_mutex_lock(&smsdb_mutex);
|
| 1432 | zUfiSms_CmtRespProc(&tCmtRsp);
|
| 1433 | zUfiMmi_SendSmsStatus();
|
| 1434 | pthread_mutex_unlock(&smsdb_mutex);
|
| 1435 | sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
|
| 1436 | }
|
| 1437 | else
|
| 1438 | {
|
| 1439 | memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
|
| 1440 | atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas));
|
| 1441 | printf("[SMS] cmt ind! pResLine->resParas:%s.\n", pResLine->resParas);
|
| 1442 | sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length);
|
| 1443 | printf("[SMS] cmt ind! length:%d.\n", tSmsPara.length);
|
| 1444 | }
|
| 1445 | }
|
| 1446 |
|
| 1447 | VOID atSms_RecvCmtiRsp(T_zAt_AtRes *pResLine)
|
| 1448 | {
|
| 1449 | //ÅжÏÊÇ·ñÖ§³ÖSMS
|
| 1450 | //added by wenqin 2016-5-18
|
| 1451 | CHAR needSMS[50] = {0};
|
| 1452 | sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
|
| 1453 | if(0 == strcmp(needSMS, "no"))
|
| 1454 | {
|
| 1455 | printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
|
| 1456 | return;
|
| 1457 | }
|
| 1458 |
|
| 1459 | char sms_Main_state[30]={0};
|
| 1460 | char * memory = NULL;
|
| 1461 |
|
| 1462 | printf("[SMS] atSms_RecvCmtiRsp enter %s.\n",pResLine->resParas);
|
| 1463 |
|
| 1464 | if(NULL == pResLine)
|
| 1465 | {
|
| 1466 | return;
|
| 1467 | }
|
| 1468 |
|
| 1469 | if(ZAT_CMTI_CMD != pResLine->atCmdId)
|
| 1470 | {
|
| 1471 | return;
|
| 1472 | }
|
| 1473 |
|
| 1474 | //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
|
| 1475 | sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
|
| 1476 | if(strcmp(sms_Main_state,"sms_deling")==0)
|
| 1477 | {
|
| 1478 | printf("[SMS] atSms_RecvCmtiRsp: sms_deling\n");
|
| 1479 | return;
|
| 1480 | }
|
| 1481 |
|
| 1482 | // ÉèÖöÌÐÅ´æ´¢ÇøÓò£¬ZMGRÈ¥¶ÁÈ¡
|
| 1483 | memory = strstr(pResLine->resParas,"\"");
|
| 1484 | if(NULL != memory)
|
| 1485 | {
|
| 1486 | memory++;
|
| 1487 | }
|
| 1488 |
|
| 1489 | if(0 == strncmp("SM", memory, 2))
|
| 1490 | {
|
| 1491 | zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
|
| 1492 | zUfiSms_ChangeMainState(SMS_STATE_RECVING);
|
| 1493 | memory += 4;
|
| 1494 | printf("[SMS] send cmgr: %s\n",memory);
|
| 1495 | zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory);
|
| 1496 | }
|
| 1497 | else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
|
| 1498 | {
|
| 1499 | printf("[SMS] atSms_RecvCmtiRsp :store location not SM.\n");
|
| 1500 | }
|
| 1501 | sc_cfg_set(NV_SMS_RECV_RESULT, "");
|
| 1502 | }
|
| 1503 |
|
| 1504 | VOID atSms_RecvCdsRsp(T_zAt_AtRes *pResLine)
|
| 1505 | {
|
| 1506 | //ÅжÏÊÇ·ñÖ§³ÖSMS
|
| 1507 | //added by wenqin 2016-5-18
|
| 1508 | CHAR needSMS[50] = {0};
|
| 1509 | sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
|
| 1510 | if(0 == strcmp(needSMS, "no"))
|
| 1511 | {
|
| 1512 | printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
|
| 1513 | return;
|
| 1514 | }
|
| 1515 |
|
| 1516 | static T_zUfiSms_SmsItem tSmsPara = {0};
|
| 1517 | T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
|
| 1518 |
|
| 1519 | if(NULL == pResLine)
|
| 1520 | {
|
| 1521 | return;
|
| 1522 | }
|
| 1523 |
|
| 1524 | if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
|
| 1525 | {
|
| 1526 |
|
| 1527 | if(ZAT_RESULT_AUTOREPORT != pResLine->result)
|
| 1528 | {
|
| 1529 | printf("[SMS] atSms_RecvCdsRsp get result Error.\n");
|
| 1530 | return;
|
| 1531 | }
|
| 1532 |
|
| 1533 | tCmgrRsp.length = tSmsPara.length;
|
| 1534 | sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
|
| 1535 |
|
| 1536 | pthread_mutex_lock(&smsdb_mutex);
|
| 1537 | zUfiSms_CdsRespProc(&tCmgrRsp);
|
| 1538 | zUfiMmi_SendSmsStatus();
|
| 1539 | pthread_mutex_unlock(&smsdb_mutex);
|
| 1540 | sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
|
| 1541 | }
|
| 1542 | else
|
| 1543 | {
|
| 1544 | memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
|
| 1545 | atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas));
|
| 1546 | printf("[SMS] cds ind! pResLine->resParas:%s.\n", pResLine->resParas);
|
| 1547 | sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length);
|
| 1548 | printf("[SMS] atSms_RecvCdsRsp cds ind! length:%d.\n", tSmsPara.length);
|
| 1549 | }
|
| 1550 | }
|
| 1551 |
|
| 1552 | VOID atSms_RecvCdsiRsp(T_zAt_AtRes *pResLine)
|
| 1553 | {
|
| 1554 | //ÅжÏÊÇ·ñÖ§³ÖSMS
|
| 1555 | //added by wenqin 2016-5-18
|
| 1556 | CHAR needSMS[50] = {0};
|
| 1557 | sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
|
| 1558 | if(0 == strcmp(needSMS, "no"))
|
| 1559 | {
|
| 1560 | printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
|
| 1561 | return;
|
| 1562 | }
|
| 1563 |
|
| 1564 | char sms_Main_state[30]={0};
|
| 1565 | char * memory = NULL;
|
| 1566 |
|
| 1567 | printf("[SMS] atSms_RecvCdsiRsp enter %s.\n",pResLine->resParas);
|
| 1568 |
|
| 1569 | if(NULL == pResLine)
|
| 1570 | {
|
| 1571 | return;
|
| 1572 | }
|
| 1573 |
|
| 1574 | if(ZAT_CDSI_CMD != pResLine->atCmdId)
|
| 1575 | {
|
| 1576 | return;
|
| 1577 | }
|
| 1578 |
|
| 1579 | //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
|
| 1580 | sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
|
| 1581 | if(strcmp(sms_Main_state,"sms_deling")==0)
|
| 1582 | {
|
| 1583 | printf("[SMS] atSms_RecvCdsiRsp: sms_deling\n");
|
| 1584 | return;
|
| 1585 | }
|
| 1586 |
|
| 1587 | memory = strstr(pResLine->resParas,"\"");
|
| 1588 | if(NULL != memory)
|
| 1589 | {
|
| 1590 | memory++;
|
| 1591 | }
|
| 1592 | printf("[SMS] atSms_RecvCdsiRsp: memory = %s\n", memory);
|
| 1593 | if(0 == strncmp("SM", memory, 2))
|
| 1594 | {
|
| 1595 | zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
|
| 1596 | zUfiSms_ChangeMainState(SMS_STATE_RECVING);
|
| 1597 | memory += 4;
|
| 1598 | printf("[SMS] send cmgr: %s\n",memory);
|
| 1599 | zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory);
|
| 1600 | }
|
| 1601 | else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
|
| 1602 | {
|
| 1603 | printf("[SMS] atSms_RecvCdsiRsp :store location not SM.\n");
|
| 1604 | }
|
| 1605 | sc_cfg_set(NV_SMS_RECV_RESULT, "");
|
| 1606 | }
|
| 1607 |
|
| 1608 | int atSms_SendZmenaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1609 | {
|
| 1610 | CHAR pAtcmdStr[20] = {0};
|
| 1611 |
|
| 1612 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMENA=%s\r\n", pAtCmdPara);
|
| 1613 | return zSvr_SendAtSyn(ZAT_ZMENA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1614 | }
|
| 1615 |
|
| 1616 | VOID atSms_RecvZmenaOk(VOID)
|
| 1617 | {
|
| 1618 | g_Zmena_rsp = TRUE;
|
| 1619 | return;
|
| 1620 | }
|
| 1621 |
|
| 1622 | VOID atSms_RecvZmenaErr(VOID)
|
| 1623 | {
|
| 1624 | g_Zmena_rsp = FALSE;
|
| 1625 | return;
|
| 1626 | }
|
| 1627 |
|
| 1628 |
|
| 1629 | int atSms_SendCnmaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
|
| 1630 | {
|
| 1631 | int atRes = 0;
|
| 1632 | CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0};
|
| 1633 | CHAR ackPduStr[50] = {0};
|
| 1634 |
|
| 1635 | if(atoi(pAtCmdPara) == 1)
|
| 1636 | {
|
| 1637 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s\r\n", pAtCmdPara);
|
| 1638 | atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1639 | printf("[SMS] atSms_SendCnmaReq 111111 ack ok = %s.\n", pAtcmdStr);
|
| 1640 | return 0;
|
| 1641 | }
|
| 1642 | else
|
| 1643 | {
|
| 1644 | zUfiSms_EncodePdu_DeliverReport(ackPduStr, 0xD3);
|
| 1645 |
|
| 1646 | snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s,%d\r\n", pAtCmdPara, strlen(ackPduStr)/2);
|
| 1647 | atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1648 | if(atRes != ZAT_RESULT_SMS)
|
| 1649 | {
|
| 1650 | return atRes;
|
| 1651 | }
|
| 1652 | printf("[SMS] atSms_SendCnmaReq = %s.\n", pAtcmdStr);
|
| 1653 |
|
| 1654 | memset(pAtcmdStr, 0, ZSMS_PDU_SIZE);
|
| 1655 |
|
| 1656 | if(strlen(ackPduStr)< ZSMS_PDU_SIZE-1)
|
| 1657 | {
|
| 1658 | memcpy(pAtcmdStr, ackPduStr, strlen(ackPduStr));
|
| 1659 | }
|
| 1660 | else
|
| 1661 | {
|
| 1662 | printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",ackPduStr);
|
| 1663 | memcpy(pAtcmdStr, ackPduStr, ZSMS_PDU_SIZE-2);
|
| 1664 | }
|
| 1665 |
|
| 1666 | // Ìí¼Ó½áβ·û
|
| 1667 | *(pAtcmdStr + strlen(ackPduStr)) = ZSMS_CTRL_Z_CHAR;
|
| 1668 | printf("[SMS] atSms_SendCnmaReq. pdu= %s\n", pAtcmdStr);
|
| 1669 | memset(pAtRst, 0, atRstSize);
|
| 1670 | return zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
|
| 1671 | }
|
| 1672 |
|
| 1673 | }
|
| 1674 |
|
| 1675 | VOID atSms_RecvCnmaRsp(T_zAt_AtRes *pResLine)
|
| 1676 | {
|
| 1677 | return;
|
| 1678 | }
|
| 1679 |
|
| 1680 |
|
| 1681 | VOID atUnsoli_Delete_Sim_Sms(UINT8 *pDatabuf, int cid)
|
| 1682 | {
|
| 1683 | CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
|
| 1684 | int atRes = 0;
|
| 1685 |
|
| 1686 | if(pDatabuf == NULL)
|
| 1687 | {
|
| 1688 | return;
|
| 1689 | }
|
| 1690 | atRes = atSms_SendCmgdReq(pDatabuf, cid, errCode, ZSVR_AT_RES_CODE_LEN);
|
| 1691 | if(atRes == ZSMS_RESULT_OK)
|
| 1692 | {
|
| 1693 | atSms_RecvCmgdOk();
|
| 1694 | }
|
| 1695 | else
|
| 1696 | {
|
| 1697 | atSms_RecvCmgdErr();
|
| 1698 | }
|
| 1699 | atSms_RecvCmgdFinish();
|
| 1700 | }
|
| 1701 |
|
| 1702 |
|
| 1703 | VOID atUnsoli_Report_Cnma(UINT8 *pDatabuf, int cid)
|
| 1704 | {
|
| 1705 | CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
|
| 1706 | if(pDatabuf == NULL)
|
| 1707 | {
|
| 1708 | printf("[SMS] atUnsoli_Report_Cnma null");
|
| 1709 | return;
|
| 1710 | }
|
| 1711 | atSms_SendCnmaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
|
| 1712 | }
|
| 1713 |
|
| 1714 |
|
| 1715 | VOID atUnsoli_Report_Zmena(UINT8 *pDatabuf, int cid)
|
| 1716 | {
|
| 1717 | CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
|
| 1718 | int atRes = 0;
|
| 1719 |
|
| 1720 | if(pDatabuf == NULL)
|
| 1721 | {
|
| 1722 | printf("[SMS] atUnsoli_Report_Zmena null");
|
| 1723 | return;
|
| 1724 | }
|
| 1725 |
|
| 1726 | atRes = atSms_SendZmenaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
|
| 1727 | if(atRes == ZSMS_RESULT_OK)
|
| 1728 | {
|
| 1729 | atSms_RecvZmenaOk();
|
| 1730 | }
|
| 1731 | else
|
| 1732 | {
|
| 1733 | atSms_RecvZmenaErr();
|
| 1734 | }
|
| 1735 | }
|
| 1736 |
|
| 1737 | VOID atUnsoli_Report_Zmgr(UINT8 *pDatabuf, int cid)
|
| 1738 | {
|
| 1739 | CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
|
| 1740 | if(pDatabuf == NULL)
|
| 1741 | {
|
| 1742 | printf("[SMS] atUnsoli_Report_Zmgr null");
|
| 1743 | return;
|
| 1744 | }
|
| 1745 | atSms_SendZmgrReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
|
| 1746 | }
|
xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame] | 1747 | #endif
|
xf.li | 771eb06 | 2025-02-09 23:05:11 -0800 | [diff] [blame^] | 1748 |
|