blob: 088312e5757789032429833be997a6b0558da092 [file] [log] [blame]
mj.qu1524fc92025-06-11 04:34:13 -07001/**************************************************************************
2*
3* Copyright (c) 2013 ZTE Corporation.
4*
5***************************************************************************
6* Ä£ ¿é Ãû : CcApp
7* ÎÄ ¼þ Ãû : at_proc.c
8* Ïà¹ØÎļþ :
9* ʵÏÖ¹¦ÄÜ : ATÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
10* ×÷ Õß : syx
11* °æ ±¾ : V1.0
12* Íê³ÉÈÕÆÚ : 2013-01-05
13* ÆäËü˵Ã÷ :
14**************************************************************************/
15
16/**************************************************************************
17* Ð޸ļǼ :
18***************************************************************************/
19/**************************************************************************
20* Ð޸ıàºÅ : 0001
21* ÐÞ ¸Ä ÈË :
22* ÐÞ¸ÄÈÕÆÚ :
23* ÐÞ¸ÄÄÚÈÝ :
24**************************************************************************/
25
26/**************************************************************************
27* #includeÇø
28**************************************************************************/
29#include "cc_main.h"
30#include "cc_proc.h"
31#include "cc_com.h"
32#include "cc_at.h"
33#include "cc_timer.h"
34#include "string.h"
35#ifdef TEST_CCAPP
36#include "soft_timer.h"
37#endif
38
39#include "slic_inf.h"
40#include <stdint.h>
41#include <linux/volte_drv.h>
42#include "voice_lib.h"
43
44#define LOCAL_TEST_CALL_CODE "*#66*#"
45#define TZ_TEST_TIMING "*#83781234*#"
46typedef enum{
47 LocalTestCallST_None = 0,
48 LocalTestCallST_Start,
49 LocalTestCallST_Ring,
50 LocalTestCallST_End
51}eLocalTestCallST;
52int local_test_call_st = 0;
53typedef enum{
54 LocalTestCallType_None = 0,
55 LocalTestCallType_LOOP
56}eLocalTestCallType;
57int local_test_call_type = 0;
58
59extern SINT32 g_zCc_AtRspId;
60
61int zCc_find_held_cid(void);
62int zCc_find_held_incoming_cid(void);
63int zCc_find_all_callout(int slave[ZCC_SLAVES]);
64int zCc_talking_count(void);
65char *get_local_date_time(void);
66char *get_local_datetime(char *buff);
mj.qu58875012025-06-19 02:45:53 -070067int g_chup_flag = 0;
mj.qu1524fc92025-06-11 04:34:13 -070068
69
70/**************************************************************************
71* ³£Á¿¶¨ÒåÇø
72**************************************************************************/
73
74/* {
75 ZCC_S_IDLE_S = 0,
76 ZCC_S_DT_S ,
77 ZCC_S_DACCM_S ,
78 ZCC_S_DIALING_S ,
79 ZCC_S_RINGBACK_S ,// Ö÷½Ð¹ý³ÌÖеÄÕñÁå̬
80 ZCC_S_BSYT_S ,
81 ZCC_S_TKYT_S ,
82 ZCC_S_SIL_S ,
83 ZCC_S_TALKING_S ,
84 ZCC_S_TRYING_S ,
85 ZCC_S_WAIT_RESOURCE_S ,
86} */
87const pCcSlaveFsmFunc zCcSlaveFsmFunc[] = {zCc_SIdleState,
88 zCc_SDtState,
89 zCc_SDaccmState,
90 zCc_SDialingState,
91 zCc_SRingbackState,
92 zCc_SBsyToneState,
93 zCc_STkytState,
94 zCc_SSilState,
95 zCc_STalkingState,
96 zCc_STryingState,
97 zCc_SWaitResourceState
98 };
99 /*
100 CB
101 *54*KSSSS# REGISTER AT+CLCK="AO",1,"SSSS"
102 #54*KSSSS# DeREGISTER AT+CLCK="AO",0,"SSSS"
103 *#54# QUERY/CHECK AT+CLCK="AO",2,"SSSS" not supported---------------------------
104 K=1 "AO"; K=2 or K=3 "OI"(ÒÆ¶¯ÍøÃ»ÓйúÄÚ³¤Í¾ÏÞÖÆÒµÎñ); SSSS password
105 *56# REGISTER AT+CLCK="AI",1,"SSSS" ÐèÒªÖÕ¶Ë·½°¸»ò¸Ä²Ù×÷·½Ê½---------------------------
106 #56# DeREGISTER AT+CLCK="AI",0,"SSSS" ---------------------------
107 CFU
108 *57*DN# REGISTER AT+CCFC=0,1,"DN"
109 #57# DeREGISTER AT+CCFC=0,0
110 *#57*DN# AT+CCFC=0,2 not supported---------------------------
111 CFNRy
112 *41*DN# REGISTER AT+CCFC=2,1,"DN"
113 #41# DeREGISTER AT+CCFC=2,0
114 *#41*DN# AT+CCFC=2,2 not supported---------------------------
115 CFB
116 *40*DN# REGISTER AT+CCFC=1,1,"DN"
117 #40# DeREGISTER AT+CCFC=1,0
118 *#40*DN# AT+CCFC=1,2 not supported---------------------------
119 CW ( ÖÕ¶Ë·½°¸´ý¼Ó )
120 *58# REGISTER AT+CCWA=0,1 ---------------------------
121 #58# DeREGISTER AT+CCWA=0,0 ---------------------------
122 */
123static const T_zCc_ScTab g_zCc_SCTab[] =
124{
125 {ZCC_BAOC_REG, 10, 10, "*54*1"},
126 {ZCC_BAOC_DEREG, 10, 10, "#54*1"},
127 {ZCC_BOIC_REG, 10, 10, "*54*2"},
128 {ZCC_BOIC_DEREG, 10, 10, "#54*2"},
129 {ZCC_BOIC_REG, 10, 10, "*54*3"},
130 {ZCC_BOIC_DEREG, 10, 10, "#54*3"},
131 {ZCC_CFU_REG, 6, SC_MAXLEN, "*57*"},
132 {ZCC_CFU_DEREG, 4, 4, "#57#"},
133 {ZCC_CFNRY_REG, 6, SC_MAXLEN, "*41*"},
134 {ZCC_CFNRY_DEREG, 4, 4, "#41#"},
135 {ZCC_CFB_REG, 6, SC_MAXLEN, "*40*"},
136 {ZCC_CFB_DEREG, 4, 4, "#40#"},
137};
138
139
140
141T_CC_APP_RecvAtIndItem gCcAppRecvAtIndProc[]=
142{
143 {MSG_CMD_DSCI_IND, zCc_RecvDsciInd},
144 {MSG_CMD_ZCPI,zCc_RecvZcpiInd},
145 {MSG_CMD_ZIMSPLUS_IND,zCc_RecvImsplusInd},
146 {MSG_CMD_ZVOICECHNL,zCc_RecvZvoiceChnl},
147 {MSG_CMD_ATD_DIAL_RSP,zCc_RecvRsp},
148 {MSG_CMD_ATA_RSP,zCc_RecvRsp},
149 {MSG_CMD_CHUP_RSP,zCc_RecvRsp},
150 {MSG_CMD_VTS_RSP,zCc_RecvRsp},
151 {MSG_CMD_ZIMSPLUS_RSP,zCc_RecvRsp},
152 {MSG_CMD_CLCK_RSP,zCc_RecvRsp},
153 {MSG_CMD_CCFC_RSP,zCc_RecvRsp},
154 {MSG_CMD_CHLD_RSP,zCc_RecvRsp}
155};
156 T_CC_APP_AtIndProcItem gCcAppAtIndProc[]=
157{
158 {MSG_CMD_DSCI_IND, zCc_DsciIndProc},
159 {MSG_CMD_ZCPI,zCc_ZcpiIndProc},
160 {MSG_CMD_ZIMSPLUS_IND,zCc_ZimsplusProc},
161 {MSG_CMD_ZVOICECHNL,zCc_ZvoicechnlProc}
162};
163
164
165SINT32 gCcAppRecvAtIndProcCnt = sizeof(gCcAppRecvAtIndProc)/sizeof(gCcAppRecvAtIndProc[0]);
166SINT32 gCcAppRecvAtIndCnt = sizeof(gCcAppAtIndProc)/sizeof(gCcAppAtIndProc[0]);
167char g_zCcApp_AtRecvBuf[ZCC_APP_AT_BUF_MAX_LEN+1] = {0};
168T_zCc_CurAtCmdInfo * g_Cc_AtIndRspMsg;
169
mj.qu58875012025-06-19 02:45:53 -0700170static int check_phone_number_in_file(const char* phoneNumber, const char* filename)
171{
172 FILE* file = fopen(filename, "r");
173 if (file == NULL) {
174 return 0;
175 }
176
177 char buffer[20];
178 while (fgets(buffer, sizeof(buffer), file) != NULL) {
179
180 char* newline = strchr(buffer, '\n');
181 if (newline) {
182 *newline = '\0';
183 }
184
185 if (strcmp(buffer, phoneNumber) == 0) {
186 fclose(file);
187 return 1;
188 }
189 }
190
191 fclose(file);
192 return 0;
193}
194
mj.qu1524fc92025-06-11 04:34:13 -0700195VOID zCc_ShowAllSlave(VOID)
196{
197 UINT8 slave = 0;
198
199 for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
200 {
201 ccapp_log(" slave=%d number=%s cid=%d state=%d tone=%d msg=%d held=%d isOut=%d dsci6=%d",
202 slave,
203 g_Cc_CallDetail.slaveObj[slave].number,
204 g_Cc_CallDetail.slaveObj[slave].cid,
205 g_Cc_CallDetail.slaveObj[slave].state,
206 g_Cc_CallDetail.slaveObj[slave].tone,
207 g_Cc_CallDetail.slaveObj[slave].sMsg,
208 g_Cc_CallDetail.slaveObj[slave].heldcall,
209 g_Cc_CallDetail.slaveObj[slave].is_callout,
210 g_Cc_CallDetail.slaveObj[slave].waitDSCI6);
211 }
212}
213
214VOID zCc_ShowAllSlaveWithTips(const char *tips)
215{
216
217 UINT8 slave = 0;
218
219 for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
220 {
221 printf/*ccapp_log*/("%s master_state=%d\n slave=%d number=%s cid=%d state=%d tone=%d msg=%d held=%d isOut=%d dsci6=%d",
222 tips, g_Cc_CallDetail.state,
223 slave,
224 g_Cc_CallDetail.slaveObj[slave].number,
225 g_Cc_CallDetail.slaveObj[slave].cid,
226 g_Cc_CallDetail.slaveObj[slave].state,
227 g_Cc_CallDetail.slaveObj[slave].tone,
228 g_Cc_CallDetail.slaveObj[slave].sMsg,
229 g_Cc_CallDetail.slaveObj[slave].heldcall,
230 g_Cc_CallDetail.slaveObj[slave].is_callout,
231 g_Cc_CallDetail.slaveObj[slave].waitDSCI6);
232 }
233}
234
235
236VOID zCc_CheckSlaveState(const char *tips)
237{
238 UINT8 slave = 0;
239
240 if(g_Cc_CallDetail.old_state != g_Cc_CallDetail.state)
241 {
242 ccapp_log("=========== %s =============\n master state %d --> %d",
243 tips,
244 g_Cc_CallDetail.old_state,
245 g_Cc_CallDetail.state);
246 g_Cc_CallDetail.old_state = g_Cc_CallDetail.state;
247 }
248
249 for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
250 {
251 if(g_Cc_CallDetail.slaveObj[slave].old_state != g_Cc_CallDetail.slaveObj[slave].state)
252 {
253 ccapp_log("=========== %s =============\n slave=%d state %d --> %d",
254 tips,
255 slave,
256 g_Cc_CallDetail.slaveObj[slave].old_state,
257 g_Cc_CallDetail.slaveObj[slave].state);
258
259 g_Cc_CallDetail.slaveObj[slave].old_state = g_Cc_CallDetail.slaveObj[slave].state;
260 }
261 }
262}
263
264
265VOID zCc_ClearDigits(VOID)
266{
267 g_Cc_CallDetail.dCount = 0;
268 memset(g_Cc_CallDetail.digits, 0, sizeof(g_Cc_CallDetail.digits));
269 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ClearDigits: digits cleared\n",__FUNCTION__);
270}
271
272VOID zCc_InitSlaveObj(UINT8 slave)
273{
274 memset(&g_Cc_CallDetail.slaveObj[slave], 0, sizeof(T_zCc_SlaveObj));
275 if (slave == g_Cc_CallDetail.ringCid)
276 {
277 g_Cc_CallDetail.ringCid = 0;
278 }
279}
280
281UINT8 zCc_TalkingCall(UINT8 heldcall)
282{
283 UINT8 slave = 0, cnt = 0;
284
285 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
286 {
287 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TALKING_S
288 && g_Cc_CallDetail.slaveObj[slave].heldcall == heldcall
289 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
290 {
291 cnt++;
292 }
293 }
294
295 return cnt;
296}
297
298UINT8 zCc_GetWaitDisc6Slave(VOID)
299{
300 UINT8 slave = 0, cnt = 0;
301
302 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
303 {
304 if (g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 1)
305 {
306 cnt++;
307 }
308 }
309 return cnt;
310}
311
312UINT8 zCc_BusyToneAllowed(VOID)
313{
314 UINT8 slave = 0, cnt = 0;
315
316 for (slave = 0; slave < ZCC_SLAVES; slave++)
317 {
318 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S )
319 {
320 cnt++;
321 }
322 }
323 if ((1 == cnt)//µ±Ç°Ã»ÓÐÆäËûºô½Ð
324 ||(cnt == 2 && g_Cc_CallDetail.ringCid !=0
325 && g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].state == ZCC_S_TRYING_S
326 && g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone != ZCC_TONE_CIDCW_A)//Õª»ú̬»¹ÓÐÀ´µçÇÒδ·ÅÒô
327 ||(cnt == zCc_GetWaitDisc6Slave()+1))//ÆäËûºô½Ð¶¼ÊÇÔÚµÈdsci6µÄ
328 {
329 return 1;
330 }
331 else
332 {
333 return 0;
334 }
335
336}
337
338UINT8 zCc_ActiveCall(VOID)
339{
340 return zCc_TalkingCall(0);
341}
342
343UINT8 zCc_HeldCall(VOID)
344{
345 return zCc_TalkingCall(1);
346}
347
348UINT8 zCc_GetSpecSlave(UINT8 state)
349{
350 UINT8 slave = 0;
351
352 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
353 {
354 if (g_Cc_CallDetail.slaveObj[slave].state == state && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
355 {
356 return slave;
357 }
358 }
359 return 0;
360}
361
362UINT8 zCc_GetSpecSlaveIgnoreWaitDSCI6(UINT8 state)
363{
364 UINT8 slave = 0;
365
366 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
367 {
368 if (g_Cc_CallDetail.slaveObj[slave].state == state)
369 {
370 return slave;
371 }
372 }
373 return 0;
374}
375
376UINT8 zCc_Find_waitDSCI6_cid(void)
377{
378 UINT8 slave = 0;
379
380 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
381 {
382 if (g_Cc_CallDetail.slaveObj[slave].state!=ZCC_S_IDLE_S &&
383 g_Cc_CallDetail.slaveObj[slave].waitDSCI6!=0)
384 {
385 return slave;
386 }
387 }
388 return 0;
389}
390
391
392
393
394UINT8 zCc_GetDialingSlave(UINT8 waitDSCI6)
395{
396 UINT8 slave = 0;
397
398 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
399 {
400 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DIALING_S )
401 {
402 if (waitDSCI6)
403 {
404 if (g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
405 {
406 return slave;
407 }
408 }
409 else
410 {
411 return slave;
412 }
413 }
414 }
415 return 0;
416}
417
418UINT8 zCc_GetDiscSlave(UINT8 state)
419{
420 UINT8 slave = 0;
421 UINT8 cnt = 0;
422
423 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
424 {
425 if (g_Cc_CallDetail.slaveObj[slave].sMsg== ZCC_SDISCN_M && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
426 {
427 cnt++;
428 }
429 }
430 return cnt;
431}
432
433
434int tz_lock_cellid_is_limit_callin()
435{
436 char cellid_is_lock[4] = {0};
437
438 cfg_get_item("cellid_is_lock",cellid_is_lock,sizeof(cellid_is_lock));
439 if(strcmp(cellid_is_lock, "1") == 0)
440 return 1;
441
442 return 0;
443}
444
445int tz_lock_cellid_check_sos_num()
446{
447 int ret = 0;
448 char tz_Mexico_sos_lock_cellid[128] = {0};
449
450 ret = strlen(g_Cc_CallDetail.digits);
451 cfg_get_item("tz_Mexico_sos_lock_cellid",tz_Mexico_sos_lock_cellid,sizeof(tz_Mexico_sos_lock_cellid));
452 if(ret > 0 && ((g_Cc_CallDetail.digits[ret-1] == '#') || (g_Cc_CallDetail.digits[ret-1] == 'T')))
453 {
454 return TRUE;
455 }
456 else if(strstr(tz_Mexico_sos_lock_cellid, g_Cc_CallDetail.digits) != NULL)
457 {
458 return TRUE;
459 }
460 else
461 {
462 return FALSE;
463 }
464
465}
466
467extern int digit_map_call(char *num);
468/* µ±Ç°Ò»Â· ·Ç ±£³ÖµÄ ºô½Ð£¬FLASH£¬µ±Ç°ºô½Ð±»±£³Ö»òÊÍ·Å£¬digitsÖ»¼Ç¼Óû§²¦´òµÄºÅÂ룻
469 µ±Ç°Ò»Â· ·Ç ±£³ÖµÄ ºô½Ð£¬FLASH£¬µ±Ç°ºô½Ð±»»Ö¸´£»
470 ÆäËü³¡¾°ÐèÒªdigits ¼Ç¼ZCC_FLASH_SIGNºÍÓû§ ²¦´òµÄһλºÅÂë */
471UINT8 zCc_DigitsMatch(VOID)
472{
473 UINT16 i = 0;
474 UINT8 scSum = sizeof(g_zCc_SCTab)/sizeof(T_zCc_ScTab);
475
476 ccapp_log("zCc_DigitsMatch: digits=%s dCount=%d\n",g_Cc_CallDetail.digits,g_Cc_CallDetail.dCount);
477 if(tz_lock_cellid_is_limit_callin())
478 {
479 if(tz_lock_cellid_check_sos_num() == FALSE)
480 return ZCC_MATCHERR;
481 }
482
483 if (g_Cc_CallDetail.dCount == 0)
484 {
485 //ccapp_log("1");
486 return ZCC_NO_RESULT;
487 }
488
489 if(g_Cc_CallDetail.dCount >= 2 && g_Cc_CallDetail.dCount<ZDIAL_NUM_MAX)
490 {
491 if(g_Cc_CallDetail.digits[0]!=ZCC_FLASH_SIGN &&
492 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1]!=ZCC_TIMEOUT_SIGN)
493 {
494 printf("g_Cc_CallDetail.digits = %s\n",g_Cc_CallDetail.digits);
495 if(strcmp(LOCAL_TEST_CALL_CODE, g_Cc_CallDetail.digits)==0)
496 {
497 //ccapp_log("2");
498 local_test_call_type = LocalTestCallType_None;
499 return ZCC_LOCAL_TEST_CALL;
500 }
501 else if(strcmp(TZ_TEST_TIMING, g_Cc_CallDetail.digits)==0)
502 {
503 local_test_call_type = LocalTestCallType_LOOP;
504 return ZCC_LOCAL_TEST_CALL;
505 }
506 }
507
508 if(g_Cc_CallDetail.digits[0]=='*' && g_Cc_CallDetail.digits[1]=='#')
509 {
510 //ccapp_log("3");
511 return ZCC_NO_RESULT;
512 }
513 }
514
515 if(g_Cc_CallDetail.dCount>=ZDIAL_NUM_MAX)
516 {
517 //ccapp_log("4");
518 return ZCC_MATCHERR;
519 }
520
521 if(digit_map_call(g_Cc_CallDetail.digits)!=0)
522 {
523 ccapp_log("digit_map_call match %s", g_Cc_CallDetail.digits);
524 return ZCC_CALL;
525 }
526
527 if (g_Cc_CallDetail.digits[0] >= '0' && g_Cc_CallDetail.digits[0] <= '9')
528 {
529 //ccapp_log("5");
530 return (g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#'
531 || g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == ZCC_TIMEOUT_SIGN
532 || g_Cc_CallDetail.dCount == ZDIAL_NUM_MAX) ? ZCC_CALL : ZCC_NO_RESULT;
533 }
534
535 //ccapp_log("6");
536 if (g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN) //ÖÁÉÙÓÐ2·ºô½ÐÁË
537 {
538 switch (g_Cc_CallDetail.digits[1])
539 {
540 case '0':
541 return ZCC_FLASH_0;
542 case '1':
543 return ZCC_FLASH_1;
544 case '2':
545 case ZCC_TIMEOUT_SIGN:
546 return ZCC_FLASH_2;
547 case '3':
548 return ZCC_FLASH_3;
549 case '4':
550 return ZCC_FLASH_4;
551 default:
552 return ZCC_MATCHERR;
553 }
554 }
555
556 /*for (i = 0; i<scSum; i++)
557 {
558 if (strncmp((CHAR *)g_zCc_SCTab[i].sc, (CHAR *)g_Cc_CallDetail.digits,
559 (UINT32)(strlen(g_zCc_SCTab[i].sc)<g_Cc_CallDetail.dCount)?strlen(g_zCc_SCTab[i].sc):g_Cc_CallDetail.dCount) == 0)
560 {
561 if (g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#')
562 {
563 return g_zCc_SCTab[i].scName;
564 }
565 if (g_Cc_CallDetail.dCount < g_zCc_SCTab[i].scMaxLen)
566 {
567 return ZCC_NO_RESULT;
568 }
569 if (g_Cc_CallDetail.dCount == g_zCc_SCTab[i].scMaxLen)
570 {
571 return ZCC_MATCHERR;
572 }
573 }
574 }*/
575
576 if(g_Cc_CallDetail.dCount>=2 &&
577 g_Cc_CallDetail.dCount<ZDIAL_NUM_MAX &&
578 g_Cc_CallDetail.digits[0]=='*')
579 {
580 if(g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#'
581 || g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == ZCC_TIMEOUT_SIGN)
582 {
583 ccapp_log("match special code: %s", g_Cc_CallDetail.digits);
584 return ZCC_CALL;
585 }
586 else
587 {
588 //ccapp_log("8");
589 return ZCC_NO_RESULT;
590 }
591 }
592
593 //ccapp_log("9");
594 return ZCC_MATCHERR;
595}
596
597VOID zCc_DigitsMatchRltProc(UINT8 ret)
598{
599 UINT8 callCnt = 0, slave = 0;
600 SINT32 chldret = -1;
mj.qu8ddc7642025-06-11 04:37:19 -0700601 char voice_dial_time[4] = {0};
602 unsigned int dtmf_interval;
mj.qu1524fc92025-06-11 04:34:13 -0700603
mj.qu8ddc7642025-06-11 04:37:19 -0700604 cfg_get_item("voice_dial_time", voice_dial_time, sizeof(voice_dial_time));
605 dtmf_interval = atoi(voice_dial_time) * 1000;
mj.qu1524fc92025-06-11 04:34:13 -0700606 ccapp_log("ret=%d", ret);
607
608 slave = zCc_GetSpecSlave(ZCC_S_DACCM_S);
609 switch (ret)
610 {
611 case ZCC_NO_RESULT:
612 CreateSoftTimer(ZCCAPP_TIMER_DTMF_DETECT,
613 0,
mj.qu8ddc7642025-06-11 04:37:19 -0700614 dtmf_interval,
mj.qu1524fc92025-06-11 04:34:13 -0700615 zCcApp_DtmfTimer,
616 NULL);
617 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc CreateSoftTimer zCcApp_DtmfTimer\n",__FUNCTION__);
618 return;
619
620 case ZCC_CALL:
621 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SINV_M;
622 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DIALING_S;
623 if(g_Cc_CallDetail.digits[0]!='*' && (digit_map_call(g_Cc_CallDetail.digits)==0))
624 {
625 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] = 0;
626 g_Cc_CallDetail.dCount--;
627 }
628 strcpy(g_Cc_CallDetail.slaveObj[slave].number, g_Cc_CallDetail.digits);
629 g_Cc_CallDetail.slaveObj[slave].is_callout = TRUE;
630 return;
631
632 case ZCC_FLASH_1:
633 callCnt = zCc_CallCount();
634 if ((1 < callCnt) && (zCc_ActiveCall() == callCnt) ) // ¼Ç¼±¾´Î²Ù×÷ΪÕë¶Ôconf µÄ
635 {
636 chldret = zCc_SendAtChldReq(21);
637 }
638 else //if (1 < callCnt)
639 {
640 slave = zCc_GetSpecSlave(ZCC_S_DIALING_S);
641 if(slave)
642 {
643 ccapp_log("zCc_SendAtChldReq(%d) dialing", 10+slave);
644 chldret = zCc_SendAtChldReq(10+slave);
645 SLIC_Stop_Signal(0,TONE_SIGNAL);
646 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
647 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
648 break;
649 }
650
651 slave = zCc_GetSpecSlave(ZCC_S_RINGBACK_S);
652 if(slave)
653 {
654 ccapp_log("zCc_SendAtChldReq(%d) ringback", 10+slave);
655 chldret = zCc_SendAtChldReq(10+slave);
656 SLIC_Stop_Signal(0,TONE_SIGNAL);
657 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
658 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
659 break;
660 }
661
662 ccapp_log("zCc_SendAtChldReq(1)-");
663 chldret = zCc_SendAtChldReq(1);
664 }
665 break;
666
667 case ZCC_FLASH_2:
668 chldret = zCc_SendAtChldReq(2);
669 break;
670
671 case ZCC_FLASH_3:
672 if(zCc_talking_count()==1 && zCc_GetSpecSlave(ZCC_S_TRYING_S))
673 {
674 // talking + incoming, skip hookflash+3, do nothing
675 }
676 else
677 chldret = zCc_SendAtChldReq(3);
678 break;
679
680 case ZCC_FLASH_4:
681 if( zCc_CallCount()> 1)
682 {
683 //system("at_cmd AT+ZTOR=2");
684 //zCcApp_send_message(MSG_CMD_ACTIVE_CALL_TRANSFER, 0, NULL);
685 //ccapp_log("send MSG_CMD_ACTIVE_CALL_TRANSFER");
686 chldret = zCc_SendAtChldReq(4); //AT+CHLD=4
687 }
688 else
689 ccapp_log("skip at_cmd AT+ZTOR=2");
690 break;
691
692 case ZCC_FLASH_0://¾Ü½ÓÀ´µç£¬Í£Ö¹·ÅÒô£¬»Ö¸´ÓïÒô
693 SLIC_Stop_Signal(0,0);
694 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
695 zCc_InitSlaveObj(0);
696 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
697 SLIC_Start_PCM();
698 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc: SLIC_Start_PCM <---\n",__FUNCTION__);
699 chldret = zCc_SendAtChldReq(0);
700 break;
701
702 case ZCC_MATCHERR:
703 if (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN)
704 {
705 zCc_ClearDigits();
706 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
707 {
708 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
709 0,
710 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
711 zCcApp_BusyToneTimer,
712 NULL);
713 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
714 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
715 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
716 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
717 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
718 }
719 else
720 {
721 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
722 zCc_InitSlaveObj(slave);
723 }
724 return;
725 }
726 break;
727
728 default:
729 if (ret >= ZCC_BAOC_REG && ret <= ZCC_CFB_DEREG)// SS slave=1
730 {
731 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SINV_M;
732 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_IDLE_S;//±ÜÃâºóÃæ¹Ò»ú»á·¢Æðchup
733 }
734 return;
735 }
736
737 zCc_ClearDigits();
738 //zCc_InitSlaveObj(slave);
739}
740#if 0
741VOID zCc_PreProcRes(CHAR *pParaLine)
742{
743 SINT32 flg = 0;
744 UINT32 i = 0;
745 UINT32 length = 0;
746 CHAR *pSource = pParaLine;
747 CHAR *pDest = NULL;
748
749 CHAR *pStrDestMalloc = (CHAR *)malloc(AT_CMD_MAX);
750 if (NULL == pStrDestMalloc)
751 {
752 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_PreProcRes: Malloc failed !!!\n",__FUNCTION__);
753 return;
754 }
755 memset(pStrDestMalloc, 0, AT_CMD_MAX);
756
757 assert(pParaLine != NULL);
758 pDest = pStrDestMalloc;
759 length = strlen(pParaLine);
760 if (length == 0 || length >= ZAT_MAX_LEN)
761 {
762 free(pStrDestMalloc);
763 return;
764 }
765 for (i = 0; (i < length )&& (pDest - pStrDestMalloc < AT_CMD_MAX); i++)
766 {
767 if ('"' == *pSource)
768 {
769 flg = (0 == flg)?1:0; /* Ë«ÒýºÅ ɾ³ý */
770 if ('"' == *(pSource + 1)) /* ÐǺźóÃæ½ô¸úÐǺţ¬²åÈë¿Õ´®Õ¼Î»·û */
771 {
772 *pDest++ = (CHAR)ZAT_NULL_FILL;
773 }
774 }
775 else if ((',' == *pSource) && (0 == flg))
776 {
777 *pDest++ = ' '; /* Ë«ÒýºÅÍâÃæµÄ¶ººÅ£¬Ìæ»»³É¿Õ¸ñ */
778 if (',' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
779 {
780 *pDest++ = '9'; //±£Áô²ÎÊýÓÃ9ÔÝʱ´úÌæ
781 }
782 else if ('\0' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
783 {
784 *pDest++ = (CHAR)ZAT_NULL_FILL;
785 }
786 }
787 else if (('\r' == *pSource) ||('\n' == *pSource))
788 {
789 pSource++;
790 }
791 else
792 {
793 *pDest++ = ((' ' == *pSource) && (1 == flg))?(CHAR)ZAT_SPACE_REPLACE:((('\t' == *pSource) && (1 == flg))?(CHAR)ZAT_TAB_REPLACE:(*pSource));
794 }
795 pSource++;
796 }
797
798 memset(pParaLine, 0, length); /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */
799 strcpy(pParaLine, pStrDestMalloc);
800 free(pStrDestMalloc);
801}
802#endif
803UINT8 zCc_CallCount(VOID)
804{
805 UINT8 slave = 0, cnt = 0;
806
807 for (slave = 1; slave < ZCC_SLAVES; slave++)
808 {
809 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S
810 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
811 //&& !(g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 1
812 //&& g_Cc_CallDetail.slaveObj[slave].state ==ZCC_S_TRYING_S))
813 {
814 cnt++;
815 }
816 }
817
818 return cnt;
819}
820
821UINT8 zCc_FlashClearCall(VOID)
822{
823 UINT8 slave = 0, cnt = 0;
824
825 for (slave = 1; slave < ZCC_SLAVES; slave++)
826 {
827 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DACCM_S//Õª»úµ½atdÏ·¢Ç°
828 || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_BSYT_S
829 || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TKYT_S
830 || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_SIL_S//·ÅæÒô¡¢º¿ÃùÒô¡¢¾²Òô
831 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
832 {
833 zCc_InitSlaveObj(slave);
834 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
835 cnt++;
836 }
837 }
838
839 return cnt;
840}
841
842UINT8 zCc_MoInactiveCall(VOID)
843{
844 UINT8 slave = 0, cnt = 0;
845
846 for (slave = 0; slave < ZCC_SLAVES; slave++)
847 {
848 if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
849 && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_BSYT_S
850 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
851 {
852 cnt++;
853 }
854 }
855
856 return cnt;
857}
858UINT8 zCc_MoBeforDialingCall(VOID)
859{
860 UINT8 slave = 0, cnt = 0;
861
862 for (slave = 0; slave < ZCC_SLAVES; slave++)
863 {
864 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
865 {
866 ccapp_log("zCc_MoBeforDialingCall slave[%d]=%d",
867 slave,
868 g_Cc_CallDetail.slaveObj[slave].state);
869 }
870
871 if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
872 && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_DIALING_S
873 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
874 {
875 cnt++;
876 }
877 }
878
879 return cnt;
880}
881
882int zCc_GetMoBeforDialingCallCID(VOID)
883{
884 UINT8 slave = 0, cnt = 0;
885
886 for (slave = 0; slave < ZCC_SLAVES; slave++)
887 {
888 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
889 {
890 ccapp_log("zCc_GetMoBeforDialingCallCID slave[%d]=%d",
891 slave,
892 g_Cc_CallDetail.slaveObj[slave].state);
893 }
894
895 if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
896 && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_DIALING_S
897 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
898 {
899 return slave;
900 }
901 }
902
903 return -1;
904}
905
906
907int zCc_findCID_by_number(const char *number)
908{
909 UINT8 slave = 0, len = 0;
910 char slave_number[ZDIAL_NUM_MAX];
911
912 for (slave = 1; slave < ZCC_SLAVES; slave++)
913 {
914 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
915 {
916 ccapp_log("zCc_findCID_by_number[%s] slave[%d]=%d num=%s",
917 number,
918 slave,
919 g_Cc_CallDetail.slaveObj[slave].state,
920 g_Cc_CallDetail.slaveObj[slave].number);
921 }
922
923 strcpy(slave_number, g_Cc_CallDetail.slaveObj[slave].number);
924 len = strlen(slave_number);
925 if(len>0)
926 {
927 if(slave_number[len-1]=='T')
928 slave_number[len-1]='\0';
929 }
930
931 if (strcmp(slave_number, number)==0)
932 return slave;
933 }
934
935 return 0;
936}
937
938int check_incoming_call_is_in_slave(MSG_BUF *ptMsgBuf)
939{
940 T_zCcApp_DsciInd tDiscInd = {0};
941 memcpy(&tDiscInd, (T_zCcApp_DsciInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_DsciInd));
942
943 if(tDiscInd.cid==0)
944 return 0;
945
946 return zCc_findCID_by_number(tDiscInd.num);
947}
948
949
950UINT8 zCc_MtInactiveCall(VOID)
951{
952 UINT8 slave = 0, cnt = 0;
953
954 for (slave = 0; slave < ZCC_SLAVES; slave++)
955 {
956 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TRYING_S
957 || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_WAIT_RESOURCE_S)
958 //&& g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
959 {
960 cnt++;
961 }
962 }
963
964 return cnt;
965}
966UINT8 zCc_GetCallSlave(UINT8 heldcall)//°´×î¶àÁ½Â·ÊµÏÖ
967{
968 UINT8 slave = 0;
969
970 for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
971 {
972 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TALKING_S
973 && g_Cc_CallDetail.slaveObj[slave].heldcall == heldcall
974 && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
975 {
976 return slave;
977 }
978 }
979 return 0;
980}
981
982VOID zCc_ControlTone(VOID)
983{
984 T_zCc_Tone tone = ZCC_TONE_OFF_A; /* What tone to play */
985 SIGNAL_DATA tSig;
986 memset(tSig.cid, 0, 32);
987 UINT8 slave = 0;
988
989 for (slave = 0; slave < ZCC_SLAVES; slave++)
990 {
991 if (g_Cc_CallDetail.slaveObj[slave].tone != ZCC_TONE_OFF_A)
992 {
993 tone = g_Cc_CallDetail.slaveObj[slave].tone;
994 break;
995 }
996 }
997 printf("[ccapp_debug]:zCc_ControlTone,cur_tone=%d, last_tone=%d\n",tone,g_Cc_CallDetail.lastTone);
998 if (g_Cc_CallDetail.lastTone == tone || ZCC_TONE_OFF_A == tone)
999 {
1000 return;
1001 }
1002
1003 if(local_test_call_st != 0)
1004 {
1005 g_Cc_CallDetail.lastTone = tone;
1006 return ;
1007 }
1008
1009 switch (tone)
1010 {
1011 case ZCC_TONE_DIAL_A:
1012 if (g_Cc_CallDetail.lastTone == ZCC_TONE_CIDCW_A)//¶à²»¶àÓà
1013 {
1014 SLIC_Stop_PCM();
1015 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Stop_PCM <---\n",__FUNCTION__);
1016 }
1017 tSig.signal_type= TONE_SIGNAL;
1018 tSig.tone_type = TONE_DIAL;
1019 SLIC_Play_Signal(0, 0, &tSig);
1020 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_DIAL<---\n",__FUNCTION__);
1021 break;
1022 case ZCC_TONE_RB_A:
1023 tSig.signal_type= TONE_SIGNAL;
1024 tSig.tone_type = TONE_RINGBACK;
1025 SLIC_Play_Signal(0, 0, &tSig);
1026 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal ZCC_TONE_RB_A<---\n",__FUNCTION__);
1027 break;
1028 case ZCC_TONE_BSY_A:
1029 tSig.signal_type= TONE_SIGNAL;
1030 tSig.tone_type = TONE_BUSY;
1031 SLIC_Play_Signal(0, 0, &tSig);
1032 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_BUSY<---\n",__FUNCTION__);
1033 break;
1034 case ZCC_TONE_SIL_A:
1035 SLIC_Stop_Signal(0, TONE_SIGNAL);
1036 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Stop_Signal <---\n",__FUNCTION__);
1037 break;
1038 case ZCC_TONE_CIDCW_A:
1039 memset(&tSig, 0, sizeof(tSig));
1040 tSig.signal_type= TONE_SIGNAL;
1041 tSig.tone_type = TONE_CW;
1042 //memcpy(tSig.cid, g_Cc_CallDetail.number, strlen(g_Cc_CallDetail.number));
1043 strncpy(tSig.cid, g_Cc_CallDetail.number, sizeof(tSig.cid)-1);
1044 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone ZCC_TONE_CIDCW_A,number = %s\n",__FUNCTION__,g_Cc_CallDetail.number);
1045 zCc_sleep(100);
1046 SLIC_Play_Signal(0, 0, &tSig);
1047 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_CW<---\n",__FUNCTION__);
1048 break;
1049 case ZCC_TONE_TKY_A:
1050 tSig.signal_type= TONE_SIGNAL;
1051 tSig.tone_type = TONE_TKY;
1052 SLIC_Play_Signal(0, 0, &tSig);
1053 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_TKY<---\n",__FUNCTION__);
1054 break;
1055 }
1056 g_Cc_CallDetail.lastTone = tone;
1057
1058}
1059void zCcApp_SetAtChnlCmdId(E_CC_APP_AtReqCmdId AtCmdId)
1060{
1061 g_Cc_CallDetail.curAtCmdId = AtCmdId;
1062}
1063VOID zCc_SendSsReq(PSTR pAtCmdPara)
1064{
1065 CHAR pw[5] = {0};
1066 CHAR dn[ZDIAL_NUM_MAX] = {0};
1067 UINT8 scSum = sizeof(g_zCc_SCTab)/sizeof(T_zCc_ScTab);
1068 UINT8 scName = 0;
1069 UINT8 i = 0;
1070 T_zCcapp_ClckReq tclckreq = {0};
1071 T_zCcapp_CcfcReq tccfcreq = {0};
1072
1073 for (i = 0; i<scSum; i++)
1074 {
1075 if (strncmp((CHAR *)g_zCc_SCTab[i].sc, (CHAR *)g_Cc_CallDetail.digits,
1076 (UINT32)(strlen(g_zCc_SCTab[i].sc)<g_Cc_CallDetail.dCount)?strlen(g_zCc_SCTab[i].sc):g_Cc_CallDetail.dCount) == 0)
1077 {
1078 scName = g_zCc_SCTab[i].scName;
1079 break;
1080 }
1081 }
1082 switch(scName)
1083 {
1084 case ZCC_BAOC_REG:
1085 sscanf(pAtCmdPara, "%*5s%4s#", pw);
1086 pw[4] = '\0';
1087 tclckreq.type = 0;//AO
1088 tclckreq.act = 1;
1089 strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
1090 break;
1091 case ZCC_BAOC_DEREG:
1092 sscanf(pAtCmdPara, "%*5s%4s#", pw);
1093 pw[4] = '\0';
1094 tclckreq.type = 0;//AO
1095 tclckreq.act = 0;
1096 strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
1097 break;
1098 case ZCC_BOIC_REG:
1099 sscanf(pAtCmdPara, "%*5s%4s#", pw);
1100 pw[4] = '\0';
1101 tclckreq.type = 1;//OI
1102 tclckreq.act = 1;
1103 strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
1104 break;
1105 case ZCC_BOIC_DEREG:
1106 sscanf(pAtCmdPara, "%*5s%4s#", pw);
1107 pw[4] = '\0';
1108 tclckreq.type = 1;//OI
1109 tclckreq.act = 0;
1110 strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
1111 break;
1112 case ZCC_CFU_REG:
1113 sscanf(pAtCmdPara, "%*4s%47s#", dn);
1114 dn[strlen(dn)-1] = '\0';
1115 tccfcreq.type = 0;
1116 tccfcreq.act = 1;
1117 strncpy(tccfcreq.dn, dn, strlen(dn));
1118 break;
1119 case ZCC_CFU_DEREG:
1120 tccfcreq.type = 0;
1121 tccfcreq.act = 0;
1122 break;
1123 case ZCC_CFNRY_REG:
1124 sscanf(pAtCmdPara, "%*4s%47s#", dn);
1125 dn[strlen(dn)-1] = '\0';
1126 tccfcreq.type = 2;
1127 tccfcreq.act = 1;
1128 strncpy(tccfcreq.dn, dn, strlen(dn));
1129 break;
1130 case ZCC_CFNRY_DEREG:
1131 tccfcreq.type = 2;
1132 tccfcreq.act = 0;
1133 break;
1134 case ZCC_CFB_REG:
1135 sscanf(pAtCmdPara, "%*4s%47s#", dn);
1136 dn[strlen(dn)-1] = '\0';
1137 tccfcreq.type = 1;
1138 tccfcreq.act = 1;
1139 strncpy(tccfcreq.dn, dn, strlen(dn));
1140 break;
1141 case ZCC_CFB_DEREG:
1142 tccfcreq.type = 1;
1143 tccfcreq.act = 0;
1144 break;
1145 }
1146
1147
1148 if (scName > ZCC_BOIC_DEREG)
1149 {
1150 zCcApp_Ccfc(&tccfcreq);
1151 }
1152 else
1153 {
1154 zCcApp_Clck(&tclckreq);
1155 }
1156
1157}
1158
1159VOID zCc_SendAtDialReq(PSTR pAtCmdPara)
1160{
1161 UINT8 slave =0;
1162
1163 //ccapp_log("pAtCmdPara=%s len=%s", pAtCmdPara, strlen(pAtCmdPara));
1164
1165 if (strlen(pAtCmdPara)+1 > ZDIAL_NUM_MAX)
1166 {
1167 return;
1168 }
1169 else if (strlen(pAtCmdPara) <= 2)
1170 {
1171 slave = zCc_GetDialingSlave(1);
1172 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
1173 {
1174 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
1175 0,
1176 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
1177 zCcApp_BusyToneTimer,
1178 NULL);
1179 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
1180 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
1181 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
1182 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
1183 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
1184 }
1185 else
1186 {
1187 int index;
1188 zCc_InitSlaveObj(slave);
1189 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
1190 index = zCc_find_held_cid(); // hookflash + onekey and dtmf timeout
1191 if(index!=0)
1192 zCc_SendAtChldReq(2);
1193 }
1194 return;
1195 }
1196 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_D;
1197 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq:AtcmdMsg = %s\n",__FUNCTION__,pAtCmdPara);
1198 zCcApp_Dial((char *)pAtCmdPara);
1199
1200}
1201
1202VOID zCc_SendAtAnswerReq(VOID)
1203{
1204 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtAnswerReq\n",__FUNCTION__);
1205 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_A;
1206 zCcApp_Answer();
1207}
1208
1209VOID zCc_SendAtHangupReq(VOID)
1210{
1211 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtHangupReq\n",__FUNCTION__);
1212 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_CHUP;
1213 zCcApp_Chup();
1214}
1215
1216VOID zCc_SendAtDtmfReq(char* dtmfchar)
1217{
1218 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_VTS;
1219 zCcApp_Vts(dtmfchar);
1220}
1221
1222VOID zCc_SendAtImsPlusReq(int rate, int setfg)
1223{
1224 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtImsPlusReq\n",__FUNCTION__);
1225 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_IMSPLUS;
1226 zCcApp_SetImsPlus(rate, setfg);
1227}
1228#if 0
1229VOID zCc_SendAtVolumnReq(PSTR pAtCmdPara)
1230{
1231 CHAR AtcmdMsg[ZAT_PARAM_LEN50] = {0};
1232
1233 if (pAtCmdPara[0] == 0 || strlen(pAtCmdPara)+1 > ZDIAL_NUM_MAX)
1234 {
1235 return;
1236 }
1237 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_VTS;
1238 sprintf(AtcmdMsg, "AT+VTS=\"%s\",20\r\n", pAtCmdPara);
1239 printf( "---> ccApp zCc_SendAtDtmfReq:AtcmdMsg = %s\n", AtcmdMsg);
1240 zCcApp_Vts(AtcmdMsg);
1241}
1242#endif
1243SINT32 zCc_SendAtChldReq(int chldtype)
1244{
1245 SINT32 ret = -1;
1246
1247 if (g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
1248 {
1249 zCc_ClearDigits();
1250 }
1251 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
1252 g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_SET_CHLD;
1253 ret = zCcApp_Chld(chldtype);
1254 return ret;
1255}
1256
1257VOID zCc_SendLedInformMsg(VOID)
1258{
1259 int lRet = -1;
1260 int lTgtMsgID = 0;
1261 MSG_BUF stMsg;
1262 LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
1263
1264#ifndef TEST_CCAPP
1265 lTgtMsgID = msgget(MODULE_ID_MMI, 0);
1266 if (-1 == lTgtMsgID)
1267 {
1268 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendLedInformMsg msgget MMI fail\n",__FUNCTION__);
1269 return;
1270 }
1271
1272 memset(&stMsg, 0, sizeof(MSG_BUF));
1273 stMsg.ulMagic = MSG_MAGIC_WORD;
1274 stMsg.lMsgType = MSG_TYPE_DEFAULT;
1275 stMsg.src_id = MODULE_ID_CALL_CTRL;
1276 stMsg.dst_id = MODULE_ID_MMI;
1277 stMsg.usMsgCmd = MSG_CMD_VOIP_STATUS_INFO;
1278 stMsg.usDataLen = 0;
1279 lRet = msgsnd(lTgtMsgID, &stMsg, msgSize, IPC_NOWAIT);
1280 if (lRet < 0)
1281 {
1282 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendLedInformMsg msgsnd to MMI fail\n",__FUNCTION__);
1283 return;
1284 }
1285#endif
1286}
1287
1288VOID zCc_SetLedStatus(char* LedStatus)
1289{
1290
1291#ifndef TEST_CCAPP
1292 cfg_set("voip_status", LedStatus);
1293#endif
1294 zCc_SendLedInformMsg();
1295 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SetLedStatus = %s\n",__FUNCTION__,LedStatus);
1296}
1297
1298SINT32 zCc_RecvDsciInd(MSG_BUF *ptMsgBuf)
1299{
1300 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV dsciind!!!<---\n");
1301 //ptMsgBuf->usMsgCmd = ZCC_NO_E;
1302 //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_DSCI;
1303 //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
1304
1305 zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
1306 return 0;
1307}
1308
1309int is_onecall_in_help_and_ready_to_input_new_call(void)
1310{
1311 int i;
1312 if(zCc_find_held_cid()==0)
1313 return 0;
1314
1315 for(i=0;i<ZCC_SLAVES;i++) // should start from 0, it'll be 0 when hookflash comes but not input any key
1316 if(g_Cc_CallDetail.slaveObj[i].state==ZCC_S_DT_S ||
1317 g_Cc_CallDetail.slaveObj[i].state==ZCC_S_DACCM_S)
1318 return 1;
1319
1320 return 0;
1321}
1322
1323void tz_lock_cellid_active_for_call(int state)
1324{
1325 static int old_state = -1;
1326 static int cellid_active_count = 0;
1327 char tz_lock_cellid_active[4] = {0};
1328
1329 cfg_get_item("tz_lock_cellid_active",tz_lock_cellid_active,sizeof(tz_lock_cellid_active));
1330 if(strcmp(tz_lock_cellid_active, "1") == 0)
1331 return;
1332
1333 if((old_state == 3) && (state == 0) && (cellid_active_count < 3))
1334 {
1335 cellid_active_count++;
1336 if(cellid_active_count == 3)
1337 {
1338 cfg_set("tz_lock_cellid_call_active", "1");
1339 }
1340 }
1341 old_state = state;
1342 return;
1343}
1344
1345SINT32 zCc_DsciIndProc(MSG_BUF *ptMsgBuf)
1346{
1347 int inMpty = 0;
1348 int cid = 0;
1349 int state = 0;
1350 int dir = 0;
1351 CHAR num[ZDIAL_NUM_MAX] = {0};
1352 CHAR voip_status[ZDIAL_NUM_MAX] = {0};
1353 T_zCcApp_DsciInd tDiscInd = {0};
1354
1355 int n;
1356 int slave_callout[ZCC_SLAVES];
1357
mj.qu58875012025-06-19 02:45:53 -07001358 MSG_BUF msgBuf = {0};
1359 char callback_enable[4] = {0};
1360 char callback_number[20] = {0};
1361 cfg_get_item("callback_enable", callback_enable, sizeof(callback_enable));
1362 cfg_get_item("callback_number", callback_number, sizeof(callback_number));
1363
mj.qu1524fc92025-06-11 04:34:13 -07001364 memcpy(&tDiscInd, (T_zCcApp_DsciInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_DsciInd));
1365 cid = tDiscInd.cid;
1366 inMpty = tDiscInd.inMpty;
1367 dir = tDiscInd.dir;
1368 state = tDiscInd.state;
1369 strncpy(num, tDiscInd.num,sizeof(num)-1);
1370 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s RECV dsciind: cid=%d num=%s dir=%d inMpty=%d state=%d !!!<---\n",
1371 __FUNCTION__, cid, num, dir,inMpty,state);
1372 zCc_ShowAllSlave();
1373
1374 if (cid < ZCC_MINCID || cid > ZCC_MAXCID)
1375 {
1376 return 0;
1377 }
1378 if (num[0] < 0)
1379 {
1380 memset(num,0,ZDIAL_NUM_MAX);
1381 }
1382 ptMsgBuf->dst_id = cid;
1383 tz_lock_cellid_active_for_call(state);
1384 switch(state)
1385 {
1386 case 0://Z_MMIACC_CALL_STATE_ACTIVE
1387 if (g_Cc_CallDetail.slaveObj[cid].state == ZCC_S_TALKING_S)//held->active
1388 {
1389 SLIC_Start_PCM();
1390 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Start_PCM <---\n",__FUNCTION__);
1391
1392 if (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A
1393 && g_Cc_CallDetail.slaveObj[0].tone == ZCC_TONE_DIAL_A)
1394 {
1395 SLIC_Stop_Signal(0, TONE_SIGNAL);
1396 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
1397 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
1398 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc handling zCc_InitSlaveObj(0)\n",__FUNCTION__);
1399 zCc_InitSlaveObj(0);
1400 }
1401 g_Cc_CallDetail.slaveObj[cid].heldcall = 0;
1402 g_Cc_CallDetail.slaveObj[cid].confcall = inMpty;
1403 }
1404 else
1405 {
1406 ptMsgBuf->usMsgCmd = ZCC_SANS_E;
1407 }
1408
1409#ifndef TEST_CCAPP
1410 cfg_get_item("voip_status",voip_status,sizeof(voip_status));
1411 if (0 != strcmp("ledon" , voip_status))
1412#endif
1413 {
1414 zCc_SetLedStatus("ledon");
1415 }
1416 break;
1417 case 1://Z_MMIACC_CALL_STATE_HELD
1418 if (g_Cc_CallDetail.slaveObj[cid].state == ZCC_S_TALKING_S)//active->held
1419 {
1420 if (1 == zCc_CallCount())
1421 {
1422 //SLIC_Stop_PCM();
1423 }
1424 g_Cc_CallDetail.slaveObj[cid].heldcall = 1;
1425 g_Cc_CallDetail.slaveObj[cid].confcall = inMpty;
1426
1427 }
1428 break;
1429 case 3://Z_MMIACC_CALL_STATE_MO_ALERTING
1430 ptMsgBuf->usMsgCmd = ZCC_SRING_E;
1431 break;
1432 case 4://Z_MMIACC_CALL_STATE_MT_INCOMING
1433 if(tz_lock_cellid_is_limit_callin())
1434 {
1435 zCc_SendAtChldReq(10+cid);
1436 break;
1437 }
1438
1439 if(g_Cc_CallDetail.state==ZCC_M_SEIZE_S)
1440 {
1441 int cnt;
1442
1443 cnt= zCc_CallCount();
1444 ccapp_log("cnt=%d slave[0]=%d", cnt, g_Cc_CallDetail.slaveObj[0].state);
1445
1446 if(cnt==0) // hookoff but not dail out utill dtmf-timer timeout
1447 {
1448 if(ZCC_S_BSYT_S<=g_Cc_CallDetail.slaveObj[0].state &&
1449 g_Cc_CallDetail.slaveObj[0].state<=ZCC_S_SIL_S)
1450 {
1451 zCc_SendAtChldReq(10+cid);
1452 break;
1453 }
1454 }
1455
1456 if(zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_BSYT_S)||
1457 zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_TKYT_S)|| // fast dududu is being ....
1458 zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_SIL_S)) // fast dududu is end ....
1459 {
1460 zCc_SendAtChldReq(10+cid);
1461 break;
1462 }
1463 }
1464 else if(g_Cc_CallDetail.state==ZCC_M_RELEASE_S)
1465 {
1466 int dsci6_cid = zCc_Find_waitDSCI6_cid();
1467 if(dsci6_cid!=0 && dsci6_cid==cid)
1468 {
1469 zCc_SendAtChldReq(10+cid);
1470 zCc_InitSlaveObj(cid);
1471 ccapp_log("zCc_Find_waitDSCI6_cid and skip this call %s", num);
1472
1473 char temp[200];
1474 sprintf(temp, "echo \"%s get error incoming call cid=%d num=%s\" > /tmp/log.ccapp.callin.err",
1475 get_local_date_time(), cid, num);
1476 soft_system(temp);
1477 break;
1478 }
1479 }
1480
1481 ptMsgBuf->usMsgCmd = ZCC_SINVITE_E;
1482 memset(g_Cc_CallDetail.number, 0, sizeof(g_Cc_CallDetail.number));
1483 memcpy(g_Cc_CallDetail.number, num, ZDIAL_NUM_MAX);
1484 break;
1485 case 5://Z_MMIACC_CALL_STATE_MT_WAITING
1486 if(g_Cc_CallDetail.state==ZCC_M_RINGING_S && zCc_find_held_cid())
1487 {
1488 zCc_SendAtChldReq(10+cid);
1489 break;
1490 }
1491 else if(is_onecall_in_help_and_ready_to_input_new_call())
1492 {
1493 zCc_SendAtChldReq(10+cid);
1494 break;
1495 }
1496
1497 if(zCc_CallCount()>=2)
1498 {
1499 zCc_SendAtChldReq(10+cid);
1500 break;
1501 }
1502
1503 ptMsgBuf->usMsgCmd = ZCC_CIDCW_E;
1504 memset(g_Cc_CallDetail.number, 0, sizeof(g_Cc_CallDetail.number));
1505 memcpy(g_Cc_CallDetail.number, num, ZDIAL_NUM_MAX);
1506 break;
1507 case 6://Z_MMIACC_CALL_STATE_END
1508 zCcApp_Vts_CleanReq();
1509 if(zCc_findCID_by_number(num)==0)
1510 break;
1511
1512 ptMsgBuf->usMsgCmd = dir?ZCC_SDISCN_MT_E: ZCC_SDISCN_MO_E;
1513 g_Cc_CallDetail.chupSent = 0;
1514
1515 memset(slave_callout, 0, sizeof(slave_callout));
1516 n = zCc_find_all_callout(slave_callout);
1517
1518 ccapp_log("DscInd 6, dir=%d is_callout=%d, find_all_callout=%d",
1519 dir,
1520 g_Cc_CallDetail.slaveObj[cid].is_callout,
1521 n);
1522
1523 if(dir==0 && g_Cc_CallDetail.slaveObj[cid].is_callout == TRUE)
1524 {
1525 if(n<1 || (n==1 && slave_callout[0]==cid))
1526 SLIC_PolarityReverse(0, FALSE);
1527 }
1528
1529 if ((cid == g_Cc_CallDetail.ringCid) && (ZCC_TONE_CIDCW_A == g_Cc_CallDetail.lastTone))
1530 {
1531 SLIC_Stop_Signal(0, 0);//Í£Ö¹ºô½ÐµÈ´ýÒô
1532 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
1533 g_Cc_CallDetail.slaveObj[0].tone = ZCC_TONE_OFF_A;
1534 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
1535 }
mj.qu58875012025-06-19 02:45:53 -07001536
1537 if(1 == g_chup_flag && 1 == dir && 0 == strcmp(callback_enable, "1") && 1 == check_phone_number_in_file(callback_number, "/cache/call_back_list"))
1538 {
1539 g_chup_flag = 0;
1540 msgBuf.usMsgCmd = ZCC_SEIZE_E;
1541 msgBuf.src_id = MODULE_ID_SLIC;
1542 zCc_SendMsgToSub(&msgBuf);
1543
1544 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: send ZCC_SEIZE_E to sub <---\n",__FUNCTION__);
1545 }
mj.quebc66052025-06-19 18:19:54 -07001546 else
1547 {
1548 cfg_set("callback_number", "");
1549 }
mj.qu1524fc92025-06-11 04:34:13 -07001550
1551 break;
1552 case 2://Z_MMIACC_CALL_STATE_MO_DIALING
1553 ptMsgBuf->usMsgCmd = ZCC_SDIALLING_E;
1554 break;
1555 case 7://Z_MMIACC_CALL_STATE_MT_CONNREQ
1556 case 8://Z_MMIACC_CALL_STATE_DISC
1557 default:
1558 break;
1559 }
1560 return 0;
1561}
1562
1563
1564
1565SINT32 zCc_RecvZvoiceChnl(MSG_BUF *ptMsgBuf)
1566{
1567 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV zvoicechnl!!!<---\n");
1568 //if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)
1569 //{
1570 // return 0;
1571 //}
1572 printf("[ccapp_debug]:recv zvoicechnl and send to local cc\n");
1573
1574 //ptMsgBuf->usMsgCmd = ZCC_NO_E;
1575 //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_IMSPLUS;
1576 //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
1577
1578 zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
1579 return 0;
1580}
1581
1582
1583
1584SINT32 zCc_RecvImsplusInd(MSG_BUF *ptMsgBuf)
1585{
1586 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV imsplusind!!!<---\n");
1587 //if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)
1588 //{
1589 // return 0;
1590 //}
1591 printf("[ccapp_debug]:recv imsplus and send to local cc\n");
1592
1593 //ptMsgBuf->usMsgCmd = ZCC_NO_E;
1594 //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_IMSPLUS;
1595 //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
1596
1597 zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
1598 return 0;
1599}
1600SINT32 zCc_RecvRsp(MSG_BUF *ptMsgBuf)
1601{
1602 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV at_rsp %d !!!<---\n", ptMsgBuf->usMsgCmd);
1603
1604 zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
1605 return 0;
1606}
1607
1608static inline unsigned char zCc_MapVoiceChnlAct(unsigned char act)
1609{
1610 if (act == 3)
1611 {
1612 return 0; //gsm
1613 }
1614 else if (act == 5)
1615 {
1616 return 2; //wcdma
1617 }
1618 else if (act == 15)
1619 {
1620 return 1;
1621 }
1622 else
1623 {
1624 assert(0);
1625 }
1626 return 3;
1627}
1628
1629static unsigned char g_zCc_VoiceOpenSucc = 1;
1630
1631static T_Voice_Para g_zCc_VoicePara_bak;
1632
1633static unsigned int g_zCc_pcm_bak = 0; /*new add*/
1634
1635SINT32 zCc_ZvoicechnlProc(MSG_BUF *ptMsgBuf)
1636{
1637 T_zCcApp_VoiceChnl tVoiceChnl;
1638 T_Voice_Para tVoicePara = {0};
1639 memcpy(&tVoiceChnl, (T_zCcApp_VoiceChnl*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_VoiceChnl));
1640
1641 tVoicePara.mode = zCc_MapVoiceChnlAct(tVoiceChnl.act);
1642 tVoicePara.codec_type = tVoiceChnl.codetype; //0-nb, 1-wb
1643 if ( tVoicePara.codec_type == 1)
1644 tVoicePara.clock_rate = 16000;
1645 else
1646 tVoicePara.clock_rate = 8000;
1647
1648 tVoicePara.codec_path = tVoiceChnl.amrpath;
1649
1650 printf("[ccapp_debug]:recv zvoicechnl, tVoicePara=%d,%d,%d,%d\n",tVoicePara.clock_rate,tVoicePara.mode,tVoicePara.codec_type,tVoicePara.codec_path);
1651 if (tVoiceChnl.op == 1)
1652 {
1653 /* new add begin*/
1654 //start voice
1655 if (/*voice_open(&tVoicePara) != 0 ||*/ g_Cc_CallDetail.state == ZCC_M_RINGING_S)
1656 {
1657 printf("[ccapp]:voice open fail");//´ò¿ªvoiceʧ°Ü£¬»òÕßÕñÁå̬ÊÕµ½zvoicechnl£¬¶¼ÈÏΪʧ°Ü
1658 g_zCc_VoiceOpenSucc = 0;
1659 g_zCc_VoicePara_bak = tVoicePara;
1660 }
1661 else if (g_Cc_CallDetail.state == ZCC_M_SEIZE_S)
1662 {
1663
1664 if ( voice_open(&tVoicePara) != 0)
1665
1666 {
1667
1668 printf("[ccapp_debug]:mo call voice_open fail!!!\n");
1669
1670 voice_close(&tVoicePara);
1671
1672 }
1673
1674 }
1675/* new add end*/
1676 printf("[ccapp_debug]:voice_open:rlt=%d\n",g_zCc_VoiceOpenSucc);
1677
1678 }
1679 else
1680 {
1681 //close voice
1682 g_zCc_VoiceOpenSucc = 1;
1683 voice_close(&tVoicePara);
1684 printf("[ccapp_debug]:voice_close:rlt=%d\n",g_zCc_VoiceOpenSucc);
1685
1686 }
1687 return 0;
1688}
1689
1690
1691
1692
1693
1694SINT32 zCc_ZimsplusProc(MSG_BUF *ptMsgBuf)
1695{
1696 int act = 0;
1697 int rate = 0;
1698 T_zCcApp_ImsplusInd tImsplusInd = {0};
1699
1700 memcpy(&tImsplusInd, (T_zCcApp_ImsplusInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_ImsplusInd));
1701 act = tImsplusInd.act;
1702 rate = tImsplusInd.rate;
1703 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: act = %d rate = %d new!!!<---\n",__FUNCTION__, act, rate);
1704 printf("[ccapp_debug]:recv imsplus, tImsplusInd=%d,%d\n",tImsplusInd.act,tImsplusInd.rate);
1705
1706
1707 if (act == 0)
1708 {
1709 SLIC_Stop_PCM();
1710 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_PCM <---\n",__FUNCTION__);
1711 }
1712 else if (act == 1)
1713 {
1714 /* new add begin*/
1715 if ( g_Cc_CallDetail.state == ZCC_M_RINGING_S)
1716 {
1717 g_zCc_pcm_bak = rate;
1718 return 0;
1719 }
1720 /* new add end */
1721
1722 if (rate == 8000)
1723 {
1724 SLIC_PCM_Set_NB();
1725 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_NB <---\n",__FUNCTION__);
1726 SLIC_Start_PCM();
1727 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
1728 }
1729 else if (rate == 16000)
1730 {
1731 SLIC_PCM_Set_WB();
1732 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_WB <---\n",__FUNCTION__);
1733 SLIC_Start_PCM();
1734 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
1735 }
1736 }
1737 else if (act == 2)//¹Ø±Õpcm£¬·Å±¾µØ»ØÁåÒô
1738 {
1739 if (ZCC_S_RINGBACK_S != g_Cc_CallDetail.slaveObj[rate].state)
1740 {
1741 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: act 2,cid err <---\n",__FUNCTION__);
1742 return 0;
1743 }
1744 SLIC_Stop_PCM();
1745 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_PCM <---\n",__FUNCTION__);
1746 g_Cc_CallDetail.slaveObj[rate].tone = ZCC_TONE_RB_A;
1747 }
1748 else if (act == 3)//ºóÐø»áÔÙÓÐact1Éϱ¨£¬ËùÒÔ´Ëʱ²»´ò¿ªpcm
1749 {
1750 SLIC_Stop_Signal(0,0);
1751 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
1752
1753 zCc_SendAtImsPlusReq(rate,0);
1754 g_Cc_CallDetail.slaveObj[rate].tone = ZCC_TONE_OFF_A;
1755 }
1756 return 0;
1757}
1758SINT32 zCc_RecvZcpiInd(MSG_BUF *ptMsgBuf)
1759{
1760 //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_ZCPI;
1761 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV zcpiind!!!<---\n");
1762 //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
1763 zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
1764 return 0;
1765}
1766
1767SINT32 zCc_ZcpiIndProc(MSG_BUF *ptMsgBuf)
1768{
1769 int state = 0;
1770 int cid = 0;
1771 int progdsp = 0;
1772 T_zCcApp_ZcpiInd tZcpiInd = {0};
1773
1774 memcpy(&tZcpiInd, (T_zCcApp_ZcpiInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_ZcpiInd));
1775 state = tZcpiInd.state;
1776 cid = tZcpiInd.cid;
1777 progdsp = tZcpiInd.progdsp;
1778
1779 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZcpiIndProc: cid= %d, state=%d, progdsp=%d <---\n",__FUNCTION__,cid,state,progdsp);
1780 if (5 == state)
1781 {
1782 ptMsgBuf->dst_id = cid;
1783 ptMsgBuf->usMsgCmd = ZCC_RESOURCE_READY_E;
1784 g_Cc_CallDetail.resourceReady = 1;
1785 }
1786 else if (6 == state)
1787 {
1788 g_Cc_CallDetail.resourceReady = 0;
1789 }
1790
1791 if (8 == progdsp)
1792 {
1793 SLIC_Start_PCM();
1794 }
1795
1796 return 0;
1797}
1798
1799LONG zCcApp_send_message(unsigned short Msg_cmd,unsigned short us_DataLen,unsigned char *pData)
1800{
1801 ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_AT_CTL, Msg_cmd, us_DataLen, (unsigned char *)pData,0);
1802 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg_cmd is %d<---\n",__FUNCTION__, Msg_cmd);
1803
1804 return 0;
1805}
1806
1807VOID zCcApp_Dial(char *ptMsgBuf)
1808{
1809 SINT32 ret = -1;
1810 MSG_BUF stMsg;
1811 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1812 T_zCcapp_CallMoReq tcallReq = {0};
1813
1814 memset(tcallReq.number, 0, sizeof(tcallReq.number));
1815 //strncpy(tcallReq.number, ptMsgBuf,strlen(ptMsgBuf));
1816 strncpy(tcallReq.number, ptMsgBuf,sizeof(tcallReq.number)-1);
1817 zCcApp_send_message(MSG_CMD_ATD_DIAL_REQ, sizeof(T_zCcapp_CallMoReq), (unsigned char *) &tcallReq);
1818 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ATD_DIAL_REQ<---\n",__FUNCTION__);
1819
1820}
1821SINT32 zCcApp_Ccfc(T_zCcapp_CcfcReq *ptccfcreq)
1822{
1823 SINT32 ret = -1;
1824 MSG_BUF stMsg;
1825 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1826
1827 zCcApp_send_message(MSG_CMD_CCFC_REQ, sizeof(T_zCcapp_CcfcReq), (unsigned char *) ptccfcreq);
1828 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CCFC_REQ<---\n",__FUNCTION__);
1829
1830 return 0;
1831}
1832SINT32 zCcApp_Clck(T_zCcapp_ClckReq *ptclckreq)
1833{
1834 SINT32 ret = -1;
1835 MSG_BUF stMsg;
1836 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1837
1838 zCcApp_send_message( MSG_CMD_CLCK_REQ, sizeof(T_zCcapp_ClckReq), (unsigned char *) ptclckreq);
1839 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CLCK_REQ<---\n",__FUNCTION__);
1840
1841 return 0;
1842}
1843
1844SINT32 zCcApp_Answer(VOID)
1845{
1846 SINT32 ret = -1;
1847 MSG_BUF stMsg;
1848 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1849
1850 zCcApp_send_message(MSG_CMD_ATA_REQ, 0, NULL);
1851 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ATA_REQ<---\n",__FUNCTION__);
1852
1853 return 0;
1854}
1855
1856SINT32 zCcApp_Chup(void)
1857{
1858 SINT32 ret = -1;
1859 MSG_BUF stMsg;
1860 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1861
1862 zCcApp_send_message(MSG_CMD_CHUP_REQ, 0, NULL);
1863 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg isMSG_CMD_CHUP_REQ<---\n",__FUNCTION__);
1864
1865 return 0;
1866}
1867
1868//µ±ÉÏÒ»¸öVTSûÓÐÊÕµ½OKǰ£¬ÆäËûµÄVTSÈ«²¿»º´æÔÚÁ´±íÀ´ýÊÕµ½ÉÏÒ»¸öOKʱÔÚÏ·¢ÏÂÒ»¸ö
1869//¶¼ÔÚmainÏ̴߳¦Àí£¬ÎÞÐ軥³â
1870typedef struct {
1871 struct list_head list;
1872 T_zCcapp_VtsReq vts;
1873}T_zCcapp_VtsReq_list;
1874
1875static LIST_HEAD(ccapp_vts_waitqueue);
1876static int ccapp_vts_flag = 0;
1877
1878void zCcApp_Vts_CleanReq(void)
1879{
1880 struct list_head *head = &ccapp_vts_waitqueue;
1881 T_zCcapp_VtsReq_list *l, *tmp;
1882
1883 if(!list_empty(head))
1884 {
1885 list_for_each_entry_safe(l, tmp, head, list)
1886 {
1887 list_del(&l->list);
1888 free(l);
1889 }
1890 ccapp_vts_flag = 0;
1891 }
1892}
1893
1894void zCcApp_Vts_Rsp(void)
1895{
1896 struct list_head *head = &ccapp_vts_waitqueue;
1897 printf("[ccapp_debug]:Vts_Rsp flag=%d\n",ccapp_vts_flag);
1898 if(list_empty(head))
1899 {
1900 ccapp_vts_flag = 0;
1901 }
1902 else
1903 {
1904 T_zCcapp_VtsReq_list *node = list_entry(head->next,T_zCcapp_VtsReq_list,list);
1905
1906 zCcApp_send_message(MSG_CMD_VTS_REQ, sizeof(T_zCcapp_VtsReq), (unsigned char *) &node->vts);
1907 ccapp_vts_flag = 1;
1908 list_del(&node->list);
1909 free(node);
1910 }
1911}
1912
1913SINT32 zCcApp_Vts(char* dtmfchar)
1914{
1915 T_zCcapp_VtsReq tvtsreq = {0};
1916 struct list_head *head = &ccapp_vts_waitqueue;
1917
1918 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","vtschar=%s<---\n",dtmfchar);
1919 tvtsreq.dtmfchar=*dtmfchar;
1920 printf("[ccapp_debug]:Vts_Req flag=%d\n",ccapp_vts_flag);
1921 if(list_empty(head) && ccapp_vts_flag == 0)
1922 {
1923 zCcApp_send_message(MSG_CMD_VTS_REQ, sizeof(T_zCcapp_VtsReq), (unsigned char *) &tvtsreq);
1924 ccapp_vts_flag = 1;
1925 }
1926 else
1927 {
1928 T_zCcapp_VtsReq_list *node = (T_zCcapp_VtsReq_list *)malloc(sizeof(T_zCcapp_VtsReq_list));
1929 if(node == NULL)
1930 {
1931 printf("[ccapp_debug]: zCcApp_Vts malloc fail!!!\n");
1932 return 0;
1933 }
1934 memset(node, 0 , sizeof(T_zCcapp_VtsReq_list));
1935 node->vts.dtmfchar = tvtsreq.dtmfchar;
1936 list_add_tail(&node->list,head);
1937 }
1938 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_VTS_REQ<---\n",__FUNCTION__);
1939
1940 return 0;
1941}
1942SINT32 zCcApp_SetImsPlus(int rate, int setfg)
1943{
1944 SINT32 ret = -1;
1945 MSG_BUF stMsg;
1946 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1947 T_zCcapp_ImsplusReq timsplusreq= {0};
1948
1949 timsplusreq.act = rate;
1950 timsplusreq.setfg = setfg;
1951
1952 zCcApp_send_message(MSG_CMD_ZIMSPLUS_REQ, sizeof(T_zCcapp_ImsplusReq), (unsigned char *) &timsplusreq);
1953 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ZIMSPLUS_REQ<---\n",__FUNCTION__);
1954
1955 return 0;
1956}
1957
1958SINT32 zCcApp_Chld(int chldtype)
1959{
1960 SINT32 ret = -1;
1961 MSG_BUF stMsg;
1962 LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
1963
1964 T_zCcapp_ChldReq tchldreq = {0};
1965
1966 tchldreq.type = chldtype;
1967
1968 zCcApp_send_message(MSG_CMD_CHLD_REQ, sizeof(T_zCcapp_ChldReq), (unsigned char *) &tchldreq);
1969 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CHLD_REQ[%d]<---\n",__FUNCTION__,chldtype);
1970
1971 return 0;
1972}
1973
1974SINT32 zCcApp_AtIndRspProc(MSG_BUF *ptMsgBuf)
1975{
1976 SINT32 i ;
1977 SINT32 ret = -1;
1978 for(i=0;i< gCcAppRecvAtIndProcCnt;i++)
1979 {
1980 if(ptMsgBuf->usMsgCmd == gCcAppRecvAtIndProc[i].AtIndCmd)
1981 {
1982 if(NULL!= gCcAppRecvAtIndProc[i].RecvAtIndProcFun)
1983 {
1984 ret = gCcAppRecvAtIndProc[i].RecvAtIndProcFun(ptMsgBuf);
1985 }
1986 break;
1987 }
1988 }
1989
1990 return ret;
1991}
1992VOID zCc_MReleaseState(MSG_BUF *ptMsgBuf)
1993{
1994 CHAR voip_status[ZDIAL_NUM_MAX] = {0};
1995 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MReleaseState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
1996
1997 printf("[ccapp_debug]: Release State Recv MsgCmd: %d\n",ptMsgBuf->usMsgCmd);
1998
1999 switch (ptMsgBuf->usMsgCmd)
2000 {
2001 case ZCC_SEIZE_E: // ͻȜ
2002 // slave[0] to play dial tone
2003 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
2004 g_Cc_CallDetail.state = ZCC_M_SEIZE_S;
2005 g_Cc_CallDetail.chupSent = FALSE;
2006 g_Cc_CallDetail.hookofffg = TRUE;
2007 if (g_Cc_CallDetail.ringCid)// ¾Ü¾øµÈ´ý×ÊԴ״̬µÄincoming call
2008 {
2009 zCc_SendAtHangupReq();
2010 g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].waitDSCI6 = 1;
2011 }
2012
2013#ifndef TEST_CCAPP
2014 cfg_get_item("voip_status",voip_status,sizeof(voip_status));
2015
2016 if (0 != strcmp("ledblink" , voip_status))
2017#endif
2018 {
2019 zCc_SetLedStatus("ledblink");
2020 }
2021 break;
2022
2023 case ZCC_SINVITE_E:
2024 g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ZCC_SINVITE_E;
2025 //g_Cc_CallDetail.state = ZCC_M_RINGING_S; È·ÈÏ×ÊÔ´·ÖÅäºóÔÙǨ״̬
2026 break;
2027
2028 case ZCC_RESOURCE_READY_E:
2029 ccapp_log("g_Cc_CallDetail.ringCid=%d", g_Cc_CallDetail.ringCid);
2030 if (g_Cc_CallDetail.ringCid)
2031 {
2032 g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_RESOURCE_READY_E;
2033 }
2034 break;
2035
2036 case ZCC_SDISCN_MO_E:
2037 case ZCC_SDISCN_MT_E:
2038 g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ptMsgBuf->usMsgCmd;
2039 break;
2040
2041 case ZCC_RELEASE_E:
2042 case ZCC_FLASH_E:
2043 default:
2044 // do nothing
2045 break;
2046 }
2047}
2048
2049pthread_t slic_ring_test_pid;
2050void* slic_ring_test_thread(void * ptr)
2051{
2052 SIGNAL_DATA tSig;
2053 while(1)
2054 {
2055 sleep(30);
2056 printf("ring stop\n");
2057 SLIC_Stop_Signal(0, RING_SIGNAL);
2058 zCc_SetLedStatus("ledoff");
2059
2060 sleep(30);
2061 printf("ringing\n");
2062 memset(&tSig, 0, sizeof(tSig));
2063 tSig.signal_type = RING_SIGNAL;
2064 strcpy(g_Cc_CallDetail.number, "1234567890");
2065 strncpy(tSig.cid, g_Cc_CallDetail.number,sizeof(tSig.cid)-1);
2066 get_local_datetime(tSig.date_time);
2067 ccapp_log("local test call RING_SIGNAL,number = %s\n",g_Cc_CallDetail.number);
2068 SLIC_Play_Signal(0, 0, &tSig);
2069 zCc_SetLedStatus("ledblink");
2070 }
2071 return NULL;
2072}
2073
2074VOID zCc_MRingingState(MSG_BUF *ptMsgBuf)
2075{
2076 int held_call_cid = 0;
2077 int incoming_call_cid = 0;
2078 int shall_ring_cid;
mj.qu58875012025-06-19 02:45:53 -07002079
2080 MSG_BUF msgBuf = {0};
2081 char callback_enable[4] = {0};
2082 char callback_number[20] = {0};
2083 cfg_get_item("callback_enable", callback_enable, sizeof(callback_enable));
2084 cfg_get_item("callback_number", callback_number, sizeof(callback_number));
mj.qu1524fc92025-06-11 04:34:13 -07002085
2086 SIGNAL_DATA tSig;
2087
2088 CHAR voip_status[ZDIAL_NUM_MAX] = {0};
2089 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
2090 switch (ptMsgBuf->usMsgCmd)
2091 {
2092 case ZCC_SEIZE_E: // ͻȜ
2093 g_Cc_CallDetail.state = ZCC_M_SEIZE_S;
2094 SLIC_Stop_Signal(0, RING_SIGNAL);
2095 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2096 if (g_zCc_VoiceOpenSucc == 0)
2097 {
2098 g_zCc_VoiceOpenSucc = 1;
2099 voice_open(&g_zCc_VoicePara_bak);
2100 /* new add begin */
2101 if (g_zCc_pcm_bak == 8000)
2102 {
2103 SLIC_PCM_Set_NB();
2104 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_NB <---\n",__FUNCTION__);
2105 SLIC_Start_PCM();
2106 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
2107 }
2108 else if (g_zCc_pcm_bak == 16000)
2109 {
2110 SLIC_PCM_Set_WB();
2111 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_WB <---\n",__FUNCTION__);
2112 SLIC_Start_PCM();
2113 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
2114 }
2115 g_zCc_pcm_bak = 0;
2116 /* new add end */
2117 }
2118
2119 g_Cc_CallDetail.chupSent = FALSE;
2120
2121 ccapp_log("ZCC_SEIZE_E held_cid=%d held_incoming_cid=%d",
2122 zCc_find_held_cid(),
2123 zCc_find_held_incoming_cid());
2124
2125 if(local_test_call_st==LocalTestCallST_Ring)
2126 {
2127 /*memset(&tSig, 0, sizeof(tSig));
2128 tSig.signal_type= TONE_SIGNAL;
2129 tSig.tone_type = TONE_TKY;
2130 SLIC_Play_Signal(0, 0, &tSig);*/
2131 if(local_test_call_type == LocalTestCallType_LOOP)
2132 pthread_cancel(slic_ring_test_pid);
2133
2134 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2135 g_Cc_CallDetail.evt[0]= ZCC_NO_E;
2136 g_Cc_CallDetail.slaveObj[0].sMsg = ZCC_SNO_M;
2137
2138 local_test_call_st = LocalTestCallST_End;
2139
2140 //system("echo loop_1 >> /tmp/log.ccapp.vploop");
2141 //system("( sleep 1 && at_cmd AT+VPLOOP=1 ) &");
2142 cfg_set("tz_vploop", "1");
2143 ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL,
2144 MODULE_ID_AT_CTL,
2145 MSG_CMD_SET_VPLOOP_REQ,
2146 0,
2147 NULL,
2148 0);
2149
2150 zCc_ShowAllSlaveWithTips("testCall-end");
2151 break;
2152 }
2153
2154 incoming_call_cid = zCc_find_held_incoming_cid();
2155 ccapp_log("incoming_call_cid=%d is_cidcw=%d",
2156 incoming_call_cid,
2157 g_Cc_CallDetail.slaveObj[incoming_call_cid].is_cidcw);
2158
2159 if(zCc_find_held_cid())
2160 {
2161 zCc_SendAtChldReq(1);
2162 }
2163 else if(incoming_call_cid)
2164 {
2165 if(g_Cc_CallDetail.slaveObj[incoming_call_cid].is_cidcw == TRUE)
2166 zCc_SendAtChldReq(1);
2167 else
2168 {
2169 if (g_Cc_CallDetail.ringCid)
2170 {
2171 g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_CNCT_E;
2172 zCc_SendAtAnswerReq();
2173 }
2174 }
2175 }
2176 else
2177 {
2178 if (g_Cc_CallDetail.ringCid)
2179 {
2180 g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_CNCT_E;
2181 zCc_SendAtAnswerReq();
2182 }
2183 }
mj.qu58875012025-06-19 02:45:53 -07002184
2185 if(0 == strcmp(callback_enable, "1") && 1 == check_phone_number_in_file(callback_number, "/cache/call_back_list"))
2186 {
2187 g_chup_flag = 1;
2188 msgBuf.usMsgCmd = ZCC_RELEASE_E;
2189 msgBuf.src_id = MODULE_ID_SLIC;
2190 zCc_SendMsgToSub(&msgBuf);
mj.qu435a4e42025-08-06 19:00:49 -07002191
2192 sleep(1);
mj.qu58875012025-06-19 02:45:53 -07002193
2194 zCc_SendAtHangupReq();
2195 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState: ZCC_RELEASE_E <---\n",__FUNCTION__);
2196 }
2197
mj.qu1524fc92025-06-11 04:34:13 -07002198 break;
2199
2200// case ZCC_SINVITE_E:
2201 case ZCC_SDISCN_MT_E:
2202 case ZCC_SDISCN_MO_E:
2203 if(check_incoming_call_is_in_slave(ptMsgBuf)==0)
2204 break;
2205
2206 g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ptMsgBuf->usMsgCmd;
2207 g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
2208 SLIC_Stop_Signal(0, RING_SIGNAL);
2209 g_zCc_VoiceOpenSucc = 1;
2210 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2211#ifndef TEST_CCAPP
2212 cfg_get_item("voip_status",voip_status,sizeof(voip_status));
2213
2214 if (0 != strcmp("ledoff" , voip_status ))
2215#endif
2216 {
2217 zCc_SetLedStatus("ledoff");
2218 }
2219
2220 shall_ring_cid = 0;
2221 held_call_cid = zCc_find_held_cid();
2222 incoming_call_cid = zCc_find_held_incoming_cid();
2223 if(held_call_cid && (ptMsgBuf->dst_id!=held_call_cid))
2224 shall_ring_cid = held_call_cid;
2225 else if(incoming_call_cid && (ptMsgBuf->dst_id!=incoming_call_cid))
2226 shall_ring_cid = incoming_call_cid;
2227
2228 if(shall_ring_cid!=0)
2229 {
2230 memset(&tSig, 0, sizeof(tSig));
2231 g_Cc_CallDetail.state = ZCC_M_RINGING_S;
2232 tSig.signal_type = RING_SIGNAL;
2233 /*memcpy(tSig.cid,
2234 g_Cc_CallDetail.slaveObj[shall_ring_cid].number,
2235 strlen(g_Cc_CallDetail.slaveObj[shall_ring_cid].number));*/
2236 strncpy(tSig.cid, g_Cc_CallDetail.slaveObj[shall_ring_cid].number, sizeof(tSig.cid)-1);
2237 get_local_datetime(tSig.date_time);
2238 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_RunMaster RING_SIGNAL,number = %s\n",__FUNCTION__,g_Cc_CallDetail.slaveObj[held_call_cid].number);
2239 SLIC_Play_Signal(0, 0, &tSig);
2240 zCc_SetLedStatus("ledblink");
2241 }
2242 break;
2243
2244 default:
2245 // do nothing
2246 break;
2247 }
2248}
2249
2250VOID zCc_MSeizeState(MSG_BUF *ptMsgBuf)
2251{
2252 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
2253 UINT8 slave = (UINT8)ptMsgBuf->dst_id;
2254 UINT8 callCnt = 0;
2255 UINT8 ret = 0;
2256 SINT32 chldret = -1;
2257 UINT8 tmpslave = 0;
2258 CHAR voip_status[ZDIAL_NUM_MAX] = {0};
mj.qu8ddc7642025-06-11 04:37:19 -07002259 char hotline_time[4] = {0};
mj.qu1524fc92025-06-11 04:34:13 -07002260
mj.qu58875012025-06-19 02:45:53 -07002261 char callback_enable[4] = {0};
2262 char callback_number[20] = {0};
2263 cfg_get_item("callback_enable", callback_enable, sizeof(callback_enable));
2264 cfg_get_item("callback_number", callback_number, sizeof(callback_number));
2265
mj.qu1524fc92025-06-11 04:34:13 -07002266 printf("[ccapp_debug]: Seize State Recv MsgCmd: %d,localtest=%d\n",ptMsgBuf->usMsgCmd,local_test_call_st);
2267
2268 switch (ptMsgBuf->usMsgCmd)
2269 {
2270 case ZCC_DTMF_E: // ²¦ºÅ
2271 // slave[0] dial , or other call's DTMF
2272 ccapp_log("--> ZCC_DTMF_E[%c] lastTone=%d Count=%d Held=%d Active=%d getSlave(DACCM)=%d getSlave(RINGBACK)=%d ringCid=%d dig=%s",
2273 ptMsgBuf->aucDataBuf[0],
2274 g_Cc_CallDetail.lastTone,
2275 zCc_CallCount(),
2276 zCc_HeldCall(),
2277 zCc_ActiveCall(),
2278 zCc_GetSpecSlave(ZCC_S_DACCM_S),
2279 zCc_GetSpecSlave(ZCC_S_RINGBACK_S),
2280 g_Cc_CallDetail.ringCid,
2281 g_Cc_CallDetail.digits);
2282 printf("[ccapp_debug]: ZCC_DTMF_E[%c] lastTone=%d Count=%d Held=%d Active=%d getSlave(DACCM)=%d getSlave(RINGBACK)=%d ringCid=%d dig=%s\n",
2283 ptMsgBuf->aucDataBuf[0],
2284 g_Cc_CallDetail.lastTone,
2285 zCc_CallCount(),
2286 zCc_HeldCall(),
2287 zCc_ActiveCall(),
2288 zCc_GetSpecSlave(ZCC_S_DACCM_S),
2289 zCc_GetSpecSlave(ZCC_S_RINGBACK_S),
2290 g_Cc_CallDetail.ringCid,
2291 g_Cc_CallDetail.digits);
2292
2293 /* callwait ringback but he drop then we hookflash+1
2294lastTone=6 Count=2 Held=1 Active=0 getSlave(DACCM)=0 getSlave(RINGBACK)=2 ringCid=0 dig[0]=F
2295 */
2296 if ((g_Cc_CallDetail.lastTone == ZCC_TONE_BSY_A) || (g_Cc_CallDetail.lastTone == ZCC_TONE_TKY_A))//æÒôºÍÃùº¿Òô£¬²»´¦Àí°´¼üÏûÏ¢
2297 {
2298 zCc_ClearDigits();
2299 break;
2300 }
2301 callCnt = zCc_CallCount();
2302 if ( (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A || callCnt == zCc_HeldCall()) //Ö»Óб£³Öºô½Ð£¬²¦ºÅ·¢Æðкô½Ð
2303 && g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN
2304 && 0 == zCc_ActiveCall())//·Å²¦ºÅÒô»òÒÑÓб£³Öºô½ÐʱÓû§²¦ºÅ,µÚÒ»¸ö×Ö·û£¬Åųýactive+heldʱÏ·¢F2
2305 {
2306 slave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
2307 if (0 == slave )
2308 {
2309 return;
2310 }
2311 g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[0];
2312 g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
2313 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
2314 zCc_InitSlaveObj(0);
2315 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
2316 break;
2317 }
2318 else if ((g_Cc_CallDetail.lastTone == ZCC_TONE_SIL_A) && (0 != zCc_GetSpecSlave(ZCC_S_DACCM_S)))//¼ÌÐø²¦ºÅ
2319 {
2320 slave = zCc_GetSpecSlave(ZCC_S_DACCM_S);
2321 g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
2322 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
2323 break;
2324 }
2325 else if ((g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN) && ((0 != zCc_ActiveCall())
2326 ||((0 == zCc_ActiveCall()) && (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))))//·¢dtmf
2327 {
2328 if (0 != zCc_ActiveCall())
2329 {
2330 slave = zCc_GetCallSlave(0);
2331 }
2332 else
2333 {
2334 slave = zCc_GetSpecSlave(ZCC_S_RINGBACK_S);
2335 }
2336 g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
2337 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
2338 break;
2339 }
2340 else if ((0 == zCc_ActiveCall()) && (0 == zCc_GetSpecSlave(ZCC_S_RINGBACK_S))
2341 && (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN))//·ÇÎÈ̬·Ç»ØÁåÒô״̬ÊÕµ½×Ö·û£¬¶ªÆú
2342 {
2343 zCc_ClearDigits();
2344 return;
2345 }
2346 else
2347 {
2348 if (g_Cc_CallDetail.ringCid && (g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone == ZCC_TONE_CIDCW_A))//active+waiting+flashordtmf
2349 {
2350 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
2351 if (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN)
2352 {
2353 slave = zCc_GetSpecSlave(ZCC_S_TALKING_S);
2354 if (0 == slave )
2355 {
2356 return;
2357 }
2358 g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
2359 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
2360 break;
2361 }
2362 }
2363
2364 DeleteSoftTimer(ZCCAPP_TIMER_DTMF_DETECT);
2365 ret = zCc_DigitsMatch();
2366 if ((ZCC_NO_RESULT != ret && ZCC_MATCHERR != ret && g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A)
2367 ||(ZCC_MATCHERR == ret && g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A && 2 <= zCc_CallCount()))
2368 {//call waitingÊÕµ½flash4£¬Í£Ö¹²¦ºÅÒô»Ö¸´ºô½ÐµÈ´ýÒô
2369 SLIC_Stop_Signal(0, TONE_SIGNAL);
2370 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2371 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2372 if (g_Cc_CallDetail.slaveObj[0].tone != ZCC_TONE_OFF_A)
2373 {
2374 zCc_InitSlaveObj(0);
2375 }
2376 if (0 != zCc_ActiveCall())
2377 {
2378 SLIC_Start_PCM();
2379 }
2380 if ((ZCC_FLASH_1 == ret || ZCC_FLASH_2 == ret) && (g_Cc_CallDetail.ringCid != 0))//½ÓÌýwaiting call£¬ºô½ÐµÈ´ýÒôÓ¦Çå¿Õ
2381 {
2382 g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone = ZCC_TONE_OFF_A;
2383 }
2384 }
2385 zCc_DigitsMatchRltProc(ret);
2386 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
2387 }
2388
2389 break;
2390
2391 case ZCC_SDIALLING_E: // ·¢³öÁËSIP INVITE »ò CC SETUP , ͨ¹ýÕâ¸öÏûÏ¢Éϱ¨ cid
2392 if (0 != zCc_GetDialingSlave(0))
2393 {
2394 tmpslave = zCc_GetDialingSlave(0);
2395 if (tmpslave != slave)
2396 {
2397 g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
2398 zCc_InitSlaveObj(tmpslave);
2399 }
2400 }
2401 break;
2402
2403 case ZCC_SRING_E:
2404 case ZCC_SANS_E:
2405 case ZCC_SINVITE_E:
2406 case ZCC_CIDCW_E:
2407 g_Cc_CallDetail.evt[slave] = ptMsgBuf->usMsgCmd;
2408 break;
2409
2410 case ZCC_SDISCN_MT_E:
2411 case ZCC_SDISCN_MO_E:
2412 { //cov m
2413 if(check_incoming_call_is_in_slave(ptMsgBuf)==0)
2414 break;
2415
2416 g_Cc_CallDetail.evt[slave] = ptMsgBuf->usMsgCmd;
2417
2418 T_zCcApp_DsciInd *ptr = ptMsgBuf->aucDataBuf;
2419
2420 /* somebody drop the call
2421 zCc_MSeizeState zCc_MSeizeState ptMsgBuf->usMsgCmd = 43
2422 zCc_MSeizeState ==> get MT/MO cid=1 num=13088877803 stat=6 inMp=0 getCnt=2
2423 zCc_MSeizeState slv=1 cid=0 held=1 stat=8
2424 zCc_MSeizeState slv=2 cid=0 held=0 stat=8
2425 zCc_STalkingState zCc_STalkingState g_Cc_CallDetail.evt[1] = 43
2426 */
2427 ccapp_log("==> get MT/MO cid=%d num=%s stat=%d inMp=%d getCnt=%d",
2428 ptr->cid, ptr->num, ptr->state, ptr->inMpty,
2429 zCc_CallCount());
2430
2431 for (tmpslave = 0; tmpslave < ZCC_SLAVES; tmpslave++)
2432 {
2433 if (g_Cc_CallDetail.slaveObj[tmpslave].state != ZCC_S_IDLE_S)
2434 {
2435 ccapp_log(" slave=%d cid=%d held=%d stat=%d",
2436 tmpslave,
2437 g_Cc_CallDetail.slaveObj[tmpslave].cid,
2438 g_Cc_CallDetail.slaveObj[tmpslave].heldcall,
2439 g_Cc_CallDetail.slaveObj[tmpslave].state);
2440 }
2441 }
2442
2443 if(zCc_CallCount()<2)
2444 break;
2445
2446 if(ptr->cid>=ZCC_SLAVES) //cov m
2447 break;
2448
2449 if(g_Cc_CallDetail.slaveObj[ptr->cid].heldcall==0 &&
2450 g_Cc_CallDetail.slaveObj[ptr->cid].confcall==0)
2451 {
2452 if(zCc_HeldCall())
2453 {
2454 zCc_SendAtChldReq(1);
2455 break;
2456 }
2457 }
2458
2459 int incoming_call_cid = zCc_GetSpecSlave(ZCC_S_TRYING_S);
2460 if(incoming_call_cid!=0 && incoming_call_cid!=ptr->cid)
2461 zCc_SendAtChldReq(2);
2462
2463 #if 0
2464 tmpslave = zCc_GetSpecSlave(ZCC_S_TRYING_S); // incoming call here and wait for to be accepted
2465 ccapp_log("zCc_CallCount()=%d zCc_GetSpecSlave(ZCC_S_TRYING_S)=%d",
2466 zCc_CallCount(),
2467 tmpslave);
2468 if(tmpslave!=0 && ptMsgBuf->usMsgCmd==ZCC_SDISCN_MO_E) // foreground drop, automaticly accept the incoming call
2469 {
2470 SLIC_Stop_Signal(0, TONE_SIGNAL);
2471 zCc_SendAtChldReq(1);
2472 break;
2473 }
2474
2475 if(zCc_CallCount()<2)
2476 break;
2477
2478 if(ptr->cid<0 || ptr->cid>=ZCC_SLAVES)
2479 break;
2480
2481 if(g_Cc_CallDetail.slaveObj[ptr->cid].heldcall==0 &&
2482 g_Cc_CallDetail.slaveObj[ptr->cid].confcall==0)
2483 {
2484 /*if(g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_DIALING_S ||
2485 g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_RINGBACK_S ||
2486 g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_TALKING_S) */
2487 if(zCc_HeldCall())
2488 {
2489 zCc_SendAtChldReq(1);
2490 }
2491 }
2492 #endif
2493 break;
2494 }
2495 case ZCC_RELEASE_E:
2496 if(local_test_call_st==LocalTestCallST_Start)
2497 {
2498 SIGNAL_DATA tSig;
2499
2500 SLIC_Stop_Signal(0, TONE_SIGNAL);
2501
2502 memset(&tSig, 0, sizeof(tSig));
2503 tSig.signal_type = RING_SIGNAL;
2504 strcpy(g_Cc_CallDetail.number, "1234567890");
2505 strncpy(tSig.cid, g_Cc_CallDetail.number,sizeof(tSig.cid)-1);
2506 get_local_datetime(tSig.date_time);
2507 ccapp_log("local test call RING_SIGNAL,number = %s\n",g_Cc_CallDetail.number);
2508 SLIC_Play_Signal(0, 0, &tSig);
2509 zCc_SetLedStatus("ledblink");
2510
2511 if(local_test_call_type == LocalTestCallType_LOOP) {
2512 if (pthread_create(&slic_ring_test_pid, NULL, slic_ring_test_thread,0) != 0) //cov m
2513 printf("slic_ring_test_thread create fail\n");
2514 }
2515
2516 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2517 g_Cc_CallDetail.evt[slave]= ZCC_NO_E;
2518 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
2519 g_Cc_CallDetail.state = ZCC_M_RINGING_S;
2520
2521 local_test_call_st = LocalTestCallST_Ring;
2522 zCc_ShowAllSlaveWithTips("testCall-ring");
2523 break;
2524 }
2525 else if(local_test_call_st==LocalTestCallST_End)
2526 {
2527 zCc_ClearDigits();
2528 zCc_InitSlaveObj(0);
2529 for (slave = 1; slave < ZCC_SLAVES; slave++)
2530 {
2531 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
2532 zCc_InitSlaveObj(slave);
2533 }
2534
2535 SLIC_Stop_Signal(0, TONE_SIGNAL);
2536 SLIC_Stop_PCM();
2537 zCc_SetLedStatus("ledoff");
2538
2539 g_Cc_CallDetail.resourceReady = 0;
2540 g_Cc_CallDetail.hookofffg = FALSE;
2541 g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
2542
2543 //system("echo loop_0 >> /tmp/log.ccapp.vploop");
2544 //system("( sleep 1 && at_cmd AT+VPLOOP=0 ) &");
2545 cfg_set("tz_vploop", "0");
2546 ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL,
2547 MODULE_ID_AT_CTL,
2548 MSG_CMD_SET_VPLOOP_REQ,
2549 0,
2550 NULL,
2551 0);
2552
2553 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);
2554 DeleteSoftTimer(ZCCAPP_TIMER_DTMF_DETECT);
2555 DeleteSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT);
2556 DeleteSoftTimer(ZCCAPP_TIMER_TKYTONE_DETECT);
2557 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
2558 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);
2559
2560 local_test_call_st = LocalTestCallST_None;
2561 zCc_ShowAllSlaveWithTips("testCall-end-none");
2562 break;
2563 }
2564
2565 for (slave = 1; slave < ZCC_SLAVES; slave++)
2566 {
2567 if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
2568 {
2569 g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
2570 }
2571 }
2572 //if(slave == ZCC_SLAVES)
2573 // return;
2574 if (g_Cc_CallDetail.slaveObj[0].state != ZCC_S_IDLE_S)//slave0½öÓÃÓÚ·ÅÒô£¬²»¶ÔÓ¦ºô½Ð
2575 {
2576 zCc_InitSlaveObj(0);
2577 }
2578 SLIC_Stop_Signal(0, TONE_SIGNAL);
2579 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2580 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2581 //g_Cc_CallDetail.chupSent = FALSE;
2582 //SLIC_Stop_PCM();
2583 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_PCM <---\n",__FUNCTION__);
2584
2585#ifndef TEST_CCAPP
2586
2587
2588 cfg_get_item("voip_status",voip_status,sizeof(voip_status));
2589
2590 if (0 != strcmp("ledoff" , voip_status ))
2591#endif
2592 {
2593 zCc_SetLedStatus("ledoff");
2594 }
2595 g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
2596 if (!(0 != zCc_GetSpecSlave(ZCC_S_TRYING_S) && (1 == zCc_CallCount())))//Õª»úʱµÄÀ´µç£¬²»Çå
2597 {
2598 g_Cc_CallDetail.resourceReady = 0;
2599 }
2600 zCc_ClearDigits();
2601 g_Cc_CallDetail.hookofffg = FALSE;
2602 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);//ÊÕµ½ÉÁ¶Ï£¬µ±Ç°¶¨Ê±Æ÷¶¼ÐèҪֹͣ£¬ºóÐøÔÙÆô¶¯
2603 DeleteSoftTimer(ZCCAPP_TIMER_DTMF_DETECT);
2604 DeleteSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT);
2605 DeleteSoftTimer(ZCCAPP_TIMER_TKYTONE_DETECT);
2606 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
2607
2608 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);
2609 for (slave = 1; slave < ZCC_SLAVES; slave++)
2610 {
2611 g_Cc_CallDetail.slaveObj[slave].idle_second = 0;//hook off ldle timer is killed, time_cnt reset
2612 }
2613
2614 break;
2615 case ZCC_BUSYTONETIMER_E:
2616 for (slave = 0; slave < ZCC_SLAVES; slave++)
2617 {
2618 if(g_Cc_CallDetail.slaveObj[slave].tone == ZCC_TONE_BSY_A)
2619 break;
2620 }
2621 if(slave == ZCC_SLAVES)
2622 return;
2623 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_TKY_A;
2624 CreateSoftTimer(ZCCAPP_TIMER_TKYTONE_DETECT,
2625 0,
2626 ZCCAPP_TIMER_TKYTONE_INTERVAL,
2627 zCcApp_TkyToneTimer,
2628 NULL);
2629 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState CreateSoftTimer zCcApp_TkyToneTimer\n",__FUNCTION__);
2630 if (!(0 == zCc_GetSpecSlave(ZCC_S_BSYT_S)
2631 &&(g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_WAIT_RESOURCE_S
2632 ||g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_TRYING_S)
2633 && g_Cc_CallDetail.lastTone == ZCC_TONE_BSY_A))
2634 {
2635 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TKYT_S;
2636 }
2637 return;
2638 case ZCC_HOOKOFFTIMER_E:
2639 for (slave = 0; slave < ZCC_SLAVES; slave++)
2640 {
2641 if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DT_S)
2642 break;
2643 }
2644 if(slave == ZCC_SLAVES)
2645 return;
2646 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
2647 {
2648 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
2649 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
2650 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
2651 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
2652 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
2653 0,
2654 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
2655 zCcApp_BusyToneTimer,
2656 NULL);
2657 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState CreateSoftTimer zCcApp_BusyToneTimer22222\n",__FUNCTION__);
2658 }
2659 else
2660 {
2661 zCc_InitSlaveObj(slave);
2662 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
2663 }
2664 return;
2665 case ZCC_HOOKOFF_IDLE_TIMER_E:
2666 for (slave = 0; slave < ZCC_SLAVES; slave++)
2667 {
2668 if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DT_S)
2669 {
mj.qu58875012025-06-19 02:45:53 -07002670 if(0 == strcmp(callback_enable, "1") && 1 == check_phone_number_in_file(callback_number, "/cache/call_back_list"))
2671 {
2672 if(strlen(callback_number) <=0 )
2673 {
2674 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);
2675 break;
2676 }
2677
2678 strcpy(g_Cc_CallDetail.digits, callback_number);
2679 g_Cc_CallDetail.dCount = strlen(callback_number);
2680
2681 MSG_BUF msgBuf = {0};
2682 msgBuf.usMsgCmd = ZCC_DTMF_E;
2683 msgBuf.src_id = MODULE_ID_SLIC;
2684 msgBuf.aucDataBuf[0] = (UINT8)'#';
2685 msgBuf.usDataLen = 1;
2686 zCc_SendMsgToSub(&msgBuf);
2687
2688 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
2689 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
2690
2691 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);
2692
2693 ccapp_log("==> HOOKOFF_IDLE_TIMER send callback_number=%s\n", callback_number);
2694
2695 break;
2696 }
2697
mj.qu8ddc7642025-06-11 04:37:19 -07002698 cfg_get_item("hotline_time", hotline_time, sizeof(hotline_time));
mj.qu1524fc92025-06-11 04:34:13 -07002699 g_Cc_CallDetail.slaveObj[slave].idle_second++;
mj.qu8ddc7642025-06-11 04:37:19 -07002700 if(g_Cc_CallDetail.slaveObj[slave].idle_second >= atoi(hotline_time) * 2)
mj.qu1524fc92025-06-11 04:34:13 -07002701 {
2702 int rt;
2703 char hotline[ZDIAL_NUM_MAX-1];
2704
2705 memset(hotline, 0, sizeof(hotline));
mj.qu8ddc7642025-06-11 04:37:19 -07002706 rt = cfg_get_item("hotline_number", hotline, sizeof(hotline)-1);
mj.qu1524fc92025-06-11 04:34:13 -07002707 if(rt!=0 || strlen(hotline)<=0)
2708 {
2709 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);
2710 break;
2711 }
2712
2713 strcpy(g_Cc_CallDetail.digits, hotline);
2714 g_Cc_CallDetail.dCount = strlen(hotline);
2715
2716 MSG_BUF msgBuf = {0};
2717 msgBuf.usMsgCmd = ZCC_DTMF_E;
2718 msgBuf.src_id = MODULE_ID_SLIC;
2719 msgBuf.aucDataBuf[0] = (UINT8)'#';
2720 msgBuf.usDataLen = 1;
2721 zCc_SendMsgToSub(&msgBuf);
2722
2723 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
2724 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
2725
2726 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);
2727
2728 ccapp_log("==> HOOKOFF_IDLE_TIMER send hotline=%s\n", hotline);
2729 }
2730 }
2731 }
2732 break;
2733 case ZCC_DTMFTIMER_E:
2734 for (slave = 0; slave < ZCC_SLAVES; slave++)
2735 {
2736 if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DACCM_S)
2737 break;
2738 }
2739 if(slave == ZCC_SLAVES)
2740 return;
2741 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_TIMEOUT_SIGN;
2742 ret = zCc_DigitsMatch();
2743 zCc_DigitsMatchRltProc(ret);
2744 if (ZCC_MATCHERR != ret)
2745 {
2746 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_IDLE_S)//ss
2747 {
2748 zCc_SendSsReq(g_Cc_CallDetail.digits);
2749 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
2750 }
2751 else
2752 {
2753 zCc_SendAtDialReq(g_Cc_CallDetail.digits);
2754 }
2755 }
2756 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
2757 zCc_ClearDigits();
2758 return;
2759 case ZCC_TKYTIMER_E:
2760 for (slave = 0; slave < ZCC_SLAVES; slave++)
2761 {
2762 if(g_Cc_CallDetail.slaveObj[slave].tone == ZCC_TONE_TKY_A)
2763 break;
2764 }
2765 if(slave == ZCC_SLAVES)
2766 return;
2767 SLIC_Stop_Signal(0, TONE_SIGNAL);
2768 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2769 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
2770 if (!(0 == zCc_GetSpecSlave(ZCC_S_TKYT_S)
2771 &&(g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_WAIT_RESOURCE_S
2772 ||g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_TRYING_S)
2773 && g_Cc_CallDetail.lastTone == ZCC_TONE_TKY_A))
2774 {
2775 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_SIL_S;
2776 }
2777 g_Cc_CallDetail.lastTone = ZCC_TONE_SIL_A;
2778 return;
2779 case ZCC_SSDIALTONETIMER_E:
2780 zCc_InitSlaveObj(0);//·Å²¦ºÅÒôµÄslave0 Çå¿Õ
2781 zCc_ClearDigits();
2782 if (1 == zCc_CallCount()
2783 && (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A))//µ±Ç°Ö»ÓÐһ·£¬Í£Ö¹²¦ºÅÒô
2784 {
2785 SLIC_Stop_Signal(0,0);
2786 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2787 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2788 if (1 == zCc_HeldCall())//Òѱ£³Ö£¬»Ö¸´
2789 {
2790 chldret = zCc_SendAtChldReq(2);
2791 }
2792 else if (0 != zCc_ActiveCall())
2793 {
2794 SLIC_Start_PCM();
2795 }
2796 }
2797 else if (1 < zCc_CallCount() && (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A))//active/held mpty and held+waiting
2798 {
2799 SLIC_Stop_Signal(0,0);
2800 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2801 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2802 if((0 == zCc_HeldCall() && 0 != g_Cc_CallDetail.ringCid)//active+waiting »Ö¸´ÓïÒô£¬held+waiting, ²»»Ö¸´ÓïÒô£¬·Åºô½ÐµÈ´ýÒô
2803 ||(0 != zCc_HeldCall() && 0 !=zCc_ActiveCall()))//active+held»Ö¸´ÓïÒô
2804 {
2805 SLIC_Start_PCM();
2806 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Start_PCM <---\n",__FUNCTION__);
2807 }
2808 }
2809 return;
2810 case ZCC_FLASH_E:
2811 ccapp_log("ZCC_FLASH_E cnt=%d held=%d active=%d BefDial=%d",
2812 zCc_CallCount(),
2813 zCc_HeldCall(),
2814 zCc_ActiveCall(),
2815 zCc_MoBeforDialingCall());
2816
2817 if (!(zCc_CallCount() > 1 && g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN))//¶à·ºô½Ðʱ£¬ÐèÒªÅжÏflashÁ¬·¢Á½´ÎµÄ³¡¾°£¬²»Çå³ý
2818 {
2819 zCc_ClearDigits();
2820 }
2821 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);//ÊÕµ½ÉÁ¶Ï£¬µ±Ç°¶¨Ê±Æ÷¶¼ÐèҪֹͣ£¬ºóÐøÔÙÆô¶¯
2822 DeleteSoftTimer(ZCCAPP_TIMER_DTMF_DETECT);
2823 DeleteSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT);
2824 DeleteSoftTimer(ZCCAPP_TIMER_TKYTONE_DETECT);
2825 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
2826
2827 callCnt = zCc_CallCount();
2828
2829 if (g_Cc_CallDetail.ringCid && (g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone == ZCC_TONE_CIDCW_A))//ºô½ÐµÈ´ý£¬¸ù¾ÝflashºóÃæµÄ×Ö·û¾ö¶¨ºóÐø²Ù×÷
2830 {
2831 if(g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
2832 {
2833 zCc_InitSlaveObj(0);
2834 zCc_ClearDigits();
2835 SLIC_Stop_Signal(0,0);
2836 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2837 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2838 if (0 != zCc_ActiveCall())
2839 {
2840 SLIC_Start_PCM();
2841 }
2842 break;
2843 }
2844 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
2845 // slave[0] to play dial tone
2846 CreateSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT,
2847 0,
2848 ZCCAPP_TIMER_HOOKOFF_INTERVAL,
2849 zCcApp_SsDialToneTimer,
2850 NULL);
2851 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: CreateSoftTimer zCcApp_SsDialToneTimer\n",__FUNCTION__);
2852 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
2853 //g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone = ZCC_TONE_OFF_A;±£Áô¸Ã×ֶΣ¬ÓÃÓÚflash4µÈʧ°Üʱ»Ö¸´ºô½ÐµÈ´ýÒô
2854 SLIC_Stop_PCM();
2855 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_PCM2222\n",__FUNCTION__);
2856 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
2857 break;
2858 }
2859
2860 if ( callCnt==0 //·Å²¦ºÅÒô»¹Î´Íê³É²¦ºÅ»òÕª»ú䲦ºÅ·ÅæÒôº¿ÃùÒô¾²Òô
2861 ||(callCnt ==1 && zCc_FlashClearCall() > 0)) //ÕÒµ½½¨Á¢ÖеÄÖ÷½ÐÒÔ¼°ÊÍ·ÅÖеĺô½Ð£¬ÊÍ·Å£¬²¢·Å²¦ºÅÒô
2862 {
2863 zCc_InitSlaveObj(0);
2864 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
2865 SLIC_Stop_PCM();
2866 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
2867 g_Cc_CallDetail.hookofffg = TRUE;
2868 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
2869 break;
2870 }
2871
2872 if (zCc_ActiveCall() == callCnt) //Ö»ÓÐactive call£¬±£³ÖËü£¬²¢·Å²¦ºÅÒô
2873 {
2874 if (callCnt > 1) // conf call, ·Å²¦ºÅÒô
2875 {
2876 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
2877 g_Cc_CallDetail.digits[ZDIAL_NUM_MAX-1] = 1;// ¼Ç¼±¾´Î²Ù×÷ΪÕë¶Ôconf µÄ
2878 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
2879 }
2880 else
2881 {
2882 chldret = zCc_SendAtChldReq(2);
2883 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
2884 g_Cc_CallDetail.waitchldresult = 1;
2885 }
2886 break;
2887 }
2888
2889 if (zCc_HeldCall() == callCnt) //Ö»ÓÐheld call£¬»Ö¸´
2890 {
2891 if (callCnt == 1 )
2892 {
2893 chldret = zCc_SendAtChldReq(2);
2894 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
2895 }
2896 else
2897 {
2898 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
2899 CreateSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT,
2900 0,
2901 ZCCAPP_TIMER_HOOKOFF_INTERVAL,
2902 zCcApp_SsDialToneTimer,
2903 NULL);
2904 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:CreateSoftTimer zCcApp_SsDialToneTimer\n",__FUNCTION__);
2905 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
2906
2907 }
2908 break;
2909 }
2910 //active + held
2911
2912 if(g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
2913 {
2914 zCc_InitSlaveObj(0);
2915 zCc_ClearDigits();
2916 SLIC_Stop_Signal(0,0);
2917 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
2918 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
2919 if (0 != zCc_ActiveCall())
2920 {
2921 SLIC_Start_PCM();
2922 }
2923 break;
2924 }
2925
2926 /*
2927 zCc_MSeizeState befor=1 act=0 held=1 callCnt=2
2928 zCc_MoBeforDialingCall slave[1]=8
2929 zCc_MoBeforDialingCall slave[2]=4
2930 */
2931 ccapp_log("ZCC_FLASH_E befor=%d active=%d held=%d callCnt=%d",
2932 zCc_MoBeforDialingCall(),
2933 zCc_ActiveCall(),
2934 zCc_HeldCall(),
2935 callCnt);
2936
2937 if (((0 != zCc_MoBeforDialingCall())
2938 && (0 != zCc_ActiveCall() || 0 != zCc_HeldCall())) //active or held + ½¨Á¢Öеĺô½Ð
2939 ||(0 != zCc_MoBeforDialingCall() && 1 == callCnt))
2940 {
2941 /*if(g_Cc_CallDetail.digits[0]==ZCC_FLASH_SIGN &&
2942 strlen(g_Cc_CallDetail.digits)<=3)
2943 {
2944 zCc_InitSlaveObj(0);
2945 zCc_ClearDigits();
2946 zCc_SendAtChldReq(2);
2947 ccapp_log("get ZCC_FLASH_SIGN and return to old talk");
2948 }*/
2949
2950 int cid = zCc_GetMoBeforDialingCallCID();
2951 if(cid>=0 && zCc_HeldCall()!=0) // drop the beforeDialing call
2952 {
2953 zCc_InitSlaveObj(cid);
2954 zCc_ClearDigits();
2955 zCc_SendAtChldReq(1);
2956 ccapp_log("drop the beforeDialing call cid=%d", cid);
2957 }
2958
2959 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E return\n",__FUNCTION__);
2960 return;
2961 }
2962
2963 g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
2964 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
2965 CreateSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT,
2966 0,
2967 ZCCAPP_TIMER_HOOKOFF_INTERVAL,
2968 zCcApp_SsDialToneTimer,
2969 NULL);
2970 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:CreateSoftTimer zCcApp_SsDialToneTimer\n",__FUNCTION__);
2971 SLIC_Stop_PCM();
2972 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
2973 break;
2974
2975 case ZCC_RESOURCE_READY_E:
2976 g_Cc_CallDetail.evt[slave] = ZCC_RESOURCE_READY_E;
2977 break;
2978 /*ATÃüÁîÏìÓ¦£¬Ä¿Ç°Ö»ÓÐatdµÄÏìÓ¦ÐèÒª´¦Àí*/
2979 case MSG_CMD_ATD_DIAL_RSP:
2980 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ATD_rsp=%d\n",__FUNCTION__,((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result);
2981 if(((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result == 0)
2982 break;
2983 slave = zCc_GetDialingSlave(1);
2984 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq:RECV ERROR\n",__FUNCTION__);
2985 slave = zCc_GetDialingSlave(1);
2986 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
2987 {
2988 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
2989 0,
2990 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
2991 zCcApp_BusyToneTimer,
2992 NULL);
2993 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
2994 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
2995 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
2996 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
2997 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
2998 }
2999 else
3000 {
3001 char num[ZDIAL_NUM_MAX+1];
3002 strcpy(num, g_Cc_CallDetail.slaveObj[slave].number);
3003
3004 zCc_InitSlaveObj(slave);
3005 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3006
3007 if(zCc_find_held_cid()|| zCc_find_held_incoming_cid()) // restore prvious talk to active
3008 {
3009 zCc_SendAtChldReq(2);
3010
3011 char temp[200];
3012 sprintf(temp, "echo \"%s get error dialout cid=%d num=%s\" > /tmp/log.ccapp.callout.err",
3013 get_local_date_time(), slave, num);
3014 soft_system(temp);
3015 }
3016 }
3017 break;
3018 /*case MSG_CMD_ATA_RSP:
3019 case MSG_CMD_CHUP_RSP:
3020 case MSG_CMD_VTS_RSP:
3021 case MSG_CMD_ZIMSPLUS_RSP:
3022 case MSG_CMD_CCFC_RSP:
3023 case MSG_CMD_CLCK_RSP:
3024 break;*/
3025 case MSG_CMD_CHLD_RSP:
3026 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s CHLD_rsp=%d\n",__FUNCTION__,((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result);
3027 if(g_Cc_CallDetail.waitchldresult == 1 )
3028 {
3029 g_Cc_CallDetail.waitchldresult = 0;
3030 if (((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result == 0)
3031 {
3032 CreateSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT,
3033 0,
3034 ZCCAPP_TIMER_HOOKOFF_INTERVAL,
3035 zCcApp_SsDialToneTimer,
3036 NULL);
3037 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:CreateSoftTimer zCcApp_SsDialToneTimer\n",__FUNCTION__);
3038 g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
3039 SLIC_Stop_PCM();
3040 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
3041 }
3042 }
3043 break;
3044
3045 case ZCC_SEIZE_E: // ͻȜ
3046 default:
3047 // do nothing
3048 break;
3049 }
3050}
3051
3052
3053//get local time string , format"YYYY-MM-DD HH:MM:SS"
3054char *get_local_date_time(void)
3055{
3056 time_t now;
3057 struct tm *timenow;
3058 static char localtimestr[32];
3059
3060 time(&now);
3061 timenow = localtime(&now);
3062 memset(localtimestr, 0, 32);
3063 if(timenow)
3064 snprintf(localtimestr, 32, "%04d-%02d-%02d %02d:%02d:%02d",
3065 timenow->tm_year + 1900, timenow->tm_mon+1, timenow->tm_mday,
3066 timenow->tm_hour, timenow->tm_min, timenow->tm_sec);
3067 return localtimestr;
3068}
3069
3070
3071//get local time string , format"MMDDHHMM"
3072char *get_local_datetime(char *buff)
3073{
3074 time_t now;
3075 struct tm *timenow;
3076 static char localtimestr[48];
3077
3078 memset(localtimestr, 0, sizeof(localtimestr));
3079
3080 time(&now);
3081 timenow = localtime(&now);
3082 if(timenow)
3083 sprintf(localtimestr, "%02d%02d%02d%02d",
3084 timenow->tm_mon+1, timenow->tm_mday,
3085 timenow->tm_hour, timenow->tm_min);
3086
3087 if(buff!=NULL)
3088 strcpy(buff, localtimestr);
3089
3090 return localtimestr;
3091}
3092
3093
3094int zCc_find_held_cid(void)
3095{
3096 int slavetmp;
3097
3098 for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
3099 {
3100 if (g_Cc_CallDetail.slaveObj[slavetmp].heldcall!=0)
3101 {
3102 return slavetmp;
3103 }
3104 }
3105
3106 return 0;
3107}
3108
3109int zCc_talking_count(void)
3110{
3111 int cnt = 0;
3112 int slavetmp;
3113
3114 for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
3115 {
3116 if (g_Cc_CallDetail.slaveObj[slavetmp].state==ZCC_S_TALKING_S)
3117 cnt++;
3118 }
3119
3120 return cnt;
3121}
3122
3123
3124int zCc_find_held_incoming_cid(void)
3125{
3126 int slavetmp;
3127
3128 for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
3129 {
3130 if (g_Cc_CallDetail.slaveObj[slavetmp].state==ZCC_S_TRYING_S)
3131 {
3132 return slavetmp;
3133 }
3134 }
3135
3136 return 0;
3137}
3138
3139
3140int zCc_find_all_callout(int slave[ZCC_SLAVES])
3141{
3142 int n=0;
3143
3144 int i;
3145 for (i = 1; i < ZCC_SLAVES; i++)
3146 {
3147 if (g_Cc_CallDetail.slaveObj[i].is_callout!=0)
3148 {
3149 slave[n] = i;
3150 n++;
3151 }
3152 }
3153
3154 return n;
3155}
3156
3157
3158void zCc_hungup_all(int slave)
3159{
3160 int slavetmp;
3161 if (!g_Cc_CallDetail.chupSent)
3162 {
3163 zCc_SendAtHangupReq();
3164 for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
3165 {
3166 if (g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_DIALING_S
3167 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_RINGBACK_S
3168 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TALKING_S
3169 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TRYING_S
3170 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_WAIT_RESOURCE_S)
3171 {
3172 g_Cc_CallDetail.slaveObj[slavetmp].waitDSCI6 = 1;
3173 }
3174 }
3175 if (!((zCc_CallCount() == 1) && ((ZCC_S_DACCM_S == g_Cc_CallDetail.slaveObj[slave].state)
3176 || (ZCC_S_DIALING_S == g_Cc_CallDetail.slaveObj[slave].state)))
3177 && !((zCc_CallCount() > 1) && (0 != zCc_MtInactiveCall()) && (0 != zCc_MoInactiveCall())))//·Çidle״̬¶¼ÊÇÕª»ú̬ÊÕµ½À´µçÇҾܽÓÀ´µç
3178 {
3179 g_Cc_CallDetail.chupSent = TRUE;//»¹ÓÐÆäËûºô½Ð£¬²»ÔÙÖØ¸´·¢chup
3180 }
3181 }
3182}
3183
3184VOID zCc_RunMaster(MSG_BUF *ptMsgBuf)
3185{
3186 UINT8 slave = 0;
3187 UINT8 slavetmp = 0;
3188 SIGNAL_DATA tSig;
3189 int held_call_cid;
3190 int incoming_call_cid;
3191
3192 static int old_state = -1;
3193 if(old_state != g_Cc_CallDetail.state)
3194 {
3195 ccapp_log("=======================\n");
3196 ccapp_log("zCc_RunMaster state %d --> %d\n", old_state, g_Cc_CallDetail.state);
3197 old_state = g_Cc_CallDetail.state;
3198 }
3199
3200 memset(tSig.cid, 0, 32);
3201
3202 zCc_CheckSlaveState("start zCc_RunMaster");
3203 switch (g_Cc_CallDetail.state)
3204 {
3205 case ZCC_M_RELEASE_S:
3206 zCc_MReleaseState(ptMsgBuf);
3207 break;
3208
3209 case ZCC_M_RINGING_S:
3210 zCc_MRingingState(ptMsgBuf);
3211 break;
3212
3213 case ZCC_M_SEIZE_S:
3214 default:
3215 zCc_MSeizeState(ptMsgBuf);
3216 break;
3217 }
3218
3219 zCc_CheckSlaveState("in zCc_RunSlave");
3220 /* Now run the slaves. Since the slaves will always be run with the master , run them now. */
3221 for (slave = 0; slave < ZCC_SLAVES; slave++)
3222 {
3223 zCc_RunSlave(slave);
3224 g_Cc_CallDetail.evt[slave] = ZCC_NO_E;
3225 }
3226
3227
3228 /* Process sMsg. */
3229 for (slave = 1; slave < ZCC_SLAVES; slave++)
3230 {
3231 if(g_Cc_CallDetail.slaveObj[slave].sMsg!=ZCC_SNO_M)
3232 {
3233 zCc_CheckSlaveState("in slaveObj[slave].sMsg");
3234 ccapp_log("g_Cc_CallDetail.slaveObj[%d].sMsg=%d",
3235 slave,
3236 g_Cc_CallDetail.slaveObj[slave].sMsg);
3237 }
3238
3239 switch (g_Cc_CallDetail.slaveObj[slave].sMsg)
3240 {
3241 case ZCC_SINV_M:
3242 if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_IDLE_S)//ss
3243 {
3244 zCc_SendSsReq(g_Cc_CallDetail.digits);
3245 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3246 }
3247 else
3248 {
3249 zCc_SendAtDialReq(g_Cc_CallDetail.digits);
3250 }
3251 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3252 zCc_ClearDigits();
3253 break;
3254 case ZCC_SDTMF_M:
3255 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ZCC_SDTMF_M handling ptMsgBuf->aucDataBuf[0] = %d\n",__FUNCTION__,ptMsgBuf->aucDataBuf[0]);
3256 zCc_SendAtDtmfReq((char*)(&(ptMsgBuf->aucDataBuf[0])));
3257 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3258 if(g_Cc_CallDetail.waitchldresult == 0)//chld´¦Àí¹ý³ÌÖв»Çå³ý²¦ºÅ°´¼üadd by zpr
3259 zCc_ClearDigits();
3260 break;
3261 case ZCC_SRING_M:
3262 if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)// && g_Cc_CallDetail.ringCid)
3263 {
3264 g_Cc_CallDetail.state = ZCC_M_RINGING_S;
3265 memset(&tSig, 0, sizeof(tSig));
3266 tSig.signal_type = RING_SIGNAL;
3267 //memcpy(tSig.cid, g_Cc_CallDetail.number, strlen(g_Cc_CallDetail.number));
3268 strncpy(tSig.cid, g_Cc_CallDetail.number, sizeof(tSig.cid)-1);
3269 get_local_datetime(tSig.date_time);
3270 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_RunMaster RING_SIGNAL,number = %s\n",__FUNCTION__,g_Cc_CallDetail.number);
3271 SLIC_Play_Signal(0, 0, &tSig);
3272 zCc_SetLedStatus("ledblink");
3273 }
3274 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3275 break;
3276 case ZCC_SANS_M://ʲô³¡¾°?
3277 if (zCc_CallCount() == 1)
3278 {
3279 SLIC_Stop_Signal(0, TONE_SIGNAL);
3280 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s : SLIC_Stop_Signal <---\n",__FUNCTION__);
3281 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3282 }
3283 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3284 break;
3285 case ZCC_SDISCN_M:
3286 held_call_cid = zCc_find_held_cid();
3287 incoming_call_cid = zCc_GetSpecSlave(ZCC_S_TRYING_S);
3288 ccapp_log("ZCC_SDISCN_M held_call_cid=%d incoming_call_cid=%d chupSent=%d",
3289 held_call_cid,
3290 incoming_call_cid,
3291 g_Cc_CallDetail.chupSent);
3292
3293 if((held_call_cid!=0 ||incoming_call_cid!=0) && g_Cc_CallDetail.chupSent==FALSE)
3294 {
3295 int active_call_cid = 0;
3296
3297 for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
3298 {
3299 if( (g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_DIALING_S
3300 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_RINGBACK_S
3301 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TALKING_S
3302// || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TRYING_S // incoming_call_cid
3303 || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_WAIT_RESOURCE_S) &&
3304 g_Cc_CallDetail.slaveObj[slavetmp].heldcall==0)
3305 {
3306 active_call_cid = slavetmp;
3307 break;
3308 }
3309 }
3310
3311 ccapp_log("ZCC_SDISCN_M active_call_cid=%d", active_call_cid);
3312
3313 if(active_call_cid!=0)
3314 {
3315 zCc_SendAtChldReq(10+active_call_cid);
3316
3317 g_Cc_CallDetail.chupSent = TRUE;
3318 g_Cc_CallDetail.state = ZCC_M_RINGING_S;
3319
3320 /*MSG_BUF msgBuff = {0}; // let while(1) run one more time
3321 msgBuff.usMsgCmd = ZCC_ASSIST_MSG_E;
3322 msgBuff.src_id = MODULE_ID_SLIC;
3323 zCc_SendMsgToSub(&msgBuff);
3324
3325 ccapp_log("sendMsg ZCC_ASSIST_MSG_E"); */
3326 }
3327 else
3328 {
3329 zCc_hungup_all(slave);
3330 }
3331 }
3332 else
3333 {
3334 zCc_hungup_all(slave);
3335 }
3336
3337 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3338 break;
3339 default:
3340 break;
3341 }
3342 }
3343
3344 if (g_Cc_CallDetail.state == ZCC_M_RINGING_S
3345 && g_Cc_CallDetail.ringCid == 0
3346 && zCc_find_held_cid()==0
3347 && zCc_find_held_incoming_cid()==0
3348 && local_test_call_st==0)
3349 {
3350 g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
3351 SLIC_Stop_Signal(0, RING_SIGNAL);
3352 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s : SLIC_Stop_Signal <---\n",__FUNCTION__);
3353 }
3354 /*else if (g_Cc_CallDetail.state == ZCC_M_SEIZE_S && g_Cc_CallDetail.ringCid > 0 && zCc_CallCount() == 1)
3355 {
3356 //תΪ½ÓÌý
3357 ¹Ò»úºó¿ÉÒÔÖªµÀÀ´µç²¢½ÓÌý£¬ÎÞÐèÌØÊâ´¦Àí¡£
3358 }*/
3359 zCc_ControlTone();
3360
3361 // ´¦Àíslave·µ»ØµÄÏûÏ¢
3362 zCc_CheckSlaveState("End zCc_RunMaster");
3363}
3364
3365VOID zCc_RunSlave(UINT8 slave)
3366{
3367 if (g_Cc_CallDetail.evt[slave] == ZCC_NO_E)
3368 {
3369 return;
3370 }
3371
3372 /* Call respective state function based on the current state. */
3373 printf("[ccapp_debug]:Slave Run,slave:%d, state=%d,event=%d\n", slave, g_Cc_CallDetail.slaveObj[slave].state,g_Cc_CallDetail.evt[slave]);
3374 zCcSlaveFsmFunc[g_Cc_CallDetail.slaveObj[slave].state](slave);
3375}
3376
3377VOID zCc_SIdleState(UINT8 slave)
3378{
3379 UINT8 tmpslave = 0;
3380 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave,g_Cc_CallDetail.evt[slave]);
3381 g_Cc_CallDetail.slaveObj[slave].cid = slave;
3382 switch (g_Cc_CallDetail.evt[slave])
3383 {
3384 case ZCC_DIAL_E:
3385 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_DIAL_A;
3386 g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN ? ZCC_S_DT_S : ZCC_S_DACCM_S;
3387
3388 if (g_Cc_CallDetail.hookofffg == TRUE)
3389 {
3390 g_Cc_CallDetail.hookofffg = FALSE;
3391 CreateSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT,
3392 0,
3393 ZCCAPP_TIMER_HOOKOFF_INTERVAL,
3394 zCcApp_HookOffTimer,
3395 NULL);
3396 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState CreateSoftTimer zCcApp_HookOffTimer\n",__FUNCTION__);
3397
3398 g_Cc_CallDetail.slaveObj[slave].idle_second = 0;
3399 CreateSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE,
3400 TIMER_FLAG_RESTART,
3401 ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL,
3402 zCcApp_HookOff_Idle_Timer,
3403 NULL);
3404 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState CreateSoftTimer zCcApp_HookOff_Idle_Timer\n",__FUNCTION__);
3405 }
3406 break;
3407 case ZCC_DTMF_E://held+dailing
3408 if ( 0 != zCc_HeldCall() && 0 == zCc_ActiveCall())
3409 {
3410 DeleteSoftTimer(ZCCAPP_TIMER_SSDIALTONE_DETECT);
3411 CreateSoftTimer(ZCCAPP_TIMER_DTMF_DETECT,
3412 0,
3413 ZCCAPP_TIMER_DTMF_INTERVAL,
3414 zCcApp_DtmfTimer,
3415 NULL);
3416 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState CreateSoftTimer zCcApp_DtmfTimer\n",__FUNCTION__);
3417 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
3418 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
3419 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState handling ZCC_DTMF_E\n",__FUNCTION__);
3420 }
3421 break;
3422 case ZCC_CIDCW_E:
3423 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
3424 //lint -fallthrough
3425 case ZCC_SINVITE_E:
3426 zCc_ShowAllSlaveWithTips("zCc_SIdleState");
3427 if (((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾ­Ï·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
3428 || (0 != zCc_MoInactiveCall()))//
3429 {
3430 //zCc_InitSlaveObj(slave);¼ÌÐøµÈdsci6Éϱ¨
3431 g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
3432 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3433 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3434 return;
3435 }
3436
3437 g_Cc_CallDetail.ringCid = slave;
3438 if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
3439 g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
3440 else
3441 g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
3442 strcpy(g_Cc_CallDetail.slaveObj[slave].number, g_Cc_CallDetail.number);
3443
3444 if (g_Cc_CallDetail.resourceReady == 1)
3445 {
3446 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3447 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
3448 }
3449 else
3450 {
3451 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
3452 }
3453 break;
3454
3455 case ZCC_SRING_E://cid²»Æ¥ÅäµÄ³¡¾°
3456 tmpslave = zCc_GetDialingSlave(0);
3457 if (0 == tmpslave )
3458 {
3459 return;
3460 }
3461 g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
3462 zCc_InitSlaveObj(tmpslave);
3463 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_RINGBACK_S;
3464 break;
3465 case ZCC_SDISCN_MO_E://cid²»Æ¥ÅäµÄ³¡¾°
3466 tmpslave = zCc_GetDialingSlave(0);
3467 if (0 == tmpslave )
3468 {
3469 return;
3470 }
3471 g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
3472 zCc_InitSlaveObj(tmpslave);
3473 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, tmpslave);
3474 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0&& g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
3475 {
3476 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
3477 0,
3478 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
3479 zCcApp_BusyToneTimer,
3480 NULL);
3481 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
3482 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
3483 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
3484 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
3485 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
3486 }
3487 else
3488 {
3489 zCc_InitSlaveObj(slave);
3490 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3491 }
3492 return;
3493 default:
3494 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState:evt=%d\n",__FUNCTION__,g_Cc_CallDetail.evt[slave]);
3495 break;
3496 }
3497}
3498
3499VOID zCc_SDtState(UINT8 slave)
3500{
3501 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDtState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3502 switch (g_Cc_CallDetail.evt[slave])
3503 {
3504 case ZCC_DTMF_E:
3505 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_IDLE);
3506 g_Cc_CallDetail.slaveObj[slave].idle_second = 0;
3507
3508 DeleteSoftTimer(ZCCAPP_TIMER_HOOKOFF_DETECT);
3509
3510 CreateSoftTimer(ZCCAPP_TIMER_DTMF_DETECT,
3511 0,
3512 ZCCAPP_TIMER_DTMF_INTERVAL,
3513 zCcApp_DtmfTimer,
3514 NULL);
3515 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDtState CreateSoftTimer zCcApp_DtmfTimer\n",__FUNCTION__);
3516 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
3517 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
3518 break;
3519
3520 case ZCC_DISCN_E:
3521 //zCc_ClearDigits();
3522 zCc_InitSlaveObj(slave);
3523 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3524 return;
3525
3526 default://Ö»»áÊÇslave0£¬²»¿ÉÄÜÓëdsciµÄcid³åÍ»
3527 break;
3528 }
3529}
3530
3531VOID zCc_SDaccmState(UINT8 slave)
3532{
3533 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDaccmState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3534 UINT8 ret = 0;
3535 UINT8 tmpslave = 0;
3536
3537 switch (g_Cc_CallDetail.evt[slave])
3538 {
3539 case ZCC_DTMF_E:
3540 DeleteSoftTimer(ZCCAPP_TIMER_DTMF_DETECT);
3541 ret = zCc_DigitsMatch();
3542 break;
3543
3544 case ZCC_DISCN_E:
3545 zCc_ClearDigits();
3546 zCc_InitSlaveObj(slave);
3547 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3548 return;
3549 case ZCC_CIDCW_E:
3550 case ZCC_SINVITE_E://ÒÔdsciµÄcidΪ׼£¬ÖØÐ¸ømoµÄºô½Ð·ÖÅäidle cid
3551 tmpslave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
3552 if (0 == tmpslave )
3553 {
3554 return;
3555 }
3556 g_Cc_CallDetail.slaveObj[tmpslave] = g_Cc_CallDetail.slaveObj[slave];
3557 zCc_InitSlaveObj(slave);
3558 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3559 g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
3560 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDaccmState: reject mtcall\n",__FUNCTION__, slave);
3561 return;
3562 default:
3563 return;
3564 }
3565
3566 if(ret==ZCC_LOCAL_TEST_CALL)
3567 {
3568 SIGNAL_DATA tSig;
3569 if(zCc_talking_count())
3570 {
3571 zCc_ClearDigits();
3572 zCc_InitSlaveObj(slave);
3573 return;
3574 }
3575
3576 SLIC_Stop_Signal(0, TONE_SIGNAL);
3577 memset(&tSig, 0, sizeof(tSig));
3578 tSig.signal_type= TONE_SIGNAL;
3579 tSig.tone_type = TONE_CW;
3580 SLIC_Play_Signal(0, 0, &tSig);
3581
3582 zCc_ClearDigits();
3583
3584 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3585 g_Cc_CallDetail.evt[slave]= ZCC_NO_E;
3586 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
3587
3588 local_test_call_st = LocalTestCallST_Start;
3589
3590 zCc_ShowAllSlaveWithTips("testCall-start");
3591 return ;
3592 }
3593
3594 zCc_DigitsMatchRltProc(ret);
3595}
3596
3597VOID zCc_SDialingState(UINT8 slave)
3598{
3599 UINT8 tmpslave = 0;
3600 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3601 switch (g_Cc_CallDetail.evt[slave])
3602 {
3603 case ZCC_SRING_E:
3604 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_RINGBACK_S;
3605 break;
3606
3607 case ZCC_SANS_E:
3608 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3609 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
3610 SLIC_Stop_Signal(0, TONE_SIGNAL);
3611 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
3612 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3613 SLIC_Start_PCM();
3614 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState: SLIC_Start_PCM <---\n",__FUNCTION__);
3615 break;
3616
3617 case ZCC_DISCN_E:
3618 //zCc_InitSlaveObj(slave);
3619 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3620 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3621 return;
3622
3623 case ZCC_SDISCN_MO_E:
3624 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
3625 {
3626 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
3627 0,
3628 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
3629 zCcApp_BusyToneTimer,
3630 NULL);
3631 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
3632 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
3633 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
3634 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
3635 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
3636 }
3637 else
3638 {
3639 zCc_InitSlaveObj(slave);
3640 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3641 }
3642 return;
3643 case ZCC_SDISCN_MT_E:
3644 zCc_InitSlaveObj(slave);//Ö÷±»½Ð²¢·¢
3645 //g_Cc_CallDetail.slaveObj[slave].waitDSCI6 = 0;
3646 return;
3647 case ZCC_CIDCW_E:
3648 case ZCC_SINVITE_E://ÒÔdsciµÄcidΪ׼£¬ÖØÐ¸ømoµÄºô½Ð·ÖÅäidle cid
3649 tmpslave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
3650 if (0 == tmpslave )
3651 {
3652 return;
3653 }
3654 g_Cc_CallDetail.slaveObj[tmpslave] = g_Cc_CallDetail.slaveObj[slave];
3655 zCc_InitSlaveObj(slave);
3656 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3657 g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
3658 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDaccmState: reject mtcall\n",__FUNCTION__, slave);
3659 return;
3660
3661 default:
3662 return;
3663 }
3664}
3665
3666VOID zCc_SRingbackState(UINT8 slave)
3667{
3668 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3669 switch (g_Cc_CallDetail.evt[slave])
3670 {
3671 case ZCC_SANS_E:
3672 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3673 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
3674 SLIC_Stop_Signal(0, TONE_SIGNAL);
3675 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState: SLIC_Stop_Signal <---\n",__FUNCTION__);
3676 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3677
3678 if(g_Cc_CallDetail.slaveObj[slave].is_callout)
3679 SLIC_PolarityReverse(0, TRUE);
3680
3681 SLIC_Start_PCM();
3682 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Start_PCM2222\n",__FUNCTION__);
3683 break;
3684
3685 case ZCC_DISCN_E:
3686 //zCc_InitSlaveObj(slave);
3687 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3688 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3689 return;
3690
3691 case ZCC_SDISCN_MO_E:
3692 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
3693 {
3694 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
3695 0,
3696 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
3697 zCcApp_BusyToneTimer,
3698 NULL);
3699 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
3700 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
3701 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
3702 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
3703 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
3704 SLIC_Stop_PCM();
3705 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Stop_PCM\n",__FUNCTION__);
3706 }
3707 else
3708 {
3709 zCc_InitSlaveObj(slave);
3710 if ( 0 == zCc_ActiveCall() && 0 == zCc_HeldCall())
3711 {
3712 SLIC_Stop_PCM();
3713 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Stop_PCM\n",__FUNCTION__);
3714 }
3715 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3716 }
3717 return;
3718 case ZCC_SDISCN_MT_E:
3719 g_Cc_CallDetail.slaveObj[slave].waitDSCI6 = 0;
3720 return;
3721
3722 case ZCC_DTMF_E: // ²¦ºÅ
3723 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDTMF_M;///???
3724 return;
3725
3726 case ZCC_RESOURCE_READY_E:
3727 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3728 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState: SLIC_Stop_Signal <---\n",__FUNCTION__);
3729 SLIC_Stop_Signal(0, TONE_SIGNAL);
3730 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3731 SLIC_Start_PCM();//×ÊÔ´ÒÑ·ÖÅä£¬Íø²à·ÅÒô
3732 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Start_PCM\n",__FUNCTION__);
3733 return;
3734
3735 default:
3736 return;
3737 }
3738}
3739
3740VOID zCc_STalkingState(UINT8 slave)
3741{
3742 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STalkingState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3743 switch (g_Cc_CallDetail.evt[slave])
3744 {
3745 case ZCC_DISCN_E:
3746 //zCc_InitSlaveObj(slave);
3747 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3748 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3749 return;
3750
3751 case ZCC_SDISCN_MO_E:
3752 case ZCC_SDISCN_MT_E:
3753 //zCc_InitSlaveObj(slave);
3754 if (zCc_CallCount() >= 2 || g_Cc_CallDetail.state == ZCC_M_RELEASE_S)//»¹Ê£¶àÓÚһ·ºô½Ð
3755 {
3756 zCc_InitSlaveObj(slave);
3757 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3758 break;
3759 }
3760 if (g_Cc_CallDetail.slaveObj[0].tone != ZCC_TONE_OFF_A)
3761 {
3762 zCc_InitSlaveObj(0);
3763 }
3764 if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
3765 {
3766 CreateSoftTimer(ZCCAPP_TIMER_BUSYTONE_DETECT,
3767 0,
3768 ZCCAPP_TIMER_BUSYTONE_INTERVAL,
3769 zCcApp_BusyToneTimer,
3770 NULL);
3771 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STalkingState CreateSoftTimer zCcApp_BusyToneTimer\n",__FUNCTION__);
3772 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
3773 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
3774 g_Cc_CallDetail.slaveObj[slave].confcall = 0;
3775 g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
3776 }
3777 else
3778 {
3779 zCc_InitSlaveObj(slave);
3780 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3781 }
3782 return;
3783
3784 case ZCC_DTMF_E: // ²¦ºÅ. µ÷ÕûÒôÁ¿µÄ´¦Àí´ýÔö¼Ó
3785 if (g_Cc_CallDetail.slaveObj[slave].heldcall == 0)
3786 {
3787 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDTMF_M;///???
3788 }
3789 return;
3790 default:
3791 return;
3792 }
3793}
3794
3795VOID zCc_SWaitResourceState(UINT8 slave)
3796{
3797 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SWaitResourceState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3798 switch (g_Cc_CallDetail.evt[slave])
3799 {
3800 case ZCC_RESOURCE_READY_E:
3801 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3802 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
3803 break;
3804
3805 case ZCC_SDISCN_MT_E:
3806 zCc_InitSlaveObj(slave);
3807 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3808 return;
3809
3810 default:
3811 return;
3812 }
3813}
3814
3815VOID zCc_STryingState(UINT8 slave)
3816{
3817 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3818 switch (g_Cc_CallDetail.evt[slave])
3819 {
3820 case ZCC_CNCT_E:
3821 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SANS_M;
3822 //lint -fallthrough
3823 case ZCC_SANS_E: //CHLD=2, ÊÕµ½DSCIǨ״̬
3824 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3825 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
3826 g_Cc_CallDetail.ringCid = 0;
3827 SLIC_Stop_Signal(0, TONE_SIGNAL);
3828 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
3829 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3830 SLIC_Start_PCM();
3831 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState SLIC_Start_PCM\n",__FUNCTION__);
3832 break;
3833
3834 case ZCC_SDISCN_MT_E:
3835 zCc_InitSlaveObj(slave);
3836 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3837 return;
3838
3839 case ZCC_DISCN_E://trying ̬ÊÕµ½¹Ò»úÏûÏ¢£¬Ö»ÄÜÊÇÕª»ú̬À´µç(²»°üÀ¨ºô½ÐµÈ´ý)µÄ³¡¾°
3840 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3841 SLIC_Stop_Signal(0, TONE_SIGNAL);
3842 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
3843 g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
3844 if (1 == zCc_CallCount() && (zCc_GetDiscSlave(ZCC_SDISCN_M) == 0)// Õª»ú̬À´µçʱ¹Ò»ú£¬Èç¹ûµ±Ç°Ö»ÓÐһ·ºô½Ð£¬»°»úתÈëÕñÁå
3845 ||(2 == zCc_CallCount()
3846 && (0 != zCc_GetSpecSlave(ZCC_S_DACCM_S)
3847 ||0 != zCc_GetSpecSlave(ZCC_S_BSYT_S)
3848 ||0 != zCc_GetSpecSlave(ZCC_S_TKYT_S)
3849 ||0 != zCc_GetSpecSlave(ZCC_S_SIL_S))))//Õª»úºó£¬À´µç£¬ÔÙ²¦ºÅ£¬¹Ò»ú£¬Ò²ÐèÒªÕñÁå
3850 {
3851 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3852 }
3853 else
3854 {
3855 //zCc_InitSlaveObj(slave);
3856 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
3857 g_Cc_CallDetail.ringCid = 0;
3858 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
3859 }
3860 return;
3861
3862 default:
3863 return;
3864 }
3865}
3866
3867VOID zCc_SBsyToneState(UINT8 slave)
3868{
3869 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SBsyToneState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3870 switch (g_Cc_CallDetail.evt[slave])
3871 {
3872 case ZCC_DISCN_E:
3873 zCc_InitSlaveObj(slave);
3874 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3875 return;
3876 case ZCC_CIDCW_E:
3877 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
3878 //lint -fallthrough
3879 case ZCC_SINVITE_E:
3880 if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾ­Ï·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
3881 {
3882 zCc_InitSlaveObj(slave);
3883 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3884 g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
3885 return;
3886 }
3887 g_Cc_CallDetail.ringCid = slave;
3888
3889 if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
3890 g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
3891 else
3892 g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
3893
3894 if (g_Cc_CallDetail.resourceReady == 1)
3895 {
3896 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3897 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
3898 }
3899 else
3900 {
3901 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
3902 }
3903 break;
3904 default:
3905 return;
3906 }
3907}
3908
3909VOID zCc_STkytState(UINT8 slave)
3910{
3911 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STkytState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3912 switch (g_Cc_CallDetail.evt[slave])
3913 {
3914 case ZCC_DISCN_E:
3915 zCc_InitSlaveObj(slave);
3916 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3917 return;
3918 case ZCC_CIDCW_E:
3919 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
3920 //lint -fallthrough
3921 case ZCC_SINVITE_E:
3922 if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾ­Ï·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
3923 {
3924 zCc_InitSlaveObj(slave);
3925 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3926 g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
3927 return;
3928 }
3929 g_Cc_CallDetail.ringCid = slave;
3930
3931 if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
3932 g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
3933 else
3934 g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
3935
3936 if (g_Cc_CallDetail.resourceReady == 1)
3937 {
3938 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3939 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
3940 }
3941 else
3942 {
3943 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
3944 }
3945 break;
3946 default:
3947 return;
3948 }
3949}
3950
3951VOID zCc_SSilState(UINT8 slave)
3952{
3953 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SSilState g_Cc_CallDetail.evt[%d] = %d\n",__FUNCTION__,slave, g_Cc_CallDetail.evt[slave]);
3954 switch (g_Cc_CallDetail.evt[slave])
3955 {
3956 case ZCC_DISCN_E:
3957 zCc_InitSlaveObj(slave);
3958 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3959 return;
3960 case ZCC_CIDCW_E:
3961 g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
3962 //lint -fallthrough
3963 case ZCC_SINVITE_E:
3964 if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾ­Ï·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
3965 {
3966 zCc_InitSlaveObj(slave);
3967 zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
3968 g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
3969 return;
3970 }
3971 g_Cc_CallDetail.ringCid = slave;
3972
3973 if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
3974 g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
3975 else
3976 g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
3977
3978 if (g_Cc_CallDetail.resourceReady == 1)
3979 {
3980 g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
3981 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
3982 }
3983 else
3984 {
3985 g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
3986 }
3987 break;
3988
3989 default:
3990 return;
3991 }
3992}
3993
3994