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