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