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