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