yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /*********************************************************************************
|
| 2 | * °æ±¾ËùÓÐ (C)
|
| 3 | *
|
| 4 | * ¹¦ÄÜ : CcAppÏà¹ØAT´¦Àí
|
| 5 | * ×÷Õß :
|
| 6 | * °æ±¾ : V1.0
|
| 7 | * Íê³ÉÈÕÆÚ : 2017.2.1
|
| 8 | * ÆäËü˵Ã÷ :
|
| 9 | * ²ÎÊý :
|
| 10 | * ÊäÈë :
|
| 11 | * Êä³ö :
|
| 12 | * ¸ü¸Ä¼Ç¼ :
|
| 13 | * ʱ¼ä ×÷Õß ÄÚÈÝ
|
| 14 | *-----------------------------------------------------------------------
|
| 15 | *
|
| 16 | *
|
| 17 | ***********************************************************************************/
|
| 18 | #ifndef CONFIG_MIN_8M_VERSION
|
| 19 | #include "at_context.h"
|
| 20 | #include "cfg_nv_def.h"
|
| 21 | #include "at_com.h"
|
| 22 |
|
| 23 | #define ZAT_INVALID_LEN -1
|
| 24 | #define MSG_RETRY_NUM 4
|
| 25 | #define MSG_RETRY_INTERVAL 50
|
| 26 |
|
| 27 | char* atCcapp_SendAtdReq(void *param)
|
| 28 | {
|
| 29 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 30 | T_zCcapp_CallMoReq *callReq = (T_zCcapp_CallMoReq *)msgbuf->aucDataBuf;
|
| 31 | char *pAtcmdStr = NULL;
|
| 32 |
|
| 33 | pAtcmdStr = malloc(ZDIAL_NUM_MAX+4);
|
| 34 | assert(pAtcmdStr);
|
| 35 | memset(pAtcmdStr, 0x00, ZDIAL_NUM_MAX+4);
|
| 36 | snprintf(pAtcmdStr, ZDIAL_NUM_MAX+4,"ATD%s;\r\n", callReq->number);
|
| 37 |
|
| 38 | return pAtcmdStr;
|
| 39 | }
|
| 40 | char* atCcapp_SendAtaReq(void *param)
|
| 41 | {
|
| 42 | char *pAtcmdStr = NULL;
|
| 43 |
|
| 44 | pAtcmdStr = malloc(10);
|
| 45 | assert(pAtcmdStr);
|
| 46 | memset(pAtcmdStr, 0x00, 10);
|
| 47 | snprintf(pAtcmdStr, 10,"ATA\r\n");
|
| 48 |
|
| 49 | return pAtcmdStr;
|
| 50 | }
|
| 51 | char* atCcapp_SendChupReq(void *param)
|
| 52 | {
|
| 53 | char *pAtcmdStr = NULL;
|
| 54 |
|
| 55 | pAtcmdStr = malloc(30);
|
| 56 | assert(pAtcmdStr);
|
| 57 | memset(pAtcmdStr, 0x00, 30);
|
| 58 | snprintf(pAtcmdStr, 30,"AT+CHUP\r\n");
|
| 59 |
|
| 60 | return pAtcmdStr;
|
| 61 | }
|
| 62 | char* atCcapp_SendVtsReq(void *param)
|
| 63 | {
|
| 64 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 65 | char *pAtcmdStr = NULL;
|
| 66 | T_zCcapp_VtsReq *vtsReq = (T_zCcapp_VtsReq *)msgbuf->aucDataBuf;
|
| 67 |
|
| 68 | pAtcmdStr = malloc(30);
|
| 69 | assert(pAtcmdStr);
|
| 70 | memset(pAtcmdStr, 0x00, 30);
|
| 71 | snprintf(pAtcmdStr, 30,"AT+VTS=%c,30\r\n",vtsReq->dtmfchar);
|
| 72 |
|
| 73 | return pAtcmdStr;
|
| 74 | }
|
| 75 | char* atCcapp_SendImsplusReq(void *param)
|
| 76 | {
|
| 77 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 78 | char *pAtcmdStr = NULL;
|
| 79 | T_zCcapp_ImsplusReq *imsplusReq = (T_zCcapp_ImsplusReq *)msgbuf->aucDataBuf;
|
| 80 |
|
| 81 | pAtcmdStr = malloc(30);
|
| 82 | assert(pAtcmdStr);
|
| 83 | memset(pAtcmdStr, 0x00, 30);
|
| 84 | if (imsplusReq->setfg == 1)
|
| 85 | {
|
| 86 | snprintf(pAtcmdStr, 30,"AT+ZIMSPLUS=%d\r\n",imsplusReq->act);
|
| 87 | }
|
| 88 | else
|
| 89 | {
|
| 90 | snprintf(pAtcmdStr, 30,"AT+ZIMSPLUS=%d,4\r\n",imsplusReq->act);
|
| 91 | }
|
| 92 |
|
| 93 | return pAtcmdStr;
|
| 94 | }
|
| 95 | char* atCcapp_SendClckReq(void *param)
|
| 96 | {
|
| 97 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 98 | char *pAtcmdStr = NULL;
|
| 99 | T_zCcapp_ClckReq *clckReq = (T_zCcapp_ClckReq *)msgbuf->aucDataBuf;
|
| 100 |
|
| 101 |
|
| 102 | pAtcmdStr = malloc(50);
|
| 103 | assert(pAtcmdStr);
|
| 104 | memset(pAtcmdStr, 0x00, 50);
|
| 105 | if (clckReq->type == 0)
|
| 106 | snprintf(pAtcmdStr, 50,"AT+CLCK=\"AO\",%d,\"%s\"\r\n",clckReq->act,clckReq->pw);
|
| 107 | else if (clckReq->type == 1)
|
| 108 | snprintf(pAtcmdStr, 50,"AT+CLCK=\"OI\",%d,\"%s\"\r\n",clckReq->act,clckReq->pw);
|
| 109 |
|
| 110 | return pAtcmdStr;
|
| 111 | }
|
| 112 | char* atCcapp_SendCcfcReq(void *param)
|
| 113 | {
|
| 114 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 115 | char *pAtcmdStr = NULL;
|
| 116 | T_zCcapp_CcfcReq *ccfcReq = (T_zCcapp_CcfcReq *)msgbuf->aucDataBuf;
|
| 117 |
|
| 118 | pAtcmdStr = malloc(30);
|
| 119 | assert(pAtcmdStr);
|
| 120 | memset(pAtcmdStr, 0x00, 30);
|
| 121 | if (ccfcReq->act ==1)
|
| 122 | snprintf(pAtcmdStr, 30,"AT+CCFC=%d,%d,\"%s\"\r\n",ccfcReq->type, ccfcReq->act, ccfcReq->dn);
|
| 123 | else if (ccfcReq->act ==0)
|
| 124 | snprintf(pAtcmdStr, 30,"AT+CCFC=%d,%d\r\n",ccfcReq->type, ccfcReq->act);
|
| 125 |
|
| 126 | return pAtcmdStr;
|
| 127 | }
|
| 128 | char* atCcapp_SendChldReq(void *param)
|
| 129 | {
|
| 130 | MSG_BUF *msgbuf = (MSG_BUF *)param;
|
| 131 | char *pAtcmdStr = NULL;
|
| 132 | T_zCcapp_ChldReq *chldReq = (T_zCcapp_ChldReq *)msgbuf->aucDataBuf;
|
| 133 |
|
| 134 | pAtcmdStr = malloc(30);
|
| 135 | assert(pAtcmdStr);
|
| 136 | memset(pAtcmdStr, 0x00, 30);
|
| 137 | snprintf(pAtcmdStr, 30,"AT+CHLD=%d\r\n",chldReq->type);
|
| 138 |
|
| 139 | return pAtcmdStr;
|
| 140 | }
|
| 141 | VOID zCc_NumProc(CHAR *pParaLine)
|
| 142 | {
|
| 143 | SINT32 flg = 0;
|
| 144 | UINT32 i = 0;
|
| 145 | UINT32 length = 0;
|
| 146 | CHAR *pSource = pParaLine;
|
| 147 | CHAR *pDest = NULL;
|
| 148 | CHAR abStrDest[ZDIAL_NUM_MAX+50] = {0};
|
| 149 |
|
| 150 | pDest = abStrDest;
|
| 151 | length = strlen(pParaLine);
|
| 152 |
|
| 153 | for (i = 0; i < length ; i++)
|
| 154 | {
|
| 155 | if ('"' == *pSource)
|
| 156 | {
|
| 157 | flg = (0 == flg)?1:0;
|
| 158 | if (0 == flg)
|
| 159 | {
|
| 160 | break;
|
| 161 | }
|
| 162 | pSource++;
|
| 163 | }
|
| 164 | else
|
| 165 | {
|
| 166 | *pDest++ = *pSource++;
|
| 167 | }
|
| 168 | }
|
| 169 |
|
| 170 | memset(pParaLine, 0, length); /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */
|
| 171 | strcpy(pParaLine, abStrDest);
|
| 172 | }
|
| 173 | int atCcapp_RecvDsciInd( char *at_paras ,int is_query_report)
|
| 174 | {
|
| 175 | T_zCcApp_DsciInd *dsciInd = NULL;
|
| 176 | char abNum[ZDIAL_NUM_MAX+50]= {0};
|
| 177 | unsigned int type;
|
| 178 |
|
| 179 | dsciInd = malloc(sizeof(T_zCcApp_DsciInd));
|
| 180 | if(dsciInd==NULL){softap_assert(""); return AT_END;}
|
| 181 | memset(dsciInd, 0, sizeof(T_zCcApp_DsciInd));
|
| 182 | //zCc_PreProcRes(at_paras);
|
| 183 | at_print(AT_DEBUG,"[CCAPP] dsci ind! pResLine->resParas:%s.\n", at_paras);
|
| 184 | sscanf(at_paras, "%u, %u, %u, %u, %u, %97s", &dsciInd->cid, &dsciInd->dir, &dsciInd->state,&type, &dsciInd->inMpty, abNum);
|
| 185 | zCc_NumProc(abNum);
|
| 186 | memcpy(dsciInd->num, abNum, sizeof(dsciInd->num)-1);//cov ¿ÉÄÜÓÐÎÊÌâ
|
| 187 |
|
| 188 | at_print(AT_DEBUG,"[CCAPP] DSCI %d %d %d\n", dsciInd->cid, dsciInd->dir, dsciInd->state);
|
| 189 |
|
| 190 | ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_DSCI_IND, sizeof(T_zCcApp_DsciInd), (unsigned char *)dsciInd,0);
|
| 191 | at_print(AT_DEBUG,"[CCAPP]send DSCI %d\n ",MSG_CMD_DSCI_IND );
|
| 192 | free(dsciInd);
|
| 193 | return AT_CONTINUE;
|
| 194 | }
|
| 195 |
|
| 196 | int atCcapp_RecvZvoicechnlInd(char *at_paras ,int is_query_report)
|
| 197 | {
|
| 198 | T_zCcApp_VoiceChnl *voicechnl = NULL;
|
| 199 |
|
| 200 | voicechnl = malloc(sizeof(T_zCcApp_VoiceChnl));
|
| 201 | if(voicechnl==NULL){softap_assert(""); return AT_END;}
|
| 202 | memset(voicechnl, 0, sizeof(T_zCcApp_VoiceChnl));
|
| 203 |
|
| 204 | at_print(AT_DEBUG,"[CCAPP] voicechnl ind! pResLine->resParas:%s.\n", at_paras);
|
| 205 | sscanf(at_paras, "%u, %u, %u, %u", &voicechnl->op, &voicechnl->act, &voicechnl->codetype, &voicechnl->amrpath);
|
| 206 | at_print(AT_DEBUG,"[CCAPP] voicechnl->op= %d voicechnl->act= %d voicechnl->codetype= %d voicechnl->amrpath= %d\n", voicechnl->op, voicechnl->act, voicechnl->codetype, voicechnl->amrpath);
|
| 207 |
|
| 208 | ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZVOICECHNL, sizeof(T_zCcApp_VoiceChnl), (unsigned char *)voicechnl,0);
|
| 209 | at_print(AT_DEBUG,"[CCAPP]send VOICECHNL %d\n ",MSG_CMD_ZVOICECHNL );
|
| 210 | free(voicechnl);
|
| 211 | return AT_CONTINUE;
|
| 212 | }
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 | int atCcapp_RecvImsplusInd(char *at_paras ,int is_query_report)
|
| 217 | {
|
| 218 | T_zCcApp_ImsplusInd *imsplusInd = NULL;
|
| 219 |
|
| 220 | imsplusInd = malloc(sizeof(T_zCcApp_ImsplusInd));
|
| 221 | if(imsplusInd==NULL){softap_assert("");return AT_END;}
|
| 222 | memset(imsplusInd, 0, sizeof(T_zCcApp_ImsplusInd));
|
| 223 |
|
| 224 | //zCc_PreProcRes(at_paras);
|
| 225 | at_print(AT_DEBUG,"[CCAPP] imsplus ind! pResLine->resParas:%s.\n", at_paras);
|
| 226 | sscanf(at_paras, "%u, %u", &imsplusInd->act, &imsplusInd->rate);
|
| 227 | at_print(AT_DEBUG,"[CCAPP] imsplusInd->act= %d imsplusInd->rate= %d\n", imsplusInd->act, imsplusInd->rate);
|
| 228 |
|
| 229 | ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZIMSPLUS_IND, sizeof(T_zCcApp_ImsplusInd), (unsigned char *)imsplusInd,0);
|
| 230 | at_print(AT_DEBUG,"[CCAPP]send IMSPLUS %d\n ",MSG_CMD_ZIMSPLUS_IND );
|
| 231 | free(imsplusInd);
|
| 232 | return AT_CONTINUE;
|
| 233 | }
|
| 234 |
|
| 235 | int atCcapp_RecvZcpiInd(char *at_paras ,int is_query_report)
|
| 236 | {
|
| 237 | T_zCcApp_ZcpiInd *zcpiInd = NULL;
|
| 238 |
|
| 239 | zcpiInd = malloc(sizeof(T_zCcApp_ZcpiInd));
|
| 240 | if(zcpiInd==NULL){softap_assert("");return AT_END;}
|
| 241 | memset(zcpiInd, 0, sizeof(T_zCcApp_ZcpiInd));
|
| 242 |
|
| 243 | //zCc_PreProcRes(at_paras);
|
| 244 | at_print(AT_DEBUG,"[CCAPP] zcpi ind! pResLine->resParas:%s.\n", at_paras);
|
| 245 | sscanf(at_paras, "%u, %u, %u",&zcpiInd->cid,&zcpiInd->state,&zcpiInd->progdsp);
|
| 246 |
|
| 247 | ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZCPI, sizeof(T_zCcApp_ZcpiInd), (unsigned char *)zcpiInd,0);
|
| 248 | free(zcpiInd);
|
| 249 | return AT_CONTINUE;
|
| 250 | }
|
| 251 | int atCcapp_RecvOk(char *at_str,struct at_context *context,void **next_req,int *next_len)
|
| 252 | {
|
| 253 | T_zCcapp_optRsp* optRsp = NULL;
|
| 254 |
|
| 255 | optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
|
| 256 | if(optRsp == NULL){softap_assert("");return AT_END;}
|
| 257 | memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
|
| 258 | optRsp->result = 0;
|
| 259 | *next_req = optRsp;
|
| 260 | *next_len = sizeof(T_zCcapp_optRsp);
|
| 261 | at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive ok\n");
|
| 262 | return AT_END;
|
| 263 | }
|
| 264 |
|
| 265 | int atCcapp_RecvErr(char *at_str,struct at_context *context,void **next_req,int *next_len)
|
| 266 | {
|
| 267 | T_zCcapp_optRsp* optRsp = NULL;
|
| 268 |
|
| 269 | optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
|
| 270 | if(optRsp == NULL){softap_assert("");return AT_END;}
|
| 271 | memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
|
| 272 | optRsp->result = -1;
|
| 273 | *next_req = optRsp;
|
| 274 | *next_len = sizeof(T_zCcapp_optRsp);
|
| 275 | at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive err\n");
|
| 276 | return AT_END;
|
| 277 | }
|
| 278 |
|
| 279 | void ext_ccapp_regist(void)
|
| 280 | {
|
| 281 | /****************************************************************************************
|
| 282 | *×¢²áccAPPµÄops
|
| 283 | *****************************************************************************************/
|
| 284 | register_psclt_func(MSG_CMD_ATD_DIAL_REQ, MSG_CMD_ATD_DIAL_RSP, atCcapp_SendAtdReq);
|
| 285 | register_psclt_func(MSG_CMD_ATA_REQ, MSG_CMD_ATA_RSP, atCcapp_SendAtaReq);
|
| 286 | register_psclt_func(MSG_CMD_CHUP_REQ, MSG_CMD_CHUP_RSP, atCcapp_SendChupReq);
|
| 287 | register_psclt_func(MSG_CMD_VTS_REQ, MSG_CMD_VTS_RSP, atCcapp_SendVtsReq);
|
| 288 | register_psclt_func(MSG_CMD_ZIMSPLUS_REQ, MSG_CMD_ZIMSPLUS_RSP, atCcapp_SendImsplusReq);
|
| 289 | register_psclt_func(MSG_CMD_CHLD_REQ, MSG_CMD_CHLD_RSP, atCcapp_SendChldReq);
|
| 290 | register_psclt_func(MSG_CMD_CCFC_REQ, MSG_CMD_CCFC_RSP, atCcapp_SendCcfcReq);
|
| 291 | register_psclt_func(MSG_CMD_CLCK_REQ, MSG_CMD_CLCK_RSP, atCcapp_SendClckReq);
|
| 292 |
|
| 293 | /**********************×¢²áat_ctlÄÚ²¿µÄÇëÇóÀàµÄops********************************/
|
| 294 | register_clt_func("ATD", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 295 | register_clt_func("ATA", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 296 | register_clt_func("CHUP", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 297 | register_clt_func("VTS=", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 298 | register_clt_func("ZIMSPLUS=", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 299 | register_clt_func("CHLD=", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 300 | register_clt_func("CCFC=", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 301 | //register_clt_func("CLCK=", atCcapp_RecvOk, atCcapp_RecvErr);
|
| 302 |
|
| 303 |
|
| 304 | /**********************×¢²áPSÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨µÄ»Øµ÷**************************/
|
| 305 | /*ÒÔÏÂÊÇÇëÇóÃüÁîµÄÖмä½á¹û*/
|
| 306 | register_inform_func("DSCI",atCcapp_RecvDsciInd);
|
| 307 | register_inform_func("ZCPI",atCcapp_RecvZcpiInd);
|
| 308 | register_inform_func("ZIMSPLUS",atCcapp_RecvImsplusInd);
|
| 309 | register_inform_func("ZVOICECHNL",atCcapp_RecvZvoicechnlInd);
|
| 310 | }
|
| 311 |
|
| 312 | #endif
|