blob: f0a6b1627fdc367ce002a3cbd3ec74116d1d73fd [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*********************************************************************************
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
27char* 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}
40char* 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}
51char* 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}
62char* 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}
75char* 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
93return pAtcmdStr;
94}
95char* 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}
112char* 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}
128char* 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}
141VOID 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}
173int 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
196int 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
216int 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
xf.libdd93d52023-05-12 07:10:14 -0700229#ifdef USE_CAP_SUPPORT
230 if(imsplusInd->act == 0) {//ÒôƵÉ豸¹Ø±Õ
231 }
232 else if(imsplusInd->act == 1) {//ÒôƵÉ豸¿ªÆô
233 }
234 else if(imsplusInd->act == 2) {//֪ͨ¿ªÊ¼²¥·Å±¾µØÕñÁåÒô
235 }
236 else if(imsplusInd->act == 3) {//ֹ֪ͨͣ²¥·Å±¾µØÕñÁåÒô
237 T_zCcapp_ImsplusReq imsplusReq;
238
239 imsplusReq.setfg = 0;
240 imsplusReq.act = imsplusInd->rate;
241 ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_AT_CTL, MSG_CMD_ZIMSPLUS_REQ, sizeof(T_zCcapp_ImsplusReq), (unsigned char *)&imsplusReq,0);
242 }
243
244 if(imsplusInd->rate == 8000) {
245 }
246 else if(imsplusInd->rate == 16000) {
247 }
248#else
lh9ed821d2023-04-07 01:36:19 -0700249 ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZIMSPLUS_IND, sizeof(T_zCcApp_ImsplusInd), (unsigned char *)imsplusInd,0);
250 at_print(AT_DEBUG,"[CCAPP]send IMSPLUS %d\n ",MSG_CMD_ZIMSPLUS_IND );
251 free(imsplusInd);
xf.libdd93d52023-05-12 07:10:14 -0700252#endif
253
lh9ed821d2023-04-07 01:36:19 -0700254 return AT_CONTINUE;
255}
256
257int atCcapp_RecvZcpiInd(char *at_paras ,int is_query_report)
258{
259 T_zCcApp_ZcpiInd *zcpiInd = NULL;
260
261 zcpiInd = malloc(sizeof(T_zCcApp_ZcpiInd));
262 if(zcpiInd==NULL){softap_assert("");return AT_END;}
263 memset(zcpiInd, 0, sizeof(T_zCcApp_ZcpiInd));
264
265 //zCc_PreProcRes(at_paras);
266 at_print(AT_DEBUG,"[CCAPP] zcpi ind! pResLine->resParas:%s.\n", at_paras);
267 sscanf(at_paras, "%u, %u, %u",&zcpiInd->cid,&zcpiInd->state,&zcpiInd->progdsp);
268
269 ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_CALL_CTRL, MSG_CMD_ZCPI, sizeof(T_zCcApp_ZcpiInd), (unsigned char *)zcpiInd,0);
270 free(zcpiInd);
271 return AT_CONTINUE;
272}
273int atCcapp_RecvOk(char *at_str,struct at_context *context,void **next_req,int *next_len)
274{
275 T_zCcapp_optRsp* optRsp = NULL;
276
277 optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
278 if(optRsp == NULL){softap_assert("");return AT_END;}
279 memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
280 optRsp->result = 0;
281 *next_req = optRsp;
282 *next_len = sizeof(T_zCcapp_optRsp);
283 at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive ok\n");
284 return AT_END;
285}
286
287int atCcapp_RecvErr(char *at_str,struct at_context *context,void **next_req,int *next_len)
288{
289 T_zCcapp_optRsp* optRsp = NULL;
290
291 optRsp = (T_zCcapp_optRsp *)malloc(sizeof(T_zCcapp_optRsp));
292 if(optRsp == NULL){softap_assert("");return AT_END;}
293 memset(optRsp, 0 , sizeof(T_zCcapp_optRsp));
294 optRsp->result = -1;
295 *next_req = optRsp;
296 *next_len = sizeof(T_zCcapp_optRsp);
297 at_print(AT_DEBUG,"CCAPP atCcapp_RecvOk receive err\n");
298 return AT_END;
299}
300
301void ext_ccapp_regist(void)
302{
303 /****************************************************************************************
304 *×¢²áccAPPµÄops
305 *****************************************************************************************/
306 register_psclt_func(MSG_CMD_ATD_DIAL_REQ, MSG_CMD_ATD_DIAL_RSP, atCcapp_SendAtdReq);
307 register_psclt_func(MSG_CMD_ATA_REQ, MSG_CMD_ATA_RSP, atCcapp_SendAtaReq);
308 register_psclt_func(MSG_CMD_CHUP_REQ, MSG_CMD_CHUP_RSP, atCcapp_SendChupReq);
309 register_psclt_func(MSG_CMD_VTS_REQ, MSG_CMD_VTS_RSP, atCcapp_SendVtsReq);
310 register_psclt_func(MSG_CMD_ZIMSPLUS_REQ, MSG_CMD_ZIMSPLUS_RSP, atCcapp_SendImsplusReq);
311 register_psclt_func(MSG_CMD_CHLD_REQ, MSG_CMD_CHLD_RSP, atCcapp_SendChldReq);
312 register_psclt_func(MSG_CMD_CCFC_REQ, MSG_CMD_CCFC_RSP, atCcapp_SendCcfcReq);
313 register_psclt_func(MSG_CMD_CLCK_REQ, MSG_CMD_CLCK_RSP, atCcapp_SendClckReq);
314
315 /**********************×¢²áat_ctlÄÚ²¿µÄÇëÇóÀàµÄops********************************/
316 register_clt_func("ATD", atCcapp_RecvOk, atCcapp_RecvErr);
317 register_clt_func("ATA", atCcapp_RecvOk, atCcapp_RecvErr);
318 register_clt_func("CHUP", atCcapp_RecvOk, atCcapp_RecvErr);
319 register_clt_func("VTS=", atCcapp_RecvOk, atCcapp_RecvErr);
320 register_clt_func("ZIMSPLUS=", atCcapp_RecvOk, atCcapp_RecvErr);
321 register_clt_func("CHLD=", atCcapp_RecvOk, atCcapp_RecvErr);
322 register_clt_func("CCFC=", atCcapp_RecvOk, atCcapp_RecvErr);
323 //register_clt_func("CLCK=", atCcapp_RecvOk, atCcapp_RecvErr);
324
325
326 /**********************×¢²áPSÏà¹ØµÄÖ÷¶¯Éϱ¨ºÍ²éѯÖмä½á¹ûÉϱ¨µÄ»Øµ÷**************************/
327 /*ÒÔÏÂÊÇÇëÇóÃüÁîµÄÖмä½á¹û*/
328 register_inform_func("DSCI",atCcapp_RecvDsciInd);
329 register_inform_func("ZCPI",atCcapp_RecvZcpiInd);
330 register_inform_func("ZIMSPLUS",atCcapp_RecvImsplusInd);
331 register_inform_func("ZVOICECHNL",atCcapp_RecvZvoicechnlInd);
332}
333
334#endif