[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/ccapp/112.h b/ap/app/ccapp/112.h
new file mode 100644
index 0000000..3e7deee
--- /dev/null
+++ b/ap/app/ccapp/112.h
@@ -0,0 +1,155 @@
+#ifndef _LINE_TSET_H
+#define _LINE_TSET_H
+
+/********************²âÊÔÏÒå***********************************/
+#define TI_BatteryVolt 0x1 /*²âÊÔSLC °å¶ÔÓû§ÏßµÄÀ¡µçµçѹ´óС·´¼«ÐÔ*/
+#define TI_RingVolt 0x2 /*²âÊÔSLC °å¶ÔÓû§ËÍÁåÁ÷ÊÇ·ñÕý³£¼°ÁåÁ÷µçѹ´óС£¨ ·åÖµ¡³*/
+#define TI_PulseRecv 0x3 /*²âÊÔSLC °å½ÓÊÕÂö³å»°»ú(Ä£Äâ)·¢ºÅµÄÇé¿ö*/
+#define TI_DTMFRecv 0x4 /*²âÊÔSLC °å½ÓÊÕDTMF»°»ú(Ä£Äâ)·¢ºÅµÄÇé¿ö*/
+#define TI_SendTone 0x5 /*²¦ºÅÒô£¬»ØÁåÒô£¬ÓµÈûÒô¼°Ã¦Òô¼ì²â*/
+#define TI_SendHowl 0x6 /*¶ÔÓû§ËÍ´ß¹ÒÒô*/
+#define TI_LoopCircuitAndRes 0x7 /*ÍâÏß»·Â·µçÁ÷¼°»·Â·µç×è²âÊÔ*/
+#define TI_PulseDial 0x8 /*²âÊÔÓû§»°»úÂö³å·¢ºÅµÄÄÜÁ¦*/
+#define TI_DTMFDial 0x9 /*²âÊÔÓû§»°»úµÄDTMF·¢ºÅÒÔ¼°Âö³å·¢ºÅµÄÇé¿ö*/
+#define TI_RingtoUser 0xA /*¶ÔÓû§»°»úËÍÁåÁ÷*/
+#define TI_LineVolt 0xB /*ÍâÏßÈ«µçѹ²âÊÔ*/
+#define TI_LineRes 0xC /*ÍâÏßÈ«¾øÔµµç×è²âÊÔ*/
+#define TI_LineCap 0xD /*ÍâÏßÈ«µçÈݲâÊÔ*/
+
+#define TI_Insert 0xF /*ÓëÓû§Í¨»°*/
+
+/*INVALID TEST ITEM*/
+#define TI_Hook 0x10 /*²âÊÔÓû§Õª¹Ò»ú״̬*/
+
+#define TI_VAB 0x11 /*ÍâÏßA-B¼äµçѹ²âÊÔ*/
+#define TI_VAG 0x12 /*ÍâÏßA-GND ¼äµçѹ²âÊÔ*/
+#define TI_VBG 0x13 /*ÍâÏßB-GND¼äµçѹ²âÊÔ*/
+#define TI_RAB 0x14 /*ÍâÏßA-B ¼ä¾øÔµµç×è²âÊÔ*/
+#define TI_RAG 0x15 /*ÍâÏßA-GND¼ä¾øÔµµç×è²âÊÔ*/
+#define TI_RBG 0x16 /*ÍâÏßB-GND ¼ä¾øÔµµç×è²âÊÔ*/
+#define TI_CAB 0x17 /*ÍâÏßA-B¼äµçÈݲâÊÔ*/
+#define TI_CAG 0x18 /*ÍâÏßA-GND¼äµçÈݲâÊÔ*/
+#define TI_CBG 0x19 /*ÍâÏßB-GND¼äµçÈݲâÊÔ*/
+#define TI_InverseBatt 0x1a /* ÎĵµÖÐÊDzâÄÚÏß»ØÂ·µçÁ÷²âÊÔ £¿£¿£¿£¿*/
+#define TI_InLoopCurrent 0x1B /* ÄÚÏß»ØÂ·µçÁ÷²âÊÔ*/
+#define TI_ISDNLoop 0x1C /* isdn loop Test*/
+#define TI_Outside12 0x1D /* ÍâÏß12Ïî²âÊÔ*/
+#define TI_REN 0x1e /* ÁåÁ÷Êý */
+#define TI_LineConnect 0x1f /* Ïß·Á¬½ÓÐÔ²âÊÔ*/
+
+#define TI_LineRes_reverse 0x20 /*·´¼«ÐÔ¾øÔµµç×è²âÊÔ*/
+
+#define TI_SimCaller 0x27 /*Ä£ÄâÖ÷½Ð*/
+#define TI_SimCallee 0x28 /*Ä£Äâ±»½Ð*/
+#define TI_Dual 0x29 /*41:Ë«Ïò·ÓÉ */
+
+#define TI_LeakCurrent 0x30 /*48:©µçµçÁ÷*/
+#define TI_OutsideNoise 0x31 /*49:ÍâÏßÔëÉù */
+#define TI_SimulateDial 0x33 /*51:Ä£ÄⲦÈë*/
+#define TI_Monitor 0x34 /*52:¸ß×è¼àÌý*/
+#define TI_TalkWithUser 0x35 /*53:ÓëÓû§Í¨»°*/
+#define TI_PolarityReversal 0x36 /*54:·´¼«ÐÔ²âÊÔ*/
+
+#define ROH_TEST 0x37 /*55 : Receiver Off-Hook indication */
+
+#define TI_CheckBoard 0xFF /*°åλ¼ì²éÃüÁî*/
+#define TI_SelfTest 0xFE /*×Ô²â*/
+
+/************************ÃüÁî×Ö***********************************/
+#define CMD_WRITE_START 0x01
+#define CMD_READ_STATE 0x02
+#define CMD_WRITE_ABORT 0x03
+#define CMD_READ_RESULT 0x04
+
+/*******************************²âÊÔ״̬**************************/
+#define TESTING 0x01
+#define TEST_SUCC 0x02
+#define TEST_ERROR 0x03
+
+#define NOT_TEST 0xFF
+
+#define MAX_TIMOUT 12000 /* 2 min */
+/************************´íÎó±àºÅ*********************************/
+typedef enum{
+ NO_ERROR = 0,
+ ERR_UNKONW ,
+ TESTITEM_TIMEOVER, /* Time out!*/
+ COMMAND_ERR_NOTLINE, /* No available testing line! */
+ COMMAND_ERR_NOTEST_UNIT, /* No available testing data buffer! */
+ ASSIGN_DATA_ERR, /* Data assignment failed!*/
+ TESTITEM_FAIL, /* Testing failed!*/
+ COMMAND_ERR_USER_USED, /* The user card is in testing process!*/
+ UNFIND_TEST_RECORD, /* No available testing card!*/
+ DATABASE_FAIL, /* Database accessing failed!*/
+ ALC_OFFLINE, /* The user card is offline!*/
+ USER_BUSY, /* User is busy!*/
+ BOARD_ABNORMAL, /* Board is abnormal!*/
+ TEST_USER_BUSY, /* User is busy!*/
+ USER_IS_ONHOOK, /* User is onhook state!*/
+ USER_IS_OFFHOOK, /* User is offhook state!*/
+ ARGS_ERROR , /* Testing error, please check the user line state!*/
+ USER_LINE_RES, /* User line is resistive loop, maybe short circuit!*/
+ REN_GREATER, /* REN is greater than 5000 milli,check the user line.*/
+ REN_LOWER, /* REN is lower than 175 milli,check the user line.*/
+ RES_LOWER, /* The DC resistance measured from the rtg/rrg/rrt lead to ground is less than 150k.*/
+ RESULT_OC, /* The result is over the ouside the the specified criteria.Check the user line.*/
+ NO_PHONE, /* No signal between tip and ring, maybe there is no phone!*/
+ NOT_SURPPORT /* The test item is not surpported !*/
+}ErrMsg_t;
+
+typedef struct{
+ unsigned char port; /* ¶Ë¿Ú±àºÅ */
+ unsigned char port_type; /* ¶Ë¿ÚÀàÐÍ */
+ unsigned char item; /* ²âÊÔÏî±àºÅ£¬¼ûÉÏÃæ²âÊÔÏÒå */
+ unsigned char obligate; /* ÊÇ·ñÇ¿ÖÆ²âÊÔ 0£º²»Ç¿ÖÆ£»1£ºÇ¿ÖÆ*/
+ long num; /* ²âÊÔÐòºÅ */
+ unsigned char omci_item; /* ÓÃÓÚ¶àÏî²âÊÔÖмǼomci²âÊÔÏî±àºÅ */
+ unsigned char cmd; /* ²âÊÔÆô¶¯ºÍ¶Á״̬:1,write;2,read;3,abort. */
+ unsigned char flg; /* ²âÊÔÍê³É±ê¼Ç:³É¹¦»òÕßʧ°Ü */
+}WriteCmd_t;
+
+typedef struct{
+ unsigned char port; /* ¶Ë¿Ú±àºÅ */
+ unsigned char port_type; /* ¶Ë¿ÚÀàÐÍ */
+ unsigned char item; /* ²âÊÔÏî±àºÅ */
+ unsigned char obligate; /* ÊÇ·ñÇ¿ÖÆ²âÊÔ */
+ long num; /* ²âÊÔÐòºÅ */
+ unsigned char omci_item; /* ÓÃÓÚ¶àÏî²âÊÔÖмǼomci²âÊÔÏî±àºÅ */
+ unsigned char flg; /* ²âÊÔÍê³É±ê¼Ç:³É¹¦»òÕßʧ°Ü */
+ unsigned char user_flg; /* Óû§ÊÇ·ñÔÚÏß */
+ ErrMsg_t err_num; /* ²âÊÔʧ°ÜºóµÄ´íÎó±àºÅ,²âÊԳɹ¦ÔòÎÞÒâÒå */
+
+ /* TI_LineVolt */
+ signed long vac_tr; /* ½»Á÷µçѹ£ºTip-Ring */
+ signed long vac_tg; /* ½»Á÷µçѹ£ºTip-Gnd */
+ signed long vac_rg; /* ½»Á÷µçѹ£ºRing-Gnd */
+ signed long vdc_tr; /* Ö±Á÷µçѹ£ºTip-Ring */
+ signed long vdc_tg; /* Ö±Á÷µçѹ£ºTip-Gnd */
+ signed long vdc_rg; /* Ö±Á÷µçѹ£ºRing-Gnd */
+
+ /* TI_LineRes */
+ signed long res_tr; /* µç×裺Tip-Ring */
+ signed long res_tg; /* µç×裺Tip-Gnd */
+ signed long res_rg; /* µç×裺Ring-Gnd */
+
+ /* TI_LineCap */
+ signed long cap_tr; /* µçÈÝ£ºTip-Ring */
+ signed long cap_tg; /* µçÈÝ£ºTip-Gnd */
+ signed long cap_rg; /* µçÈÝ£ºRing-Gnd */
+
+ /* TI_RingVolt */
+ signed long ring_vol; /* ÕñÁåµçѹ */
+ signed long Hz; /* ÕñÁ寵ÂÊ */
+
+ /* TI_REN */
+ signed long ren; /* ÁåÁ÷Êý */
+
+ /* TI_InLoopCurrent */
+ signed long loop_curent; /* »ØÂ·µçÁ÷ */
+ signed long loop_res; /* »ØÂ·µç×è */
+
+ /* TI_BatteryVolt */
+ signed long battary; /* À¡µçµçѹ */
+}TestResult_t;
+
+#endif
diff --git a/ap/app/ccapp/Makefile b/ap/app/ccapp/Makefile
new file mode 100755
index 0000000..f108b1e
--- /dev/null
+++ b/ap/app/ccapp/Makefile
@@ -0,0 +1,86 @@
+# /*****************************************************************************
+#* °戨?? (C)2015, ????1???????£
+#*
+#* ?? Makefile
+#* ?? Makefile
+#* ě???: Makefile of ZTE applications
+#* ??·?·¨:
+#*
+#* О???? °汾o? О??? О??? О????
+ #* -----------------------------------------------------------------------------
+#* 2015/12/31 V2.2 Create 1?° ′′?¨
+#*
+# ******************************************************************************/
+
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+#*******************************************************************************
+# execute
+#*******************************************************************************
+EXEC = ccapp
+#EXEC2 = slictool
+#*******************************************************************************
+# objects
+#*******************************************************************************
+OBJS = cc_main.o cc_proc.o cc_timer.o cc_at.o cc_com.o slic_inf.o libzte_log.o
+OBJS2 = slic_tool.o slic_inf.o
+#*******************************************************************************
+# include path
+#*******************************************************************************
+CFLAGS += -I../include \
+ -I$(zte_lib_path)/libsoft_timer \
+ -I$(zte_lib_path)/libvoice/include \
+ -I$(zte_lib_path)/libsqlite
+CFLAGS += -g -Werror=implicit-function-declaration
+#*******************************************************************************
+# macro definition
+#*******************************************************************************
+ifeq ($(_APP_AUDIO_TYPE_),slic_le96xx)
+CFLAGS +=-DUSE_SLIC_TW
+endif
+
+#*******************************************************************************
+# library
+#*******************************************************************************
+LDLIBS += -lpthread
+LDLIBS += -lnvram_sc
+LDLIBS += -lsoftap
+LDLIBS += -lsoft_timer_sc
+LDLIBS += -ltinyalsa
+LDLIBS += -lvoice
+
+#*******************************************************************************
+# library path
+#*******************************************************************************
+LDLIBS += -L$(zte_lib_path)/libnvram
+LDLIBS += -L$(zte_lib_path)/libsoftap
+LDLIBS += -L$(zte_lib_path)/libsoft_timer
+LDLIBS += -L$(zte_lib_path)/libtinyalsa
+LDLIBS += -L$(zte_lib_path)/libvoice
+
+#LDFLAGS += -Wl,-elf2flt=-s32768
+#$(info ------------------------------------$(zte_lib_path))
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC) $(EXEC2)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
+$(EXEC2): $(OBJS2)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS2) -Wl,--start-group $(LDLIBS) -Wl,--end-group
+
+romfs:
+ cp $(EXEC) $(EXEC).elf
+ $(ROMFSINST) /bin/$(EXEC)
+# $(ROMFSINST) /bin/$(EXEC2)
+
+clean:
+ -rm -f $(EXEC) $(EXEC2) *.elf *.gdb *.o
+
+
+
diff --git a/ap/app/ccapp/cc_at.c b/ap/app/ccapp/cc_at.c
new file mode 100755
index 0000000..889cfa3
--- /dev/null
+++ b/ap/app/ccapp/cc_at.c
@@ -0,0 +1,384 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <fcntl.h>
+
+#include "cc_at.h"
+#include "cc_main.h"
+
+
+
+#define ZAT_INVALID_LEN -1
+#define MSG_RETRY_NUM 4
+#define MSG_RETRY_INTERVAL 50
+
+static CHAR g_zCc_RecvBuf[ATMAIN_AT_BUF_LEN + 1] = {0};
+
+
+/* ÔÚ×Ö·û´®ÖÐѰÕÒÆ¥ÅäµÄ×Ó´®£¬Ë«ÒýºÅÄÚµÄÄÚÈݳýÍâ */
+static PSTR zCc_FindSubStr(const PSTR pStr, const PSTR pSubStr,const SINT32 strLen)
+{
+ SINT32 subStrLen = 0;
+ BOOL bInSideQuote = FALSE; /* ±ê¼ÇÊÇ·ñÔÚË«ÒýºÅÄÚ */
+ UINT16 wIndex = 0;
+ PSTR pTmpStr = pStr;
+
+ if ((pStr == ZUFI_NULL) || (pSubStr == ZUFI_NULL) || (strLen <= 0))
+ {
+ return ZUFI_NULL;
+ }
+
+ subStrLen = (SINT32)strlen((CHAR *)pSubStr);
+
+ if (strLen < subStrLen)
+ {
+ return ZUFI_NULL;
+ }
+
+ for (wIndex=0; wIndex<((strLen-subStrLen)+1); wIndex++)
+ {
+ /* ÅжÏÊÇ·ñÔÚË«ÒýºÅÄÚ */
+ if (*pTmpStr == '"')
+ {
+ bInSideQuote = !bInSideQuote;
+ }
+ /* ×Ó´®±È½Ï */
+ if (!bInSideQuote && *pTmpStr == *pSubStr)
+ {
+ if (strncmp((CHAR *)pTmpStr, (CHAR *)pSubStr, (UINT32)subStrLen) == 0)
+ {
+ return pTmpStr;
+ }
+ }
+ pTmpStr++;
+ }
+
+ return ZUFI_NULL;
+}
+
+
+
+/* ´Óµ±Ç°×Ö·û´®ÖлñÈ¡ATÏìÓ¦×Ó´®£¬·µ»Ø×Ó´®³¤¶È */
+static SINT32 zCc_GetSubAtStr(const PSTR pCurAtStr, PSTR pSubAtStr, SINT32 iDataLen, PSTR atRecvBuf)
+{
+ PSTR pAtHead = ZUFI_NULL; /* ATÏìӦͷ²¿ */
+ PSTR pAtTail = ZUFI_NULL; /* ATÏìӦβ²¿ */
+ SINT32 iSubAtStrLen = ZAT_INVALID_LEN; /* ATÏìÓ¦×Ó´®³¤¶È */
+ SINT32 iFreeDataLen = ZAT_INVALID_LEN; /* δ½âÎöµÄATÏìÓ¦Êý¾Ý³¤¶È */
+
+ if ((pCurAtStr == ZUFI_NULL) || (pSubAtStr == ZUFI_NULL))
+ {
+ return ZAT_INVALID_LEN;
+ }
+
+ /* ÔÚATÏìÓ¦´®ÖÐËÑË÷ATÏìÓ¦¿ªÊ¼´¦µÄ"\r\n" */
+ iFreeDataLen = iDataLen - (pCurAtStr - atRecvBuf);
+ pAtHead = zCc_FindSubStr(pCurAtStr, (PSTR)"\r\n", iFreeDataLen);
+ if (pAtHead == ZUFI_NULL)
+ {
+ return ZAT_INVALID_LEN;
+ }
+
+ /* ÔÚATÏìÓ¦´®ÖÐËÑË÷ATÏìÓ¦½áÊø´¦µÄ"\r\n" */
+ pAtHead += 2;
+ iFreeDataLen = iDataLen - (pAtHead - atRecvBuf);
+ pAtTail = zCc_FindSubStr(pAtHead, (PSTR)"\r\n", iFreeDataLen);
+ if (pAtTail == ZUFI_NULL)
+ {
+ if (strlen((CHAR *)pAtHead) == 0)
+ {
+ return ZAT_INVALID_LEN;
+ }
+ else
+ {
+ pAtTail = pAtHead + strlen((CHAR *)pAtHead);
+ }
+ }
+
+ /* È¡³öÁ½¸ö"\r\n"Ö®¼äµÄATÏìÓ¦ */
+ iSubAtStrLen = pAtTail - pAtHead;
+ if ((iSubAtStrLen > 0) && (iSubAtStrLen < AT_CMD_MAX))
+ {
+ memcpy(pSubAtStr, pAtHead, (UINT32)iSubAtStrLen);
+ return iSubAtStrLen;
+ }
+
+ return iSubAtStrLen == 0? 0 : ZAT_INVALID_LEN;
+}
+static void skipWhiteSpace(char **p_cur)
+{
+ if (*p_cur == NULL)
+ {
+ return;
+ }
+
+ while (**p_cur != '\0' && isspace(**p_cur))
+ {
+ (*p_cur)++;
+ }
+}
+char *strsep(char **stringp, const char *delim)
+{
+ char *s;
+ const char *spanp;
+ int c, sc;
+ char *tok;
+
+ if ((s = *stringp) == NULL)
+ return (NULL);
+ for (tok = s;;) {
+ c = *s++;
+ spanp = delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0)
+ s = NULL;
+ else
+ s[-1] = 0;
+ *stringp = s;
+ return (tok);
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
+}
+void skipNextComma(char **p_cur)
+{
+ if (*p_cur == NULL)
+ {
+ return;
+ }
+
+ while (**p_cur != '\0' && **p_cur != ',')
+ {
+ (*p_cur)++;
+ }
+
+ if (**p_cur == ',')
+ {
+ (*p_cur)++;
+ }
+}
+static char * nextTok(char **p_cur)
+{
+ char *ret = NULL;
+
+ skipWhiteSpace(p_cur);
+
+ if (*p_cur == NULL)
+ {
+ ret = NULL;
+ }
+ else if (**p_cur == '"')
+ {
+ (*p_cur)++;
+ ret = (char*)strsep(p_cur, "\"");
+ skipNextComma(p_cur);
+ }
+ else
+ {
+ ret = (char*)strsep(p_cur, ",");
+ }
+
+ return ret;
+}
+SINT32 zCc_at_tok_start(char **p_cur)
+{
+ if (*p_cur == NULL)
+ {
+ return -1;
+ }
+
+ // skip prefix
+ // consume "^[^:]:"
+
+ *p_cur = strchr(*p_cur, ':');
+
+ if (*p_cur == NULL)
+ {
+ return -1;
+ }
+
+ (*p_cur)++;
+
+ return 0;
+}
+/**
+ * Parses the next integer in the AT response line and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ * "base" is the same as the base param in strtol
+ */
+
+static SINT32 zCc_at_tok_nextint_base(char **p_cur, SINT32 *p_out, SINT32 base, SINT32 uns)
+{
+ char *ret;
+
+ if (*p_cur == NULL)
+ {
+ return -1;
+ }
+
+ ret = nextTok(p_cur);
+
+ if (ret == NULL)
+ {
+ return -1;
+ }
+ else
+ {
+ long l;
+ char *end;
+ errno = 0;// kw CXX.ERRNO.NOT_CHECKED
+ if (uns)
+ {
+ l = strtoul(ret, &end, base);
+ }
+ else
+ {
+ l = strtol(ret, &end, base);
+ }
+ if (errno == ERANGE)// kw CXX.ERRNO.NOT_CHECKED
+ {
+ zte_log_append(__FILE__, __LINE__, "strtoul errno %d: %s\n", errno, strerror(errno));
+ }
+ *p_out = (SINT32) l;
+
+ if (end == ret)
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Parses the next base 10 integer in the AT response line
+ * and places it in *p_out
+ * returns 0 on success and -1 on fail
+ * updates *p_cur
+ */
+SINT32 zCc_at_tok_nextint(char **p_cur, SINT32 *p_out)
+{
+ return zCc_at_tok_nextint_base(p_cur, p_out, 10, 0);
+}
+
+int zCcApp_EncAtReqCcfc(char* ptMsgBuf)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_SET_CCFC);
+ sprintf(AtCmdBuf, "%s",ptMsgBuf);
+ AtLen = strlen(AtCmdBuf);
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqClck(char* ptMsgBuf)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_SET_CLCK);
+ sprintf(AtCmdBuf, "%s",ptMsgBuf);
+ AtLen = strlen(AtCmdBuf);
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqD(char* ptMsgBuf)
+{
+
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_D);
+ sprintf(AtCmdBuf, "%s",ptMsgBuf);
+ AtLen = strlen(AtCmdBuf);
+ Fd = zCcApp_GetAtCmdFd();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_EncAtReqD:AtcmdMsg = %s\n",__FUNCTION__,AtCmdBuf);
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqA(VOID)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_A);
+
+ sprintf(AtCmdBuf, "ATA\r\n");
+ AtLen = strlen(AtCmdBuf);
+
+ /*·¢ËÍ*/
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqChup(void)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_CHUP);
+
+ sprintf(AtCmdBuf, "AT+CHUP\r\n");
+ AtLen = strlen(AtCmdBuf);
+
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqVts(char *ptMsgBuf)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_VTS);
+
+ sprintf(AtCmdBuf, "%s",ptMsgBuf);
+ AtLen = strlen(AtCmdBuf);
+
+ /*·¢ËÍ*/
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqImsPlus(char *ptMsgBuf)
+{
+ int Fd ;
+ char AtCmdBuf[512] = {0};
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_IMSPLUS);
+
+ sprintf(AtCmdBuf, "%s", ptMsgBuf);
+ AtLen = strlen(AtCmdBuf);
+
+ /*·¢ËÍ*/
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtCmdBuf,AtLen);
+}
+
+int zCcApp_EncAtReqChld(char *AtcmdMsg)
+{
+ int Fd ;
+ int AtLen;
+
+ zCcApp_SetAtChnlCmdId(CC_APP_AT_CMD_REQ_SET_CHLD);
+ AtLen = strlen(AtcmdMsg);
+
+ /*·¢ËÍ*/
+ Fd = zCcApp_GetAtCmdFd();
+ return zCcApp_PortSend(Fd,AtcmdMsg,AtLen);
+}
+
diff --git a/ap/app/ccapp/cc_at.h b/ap/app/ccapp/cc_at.h
new file mode 100644
index 0000000..a78f80a
--- /dev/null
+++ b/ap/app/ccapp/cc_at.h
@@ -0,0 +1,34 @@
+#ifndef _cc_ctrm_h_
+#define _cc_ctrm_h_
+
+#include <ctype.h>
+
+#include "cc_com.h"
+#include "message.h"
+
+#define ATMAIN_AT_BUF_LEN 512
+#define ZAT_CMD_NAME_MAXLEN 32
+
+#define ZAT_INVALID_ID -1
+#define ZAT_INVALID_CMD 0xFFFFFFFF
+
+typedef struct
+{
+ UINT8 atCmdId;
+ CHAR atCmdName[ZAT_CMD_NAME_MAXLEN];
+}T_zCc_AtCmdTab;
+
+//static PSTR zCc_FindSubStr(const PSTR pStr, const PSTR pSubStr,const SINT32 strLen);
+SINT32 zCc_at_tok_nextint(char **p_cur, SINT32 *p_out);
+SINT32 zCc_at_tok_start(char **p_cur);
+int zCcApp_EncAtReqD(char* ptMsgBuf);
+int zCcApp_EncAtReqA(VOID);
+int zCcApp_EncAtReqChup(void);
+int zCcApp_EncAtReqVts(char *ptMsgBuf);
+int zCcApp_EncAtReqChld(char *AtcmdMsg);
+int zCcApp_EncAtReqCcfc(char* ptMsgBuf);
+int zCcApp_EncAtReqClck(char* ptMsgBuf);
+int zCcApp_EncAtReqImsPlus(char *ptMsgBuf);
+
+#endif
+
diff --git a/ap/app/ccapp/cc_com.c b/ap/app/ccapp/cc_com.c
new file mode 100644
index 0000000..7b6d2a3
--- /dev/null
+++ b/ap/app/ccapp/cc_com.c
@@ -0,0 +1,360 @@
+
+
+#include <fcntl.h> // open
+#include <string.h> // bzero
+#include <stdlib.h> // exit
+#include <sys/types.h> // pid_t
+//#include "ufi_def.h"
+#include "os_type_def.h"
+
+#include "cc_at.h"
+#include "cc_proc.h"
+#include "cc_main.h"
+#include <termios.h> //termios, tcgetattr(), tcsetattr()
+#ifndef TEST_CCAPP
+#include <unistd.h>
+#include <sys/ioctl.h> // ioctl
+#include <sys/times.h> // times
+#endif
+
+//ÈçºÎ¶¨Òå
+#define ZCC_APP_AT_COMM_CC "/dev/armps_rpmsgch12"
+#define ZCC_APP_AT_COMM_SS "/dev/armps_rpmsgch13"
+#define ZCC_APP_AT_COMM_DEV "/dev/armps_rpmsgch14"
+#define ZCC_APP_AT_COMM_IND "/dev/armps_rpmsgch15"
+
+
+static int g_zCcApp_ComFd[4] = {0};
+
+/*******************************************
+ * ²¨ÌØÂÊת»¯×ª»»º¯Êý
+ ********************************************/
+static int convbaud(unsigned long int baudrate)
+{
+ switch (baudrate)
+ {
+ case 2400:
+ return B2400;
+ case 4800:
+ return B4800;
+ case 9600:
+ return B9600;
+ case 19200:
+ return B19200;
+ case 38400:
+ return B38400;
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ default:
+ return B9600;
+ }
+}
+
+#ifndef TEST_CCAPP
+int zCc_CleanCCMSG()
+{
+ int ret = -1;
+ //get CC fd
+ int fd = zCcApp_GetAtCCFd();
+ fd_set readfdForCC;
+
+ struct timeval tv={0};
+
+ while(1)
+ {
+ //0s timeout
+ tv.tv_sec = 0;
+ FD_ZERO(&readfdForCC);
+ FD_SET(fd, &readfdForCC);
+ ret = select(fd + 1, &readfdForCC, NULL, NULL, &tv);
+ if(ret<0)
+ {
+ continue;
+ }
+ //"Select timeout"
+ if(ret == 0)
+ {
+ break;
+ }
+
+ if(FD_ISSET(fd, &readfdForCC))
+ {
+ char AtBuf[ZCC_APP_AT_BUF_MAX_LEN] = {0};
+ int readlen = 0;
+ readlen = read(fd, AtBuf, ZCC_APP_AT_BUF_MAX_LEN);
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return 0;
+}
+
+int zCcApp_GetAtCmdFd(void)
+{
+ int fd = 0;
+ E_CC_APP_AtReqCmdId AtChnlCmdId = g_Cc_CallDetail.curAtCmdId;
+
+ switch (AtChnlCmdId)
+ {
+ case CC_APP_AT_CMD_REQ_A:
+ case CC_APP_AT_CMD_REQ_D:
+ case CC_APP_AT_CMD_REQ_CHUP:
+ case CC_APP_AT_CMD_REQ_SET_CHLD:
+ case CC_APP_AT_CMD_REQ_VTS:
+ case CC_APP_AT_CMD_REQ_IMSPLUS:
+ fd = g_zCcApp_ComFd[1];
+ break;
+
+
+ case CC_APP_AT_CMD_REQ_GET_CLCC:
+ case CC_APP_AT_CMD_REQ_CMUT:
+ case CC_APP_AT_CMD_REQ_CLVL:
+ fd = g_zCcApp_ComFd[3];
+ break;
+
+
+
+ case CC_APP_AT_CMD_REQ_SET_CCFC:
+ case CC_APP_AT_CMD_REQ_SET_CCWA:
+ case CC_APP_AT_CMD_REQ_SET_CLCK:
+ case CC_APP_AT_CMD_REQ_GET_CCFC:
+ case CC_APP_AT_CMD_REQ_GET_CCWA:
+ case CC_APP_AT_CMD_REQ_SET_CPWD:
+ fd = g_zCcApp_ComFd[2];
+ break;
+
+ default:
+ break;
+ }
+
+ return fd;
+}
+/********************************************
+ * send data
+ * fdcom: ´®¿ÚÃèÊö·û, data: ´ý·¢ËÍÊý¾Ý, datalen: Êý¾Ý³¤¶È
+ * ·µ»ØÊµ¼Ê·¢Ëͳ¤¶È
+ *********************************************/
+int zCcApp_PortSend(int fdcom, CHAR *data, int datalen)
+{
+ int len = 0;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_PortSend:AtcmdMsg = %s\n",__FUNCTION__,data);
+ len = write(fdcom, data, datalen); //ʵ¼ÊдÈëµÄ³¤¶È
+ if (len == datalen)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_PortSend succ fdcom=%d,data=%s,len=%d\n <---\n",__FUNCTION__,fdcom,data,datalen);
+ return len;
+ }
+ else
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_PortSend fail fdcom=%d,data=%s,len=%d\n <---\n",__FUNCTION__,fdcom,data,datalen);
+ tcflush(fdcom, TCOFLUSH);
+ return -1;
+ }
+}
+
+/*******************************************
+ * receive data
+ * ·µ»ØÊµ¼Ê¶ÁÈëµÄ×Ö½ÚÊý
+ *
+ ********************************************/
+int zCcApp_PortRecv(int fdcom, CHAR *data, int datalen)
+{
+
+ char AtBuf[ZCC_APP_AT_BUF_MAX_LEN] = {0};
+ int readlen = 0;
+ readlen = read(fdcom, AtBuf, ZCC_APP_AT_BUF_MAX_LEN);
+ if (readlen >= 0) { //cov m
+ strncpy(data,AtBuf,readlen);
+ }
+
+ return readlen;
+}
+
+/*******************************************
+ * Setup comm attr
+ * fdcom: ´®¿ÚÎļþÃèÊö·û, pportinfo: ´ýÉèÖõĶ˿ÚÐÅÏ¢s
+ *
+ ********************************************/
+int zCcApp_PortSet(int fdcom, T_CC_APP_Portinfo *pPortinfo)
+{
+ struct termios termios_old, termios_new;
+ int baudrate, tmp;
+ char databit, stopbit, parity, fctl;
+ bzero(&termios_old, sizeof(termios_old));
+ bzero(&termios_new, sizeof(termios_new));
+ cfmakeraw(&termios_new);
+ tcgetattr(fdcom, &termios_old); //get the serial port attributions
+
+ /*------------ÉèÖö˿ÚÊôÐÔ----------------*/
+ //baudrates
+ baudrate = convbaud(pPortinfo->baudrate);
+ cfsetispeed(&termios_new, baudrate); //ÌîÈë´®¿ÚÊäÈë¶Ë²¨ÌØÂÊ
+ cfsetospeed(&termios_new, baudrate); //ÌîÈë´®¿ÚÊä³ö¶Ë²¨ÌØÂÊ
+ termios_new.c_cflag |= CLOCAL; //¿ØÖÆÄ£Ê½, ±£Ö¤³ÌÐò²»»á³ÉΪ¶Ë¿ÚµÄÕ¼ÓÐÕß
+ termios_new.c_cflag |= CREAD; //¿ØÖÆÄ£Ê½, ʹÄܶ˿ڶÁÈ¡ÊäÈëµÄÊý¾Ý
+
+ // ¿ØÖÆÄ£Ê½, flow control
+ fctl = pPortinfo->fctl;
+ switch (fctl)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~CRTSCTS; //no flow control
+ break;
+ }
+ case '1':
+ {
+ termios_new.c_cflag |= CRTSCTS; //hardware flow control
+ break;
+ }
+ case '2':
+ {
+ termios_new.c_iflag |= IXON | IXOFF | IXANY; //software flow control
+ break;
+ }
+ default:
+ {
+ //ZTE_LOG(LOG_ERR, "Unknown fctl %c\n", fctl);
+ break;
+ }
+ }
+
+ //¿ØÖÆÄ£Ê½, data bits
+ termios_new.c_cflag &= ~CSIZE; //¿ØÖÆÄ£Ê½, ÆÁ±Î×Ö·û´óСλ
+ databit = pPortinfo->databit;
+ switch (databit)
+ {
+ case '5':
+ termios_new.c_cflag |= CS5;
+ //lint -fallthrough
+ case '6':
+ termios_new.c_cflag |= CS6;
+ //lint -fallthrough
+ case '7':
+ termios_new.c_cflag |= CS7;
+ //lint -fallthrough
+ default:
+ termios_new.c_cflag |= CS8;
+ }
+
+ //¿ØÖÆÄ£Ê½ parity check
+ parity = pPortinfo->parity;
+ switch (parity)
+ {
+ case '0':
+ {
+ termios_new.c_cflag &= ~PARENB; //no parity check
+ break;
+ }
+ case '1':
+ {
+ termios_new.c_cflag |= PARENB; //odd check
+ termios_new.c_cflag &= ~PARODD;
+ break;
+ }
+ case '2':
+ {
+ termios_new.c_cflag |= PARENB; //even check
+ termios_new.c_cflag |= PARODD;
+ break;
+ }
+ default:
+ {
+ //ZTE_LOG(LOG_ERR, "Unknown parity %c\n", parity);
+ break;
+ }
+ }
+
+ //¿ØÖÆÄ£Ê½, stop bits
+ stopbit = pPortinfo->stopbit;
+ if (stopbit == '2')
+ {
+ termios_new.c_cflag |= CSTOPB; //2 stop bits
+ }
+ else
+ {
+ termios_new.c_cflag &= ~CSTOPB; //1 stop bits
+ }
+ //other attributions default
+ termios_new.c_oflag &= ~OPOST; //Êä³öģʽ, ÔʼÊý¾ÝÊä³ö
+ termios_new.c_cc[VMIN] = 1; //¿ØÖÆ×Ö·û, ËùÒª¶ÁÈ¡×Ö·ûµÄ×îСÊýÁ¿
+ termios_new.c_cc[VTIME] = 1; //¿ØÖÆ×Ö·û, ¶ÁÈ¡µÚÒ»¸ö×Ö·ûµÄµÈ´ýʱ¼ä, unit: (1/10)second
+ tcflush(fdcom, TCIFLUSH); //Òç³öµÄÊý¾Ý¿ÉÒÔ½ÓÊÕ,µ«²»¶Á
+ tmp = tcsetattr(fdcom, TCSANOW, &termios_new); //ÉèÖÃÐÂÊôÐÔ, TCSANOW: ËùÓɸıäÁ¢¼´ÉúЧ
+
+ tcgetattr(fdcom, &termios_old);
+
+ //printf("%s \n",__FUNCTION__);
+ //printf("%s %d: tty %d,baudrate %d,stopbit %d, parity%d, databit %d\n",__FUNCTION__,termios_old.tty,termios_old.baudrate,termios_old.stopbit,termios_old.parity,termios_old.databit);
+ return(tmp);
+}
+
+
+/*******************************************
+ * Open serial port
+ * DevName: "/dev/armps_rpmsgch9"
+ * ·µ»ØÖµÎª´®¿ÚÎļþÃèÊö·û
+ ********************************************/
+int zCcApp_PortOpen(char* DevName)
+{
+
+ // serial port information
+ T_CC_APP_Portinfo PortInfo = {'0',115200,'8', '0','0','0','0','0','1', 0 };
+ int ComFd =0 ;//serial port handle
+
+ int nTryOpen = 0;
+ ComFd = open(DevName, O_RDWR);
+ while (ComFd < 0)
+ {
+ //assert(nTryOpen < ZCC_APP_MAX_OPEN_PORT_TIMES);
+ nTryOpen++;
+ zCc_sleep(500);//500 ms later to try again
+ ComFd = open(DevName, O_RDWR);
+ }
+
+ if (ioctl(ComFd, (('R'<<8)|1|(0x4004<<16)), 0x400) < 0) {//cov m
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ioctl1 fail\n <---\n",__FUNCTION__);
+ }
+ if (ioctl(ComFd, (('R'<<8)|4|(0x4004<<16)), 0) < 0) {//cov m
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ioctl2 fail\n <---\n",__FUNCTION__);
+ }
+ zCcApp_PortSet(ComFd, &PortInfo);
+ return ComFd;
+}
+
+
+int zCcApp_StartComm(void)
+{
+ /*´ò¿ª´®¿Ú*/
+ g_zCcApp_ComFd[1] = zCcApp_PortOpen(ZCC_APP_AT_COMM_CC);
+ g_zCcApp_ComFd[2] = zCcApp_PortOpen(ZCC_APP_AT_COMM_SS);
+ g_zCcApp_ComFd[3] = zCcApp_PortOpen(ZCC_APP_AT_COMM_DEV);
+ g_zCcApp_ComFd[0] = zCcApp_PortOpen(ZCC_APP_AT_COMM_IND);
+ return 0;
+}
+
+int zCcApp_GetAtIndFd(void)
+{
+ int fd = 0;
+ fd = g_zCcApp_ComFd[0];
+
+ return fd;
+
+}
+
+int zCcApp_GetAtCCFd(void)
+{
+ int fd = 0;
+ fd = g_zCcApp_ComFd[1];
+
+ return fd;
+
+}
+#endif
+
+
diff --git a/ap/app/ccapp/cc_com.h b/ap/app/ccapp/cc_com.h
new file mode 100644
index 0000000..8511832
--- /dev/null
+++ b/ap/app/ccapp/cc_com.h
@@ -0,0 +1,85 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : cc
+* ÎÄ ¼þ Ãû : cc_com.h
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : ccÄ£¿é¹«¹²ºê¡¢ÀàÐͶ¨Òå
+* ×÷ Õß :
+* °æ ±¾ :
+* Íê³ÉÈÕÆÚ :
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ :
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+#ifndef _cc_com_h_
+#define _cc_com_h_
+
+#include <sys/types.h>
+#include "os_type_def.h"
+
+
+#define _USE_PRINTF
+#ifdef _USE_PRINTF
+ #define Z_PRINTF(X) zOss_Printf X
+#else
+ #define Z_PRINTF(X)
+#endif
+
+#define FD_SET_SIZE 10
+
+#ifdef TEST_CCAPP
+typedef struct
+{
+ UINT8 set[(FD_SET_SIZE + 8 - 1) / 8];
+} fd_set;
+struct timeval
+{
+ UINT32 tv_sec; /* seconds */
+ UINT32 tv_usec; /* microseconds */
+};
+
+#define FD_SET(fd, fdset) \
+true
+#define FD_ZERO(fdset) memset(fdset, 0, sizeof(fd_set))
+
+#define FD_ISSET(fd, fdset) \
+true
+
+#endif
+typedef struct
+{
+ CHAR prompt; //prompt after reciving data
+ int baudrate; //baudrate
+ CHAR databit; //data bits, 5, 6, 7, 8
+ CHAR debug; //debug mode, 0: none, 1: debug
+ CHAR echo; //echo mode, 0: none, 1: echo
+ CHAR fctl; //flow control, 0: none, 1: hardware, 2: software
+ CHAR tty; //tty: 0, 1, 2, 3, 4, 5, 6, 7
+ CHAR parity; //parity 0: none, 1: odd, 2: even
+ CHAR stopbit; //stop bits, 1, 2
+ int reserved; //reserved, must be zero
+}T_CC_APP_Portinfo;
+#ifndef TEST_CCAPP
+int zCc_CleanCCMSG(void);
+int zCcApp_GetAtCmdFd(void);
+int zCcApp_PortRecv(int fdcom, CHAR *data, int datalen);
+int zCcApp_PortSend(int fdcom, CHAR *data, int datalen);
+int zCcApp_StartComm(void);
+int zCcApp_StartComm(void);
+int zCcApp_PortOpen(char* DevName);
+int zCcApp_GetAtIndFd(void);
+int zCcApp_GetAtCCFd(void);
+#endif
+
+#endif
diff --git a/ap/app/ccapp/cc_main.c b/ap/app/ccapp/cc_main.c
new file mode 100644
index 0000000..2c40612
--- /dev/null
+++ b/ap/app/ccapp/cc_main.c
@@ -0,0 +1,546 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : Cc
+* ÎÄ ¼þ Ãû : Cc_main.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : µç»°ÒµÎñÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
+* ×÷ Õß :
+* °æ ±¾ :
+* Íê³ÉÈÕÆÚ :
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+#include <errno.h>
+//#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+//#include <time.h>
+#include <fcntl.h>
+#include "cc_main.h"
+#include "cc_proc.h"
+#include "cc_com.h"
+#include "cc_at.h"
+#include <sys/types.h>
+#ifdef TEST_CCAPP
+#include "soft_timer.h"
+#endif
+
+
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+extern T_CC_APP_AtIndProcItem gCcAppAtIndProc[];
+extern SINT32 gCcAppRecvAtIndCnt;
+T_zCc_CallDetail g_Cc_CallDetail;
+char g_zCcApp_AtIndBuf[ZCC_APP_AT_BUF_MAX_LEN+1];
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+static SINT32 g_zCc_MsqId = NULL;
+//static SINT32 g_zCc_AtIndRspId = NULL;
+SINT32 g_zCc_AtRspId = NULL;
+
+
+static SINT32 g_zCc_getSlicEv_threadId = -1;
+
+int zCc_sleep(long ms)
+{
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = ms * 1000;
+ return select(0, NULL, NULL, NULL, &tv);
+}
+VOID zCc_SlicMsgProc(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ //g_Cc_CallDetail.curEvt = ptMsgBuf->usMsgCmd;
+ if (ptMsgBuf->usMsgCmd == ZCC_DTMF_E && g_Cc_CallDetail.dCount < ZDIAL_NUM_MAX)
+ {
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ptMsgBuf->aucDataBuf[0];
+ ccapp_log("zCc_SlicMsgProc digit[%d]=%s", g_Cc_CallDetail.dCount, g_Cc_CallDetail.digits);
+ printf("[ccapp_debug]:collect number digit[%d]=%s\n",g_Cc_CallDetail.dCount,g_Cc_CallDetail.digits);
+ }
+}
+
+VOID zCc_SendMsgToSub(MSG_BUF *pMsg)
+{
+ MSG_BUF *ptMsgBuf = (MSG_BUF*)malloc(sizeof(MSG_BUF));
+ SINT32 iMsgQueueId = ZAT_INVALID_ID;
+
+ if(ptMsgBuf == NULL)
+ return;
+ memcpy(ptMsgBuf, pMsg, sizeof(MSG_BUF));
+
+ iMsgQueueId = msgget(MODULE_ID_CALL_CTRL_LOCAL, 0);
+ if (iMsgQueueId != ZAT_INVALID_ID)
+ {
+ ptMsgBuf->lMsgType = MSG_TYPE_DEFAULT;
+ ptMsgBuf->dst_id = MODULE_ID_CALL_CTRL_LOCAL;
+ if (msgsnd(iMsgQueueId, ptMsgBuf, sizeof(MSG_BUF) - sizeof(LONG), 0) < 0)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendMsgToSub fail!!!\n",__FUNCTION__);
+ }
+ else
+ {
+ //zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendMsgToSub ptMsgBuf->usMsgCmd = %d, errno = %d <---\n",__FUNCTION__,ptMsgBuf->usMsgCmd,errno);
+ }
+ }
+ free(ptMsgBuf);
+}
+
+void* zCcApp_AtIndReader(void * ptr)
+{
+ int ret = -1;
+ int ReadLen = -1;
+ MSG_BUF QueueMsg = {0};
+ while(1)
+ {
+ ReadLen = msgrcv(g_zCc_AtRspId,&QueueMsg, sizeof(MSG_BUF)-sizeof(LONG), 0, 0);
+ if (ReadLen > 0)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s msgrcv QueueMsg.aucDataBuf = %d \n",__FUNCTION__,QueueMsg.usMsgCmd);
+ ret = zCcApp_AtIndRspProc(&QueueMsg);
+ }
+ else
+ {
+ continue;
+ }
+
+ }
+}
+
+VOID zCc_AtRecvMsgProc(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ ULONG cmdId = ptMsgBuf->usMsgCmd;
+ SINT32 i ;
+ SINT32 ret = -1;
+
+ for(i=0;i< gCcAppRecvAtIndCnt;i++)
+ {
+ if(cmdId == gCcAppAtIndProc[i].cmdId)
+ {
+ if(NULL!= gCcAppAtIndProc[i].AtIndProcFun)
+ {
+ ret = gCcAppAtIndProc[i].AtIndProcFun(ptMsgBuf);
+ }
+ break;
+ }
+ }
+}
+
+static VOID zCc_SetRj11LedStatus(char* LedStatus)
+{
+ int ret = 0;
+
+ sc_cfg_set("cc_rj11_status", LedStatus);
+
+ ret = ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_MMI, MSG_CMD_RJ11_STATUS_INFO, 0, NULL, 0);
+ if (ret != 0) {
+ printf("zCc_SetRj11LedStatus %s failed\n", LedStatus);
+ } else {
+ printf("zCc_SetRj11LedStatus %s success\n", LedStatus);
+ }
+}
+
+VOID* zCcApp_getSlicEv_entry(VOID *pBUf)
+{
+ MSG_BUF msgBuf = {0};
+ unsigned char bEvent = EV_UNKONWN;
+ DWORD dtmf1 = 0;
+ char dtmf;
+
+ while (1)
+ {
+ if (SLIC_SUCCESS == SLIC_MsgRev(&bEvent, &dtmf1))
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_getSlicEv_entry recv msg %d\n",__FUNCTION__,bEvent);
+
+ printf("[ccapp_debug]: get slic event, bEvent = %d, dtmf1=%d\n",bEvent, dtmf1);
+
+ switch (bEvent)
+ {
+ case EV_FXS_HOOKON:
+ msgBuf.usMsgCmd = ZCC_RELEASE_E;
+ msgBuf.src_id = MODULE_ID_SLIC;
+ zCc_SendMsgToSub(&msgBuf); /* ·¢¹Ò»ú ʼþ¸øÖ÷Ïß³Ì */
+ break;
+ case EV_FXS_HOOKOFF:
+ msgBuf.usMsgCmd = ZCC_SEIZE_E;
+ msgBuf.src_id = MODULE_ID_SLIC;
+ zCc_SendMsgToSub(&msgBuf); /* ·¢Õª»úʼþ¸øÖ÷Ïß³Ì */
+ break;
+ case EV_FXS_COLLECT_DIG:// '0'-'9', '*', '#'
+ dtmf = dtmf1;
+ msgBuf.usMsgCmd = ZCC_DTMF_E;
+ msgBuf.src_id = MODULE_ID_SLIC;
+ msgBuf.aucDataBuf[0] = (UINT8)(dtmf);
+ msgBuf.usDataLen = 1;
+ zCc_SendMsgToSub(&msgBuf); /* ·¢DTMF ʼþ¸øÖ÷Ïß³Ì */
+ break;
+ case EV_FXS_FLASH:
+ msgBuf.usMsgCmd = ZCC_FLASH_E;
+ msgBuf.src_id = MODULE_ID_SLIC;
+ zCc_SendMsgToSub(&msgBuf); /* ·¢FLASH ʼþ¸øÖ÷Ïß³Ì */
+ break;
+ case EV_LT_RINGER_REN:
+ if (dtmf1 == 1) {
+ zCc_SetRj11LedStatus("ledon");
+ } else {
+ zCc_SetRj11LedStatus("ledoff");
+ }
+ break;
+ default:/* ÆäËûʼþ¶ªÆú²»´¦Àí*/
+ break;
+ }
+
+ //zCc_sleep(10);
+ }
+}
+
+#define MAX_DIGIT_MAP_NUM 20
+#define MAX_DIGIT_MAP_WHOLE_LEN 256
+#define MAX_PHONE_NUM_SIZE 32
+char tz_digitmap[MAX_DIGIT_MAP_NUM][MAX_PHONE_NUM_SIZE+1];//phone list
+int frist_get_map = 0;
+
+//(2xxxxxx|3xxxxxx|4xxxxxx|5xxxxxx|7xxxxxx|0[1-9][0-9]xxxxxxx|00xxxxxxxxxxxxxx|6xxx|8xxx|1xxx|*xx|#xx)
+void get_digit_map_list()
+{
+ int i = 0;
+ int j = 0;
+ char buff[256] = {0};
+ char *str = NULL;
+
+ //sc_cfg_set("digitmap_str", "(2xxxxxx|3xxxxxx|4xxxxxx|5xxxxxx|7xxxxxx|0[1-9][0-9]xxxxxxx|00xxxxxxxxxxxxxx|6xxx|8xxx|1xxx|*xx|#xx)");
+ //sc_cfg_save();
+ sc_cfg_get("digitmap_str",buff,sizeof(buff));
+ if (strlen(buff) == 0)
+ return;
+
+ str = buff;
+ if(*str == '(')
+ str++;
+
+ while(*str != 0)
+ {
+ if(*str == '|')
+ {
+ tz_digitmap[i][j] = 0;
+ i++;
+ j = 0;
+ }
+ else if(*str == ')')
+ {
+ break;
+ }
+ else
+ {
+ tz_digitmap[i][j] = *str;
+ j++;
+ }
+ str++;
+ }
+
+}
+
+int digit_map_call(char *num)
+{
+ int i = 0;
+ int j = 0;
+ int n = 0;
+ char flag = 0;
+ char switch_str[4] = {0};
+ static char buff[32+1] = {0};
+
+
+ sc_cfg_get("digitmap_switch",switch_str,sizeof(switch_str));
+ if(strcmp(switch_str, "0") == 0)
+ {
+ return 0;
+ }
+
+ if(0 == frist_get_map)
+ {
+ get_digit_map_list();
+ frist_get_map = 1;
+ }
+
+ strncpy(buff, num,sizeof(buff)-1);
+ //printf("buff:%s\n", buff);
+
+
+ for(i = 0; i < MAX_DIGIT_MAP_NUM; i++)
+ {
+ if(strlen(tz_digitmap[i]) != 0)
+ {
+ while(((j+n) <= MAX_PHONE_NUM_SIZE) && (tz_digitmap[i][j] != 0) && (buff[j] != 0))
+ {
+ if(tz_digitmap[i][j+n] == '[' )
+ {
+ n++;
+ while(((j+n) <= MAX_PHONE_NUM_SIZE) && tz_digitmap[i][j+n] != ']')
+ {
+ if(((j+n+2) <= MAX_PHONE_NUM_SIZE) && tz_digitmap[i][j+n+1] == '-')
+ {
+ if(tz_digitmap[i][j+n] <= buff[j] && buff[j] <= tz_digitmap[i][j+n+2])
+ {
+ //printf("digit_map:%c, %c, %c\n", tz_digitmap[i][j+n], tz_digitmap[i][j+n+2], buff[j]);
+ flag = 1;
+ }
+ n+=3;
+ }
+ else
+ {
+ if(tz_digitmap[i][j+n] == buff[j])
+ {
+ flag = 1;
+ }
+ n++;
+ }
+ }
+
+ if(flag == 0)
+ {
+ break;
+ }
+
+ flag = 0;
+
+
+ }
+ else
+ {
+ if(tz_digitmap[i][j+n] != buff[j])
+ {
+ if(!(tz_digitmap[i][j+n] == 'X' || tz_digitmap[i][j+n] == 'x'))
+ break;
+ }
+ }
+ j++;
+ if(((j+n) <= MAX_PHONE_NUM_SIZE) && (tz_digitmap[i][j+n] == 0) && (buff[j] == 0))
+ {
+ //ccapp_log("digit_map_call do Match: %d, %s, %s\n", i, tz_digitmap[i], buff);
+ return 1;
+ }
+ }
+ }
+ n = 0;
+ j = 0;
+ }
+
+ return 0;
+}
+
+#ifdef TEST_CCAPP
+VOID* zCc_main(VOID * pbuf)
+{
+ MSG_BUF QueueMsg = {0};
+ int MainQeueId = -1;
+ int ret = -1;
+ UINT8 bMsgType =1;
+ int fd = -1;
+ pthread_attr_t AtIndReaderAttr;
+ pthread_t AtIndReaderThreadId;
+
+ pthread_attr_init(&AtIndReaderAttr);
+ pthread_attr_setstacksize(&AtIndReaderAttr,4*1024);
+ fd = zCcApp_GetAtIndFd();
+ AtIndReaderThreadId = pthread_create(&AtIndReaderThreadId, NULL, zCcApp_AtIndReader, (void*)&fd);
+ if(AtIndReaderThreadId < 0)
+ {
+ return NULL;
+ }
+ while (1)
+ {
+ ret = msgrcv(MainQeueId, &QueueMsg, sizeof(MSG_BUF), bMsgType, 0);
+ if(ret == -1)
+ {
+ return NULL;
+ }
+ else
+ {
+ switch (QueueMsg.src_id)
+ {
+ case MODULE_ID_CALL_CTRL: // AT Ind msg
+ zCc_AtRecvMsgProc(&QueueMsg);
+ break;
+
+ case MODULE_ID_SLIC: // message from slic
+ default:
+ zCc_SlicMsgProc(&QueueMsg);
+ break;
+ }
+ zCc_RunMaster(&QueueMsg);
+ }
+ }
+
+}
+#endif
+#ifndef TEST_CCAPP
+
+static int polarity_reversal_flag = 0;
+int get_polarity_reversal_flag(void)
+{
+ return polarity_reversal_flag;
+}
+
+void check_polarity_reversal_cfg(void)
+{
+ int rt;
+ char buf[32];
+
+ memset(buf, 0, sizeof(buf));
+ rt = sc_cfg_get("polarity_reversal",buf,sizeof(buf));
+ if (rt != 0 || strlen(buf) == 0)
+ {
+ sc_cfg_set("polarity_reversal", "0");
+ sc_cfg_save();
+
+ polarity_reversal_flag = 0;
+ return ;
+ }
+
+ polarity_reversal_flag = atoi(buf);
+}
+
+void check_wb_mode_cfg(void)
+{
+ int rt;
+ int val;
+ char buf[64];
+
+ memset(buf, 0, sizeof(buf));
+ rt = sc_cfg_get("wb_mode",buf,sizeof(buf));
+ if (rt != 0 || strlen(buf) == 0)
+ {
+ sc_cfg_set("wb_mode", "1");
+ sc_cfg_save();
+
+ val = 1;
+ }
+ else
+ val = atoi(buf);
+
+ sprintf(buf, "at_cmd AT+ZIMSAMRW=%d", (val==0)?0:1);
+ soft_system(buf);
+
+ sprintf(buf, "echo \"at_cmd AT+ZIMSAMRW=%d\" > /tmp/log.ZIMSAMRW", (val==0)?0:1);
+ soft_system(buf);
+}
+
+
+int main(VOID)
+{
+ MSG_BUF QueueMsg = {0};
+ int ret = -1;
+ pthread_t CcAppMainThreadId;
+ pthread_attr_t AtIndReaderAttr;
+ pthread_t AtIndReaderThreadId;
+ SLIC_Initial();
+ SLIC_Dev_Init();
+ soft_system("at_cmd AT+ZIMSTEST=\"EMCALL_TO_NORMAL\",1 ");
+
+ check_wb_mode_cfg();
+ check_polarity_reversal_cfg();
+
+ g_zCc_MsqId = msgget(MODULE_ID_CALL_CTRL_LOCAL, IPC_CREAT | 0600);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s g_zCc_MsqId %d, errno:%d\n",__FUNCTION__,g_zCc_MsqId,errno);
+ if (g_zCc_MsqId == ZAT_INVALID_ID)
+ {
+ return 0;
+ }
+
+ g_zCc_AtRspId = msgget(MODULE_ID_CALL_CTRL, IPC_CREAT | 0600);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s g_zCc_AtRspId %d, errno:%d\n",__FUNCTION__,g_zCc_AtRspId,errno);
+
+ if (g_zCc_AtRspId == ZAT_INVALID_ID)
+ {
+ return 0;
+ }
+
+ g_zCc_getSlicEv_threadId = pthread_create(&CcAppMainThreadId, NULL, zCcApp_getSlicEv_entry,0);
+
+ if(g_zCc_getSlicEv_threadId!=0)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCc_getSlicEv error, errno = %d \n",__FUNCTION__,errno);
+ return -1;
+ }
+ else
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCc_getSlicEv succ\n",__FUNCTION__);
+ }
+
+ pthread_attr_init(&AtIndReaderAttr);
+ pthread_attr_setstacksize(&AtIndReaderAttr,4*1024);
+ ret = pthread_create(&AtIndReaderThreadId, NULL, zCcApp_AtIndReader, 0);
+ pthread_attr_destroy(&AtIndReaderAttr); //kw 2
+ if(ret != 0) //cov m
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCcApp_AtIndReader error, errno = %d \n",__FUNCTION__,errno);
+ return -1;
+ }
+ else
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCcApp_AtIndReader succ\n",__FUNCTION__);
+ }
+
+ zCc_SendAtImsPlusReq(1,1);//ÉèÖÃimsplusÉϱ¨
+
+ while (1)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","BACK TO main\n");
+ ret = msgrcv(g_zCc_MsqId, &QueueMsg, sizeof(MSG_BUF)-sizeof(LONG), 0, 0);
+ if(ret==-1)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s msgrcv return ret= %d errno=%d\n",__FUNCTION__,ret, errno);
+ continue;
+ }
+ else
+ {
+ switch (QueueMsg.src_id)
+ {
+ case MODULE_ID_SLIC: // message from slic
+ zCc_SlicMsgProc(&QueueMsg);
+ break;
+ default: // AT Ind msg
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","recv msg %d from at_ctl\n",QueueMsg.usMsgCmd);
+ if (QueueMsg.usMsgCmd==MSG_CMD_ZIMSPLUS_IND
+ ||QueueMsg.usMsgCmd==MSG_CMD_DSCI_IND
+ ||QueueMsg.usMsgCmd==MSG_CMD_ZCPI
+ ||QueueMsg.usMsgCmd==MSG_CMD_ZVOICECHNL)
+ {
+ zCc_CheckSlaveState("in zCc_AtRecvMsgProc");
+ zCc_AtRecvMsgProc(&QueueMsg);
+ }
+ break;
+ }
+ if (QueueMsg.usMsgCmd==MSG_CMD_VTS_RSP)
+ {
+ zCcApp_Vts_Rsp();
+ }
+ zCc_RunMaster(&QueueMsg);
+ }
+ }
+
+return 0;
+}
+#endif
+
diff --git a/ap/app/ccapp/cc_main.h b/ap/app/ccapp/cc_main.h
new file mode 100644
index 0000000..ec195c6
--- /dev/null
+++ b/ap/app/ccapp/cc_main.h
@@ -0,0 +1,248 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : CC
+* ÎÄ ¼þ Ãû : Cc_main.h
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : ATÃüÁî´¦ÀíÄ£¿éºê¡¢ÀàÐͶ¨Òå
+* ×÷ Õß :
+* °æ ±¾ :
+* Íê³ÉÈÕÆÚ :
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ :
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+#ifndef _CC_MAIN_H
+#define _CC_MAIN_H
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+#include "message.h"
+#include "softap_api.h"
+#include "cc_proc.h"
+#include "slic_type.h"
+#include "slic_inf.h"
+#include <time.h>
+#include "libzte_log.h"
+#ifndef TEST_CCAPP
+#include "sys/ipc.h"
+#include "signal.h"
+#endif
+#ifdef _OS_TOS
+#include "osa_api.h"
+#include "oss_api.h"
+#endif
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+typedef enum
+{
+ ZCCAPP_TIMER_HOOKOFF_DETECT, /*Õª»úºóµÈ´ý²¦ºÅ¶¨Ê±Æ÷*/
+ ZCCAPP_TIMER_DTMF_DETECT, /*²¦ºÅ¼ä¸ô¶¨Ê±Æ÷*/
+ ZCCAPP_TIMER_BUSYTONE_DETECT, /*æÒô¶¨Ê±Æ÷*/
+ ZCCAPP_TIMER_TKYTONE_DETECT, /*æÒôºóµÄÐ¥½ÐÒô¶¨Ê±Æ÷*/
+ ZCCAPP_TIMER_SSDIALTONE_DETECT, /*²¹³äÒµÎñ²Ù×÷ʱÊÕµ½flashºóÆô²¦ºÅÒô¶¨Ê±Æ÷*/
+ ZCCAPP_TIMER_HOOKOFF_IDLE,
+}T_zCc_TimerEv;
+
+typedef enum
+{
+ ZCCAPP_ATIND_DSCI,
+ ZCCAPP_ATIND_ZCPI,
+ ZCCAPP_ATIND_IMSPLUS,
+ ZCCAPP_ATIND_MODE
+}T_zCc_AtIndEv;
+
+
+#define ZCCAPP_TIMER_HOOKOFF_INTERVAL 10000
+#define ZCCAPP_TIMER_DTMF_INTERVAL 5000
+#define ZCCAPP_TIMER_BUSYTONE_INTERVAL 7000
+#define ZCCAPP_TIMER_TKYTONE_INTERVAL 60000
+
+#define ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL 500
+
+/*
+ * Number of slaves per master.
+ * Two slaves are required for 3-party calls.
+ */
+#define ZCC_SLAVES 8
+#define ZCC_MAXCID 7
+#define ZCC_MINCID 1
+
+#define ZDIAL_NUM_MAX 48
+#define ZCC_AT_CHNL_ID 70
+#define ZCC_FLASH_SIGN ('F')
+#define ZCC_TIMEOUT_SIGN ('T')
+/*
+ * Define how focus flag in master state machine is interpreted.
+ * XXX: Extend this for more than 3-party calls.
+ */
+#define ZCC_FOCUS_0 (1 << 0)
+#define ZCC_FOCUS_1 (1 << 1)
+#define ZCC_FOCUS_2 (1 << 2)
+#define ZCC_FOCUS_PSTN (1 << 3)
+#define ZCC_FOCUS_BOTH (ZCC_FSM_FOCUS_0 + ZCC_FSM_FOCUS_1)
+
+/*
+ * Various timeouts.
+ * These timeouts are in units of ZCC_TIMER_E.
+ */
+#define ZCC_BSYTMO (7000) /* Timeout in busy tone state */
+#define ZCC_TKYTMO (60000) /* Timeout in turkey tone state */
+//#define ZCC_FBSYTMO (40000) /* Timeout in fast busy tone state */
+#define ZCC_DACCMTMO (5000) /* Timeout (interdigit) in daccm state */
+#define ZCC_DTTMO (10000) /* Timeout in dialtone state */
+#define ZCC_RSTTMO (10) /* Timeout in master reset state */
+#define ZCC_RELTMO (10) /* Timeout in master release state */
+#define ZCC_RINGTMO (10) /* Timeout in master ringing state */
+#define ZCC_SEIZETMO (10) /* Timeout in master seize state */
+#define ZCC_RBTMO (40) /* Timeout in ringback state */
+#define ZCC_DIALTMO (30) /* Timeout in dial state */
+#define ZCC_PSTNSWTMO (5) /* Timeout in pstn switching state */
+#define ZCC_INTERDIGITSHORT (5) /* Timeout (interdigit short) in daccm state*/
+#define ZCC_WAIT_RESOURCETMO (8) /* Timeout in waiting for resource state */
+
+/* Define digits match results. */
+#define ZCC_NO_RESULT (0x00) /* need more digits */
+#define ZCC_CALL (0x01) /* all digits collected */
+#define ZCC_BAOC_REG (0x10)
+#define ZCC_BAOC_DEREG (0x11)
+#define ZCC_BOIC_REG (0x12)
+#define ZCC_BOIC_DEREG (0x13)
+#define ZCC_CFU_REG (0x20)
+#define ZCC_CFU_DEREG (0x21)
+#define ZCC_CFNRY_REG (0x22)
+#define ZCC_CFNRY_DEREG (0x23)
+#define ZCC_CFB_REG (0x24)
+#define ZCC_CFB_DEREG (0x25)
+#define ZCC_FLASH_1 (0x30) /* Release all active call and accept the other(held or waiting) call */
+#define ZCC_FLASH_2 (0x31) /* Place all active call on hold and accept the other(held or waiting) call */
+#define ZCC_FLASH_3 (0x32) /* Adds a held call to the conversation */
+#define ZCC_FLASH_4 (0x33) /* call transfer */
+#define ZCC_FLASH_0 (0x34) /* release waiting call */
+#define ZCC_LOCAL_TEST_CALL (0xFF-1)
+#define ZCC_MATCHERR (0xFF) /* wrong input */
+
+
+/* Define master state machine states. */
+typedef enum {
+ ZCC_M_RELEASE_S = 0,
+ ZCC_M_RINGING_S = 1,
+ ZCC_M_SEIZE_S = 2
+} T_zCc_MasterState;
+
+/* Define slave state machine states.˳Ðò²»¿Éµ÷Õû */
+typedef enum {
+ ZCC_S_IDLE_S = 0,
+ ZCC_S_DT_S ,
+ ZCC_S_DACCM_S ,
+ ZCC_S_DIALING_S ,
+ ZCC_S_RINGBACK_S ,// Ö÷½Ð¹ý³ÌÖеÄÕñÁå̬
+ ZCC_S_BSYT_S ,
+ ZCC_S_TKYT_S ,
+ ZCC_S_SIL_S ,
+ ZCC_S_TALKING_S ,
+ ZCC_S_TRYING_S ,
+ ZCC_S_WAIT_RESOURCE_S ,
+} T_zCc_SlaveState, T_zCc_CallState;
+
+/* Define known tone types. */
+typedef enum {
+ ZCC_TONE_OFF_A = 0,
+ ZCC_TONE_SIL_A = 1,
+ ZCC_TONE_RB_A = 2,
+ ZCC_TONE_BSY_A = 3,
+ //ZCC_TONE_FBSY_A = 4,
+ ZCC_TONE_TKY_A = 5,
+ ZCC_TONE_DIAL_A = 6,
+ ZCC_TONE_CIDCW_A = 7,
+}T_zCc_Tone;
+
+
+/* Define known messages to SIP. */
+typedef enum {
+ ZCC_SNO_M = 0,
+ ZCC_SBUSY_M = 1, /* When this node is busy */
+ ZCC_SANS_M = 2, /* When this node answered */
+ ZCC_SINV_M = 3, /* When to invite the other node */
+ ZCC_SREG_M = 4, /* When to register */
+ ZCC_SDISCN_M = 5, /* When this node disconnected */
+ ZCC_SRING_M = 6, /* When this node starts ringing */
+ ZCC_SRBANS_M = 7, /* When the other node answered */
+ ZCC_SHOLD_M = 8, /* When the other node is put on hold */
+ ZCC_SREINV_M = 9, /* When the other node is put off hold */
+ ZCC_SMEDIA_M = 10, /* When a media message is received */
+ ZCC_SDIGITS_M = 18, /* When a digits timeout occurs */
+ ZCC_SDTMF_M = 19, /* When a DTMF relay occurs */
+ ZCC_SRING_RSRC_READY_M = 119, /* When this mode start ringing for resource ready */
+} T_zCc_SResp;
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef struct
+{
+ UINT8 curCmd;
+ UINT8 curAtCmdSrc;
+}T_zCc_CurAtCmdInfo;
+
+
+/* Slave state machine object. */
+typedef struct {
+ T_zCc_SlaveState state; /* This slave's state */
+ T_zCc_SlaveState old_state;
+ T_zCc_Tone tone; /* What tone to play */
+ T_zCc_SResp sMsg; /* Action for SIP */
+ UINT8 heldcall; /* When 1, the call is in held state */
+ UINT16 confcall; /* When 1, the call is in conference */
+ UINT8 waitDSCI6; /* hookon,wait DSCI6 */
+ UINT8 cid; /* call id */
+ UINT16 idle_second; /*if hookoff but no key is down, this var show the time for waiting key to input */
+ CHAR number[ZDIAL_NUM_MAX];
+ UINT8 is_callout;
+ UINT8 is_cidcw;
+} T_zCc_SlaveObj;
+
+/* Master state machine object. */
+typedef struct {
+ T_zCc_MasterState state; /* This master's state */
+ T_zCc_SlaveObj slaveObj[ZCC_SLAVES];
+ USHORT evt[ZCC_SLAVES];
+ // UINT8 focus; /* Which slave in focus */
+ UINT8 mode; /* Current mode */
+ UINT8 chupSent;
+ UINT8 ringCid; /* Ring the phone */
+ UINT8 resourceReady; /* ZCPI: x,5 received */
+ UINT8 dCount; /* Collected DTMF digits string */
+ CHAR digits[ZDIAL_NUM_MAX];// dialled number
+ CHAR number[ZDIAL_NUM_MAX];// calling number
+ UINT8 confNum; /* total conference number */
+ E_CC_APP_AtReqCmdId curAtCmdId;
+ UINT8 hookofffg;
+ UINT8 actCallNum; /* total active call number */
+ UINT8 lastTone;
+ UINT8 waitchldresult;
+ T_zCc_MasterState old_state;
+} T_zCc_MasterObj, T_zCc_CallDetail;
+
+extern T_zCc_CallDetail g_Cc_CallDetail;
+
+extern T_zCc_CurAtCmdInfo *g_Cc_AtIndRspMsg;
+//typedef VOID (*zCc_SlicEvFunc)(UINT8 Para);
+VOID zCc_SendMsgToSub(MSG_BUF *pMsg);
+int zCc_sleep(long ms);
+VOID zCc_SendMsgToRspSub(MSG_BUF *pMsg);
+
+#endif
+
diff --git a/ap/app/ccapp/cc_proc.c b/ap/app/ccapp/cc_proc.c
new file mode 100644
index 0000000..873497e
--- /dev/null
+++ b/ap/app/ccapp/cc_proc.c
@@ -0,0 +1,3889 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : CcApp
+* ÎÄ ¼þ Ãû : at_proc.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : ATÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
+* ×÷ Õß : syx
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-01-05
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : 0001
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+#include "cc_main.h"
+#include "cc_proc.h"
+#include "cc_com.h"
+#include "cc_at.h"
+#include "cc_timer.h"
+#include "string.h"
+#ifdef TEST_CCAPP
+#include "soft_timer.h"
+#endif
+
+#include "slic_inf.h"
+#include <stdint.h>
+#include <linux/volte_drv.h>
+#include "voice_lib.h"
+
+#define LOCAL_TEST_CALL_CODE "*#66*#"
+#define TZ_TEST_TIMING "*#83781234*#"
+typedef enum{
+ LocalTestCallST_None = 0,
+ LocalTestCallST_Start,
+ LocalTestCallST_Ring,
+ LocalTestCallST_End
+}eLocalTestCallST;
+int local_test_call_st = 0;
+typedef enum{
+ LocalTestCallType_None = 0,
+ LocalTestCallType_LOOP
+}eLocalTestCallType;
+int local_test_call_type = 0;
+
+extern SINT32 g_zCc_AtRspId;
+
+int zCc_find_held_cid(void);
+int zCc_find_held_incoming_cid(void);
+int zCc_find_all_callout(int slave[ZCC_SLAVES]);
+int zCc_talking_count(void);
+char *get_local_date_time(void);
+char *get_local_datetime(char *buff);
+
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+
+/* {
+ ZCC_S_IDLE_S = 0,
+ ZCC_S_DT_S ,
+ ZCC_S_DACCM_S ,
+ ZCC_S_DIALING_S ,
+ ZCC_S_RINGBACK_S ,// Ö÷½Ð¹ý³ÌÖеÄÕñÁå̬
+ ZCC_S_BSYT_S ,
+ ZCC_S_TKYT_S ,
+ ZCC_S_SIL_S ,
+ ZCC_S_TALKING_S ,
+ ZCC_S_TRYING_S ,
+ ZCC_S_WAIT_RESOURCE_S ,
+} */
+const pCcSlaveFsmFunc zCcSlaveFsmFunc[] = {zCc_SIdleState,
+ zCc_SDtState,
+ zCc_SDaccmState,
+ zCc_SDialingState,
+ zCc_SRingbackState,
+ zCc_SBsyToneState,
+ zCc_STkytState,
+ zCc_SSilState,
+ zCc_STalkingState,
+ zCc_STryingState,
+ zCc_SWaitResourceState
+ };
+ /*
+ CB
+ *54*KSSSS# REGISTER AT+CLCK="AO",1,"SSSS"
+ #54*KSSSS# DeREGISTER AT+CLCK="AO",0,"SSSS"
+ *#54# QUERY/CHECK AT+CLCK="AO",2,"SSSS" not supported---------------------------
+ K=1 "AO"; K=2 or K=3 "OI"(ÒÆ¶¯ÍøÃ»ÓйúÄÚ³¤Í¾ÏÞÖÆÒµÎñ); SSSS password
+ *56# REGISTER AT+CLCK="AI",1,"SSSS" ÐèÒªÖÕ¶Ë·½°¸»ò¸Ä²Ù×÷·½Ê½---------------------------
+ #56# DeREGISTER AT+CLCK="AI",0,"SSSS" ---------------------------
+ CFU
+ *57*DN# REGISTER AT+CCFC=0,1,"DN"
+ #57# DeREGISTER AT+CCFC=0,0
+ *#57*DN# AT+CCFC=0,2 not supported---------------------------
+ CFNRy
+ *41*DN# REGISTER AT+CCFC=2,1,"DN"
+ #41# DeREGISTER AT+CCFC=2,0
+ *#41*DN# AT+CCFC=2,2 not supported---------------------------
+ CFB
+ *40*DN# REGISTER AT+CCFC=1,1,"DN"
+ #40# DeREGISTER AT+CCFC=1,0
+ *#40*DN# AT+CCFC=1,2 not supported---------------------------
+ CW ( ÖÕ¶Ë·½°¸´ý¼Ó )
+ *58# REGISTER AT+CCWA=0,1 ---------------------------
+ #58# DeREGISTER AT+CCWA=0,0 ---------------------------
+ */
+static const T_zCc_ScTab g_zCc_SCTab[] =
+{
+ {ZCC_BAOC_REG, 10, 10, "*54*1"},
+ {ZCC_BAOC_DEREG, 10, 10, "#54*1"},
+ {ZCC_BOIC_REG, 10, 10, "*54*2"},
+ {ZCC_BOIC_DEREG, 10, 10, "#54*2"},
+ {ZCC_BOIC_REG, 10, 10, "*54*3"},
+ {ZCC_BOIC_DEREG, 10, 10, "#54*3"},
+ {ZCC_CFU_REG, 6, SC_MAXLEN, "*57*"},
+ {ZCC_CFU_DEREG, 4, 4, "#57#"},
+ {ZCC_CFNRY_REG, 6, SC_MAXLEN, "*41*"},
+ {ZCC_CFNRY_DEREG, 4, 4, "#41#"},
+ {ZCC_CFB_REG, 6, SC_MAXLEN, "*40*"},
+ {ZCC_CFB_DEREG, 4, 4, "#40#"},
+};
+
+
+
+T_CC_APP_RecvAtIndItem gCcAppRecvAtIndProc[]=
+{
+ {MSG_CMD_DSCI_IND, zCc_RecvDsciInd},
+ {MSG_CMD_ZCPI,zCc_RecvZcpiInd},
+ {MSG_CMD_ZIMSPLUS_IND,zCc_RecvImsplusInd},
+ {MSG_CMD_ZVOICECHNL,zCc_RecvZvoiceChnl},
+ {MSG_CMD_ATD_DIAL_RSP,zCc_RecvRsp},
+ {MSG_CMD_ATA_RSP,zCc_RecvRsp},
+ {MSG_CMD_CHUP_RSP,zCc_RecvRsp},
+ {MSG_CMD_VTS_RSP,zCc_RecvRsp},
+ {MSG_CMD_ZIMSPLUS_RSP,zCc_RecvRsp},
+ {MSG_CMD_CLCK_RSP,zCc_RecvRsp},
+ {MSG_CMD_CCFC_RSP,zCc_RecvRsp},
+ {MSG_CMD_CHLD_RSP,zCc_RecvRsp}
+};
+ T_CC_APP_AtIndProcItem gCcAppAtIndProc[]=
+{
+ {MSG_CMD_DSCI_IND, zCc_DsciIndProc},
+ {MSG_CMD_ZCPI,zCc_ZcpiIndProc},
+ {MSG_CMD_ZIMSPLUS_IND,zCc_ZimsplusProc},
+ {MSG_CMD_ZVOICECHNL,zCc_ZvoicechnlProc}
+};
+
+
+SINT32 gCcAppRecvAtIndProcCnt = sizeof(gCcAppRecvAtIndProc)/sizeof(gCcAppRecvAtIndProc[0]);
+SINT32 gCcAppRecvAtIndCnt = sizeof(gCcAppAtIndProc)/sizeof(gCcAppAtIndProc[0]);
+char g_zCcApp_AtRecvBuf[ZCC_APP_AT_BUF_MAX_LEN+1] = {0};
+T_zCc_CurAtCmdInfo * g_Cc_AtIndRspMsg;
+
+VOID zCc_ShowAllSlave(VOID)
+{
+ UINT8 slave = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ ccapp_log(" slave=%d number=%s cid=%d state=%d tone=%d msg=%d held=%d isOut=%d dsci6=%d",
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].number,
+ g_Cc_CallDetail.slaveObj[slave].cid,
+ g_Cc_CallDetail.slaveObj[slave].state,
+ g_Cc_CallDetail.slaveObj[slave].tone,
+ g_Cc_CallDetail.slaveObj[slave].sMsg,
+ g_Cc_CallDetail.slaveObj[slave].heldcall,
+ g_Cc_CallDetail.slaveObj[slave].is_callout,
+ g_Cc_CallDetail.slaveObj[slave].waitDSCI6);
+ }
+}
+
+VOID zCc_ShowAllSlaveWithTips(const char *tips)
+{
+
+ UINT8 slave = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ 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",
+ tips, g_Cc_CallDetail.state,
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].number,
+ g_Cc_CallDetail.slaveObj[slave].cid,
+ g_Cc_CallDetail.slaveObj[slave].state,
+ g_Cc_CallDetail.slaveObj[slave].tone,
+ g_Cc_CallDetail.slaveObj[slave].sMsg,
+ g_Cc_CallDetail.slaveObj[slave].heldcall,
+ g_Cc_CallDetail.slaveObj[slave].is_callout,
+ g_Cc_CallDetail.slaveObj[slave].waitDSCI6);
+ }
+}
+
+
+VOID zCc_CheckSlaveState(const char *tips)
+{
+ UINT8 slave = 0;
+
+ if(g_Cc_CallDetail.old_state != g_Cc_CallDetail.state)
+ {
+ ccapp_log("=========== %s =============\n master state %d --> %d",
+ tips,
+ g_Cc_CallDetail.old_state,
+ g_Cc_CallDetail.state);
+ g_Cc_CallDetail.old_state = g_Cc_CallDetail.state;
+ }
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].old_state != g_Cc_CallDetail.slaveObj[slave].state)
+ {
+ ccapp_log("=========== %s =============\n slave=%d state %d --> %d",
+ tips,
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].old_state,
+ g_Cc_CallDetail.slaveObj[slave].state);
+
+ g_Cc_CallDetail.slaveObj[slave].old_state = g_Cc_CallDetail.slaveObj[slave].state;
+ }
+ }
+}
+
+
+VOID zCc_ClearDigits(VOID)
+{
+ g_Cc_CallDetail.dCount = 0;
+ memset(g_Cc_CallDetail.digits, 0, sizeof(g_Cc_CallDetail.digits));
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ClearDigits: digits cleared\n",__FUNCTION__);
+}
+
+VOID zCc_InitSlaveObj(UINT8 slave)
+{
+ memset(&g_Cc_CallDetail.slaveObj[slave], 0, sizeof(T_zCc_SlaveObj));
+ if (slave == g_Cc_CallDetail.ringCid)
+ {
+ g_Cc_CallDetail.ringCid = 0;
+ }
+}
+
+UINT8 zCc_TalkingCall(UINT8 heldcall)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TALKING_S
+ && g_Cc_CallDetail.slaveObj[slave].heldcall == heldcall
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
+UINT8 zCc_GetWaitDisc6Slave(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 1)
+ {
+ cnt++;
+ }
+ }
+ return cnt;
+}
+
+UINT8 zCc_BusyToneAllowed(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S )
+ {
+ cnt++;
+ }
+ }
+ if ((1 == cnt)//µ±Ç°Ã»ÓÐÆäËûºô½Ð
+ ||(cnt == 2 && g_Cc_CallDetail.ringCid !=0
+ && g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].state == ZCC_S_TRYING_S
+ && g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone != ZCC_TONE_CIDCW_A)//Õª»ú̬»¹ÓÐÀ´µçÇÒδ·ÅÒô
+ ||(cnt == zCc_GetWaitDisc6Slave()+1))//ÆäËûºô½Ð¶¼ÊÇÔÚµÈdsci6µÄ
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+
+}
+
+UINT8 zCc_ActiveCall(VOID)
+{
+ return zCc_TalkingCall(0);
+}
+
+UINT8 zCc_HeldCall(VOID)
+{
+ return zCc_TalkingCall(1);
+}
+
+UINT8 zCc_GetSpecSlave(UINT8 state)
+{
+ UINT8 slave = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == state && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ return slave;
+ }
+ }
+ return 0;
+}
+
+UINT8 zCc_GetSpecSlaveIgnoreWaitDSCI6(UINT8 state)
+{
+ UINT8 slave = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == state)
+ {
+ return slave;
+ }
+ }
+ return 0;
+}
+
+UINT8 zCc_Find_waitDSCI6_cid(void)
+{
+ UINT8 slave = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state!=ZCC_S_IDLE_S &&
+ g_Cc_CallDetail.slaveObj[slave].waitDSCI6!=0)
+ {
+ return slave;
+ }
+ }
+ return 0;
+}
+
+
+
+
+UINT8 zCc_GetDialingSlave(UINT8 waitDSCI6)
+{
+ UINT8 slave = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DIALING_S )
+ {
+ if (waitDSCI6)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ return slave;
+ }
+ }
+ else
+ {
+ return slave;
+ }
+ }
+ }
+ return 0;
+}
+
+UINT8 zCc_GetDiscSlave(UINT8 state)
+{
+ UINT8 slave = 0;
+ UINT8 cnt = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].sMsg== ZCC_SDISCN_M && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ cnt++;
+ }
+ }
+ return cnt;
+}
+
+
+int tz_lock_cellid_is_limit_callin()
+{
+ char cellid_is_lock[4] = {0};
+
+ sc_cfg_get("cellid_is_lock",cellid_is_lock,sizeof(cellid_is_lock));
+ if(strcmp(cellid_is_lock, "1") == 0)
+ return 1;
+
+ return 0;
+}
+
+int tz_lock_cellid_check_sos_num()
+{
+ int ret = 0;
+ char tz_Mexico_sos_lock_cellid[128] = {0};
+
+ ret = strlen(g_Cc_CallDetail.digits);
+ sc_cfg_get("tz_Mexico_sos_lock_cellid",tz_Mexico_sos_lock_cellid,sizeof(tz_Mexico_sos_lock_cellid));
+ if(ret > 0 && ((g_Cc_CallDetail.digits[ret-1] == '#') || (g_Cc_CallDetail.digits[ret-1] == 'T')))
+ {
+ return TRUE;
+ }
+ else if(strstr(tz_Mexico_sos_lock_cellid, g_Cc_CallDetail.digits) != NULL)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+
+}
+
+extern int digit_map_call(char *num);
+/* µ±Ç°Ò»Â· ·Ç ±£³ÖµÄ ºô½Ð£¬FLASH£¬µ±Ç°ºô½Ð±»±£³Ö»òÊÍ·Å£¬digitsÖ»¼Ç¼Óû§²¦´òµÄºÅÂ룻
+ µ±Ç°Ò»Â· ·Ç ±£³ÖµÄ ºô½Ð£¬FLASH£¬µ±Ç°ºô½Ð±»»Ö¸´£»
+ ÆäËü³¡¾°ÐèÒªdigits ¼Ç¼ZCC_FLASH_SIGNºÍÓû§ ²¦´òµÄһλºÅÂë */
+UINT8 zCc_DigitsMatch(VOID)
+{
+ UINT16 i = 0;
+ UINT8 scSum = sizeof(g_zCc_SCTab)/sizeof(T_zCc_ScTab);
+
+ ccapp_log("zCc_DigitsMatch: digits=%s dCount=%d\n",g_Cc_CallDetail.digits,g_Cc_CallDetail.dCount);
+ if(tz_lock_cellid_is_limit_callin())
+ {
+ if(tz_lock_cellid_check_sos_num() == FALSE)
+ return ZCC_MATCHERR;
+ }
+
+ if (g_Cc_CallDetail.dCount == 0)
+ {
+ //ccapp_log("1");
+ return ZCC_NO_RESULT;
+ }
+
+ if(g_Cc_CallDetail.dCount >= 2 && g_Cc_CallDetail.dCount<ZDIAL_NUM_MAX)
+ {
+ if(g_Cc_CallDetail.digits[0]!=ZCC_FLASH_SIGN &&
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1]!=ZCC_TIMEOUT_SIGN)
+ {
+ printf("g_Cc_CallDetail.digits = %s\n",g_Cc_CallDetail.digits);
+ if(strcmp(LOCAL_TEST_CALL_CODE, g_Cc_CallDetail.digits)==0)
+ {
+ //ccapp_log("2");
+ local_test_call_type = LocalTestCallType_None;
+ return ZCC_LOCAL_TEST_CALL;
+ }
+ else if(strcmp(TZ_TEST_TIMING, g_Cc_CallDetail.digits)==0)
+ {
+ local_test_call_type = LocalTestCallType_LOOP;
+ return ZCC_LOCAL_TEST_CALL;
+ }
+ }
+
+ if(g_Cc_CallDetail.digits[0]=='*' && g_Cc_CallDetail.digits[1]=='#')
+ {
+ //ccapp_log("3");
+ return ZCC_NO_RESULT;
+ }
+ }
+
+ if(g_Cc_CallDetail.dCount>=ZDIAL_NUM_MAX)
+ {
+ //ccapp_log("4");
+ return ZCC_MATCHERR;
+ }
+
+ if(digit_map_call(g_Cc_CallDetail.digits)!=0)
+ {
+ ccapp_log("digit_map_call match %s", g_Cc_CallDetail.digits);
+ return ZCC_CALL;
+ }
+
+ if (g_Cc_CallDetail.digits[0] >= '0' && g_Cc_CallDetail.digits[0] <= '9')
+ {
+ //ccapp_log("5");
+ return (g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#'
+ || g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == ZCC_TIMEOUT_SIGN
+ || g_Cc_CallDetail.dCount == ZDIAL_NUM_MAX) ? ZCC_CALL : ZCC_NO_RESULT;
+ }
+
+ //ccapp_log("6");
+ if (g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN) //ÖÁÉÙÓÐ2·ºô½ÐÁË
+ {
+ switch (g_Cc_CallDetail.digits[1])
+ {
+ case '0':
+ return ZCC_FLASH_0;
+ case '1':
+ return ZCC_FLASH_1;
+ case '2':
+ case ZCC_TIMEOUT_SIGN:
+ return ZCC_FLASH_2;
+ case '3':
+ return ZCC_FLASH_3;
+ case '4':
+ return ZCC_FLASH_4;
+ default:
+ return ZCC_MATCHERR;
+ }
+ }
+
+ /*for (i = 0; i<scSum; i++)
+ {
+ if (strncmp((CHAR *)g_zCc_SCTab[i].sc, (CHAR *)g_Cc_CallDetail.digits,
+ (UINT32)(strlen(g_zCc_SCTab[i].sc)<g_Cc_CallDetail.dCount)?strlen(g_zCc_SCTab[i].sc):g_Cc_CallDetail.dCount) == 0)
+ {
+ if (g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#')
+ {
+ return g_zCc_SCTab[i].scName;
+ }
+ if (g_Cc_CallDetail.dCount < g_zCc_SCTab[i].scMaxLen)
+ {
+ return ZCC_NO_RESULT;
+ }
+ if (g_Cc_CallDetail.dCount == g_zCc_SCTab[i].scMaxLen)
+ {
+ return ZCC_MATCHERR;
+ }
+ }
+ }*/
+
+ if(g_Cc_CallDetail.dCount>=2 &&
+ g_Cc_CallDetail.dCount<ZDIAL_NUM_MAX &&
+ g_Cc_CallDetail.digits[0]=='*')
+ {
+ if(g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == '#'
+ || g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] == ZCC_TIMEOUT_SIGN)
+ {
+ ccapp_log("match special code: %s", g_Cc_CallDetail.digits);
+ return ZCC_CALL;
+ }
+ else
+ {
+ //ccapp_log("8");
+ return ZCC_NO_RESULT;
+ }
+ }
+
+ //ccapp_log("9");
+ return ZCC_MATCHERR;
+}
+
+VOID zCc_DigitsMatchRltProc(UINT8 ret)
+{
+ UINT8 callCnt = 0, slave = 0;
+ SINT32 chldret = -1;
+
+ ccapp_log("ret=%d", ret);
+
+ slave = zCc_GetSpecSlave(ZCC_S_DACCM_S);
+ switch (ret)
+ {
+ case ZCC_NO_RESULT:
+ sc_timer_create(ZCCAPP_TIMER_DTMF_DETECT,
+ 0,
+ ZCCAPP_TIMER_DTMF_INTERVAL,
+ zCcApp_DtmfTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc sc_timer_create zCcApp_DtmfTimer\n",__FUNCTION__);
+ return;
+
+ case ZCC_CALL:
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SINV_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DIALING_S;
+ if(g_Cc_CallDetail.digits[0]!='*' && (digit_map_call(g_Cc_CallDetail.digits)==0))
+ {
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount-1] = 0;
+ g_Cc_CallDetail.dCount--;
+ }
+ strcpy(g_Cc_CallDetail.slaveObj[slave].number, g_Cc_CallDetail.digits);
+ g_Cc_CallDetail.slaveObj[slave].is_callout = TRUE;
+ return;
+
+ case ZCC_FLASH_1:
+ callCnt = zCc_CallCount();
+ if ((1 < callCnt) && (zCc_ActiveCall() == callCnt) ) // ¼Ç¼±¾´Î²Ù×÷ΪÕë¶Ôconf µÄ
+ {
+ chldret = zCc_SendAtChldReq(21);
+ }
+ else //if (1 < callCnt)
+ {
+ slave = zCc_GetSpecSlave(ZCC_S_DIALING_S);
+ if(slave)
+ {
+ ccapp_log("zCc_SendAtChldReq(%d) dialing", 10+slave);
+ chldret = zCc_SendAtChldReq(10+slave);
+ SLIC_Stop_Signal(0,TONE_SIGNAL);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ break;
+ }
+
+ slave = zCc_GetSpecSlave(ZCC_S_RINGBACK_S);
+ if(slave)
+ {
+ ccapp_log("zCc_SendAtChldReq(%d) ringback", 10+slave);
+ chldret = zCc_SendAtChldReq(10+slave);
+ SLIC_Stop_Signal(0,TONE_SIGNAL);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ break;
+ }
+
+ ccapp_log("zCc_SendAtChldReq(1)-");
+ chldret = zCc_SendAtChldReq(1);
+ }
+ break;
+
+ case ZCC_FLASH_2:
+ chldret = zCc_SendAtChldReq(2);
+ break;
+
+ case ZCC_FLASH_3:
+ if(zCc_talking_count()==1 && zCc_GetSpecSlave(ZCC_S_TRYING_S))
+ {
+ // talking + incoming, skip hookflash+3, do nothing
+ }
+ else
+ chldret = zCc_SendAtChldReq(3);
+ break;
+
+ case ZCC_FLASH_4:
+ if( zCc_CallCount()> 1)
+ {
+ //system("at_cmd AT+ZTOR=2");
+ //zCcApp_send_message(MSG_CMD_ACTIVE_CALL_TRANSFER, 0, NULL);
+ //ccapp_log("send MSG_CMD_ACTIVE_CALL_TRANSFER");
+ chldret = zCc_SendAtChldReq(4); //AT+CHLD=4
+ }
+ else
+ ccapp_log("skip at_cmd AT+ZTOR=2");
+ break;
+
+ case ZCC_FLASH_0://¾Ü½ÓÀ´µç£¬Í£Ö¹·ÅÒô£¬»Ö¸´ÓïÒô
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ zCc_InitSlaveObj(0);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+ chldret = zCc_SendAtChldReq(0);
+ break;
+
+ case ZCC_MATCHERR:
+ if (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN)
+ {
+ zCc_ClearDigits();
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DigitsMatchRltProc sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ zCc_InitSlaveObj(slave);
+ }
+ return;
+ }
+ break;
+
+ default:
+ if (ret >= ZCC_BAOC_REG && ret <= ZCC_CFB_DEREG)// SS slave=1
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SINV_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_IDLE_S;//±ÜÃâºóÃæ¹Ò»ú»á·¢Æðchup
+ }
+ return;
+ }
+
+ zCc_ClearDigits();
+ //zCc_InitSlaveObj(slave);
+}
+#if 0
+VOID zCc_PreProcRes(CHAR *pParaLine)
+{
+ SINT32 flg = 0;
+ UINT32 i = 0;
+ UINT32 length = 0;
+ CHAR *pSource = pParaLine;
+ CHAR *pDest = NULL;
+
+ CHAR *pStrDestMalloc = (CHAR *)malloc(AT_CMD_MAX);
+ if (NULL == pStrDestMalloc)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_PreProcRes: Malloc failed !!!\n",__FUNCTION__);
+ return;
+ }
+ memset(pStrDestMalloc, 0, AT_CMD_MAX);
+
+ assert(pParaLine != NULL);
+ pDest = pStrDestMalloc;
+ length = strlen(pParaLine);
+ if (length == 0 || length >= ZAT_MAX_LEN)
+ {
+ free(pStrDestMalloc);
+ return;
+ }
+ for (i = 0; (i < length )&& (pDest - pStrDestMalloc < AT_CMD_MAX); i++)
+ {
+ if ('"' == *pSource)
+ {
+ flg = (0 == flg)?1:0; /* Ë«ÒýºÅ ɾ³ý */
+ if ('"' == *(pSource + 1)) /* ÐǺźóÃæ½ô¸úÐǺţ¬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = (CHAR)ZAT_NULL_FILL;
+ }
+ }
+ else if ((',' == *pSource) && (0 == flg))
+ {
+ *pDest++ = ' '; /* Ë«ÒýºÅÍâÃæµÄ¶ººÅ£¬Ìæ»»³É¿Õ¸ñ */
+ if (',' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = '9'; //±£Áô²ÎÊýÓÃ9ÔÝʱ´úÌæ
+ }
+ else if ('\0' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = (CHAR)ZAT_NULL_FILL;
+ }
+ }
+ else if (('\r' == *pSource) ||('\n' == *pSource))
+ {
+ pSource++;
+ }
+ else
+ {
+ *pDest++ = ((' ' == *pSource) && (1 == flg))?(CHAR)ZAT_SPACE_REPLACE:((('\t' == *pSource) && (1 == flg))?(CHAR)ZAT_TAB_REPLACE:(*pSource));
+ }
+ pSource++;
+ }
+
+ memset(pParaLine, 0, length); /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */
+ strcpy(pParaLine, pStrDestMalloc);
+ free(pStrDestMalloc);
+}
+#endif
+UINT8 zCc_CallCount(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ //&& !(g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 1
+ //&& g_Cc_CallDetail.slaveObj[slave].state ==ZCC_S_TRYING_S))
+ {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
+UINT8 zCc_FlashClearCall(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DACCM_S//Õª»úµ½atdÏ·¢Ç°
+ || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_BSYT_S
+ || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TKYT_S
+ || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_SIL_S//·ÅæÒô¡¢º¿ÃùÒô¡¢¾²Òô
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
+UINT8 zCc_MoInactiveCall(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
+ && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_BSYT_S
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+UINT8 zCc_MoBeforDialingCall(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
+ {
+ ccapp_log("zCc_MoBeforDialingCall slave[%d]=%d",
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].state);
+ }
+
+ if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
+ && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_DIALING_S
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
+int zCc_GetMoBeforDialingCallCID(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
+ {
+ ccapp_log("zCc_GetMoBeforDialingCallCID slave[%d]=%d",
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].state);
+ }
+
+ if (g_Cc_CallDetail.slaveObj[slave].state > ZCC_S_IDLE_S
+ && g_Cc_CallDetail.slaveObj[slave].state < ZCC_S_DIALING_S
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ return slave;
+ }
+ }
+
+ return -1;
+}
+
+
+int zCc_findCID_by_number(const char *number)
+{
+ UINT8 slave = 0, len = 0;
+ char slave_number[ZDIAL_NUM_MAX];
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
+ {
+ ccapp_log("zCc_findCID_by_number[%s] slave[%d]=%d num=%s",
+ number,
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].state,
+ g_Cc_CallDetail.slaveObj[slave].number);
+ }
+
+ strcpy(slave_number, g_Cc_CallDetail.slaveObj[slave].number);
+ len = strlen(slave_number);
+ if(len>0)
+ {
+ if(slave_number[len-1]=='T')
+ slave_number[len-1]='\0';
+ }
+
+ if (strcmp(slave_number, number)==0)
+ return slave;
+ }
+
+ return 0;
+}
+
+int check_incoming_call_is_in_slave(MSG_BUF *ptMsgBuf)
+{
+ T_zCcApp_DsciInd tDiscInd = {0};
+ memcpy(&tDiscInd, (T_zCcApp_DsciInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_DsciInd));
+
+ if(tDiscInd.cid==0)
+ return 0;
+
+ return zCc_findCID_by_number(tDiscInd.num);
+}
+
+
+UINT8 zCc_MtInactiveCall(VOID)
+{
+ UINT8 slave = 0, cnt = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TRYING_S
+ || g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_WAIT_RESOURCE_S)
+ //&& g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+UINT8 zCc_GetCallSlave(UINT8 heldcall)//°´×î¶àÁ½Â·ÊµÏÖ
+{
+ UINT8 slave = 0;
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++) // slave[0] ²»¿ÉÄÜ
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_TALKING_S
+ && g_Cc_CallDetail.slaveObj[slave].heldcall == heldcall
+ && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ return slave;
+ }
+ }
+ return 0;
+}
+
+VOID zCc_ControlTone(VOID)
+{
+ T_zCc_Tone tone = ZCC_TONE_OFF_A; /* What tone to play */
+ SIGNAL_DATA tSig;
+ memset(tSig.cid, 0, 32);
+ UINT8 slave = 0;
+
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].tone != ZCC_TONE_OFF_A)
+ {
+ tone = g_Cc_CallDetail.slaveObj[slave].tone;
+ break;
+ }
+ }
+ printf("[ccapp_debug]:zCc_ControlTone,cur_tone=%d, last_tone=%d\n",tone,g_Cc_CallDetail.lastTone);
+ if (g_Cc_CallDetail.lastTone == tone || ZCC_TONE_OFF_A == tone)
+ {
+ return;
+ }
+
+ if(local_test_call_st != 0)
+ {
+ g_Cc_CallDetail.lastTone = tone;
+ return ;
+ }
+
+ switch (tone)
+ {
+ case ZCC_TONE_DIAL_A:
+ if (g_Cc_CallDetail.lastTone == ZCC_TONE_CIDCW_A)//¶à²»¶àÓà
+ {
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Stop_PCM <---\n",__FUNCTION__);
+ }
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_DIAL;
+ SLIC_Play_Signal(0, 0, &tSig);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_DIAL<---\n",__FUNCTION__);
+ break;
+ case ZCC_TONE_RB_A:
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_RINGBACK;
+ SLIC_Play_Signal(0, 0, &tSig);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal ZCC_TONE_RB_A<---\n",__FUNCTION__);
+ break;
+ case ZCC_TONE_BSY_A:
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_BUSY;
+ SLIC_Play_Signal(0, 0, &tSig);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_BUSY<---\n",__FUNCTION__);
+ break;
+ case ZCC_TONE_SIL_A:
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ break;
+ case ZCC_TONE_CIDCW_A:
+ memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_CW;
+ //memcpy(tSig.cid, g_Cc_CallDetail.number, strlen(g_Cc_CallDetail.number));
+ strncpy(tSig.cid, g_Cc_CallDetail.number, sizeof(tSig.cid)-1);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone ZCC_TONE_CIDCW_A,number = %s\n",__FUNCTION__,g_Cc_CallDetail.number);
+ zCc_sleep(100);
+ SLIC_Play_Signal(0, 0, &tSig);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_CW<---\n",__FUNCTION__);
+ break;
+ case ZCC_TONE_TKY_A:
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_TKY;
+ SLIC_Play_Signal(0, 0, &tSig);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ControlTone: SLIC_Play_Signal TONE_TKY<---\n",__FUNCTION__);
+ break;
+ }
+ g_Cc_CallDetail.lastTone = tone;
+
+}
+void zCcApp_SetAtChnlCmdId(E_CC_APP_AtReqCmdId AtCmdId)
+{
+ g_Cc_CallDetail.curAtCmdId = AtCmdId;
+}
+VOID zCc_SendSsReq(PSTR pAtCmdPara)
+{
+ CHAR pw[5] = {0};
+ CHAR dn[ZDIAL_NUM_MAX] = {0};
+ UINT8 scSum = sizeof(g_zCc_SCTab)/sizeof(T_zCc_ScTab);
+ UINT8 scName = 0;
+ UINT8 i = 0;
+ T_zCcapp_ClckReq tclckreq = {0};
+ T_zCcapp_CcfcReq tccfcreq = {0};
+
+ for (i = 0; i<scSum; i++)
+ {
+ if (strncmp((CHAR *)g_zCc_SCTab[i].sc, (CHAR *)g_Cc_CallDetail.digits,
+ (UINT32)(strlen(g_zCc_SCTab[i].sc)<g_Cc_CallDetail.dCount)?strlen(g_zCc_SCTab[i].sc):g_Cc_CallDetail.dCount) == 0)
+ {
+ scName = g_zCc_SCTab[i].scName;
+ break;
+ }
+ }
+ switch(scName)
+ {
+ case ZCC_BAOC_REG:
+ sscanf(pAtCmdPara, "%*5s%4s#", pw);
+ pw[4] = '\0';
+ tclckreq.type = 0;//AO
+ tclckreq.act = 1;
+ strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
+ break;
+ case ZCC_BAOC_DEREG:
+ sscanf(pAtCmdPara, "%*5s%4s#", pw);
+ pw[4] = '\0';
+ tclckreq.type = 0;//AO
+ tclckreq.act = 0;
+ strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
+ break;
+ case ZCC_BOIC_REG:
+ sscanf(pAtCmdPara, "%*5s%4s#", pw);
+ pw[4] = '\0';
+ tclckreq.type = 1;//OI
+ tclckreq.act = 1;
+ strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
+ break;
+ case ZCC_BOIC_DEREG:
+ sscanf(pAtCmdPara, "%*5s%4s#", pw);
+ pw[4] = '\0';
+ tclckreq.type = 1;//OI
+ tclckreq.act = 0;
+ strncpy(tclckreq.pw,pw,sizeof(tclckreq.pw)-1);
+ break;
+ case ZCC_CFU_REG:
+ sscanf(pAtCmdPara, "%*4s%47s#", dn);
+ dn[strlen(dn)-1] = '\0';
+ tccfcreq.type = 0;
+ tccfcreq.act = 1;
+ strncpy(tccfcreq.dn, dn, strlen(dn));
+ break;
+ case ZCC_CFU_DEREG:
+ tccfcreq.type = 0;
+ tccfcreq.act = 0;
+ break;
+ case ZCC_CFNRY_REG:
+ sscanf(pAtCmdPara, "%*4s%47s#", dn);
+ dn[strlen(dn)-1] = '\0';
+ tccfcreq.type = 2;
+ tccfcreq.act = 1;
+ strncpy(tccfcreq.dn, dn, strlen(dn));
+ break;
+ case ZCC_CFNRY_DEREG:
+ tccfcreq.type = 2;
+ tccfcreq.act = 0;
+ break;
+ case ZCC_CFB_REG:
+ sscanf(pAtCmdPara, "%*4s%47s#", dn);
+ dn[strlen(dn)-1] = '\0';
+ tccfcreq.type = 1;
+ tccfcreq.act = 1;
+ strncpy(tccfcreq.dn, dn, strlen(dn));
+ break;
+ case ZCC_CFB_DEREG:
+ tccfcreq.type = 1;
+ tccfcreq.act = 0;
+ break;
+ }
+
+
+ if (scName > ZCC_BOIC_DEREG)
+ {
+ zCcApp_Ccfc(&tccfcreq);
+ }
+ else
+ {
+ zCcApp_Clck(&tclckreq);
+ }
+
+}
+
+VOID zCc_SendAtDialReq(PSTR pAtCmdPara)
+{
+ UINT8 slave =0;
+
+ //ccapp_log("pAtCmdPara=%s len=%s", pAtCmdPara, strlen(pAtCmdPara));
+
+ if (strlen(pAtCmdPara)+1 > ZDIAL_NUM_MAX)
+ {
+ return;
+ }
+ else if (strlen(pAtCmdPara) <= 2)
+ {
+ slave = zCc_GetDialingSlave(1);
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ int index;
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ index = zCc_find_held_cid(); // hookflash + onekey and dtmf timeout
+ if(index!=0)
+ zCc_SendAtChldReq(2);
+ }
+ return;
+ }
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_D;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq:AtcmdMsg = %s\n",__FUNCTION__,pAtCmdPara);
+ zCcApp_Dial((char *)pAtCmdPara);
+
+}
+
+VOID zCc_SendAtAnswerReq(VOID)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtAnswerReq\n",__FUNCTION__);
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_A;
+ zCcApp_Answer();
+}
+
+VOID zCc_SendAtHangupReq(VOID)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtHangupReq\n",__FUNCTION__);
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_CHUP;
+ zCcApp_Chup();
+}
+
+VOID zCc_SendAtDtmfReq(char* dtmfchar)
+{
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_VTS;
+ zCcApp_Vts(dtmfchar);
+}
+
+VOID zCc_SendAtImsPlusReq(int rate, int setfg)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtImsPlusReq\n",__FUNCTION__);
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_IMSPLUS;
+ zCcApp_SetImsPlus(rate, setfg);
+}
+#if 0
+VOID zCc_SendAtVolumnReq(PSTR pAtCmdPara)
+{
+ CHAR AtcmdMsg[ZAT_PARAM_LEN50] = {0};
+
+ if (pAtCmdPara[0] == 0 || strlen(pAtCmdPara)+1 > ZDIAL_NUM_MAX)
+ {
+ return;
+ }
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_VTS;
+ sprintf(AtcmdMsg, "AT+VTS=\"%s\",20\r\n", pAtCmdPara);
+ printf( "---> ccApp zCc_SendAtDtmfReq:AtcmdMsg = %s\n", AtcmdMsg);
+ zCcApp_Vts(AtcmdMsg);
+}
+#endif
+SINT32 zCc_SendAtChldReq(int chldtype)
+{
+ SINT32 ret = -1;
+
+ if (g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
+ {
+ zCc_ClearDigits();
+ }
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+ g_Cc_CallDetail.curAtCmdId = CC_APP_AT_CMD_REQ_SET_CHLD;
+ ret = zCcApp_Chld(chldtype);
+ return ret;
+}
+
+VOID zCc_SendLedInformMsg(VOID)
+{
+ int lRet = -1;
+ int lTgtMsgID = 0;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+
+#ifndef TEST_CCAPP
+ lTgtMsgID = msgget(MODULE_ID_MMI, 0);
+ if (-1 == lTgtMsgID)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendLedInformMsg msgget MMI fail\n",__FUNCTION__);
+ return;
+ }
+
+ memset(&stMsg, 0, sizeof(MSG_BUF));
+ stMsg.ulMagic = MSG_MAGIC_WORD;
+ stMsg.lMsgType = MSG_TYPE_DEFAULT;
+ stMsg.src_id = MODULE_ID_CALL_CTRL;
+ stMsg.dst_id = MODULE_ID_MMI;
+ stMsg.usMsgCmd = MSG_CMD_VOIP_STATUS_INFO;
+ stMsg.usDataLen = 0;
+ lRet = msgsnd(lTgtMsgID, &stMsg, msgSize, IPC_NOWAIT);
+ if (lRet < 0)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendLedInformMsg msgsnd to MMI fail\n",__FUNCTION__);
+ return;
+ }
+#endif
+}
+
+VOID zCc_SetLedStatus(char* LedStatus)
+{
+
+#ifndef TEST_CCAPP
+ sc_cfg_set("voip_status", LedStatus);
+#endif
+ zCc_SendLedInformMsg();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SetLedStatus = %s\n",__FUNCTION__,LedStatus);
+}
+
+SINT32 zCc_RecvDsciInd(MSG_BUF *ptMsgBuf)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV dsciind!!!<---\n");
+ //ptMsgBuf->usMsgCmd = ZCC_NO_E;
+ //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_DSCI;
+ //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
+
+ zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ return 0;
+}
+
+int is_onecall_in_help_and_ready_to_input_new_call(void)
+{
+ int i;
+ if(zCc_find_held_cid()==0)
+ return 0;
+
+ for(i=0;i<ZCC_SLAVES;i++) // should start from 0, it'll be 0 when hookflash comes but not input any key
+ if(g_Cc_CallDetail.slaveObj[i].state==ZCC_S_DT_S ||
+ g_Cc_CallDetail.slaveObj[i].state==ZCC_S_DACCM_S)
+ return 1;
+
+ return 0;
+}
+
+void tz_lock_cellid_active_for_call(int state)
+{
+ static int old_state = -1;
+ static int cellid_active_count = 0;
+ char tz_lock_cellid_active[4] = {0};
+
+ sc_cfg_get("tz_lock_cellid_active",tz_lock_cellid_active,sizeof(tz_lock_cellid_active));
+ if(strcmp(tz_lock_cellid_active, "1") == 0)
+ return;
+
+ if((old_state == 3) && (state == 0) && (cellid_active_count < 3))
+ {
+ cellid_active_count++;
+ if(cellid_active_count == 3)
+ {
+ sc_cfg_set("tz_lock_cellid_call_active", "1");
+ }
+ }
+ old_state = state;
+ return;
+}
+
+SINT32 zCc_DsciIndProc(MSG_BUF *ptMsgBuf)
+{
+ int inMpty = 0;
+ int cid = 0;
+ int state = 0;
+ int dir = 0;
+ CHAR num[ZDIAL_NUM_MAX] = {0};
+ CHAR voip_status[ZDIAL_NUM_MAX] = {0};
+ T_zCcApp_DsciInd tDiscInd = {0};
+
+ int n;
+ int slave_callout[ZCC_SLAVES];
+
+ memcpy(&tDiscInd, (T_zCcApp_DsciInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_DsciInd));
+ cid = tDiscInd.cid;
+ inMpty = tDiscInd.inMpty;
+ dir = tDiscInd.dir;
+ state = tDiscInd.state;
+ strncpy(num, tDiscInd.num,sizeof(num)-1);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s RECV dsciind: cid=%d num=%s dir=%d inMpty=%d state=%d !!!<---\n",
+ __FUNCTION__, cid, num, dir,inMpty,state);
+ zCc_ShowAllSlave();
+
+ if (cid < ZCC_MINCID || cid > ZCC_MAXCID)
+ {
+ return 0;
+ }
+ if (num[0] < 0)
+ {
+ memset(num,0,ZDIAL_NUM_MAX);
+ }
+ ptMsgBuf->dst_id = cid;
+ tz_lock_cellid_active_for_call(state);
+ switch(state)
+ {
+ case 0://Z_MMIACC_CALL_STATE_ACTIVE
+ if (g_Cc_CallDetail.slaveObj[cid].state == ZCC_S_TALKING_S)//held->active
+ {
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+
+ if (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A
+ && g_Cc_CallDetail.slaveObj[0].tone == ZCC_TONE_DIAL_A)
+ {
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc handling zCc_InitSlaveObj(0)\n",__FUNCTION__);
+ zCc_InitSlaveObj(0);
+ }
+ g_Cc_CallDetail.slaveObj[cid].heldcall = 0;
+ g_Cc_CallDetail.slaveObj[cid].confcall = inMpty;
+ }
+ else
+ {
+ ptMsgBuf->usMsgCmd = ZCC_SANS_E;
+ }
+
+#ifndef TEST_CCAPP
+ sc_cfg_get("voip_status",voip_status,sizeof(voip_status));
+ if (0 != strcmp("ledon" , voip_status))
+#endif
+ {
+ zCc_SetLedStatus("ledon");
+ }
+ break;
+ case 1://Z_MMIACC_CALL_STATE_HELD
+ if (g_Cc_CallDetail.slaveObj[cid].state == ZCC_S_TALKING_S)//active->held
+ {
+ if (1 == zCc_CallCount())
+ {
+ //SLIC_Stop_PCM();
+ }
+ g_Cc_CallDetail.slaveObj[cid].heldcall = 1;
+ g_Cc_CallDetail.slaveObj[cid].confcall = inMpty;
+
+ }
+ break;
+ case 3://Z_MMIACC_CALL_STATE_MO_ALERTING
+ ptMsgBuf->usMsgCmd = ZCC_SRING_E;
+ break;
+ case 4://Z_MMIACC_CALL_STATE_MT_INCOMING
+ if(tz_lock_cellid_is_limit_callin())
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+
+ if(g_Cc_CallDetail.state==ZCC_M_SEIZE_S)
+ {
+ int cnt;
+
+ cnt= zCc_CallCount();
+ ccapp_log("cnt=%d slave[0]=%d", cnt, g_Cc_CallDetail.slaveObj[0].state);
+
+ if(cnt==0) // hookoff but not dail out utill dtmf-timer timeout
+ {
+ if(ZCC_S_BSYT_S<=g_Cc_CallDetail.slaveObj[0].state &&
+ g_Cc_CallDetail.slaveObj[0].state<=ZCC_S_SIL_S)
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+ }
+
+ if(zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_BSYT_S)||
+ zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_TKYT_S)|| // fast dududu is being ....
+ zCc_GetSpecSlaveIgnoreWaitDSCI6(ZCC_S_SIL_S)) // fast dududu is end ....
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+ }
+ else if(g_Cc_CallDetail.state==ZCC_M_RELEASE_S)
+ {
+ int dsci6_cid = zCc_Find_waitDSCI6_cid();
+ if(dsci6_cid!=0 && dsci6_cid==cid)
+ {
+ zCc_SendAtChldReq(10+cid);
+ zCc_InitSlaveObj(cid);
+ ccapp_log("zCc_Find_waitDSCI6_cid and skip this call %s", num);
+
+ char temp[200];
+ sprintf(temp, "echo \"%s get error incoming call cid=%d num=%s\" > /tmp/log.ccapp.callin.err",
+ get_local_date_time(), cid, num);
+ soft_system(temp);
+ break;
+ }
+ }
+
+ ptMsgBuf->usMsgCmd = ZCC_SINVITE_E;
+ memset(g_Cc_CallDetail.number, 0, sizeof(g_Cc_CallDetail.number));
+ memcpy(g_Cc_CallDetail.number, num, ZDIAL_NUM_MAX);
+ break;
+ case 5://Z_MMIACC_CALL_STATE_MT_WAITING
+ if(g_Cc_CallDetail.state==ZCC_M_RINGING_S && zCc_find_held_cid())
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+ else if(is_onecall_in_help_and_ready_to_input_new_call())
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+
+ if(zCc_CallCount()>=2)
+ {
+ zCc_SendAtChldReq(10+cid);
+ break;
+ }
+
+ ptMsgBuf->usMsgCmd = ZCC_CIDCW_E;
+ memset(g_Cc_CallDetail.number, 0, sizeof(g_Cc_CallDetail.number));
+ memcpy(g_Cc_CallDetail.number, num, ZDIAL_NUM_MAX);
+ break;
+ case 6://Z_MMIACC_CALL_STATE_END
+ zCcApp_Vts_CleanReq();
+ if(zCc_findCID_by_number(num)==0)
+ break;
+
+ ptMsgBuf->usMsgCmd = dir?ZCC_SDISCN_MT_E: ZCC_SDISCN_MO_E;
+ g_Cc_CallDetail.chupSent = 0;
+
+ memset(slave_callout, 0, sizeof(slave_callout));
+ n = zCc_find_all_callout(slave_callout);
+
+ ccapp_log("DscInd 6, dir=%d is_callout=%d, find_all_callout=%d",
+ dir,
+ g_Cc_CallDetail.slaveObj[cid].is_callout,
+ n);
+
+ if(dir==0 && g_Cc_CallDetail.slaveObj[cid].is_callout == TRUE)
+ {
+ if(n<1 || (n==1 && slave_callout[0]==cid))
+ SLIC_PolarityReverse(0, FALSE);
+ }
+
+ if ((cid == g_Cc_CallDetail.ringCid) && (ZCC_TONE_CIDCW_A == g_Cc_CallDetail.lastTone))
+ {
+ SLIC_Stop_Signal(0, 0);//Í£Ö¹ºô½ÐµÈ´ýÒô
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_DsciIndProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[0].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ }
+
+ break;
+ case 2://Z_MMIACC_CALL_STATE_MO_DIALING
+ ptMsgBuf->usMsgCmd = ZCC_SDIALLING_E;
+ break;
+ case 7://Z_MMIACC_CALL_STATE_MT_CONNREQ
+ case 8://Z_MMIACC_CALL_STATE_DISC
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+
+SINT32 zCc_RecvZvoiceChnl(MSG_BUF *ptMsgBuf)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV zvoicechnl!!!<---\n");
+ //if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)
+ //{
+ // return 0;
+ //}
+ printf("[ccapp_debug]:recv zvoicechnl and send to local cc\n");
+
+ //ptMsgBuf->usMsgCmd = ZCC_NO_E;
+ //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_IMSPLUS;
+ //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
+
+ zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ return 0;
+}
+
+
+
+SINT32 zCc_RecvImsplusInd(MSG_BUF *ptMsgBuf)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV imsplusind!!!<---\n");
+ //if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)
+ //{
+ // return 0;
+ //}
+ printf("[ccapp_debug]:recv imsplus and send to local cc\n");
+
+ //ptMsgBuf->usMsgCmd = ZCC_NO_E;
+ //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_IMSPLUS;
+ //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
+
+ zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ return 0;
+}
+SINT32 zCc_RecvRsp(MSG_BUF *ptMsgBuf)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV at_rsp %d !!!<---\n", ptMsgBuf->usMsgCmd);
+
+ zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ return 0;
+}
+
+static inline unsigned char zCc_MapVoiceChnlAct(unsigned char act)
+{
+ if (act == 3)
+ {
+ return 0; //gsm
+ }
+ else if (act == 5)
+ {
+ return 2; //wcdma
+ }
+ else if (act == 15)
+ {
+ return 1;
+ }
+ else
+ {
+ assert(0);
+ }
+ return 3;
+}
+
+static unsigned char g_zCc_VoiceOpenSucc = 1;
+
+static T_Voice_Para g_zCc_VoicePara_bak;
+
+static unsigned int g_zCc_pcm_bak = 0; /*new add*/
+
+SINT32 zCc_ZvoicechnlProc(MSG_BUF *ptMsgBuf)
+{
+ T_zCcApp_VoiceChnl tVoiceChnl;
+ T_Voice_Para tVoicePara = {0};
+ memcpy(&tVoiceChnl, (T_zCcApp_VoiceChnl*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_VoiceChnl));
+
+ tVoicePara.mode = zCc_MapVoiceChnlAct(tVoiceChnl.act);
+ tVoicePara.codec_type = tVoiceChnl.codetype; //0-nb, 1-wb
+ if ( tVoicePara.codec_type == 1)
+ tVoicePara.clock_rate = 16000;
+ else
+ tVoicePara.clock_rate = 8000;
+
+ tVoicePara.codec_path = tVoiceChnl.amrpath;
+
+ printf("[ccapp_debug]:recv zvoicechnl, tVoicePara=%d,%d,%d,%d\n",tVoicePara.clock_rate,tVoicePara.mode,tVoicePara.codec_type,tVoicePara.codec_path);
+ if (tVoiceChnl.op == 1)
+ {
+ /* new add begin*/
+ //start voice
+ if (/*voice_open(&tVoicePara) != 0 ||*/ g_Cc_CallDetail.state == ZCC_M_RINGING_S)
+ {
+ printf("[ccapp]:voice open fail");//´ò¿ªvoiceʧ°Ü£¬»òÕßÕñÁå̬ÊÕµ½zvoicechnl£¬¶¼ÈÏΪʧ°Ü
+ g_zCc_VoiceOpenSucc = 0;
+ g_zCc_VoicePara_bak = tVoicePara;
+ }
+ else if (g_Cc_CallDetail.state == ZCC_M_SEIZE_S)
+ {
+
+ if ( voice_open(&tVoicePara) != 0)
+
+ {
+
+ printf("[ccapp_debug]:mo call voice_open fail!!!\n");
+
+ voice_close(&tVoicePara);
+
+ }
+
+ }
+/* new add end*/
+ printf("[ccapp_debug]:voice_open:rlt=%d\n",g_zCc_VoiceOpenSucc);
+
+ }
+ else
+ {
+ //close voice
+ g_zCc_VoiceOpenSucc = 1;
+ voice_close(&tVoicePara);
+ printf("[ccapp_debug]:voice_close:rlt=%d\n",g_zCc_VoiceOpenSucc);
+
+ }
+ return 0;
+}
+
+
+
+
+
+SINT32 zCc_ZimsplusProc(MSG_BUF *ptMsgBuf)
+{
+ int act = 0;
+ int rate = 0;
+ T_zCcApp_ImsplusInd tImsplusInd = {0};
+
+ memcpy(&tImsplusInd, (T_zCcApp_ImsplusInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_ImsplusInd));
+ act = tImsplusInd.act;
+ rate = tImsplusInd.rate;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: act = %d rate = %d new!!!<---\n",__FUNCTION__, act, rate);
+ printf("[ccapp_debug]:recv imsplus, tImsplusInd=%d,%d\n",tImsplusInd.act,tImsplusInd.rate);
+
+
+ if (act == 0)
+ {
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_PCM <---\n",__FUNCTION__);
+ }
+ else if (act == 1)
+ {
+ /* new add begin*/
+ if ( g_Cc_CallDetail.state == ZCC_M_RINGING_S)
+ {
+ g_zCc_pcm_bak = rate;
+ return 0;
+ }
+ /* new add end */
+
+ if (rate == 8000)
+ {
+ SLIC_PCM_Set_NB();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_NB <---\n",__FUNCTION__);
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+ }
+ else if (rate == 16000)
+ {
+ SLIC_PCM_Set_WB();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_WB <---\n",__FUNCTION__);
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+ }
+ }
+ else if (act == 2)//¹Ø±Õpcm£¬·Å±¾µØ»ØÁåÒô
+ {
+ if (ZCC_S_RINGBACK_S != g_Cc_CallDetail.slaveObj[rate].state)
+ {
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: act 2,cid err <---\n",__FUNCTION__);
+ return 0;
+ }
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_PCM <---\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[rate].tone = ZCC_TONE_RB_A;
+ }
+ else if (act == 3)//ºóÐø»áÔÙÓÐact1Éϱ¨£¬ËùÒÔ´Ëʱ²»´ò¿ªpcm
+ {
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Stop_Signal <---\n",__FUNCTION__);
+
+ zCc_SendAtImsPlusReq(rate,0);
+ g_Cc_CallDetail.slaveObj[rate].tone = ZCC_TONE_OFF_A;
+ }
+ return 0;
+}
+SINT32 zCc_RecvZcpiInd(MSG_BUF *ptMsgBuf)
+{
+ //ptMsgBuf->usMsgCmd = ZCCAPP_ATIND_ZCPI;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","RECV zcpiind!!!<---\n");
+ //ptMsgBuf->usSourceModuleID = MSG_ID_CALL_CTRL;
+ zCc_SendMsgToSub(ptMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ return 0;
+}
+
+SINT32 zCc_ZcpiIndProc(MSG_BUF *ptMsgBuf)
+{
+ int state = 0;
+ int cid = 0;
+ int progdsp = 0;
+ T_zCcApp_ZcpiInd tZcpiInd = {0};
+
+ memcpy(&tZcpiInd, (T_zCcApp_ZcpiInd*)ptMsgBuf->aucDataBuf, sizeof(T_zCcApp_ZcpiInd));
+ state = tZcpiInd.state;
+ cid = tZcpiInd.cid;
+ progdsp = tZcpiInd.progdsp;
+
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZcpiIndProc: cid= %d, state=%d, progdsp=%d <---\n",__FUNCTION__,cid,state,progdsp);
+ if (5 == state)
+ {
+ ptMsgBuf->dst_id = cid;
+ ptMsgBuf->usMsgCmd = ZCC_RESOURCE_READY_E;
+ g_Cc_CallDetail.resourceReady = 1;
+ }
+ else if (6 == state)
+ {
+ g_Cc_CallDetail.resourceReady = 0;
+ }
+
+ if (8 == progdsp)
+ {
+ SLIC_Start_PCM();
+ }
+
+ return 0;
+}
+
+LONG zCcApp_send_message(unsigned short Msg_cmd,unsigned short us_DataLen,unsigned char *pData)
+{
+ ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_AT_CTL, Msg_cmd, us_DataLen, (unsigned char *)pData,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg_cmd is %d<---\n",__FUNCTION__, Msg_cmd);
+
+ return 0;
+}
+
+VOID zCcApp_Dial(char *ptMsgBuf)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+ T_zCcapp_CallMoReq tcallReq = {0};
+
+ memset(tcallReq.number, 0, sizeof(tcallReq.number));
+ //strncpy(tcallReq.number, ptMsgBuf,strlen(ptMsgBuf));
+ strncpy(tcallReq.number, ptMsgBuf,sizeof(tcallReq.number)-1);
+ zCcApp_send_message(MSG_CMD_ATD_DIAL_REQ, sizeof(T_zCcapp_CallMoReq), (unsigned char *) &tcallReq);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ATD_DIAL_REQ<---\n",__FUNCTION__);
+
+}
+SINT32 zCcApp_Ccfc(T_zCcapp_CcfcReq *ptccfcreq)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+
+ zCcApp_send_message(MSG_CMD_CCFC_REQ, sizeof(T_zCcapp_CcfcReq), (unsigned char *) ptccfcreq);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CCFC_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+SINT32 zCcApp_Clck(T_zCcapp_ClckReq *ptclckreq)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+
+ zCcApp_send_message( MSG_CMD_CLCK_REQ, sizeof(T_zCcapp_ClckReq), (unsigned char *) ptclckreq);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CLCK_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+
+SINT32 zCcApp_Answer(VOID)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+
+ zCcApp_send_message(MSG_CMD_ATA_REQ, 0, NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ATA_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+
+SINT32 zCcApp_Chup(void)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+
+ zCcApp_send_message(MSG_CMD_CHUP_REQ, 0, NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg isMSG_CMD_CHUP_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+
+//µ±ÉÏÒ»¸öVTSûÓÐÊÕµ½OKǰ£¬ÆäËûµÄVTSÈ«²¿»º´æÔÚÁ´±íÀ´ýÊÕµ½ÉÏÒ»¸öOKʱÔÚÏ·¢ÏÂÒ»¸ö
+//¶¼ÔÚmainÏ̴߳¦Àí£¬ÎÞÐ軥³â
+typedef struct {
+ struct list_head list;
+ T_zCcapp_VtsReq vts;
+}T_zCcapp_VtsReq_list;
+
+static LIST_HEAD(ccapp_vts_waitqueue);
+static int ccapp_vts_flag = 0;
+
+void zCcApp_Vts_CleanReq(void)
+{
+ struct list_head *head = &ccapp_vts_waitqueue;
+ T_zCcapp_VtsReq_list *l, *tmp;
+
+ if(!list_empty(head))
+ {
+ list_for_each_entry_safe(l, tmp, head, list)
+ {
+ list_del(&l->list);
+ free(l);
+ }
+ ccapp_vts_flag = 0;
+ }
+}
+
+void zCcApp_Vts_Rsp(void)
+{
+ struct list_head *head = &ccapp_vts_waitqueue;
+ printf("[ccapp_debug]:Vts_Rsp flag=%d\n",ccapp_vts_flag);
+ if(list_empty(head))
+ {
+ ccapp_vts_flag = 0;
+ }
+ else
+ {
+ T_zCcapp_VtsReq_list *node = list_entry(head->next,T_zCcapp_VtsReq_list,list);
+
+ zCcApp_send_message(MSG_CMD_VTS_REQ, sizeof(T_zCcapp_VtsReq), (unsigned char *) &node->vts);
+ ccapp_vts_flag = 1;
+ list_del(&node->list);
+ free(node);
+ }
+}
+
+SINT32 zCcApp_Vts(char* dtmfchar)
+{
+ T_zCcapp_VtsReq tvtsreq = {0};
+ struct list_head *head = &ccapp_vts_waitqueue;
+
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","vtschar=%s<---\n",dtmfchar);
+ tvtsreq.dtmfchar=*dtmfchar;
+ printf("[ccapp_debug]:Vts_Req flag=%d\n",ccapp_vts_flag);
+ if(list_empty(head) && ccapp_vts_flag == 0)
+ {
+ zCcApp_send_message(MSG_CMD_VTS_REQ, sizeof(T_zCcapp_VtsReq), (unsigned char *) &tvtsreq);
+ ccapp_vts_flag = 1;
+ }
+ else
+ {
+ T_zCcapp_VtsReq_list *node = (T_zCcapp_VtsReq_list *)malloc(sizeof(T_zCcapp_VtsReq_list));
+ if(node == NULL)
+ {
+ printf("[ccapp_debug]: zCcApp_Vts malloc fail!!!\n");
+ return 0;
+ }
+ memset(node, 0 , sizeof(T_zCcapp_VtsReq_list));
+ node->vts.dtmfchar = tvtsreq.dtmfchar;
+ list_add_tail(&node->list,head);
+ }
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_VTS_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+SINT32 zCcApp_SetImsPlus(int rate, int setfg)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+ T_zCcapp_ImsplusReq timsplusreq= {0};
+
+ timsplusreq.act = rate;
+ timsplusreq.setfg = setfg;
+
+ zCcApp_send_message(MSG_CMD_ZIMSPLUS_REQ, sizeof(T_zCcapp_ImsplusReq), (unsigned char *) &timsplusreq);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_ZIMSPLUS_REQ<---\n",__FUNCTION__);
+
+ return 0;
+}
+
+SINT32 zCcApp_Chld(int chldtype)
+{
+ SINT32 ret = -1;
+ MSG_BUF stMsg;
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+
+ T_zCcapp_ChldReq tchldreq = {0};
+
+ tchldreq.type = chldtype;
+
+ zCcApp_send_message(MSG_CMD_CHLD_REQ, sizeof(T_zCcapp_ChldReq), (unsigned char *) &tchldreq);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ipc_send_message:Msg is MSG_CMD_CHLD_REQ[%d]<---\n",__FUNCTION__,chldtype);
+
+ return 0;
+}
+
+SINT32 zCcApp_AtIndRspProc(MSG_BUF *ptMsgBuf)
+{
+ SINT32 i ;
+ SINT32 ret = -1;
+ for(i=0;i< gCcAppRecvAtIndProcCnt;i++)
+ {
+ if(ptMsgBuf->usMsgCmd == gCcAppRecvAtIndProc[i].AtIndCmd)
+ {
+ if(NULL!= gCcAppRecvAtIndProc[i].RecvAtIndProcFun)
+ {
+ ret = gCcAppRecvAtIndProc[i].RecvAtIndProcFun(ptMsgBuf);
+ }
+ break;
+ }
+ }
+
+ return ret;
+}
+VOID zCc_MReleaseState(MSG_BUF *ptMsgBuf)
+{
+ CHAR voip_status[ZDIAL_NUM_MAX] = {0};
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MReleaseState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
+
+ printf("[ccapp_debug]: Release State Recv MsgCmd: %d\n",ptMsgBuf->usMsgCmd);
+
+ switch (ptMsgBuf->usMsgCmd)
+ {
+ case ZCC_SEIZE_E: // ͻȜ
+ // slave[0] to play dial tone
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+ g_Cc_CallDetail.state = ZCC_M_SEIZE_S;
+ g_Cc_CallDetail.chupSent = FALSE;
+ g_Cc_CallDetail.hookofffg = TRUE;
+ if (g_Cc_CallDetail.ringCid)// ¾Ü¾øµÈ´ý×ÊԴ״̬µÄincoming call
+ {
+ zCc_SendAtHangupReq();
+ g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].waitDSCI6 = 1;
+ }
+
+#ifndef TEST_CCAPP
+ sc_cfg_get("voip_status",voip_status,sizeof(voip_status));
+
+ if (0 != strcmp("ledblink" , voip_status))
+#endif
+ {
+ zCc_SetLedStatus("ledblink");
+ }
+ break;
+
+ case ZCC_SINVITE_E:
+ g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ZCC_SINVITE_E;
+ //g_Cc_CallDetail.state = ZCC_M_RINGING_S; È·ÈÏ×ÊÔ´·ÖÅäºóÔÙǨ״̬
+ break;
+
+ case ZCC_RESOURCE_READY_E:
+ ccapp_log("g_Cc_CallDetail.ringCid=%d", g_Cc_CallDetail.ringCid);
+ if (g_Cc_CallDetail.ringCid)
+ {
+ g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_RESOURCE_READY_E;
+ }
+ break;
+
+ case ZCC_SDISCN_MO_E:
+ case ZCC_SDISCN_MT_E:
+ g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ptMsgBuf->usMsgCmd;
+ break;
+
+ case ZCC_RELEASE_E:
+ case ZCC_FLASH_E:
+ default:
+ // do nothing
+ break;
+ }
+}
+
+pthread_t slic_ring_test_pid;
+void* slic_ring_test_thread(void * ptr)
+{
+ SIGNAL_DATA tSig;
+ while(1)
+ {
+ sleep(30);
+ printf("ring stop\n");
+ SLIC_Stop_Signal(0, RING_SIGNAL);
+ zCc_SetLedStatus("ledoff");
+
+ sleep(30);
+ printf("ringing\n");
+ memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type = RING_SIGNAL;
+ strcpy(g_Cc_CallDetail.number, "1234567890");
+ strncpy(tSig.cid, g_Cc_CallDetail.number,sizeof(tSig.cid)-1);
+ get_local_datetime(tSig.date_time);
+ ccapp_log("local test call RING_SIGNAL,number = %s\n",g_Cc_CallDetail.number);
+ SLIC_Play_Signal(0, 0, &tSig);
+ zCc_SetLedStatus("ledblink");
+ }
+ return NULL;
+}
+
+VOID zCc_MRingingState(MSG_BUF *ptMsgBuf)
+{
+ int held_call_cid = 0;
+ int incoming_call_cid = 0;
+ int shall_ring_cid;
+
+ SIGNAL_DATA tSig;
+
+ CHAR voip_status[ZDIAL_NUM_MAX] = {0};
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
+ switch (ptMsgBuf->usMsgCmd)
+ {
+ case ZCC_SEIZE_E: // ͻȜ
+ g_Cc_CallDetail.state = ZCC_M_SEIZE_S;
+ SLIC_Stop_Signal(0, RING_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ if (g_zCc_VoiceOpenSucc == 0)
+ {
+ g_zCc_VoiceOpenSucc = 1;
+ voice_open(&g_zCc_VoicePara_bak);
+ /* new add begin */
+ if (g_zCc_pcm_bak == 8000)
+ {
+ SLIC_PCM_Set_NB();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_NB <---\n",__FUNCTION__);
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+ }
+ else if (g_zCc_pcm_bak == 16000)
+ {
+ SLIC_PCM_Set_WB();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_PCM_Set_WB <---\n",__FUNCTION__);
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_ZimsplusProc: SLIC_Start_PCM <---\n",__FUNCTION__);
+ }
+ g_zCc_pcm_bak = 0;
+ /* new add end */
+ }
+
+ g_Cc_CallDetail.chupSent = FALSE;
+
+ ccapp_log("ZCC_SEIZE_E held_cid=%d held_incoming_cid=%d",
+ zCc_find_held_cid(),
+ zCc_find_held_incoming_cid());
+
+ if(local_test_call_st==LocalTestCallST_Ring)
+ {
+ /*memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_TKY;
+ SLIC_Play_Signal(0, 0, &tSig);*/
+ if(local_test_call_type == LocalTestCallType_LOOP)
+ pthread_cancel(slic_ring_test_pid);
+
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.evt[0]= ZCC_NO_E;
+ g_Cc_CallDetail.slaveObj[0].sMsg = ZCC_SNO_M;
+
+ local_test_call_st = LocalTestCallST_End;
+
+ //system("echo loop_1 >> /tmp/log.ccapp.vploop");
+ //system("( sleep 1 && at_cmd AT+VPLOOP=1 ) &");
+ sc_cfg_set("tz_vploop", "1");
+ ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL,
+ MODULE_ID_AT_CTL,
+ MSG_CMD_SET_VPLOOP_REQ,
+ 0,
+ NULL,
+ 0);
+
+ zCc_ShowAllSlaveWithTips("testCall-end");
+ break;
+ }
+
+ incoming_call_cid = zCc_find_held_incoming_cid();
+ ccapp_log("incoming_call_cid=%d is_cidcw=%d",
+ incoming_call_cid,
+ g_Cc_CallDetail.slaveObj[incoming_call_cid].is_cidcw);
+
+ if(zCc_find_held_cid())
+ {
+ zCc_SendAtChldReq(1);
+ }
+ else if(incoming_call_cid)
+ {
+ if(g_Cc_CallDetail.slaveObj[incoming_call_cid].is_cidcw == TRUE)
+ zCc_SendAtChldReq(1);
+ else
+ {
+ if (g_Cc_CallDetail.ringCid)
+ {
+ g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_CNCT_E;
+ zCc_SendAtAnswerReq();
+ }
+ }
+ }
+ else
+ {
+ if (g_Cc_CallDetail.ringCid)
+ {
+ g_Cc_CallDetail.evt[g_Cc_CallDetail.ringCid] = ZCC_CNCT_E;
+ zCc_SendAtAnswerReq();
+ }
+ }
+ break;
+
+// case ZCC_SINVITE_E:
+ case ZCC_SDISCN_MT_E:
+ case ZCC_SDISCN_MO_E:
+ if(check_incoming_call_is_in_slave(ptMsgBuf)==0)
+ break;
+
+ g_Cc_CallDetail.evt[ptMsgBuf->dst_id] = ptMsgBuf->usMsgCmd;
+ g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
+ SLIC_Stop_Signal(0, RING_SIGNAL);
+ g_zCc_VoiceOpenSucc = 1;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MRingingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+#ifndef TEST_CCAPP
+ sc_cfg_get("voip_status",voip_status,sizeof(voip_status));
+
+ if (0 != strcmp("ledoff" , voip_status ))
+#endif
+ {
+ zCc_SetLedStatus("ledoff");
+ }
+
+ shall_ring_cid = 0;
+ held_call_cid = zCc_find_held_cid();
+ incoming_call_cid = zCc_find_held_incoming_cid();
+ if(held_call_cid && (ptMsgBuf->dst_id!=held_call_cid))
+ shall_ring_cid = held_call_cid;
+ else if(incoming_call_cid && (ptMsgBuf->dst_id!=incoming_call_cid))
+ shall_ring_cid = incoming_call_cid;
+
+ if(shall_ring_cid!=0)
+ {
+ memset(&tSig, 0, sizeof(tSig));
+ g_Cc_CallDetail.state = ZCC_M_RINGING_S;
+ tSig.signal_type = RING_SIGNAL;
+ /*memcpy(tSig.cid,
+ g_Cc_CallDetail.slaveObj[shall_ring_cid].number,
+ strlen(g_Cc_CallDetail.slaveObj[shall_ring_cid].number));*/
+ strncpy(tSig.cid, g_Cc_CallDetail.slaveObj[shall_ring_cid].number, sizeof(tSig.cid)-1);
+ get_local_datetime(tSig.date_time);
+ 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);
+ SLIC_Play_Signal(0, 0, &tSig);
+ zCc_SetLedStatus("ledblink");
+ }
+ break;
+
+ default:
+ // do nothing
+ break;
+ }
+}
+
+VOID zCc_MSeizeState(MSG_BUF *ptMsgBuf)
+{
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ptMsgBuf->usMsgCmd = %d\n",__FUNCTION__,ptMsgBuf->usMsgCmd);
+ UINT8 slave = (UINT8)ptMsgBuf->dst_id;
+ UINT8 callCnt = 0;
+ UINT8 ret = 0;
+ SINT32 chldret = -1;
+ UINT8 tmpslave = 0;
+ CHAR voip_status[ZDIAL_NUM_MAX] = {0};
+
+ printf("[ccapp_debug]: Seize State Recv MsgCmd: %d,localtest=%d\n",ptMsgBuf->usMsgCmd,local_test_call_st);
+
+ switch (ptMsgBuf->usMsgCmd)
+ {
+ case ZCC_DTMF_E: // ²¦ºÅ
+ // slave[0] dial , or other call's DTMF
+ ccapp_log("--> ZCC_DTMF_E[%c] lastTone=%d Count=%d Held=%d Active=%d getSlave(DACCM)=%d getSlave(RINGBACK)=%d ringCid=%d dig=%s",
+ ptMsgBuf->aucDataBuf[0],
+ g_Cc_CallDetail.lastTone,
+ zCc_CallCount(),
+ zCc_HeldCall(),
+ zCc_ActiveCall(),
+ zCc_GetSpecSlave(ZCC_S_DACCM_S),
+ zCc_GetSpecSlave(ZCC_S_RINGBACK_S),
+ g_Cc_CallDetail.ringCid,
+ g_Cc_CallDetail.digits);
+ 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",
+ ptMsgBuf->aucDataBuf[0],
+ g_Cc_CallDetail.lastTone,
+ zCc_CallCount(),
+ zCc_HeldCall(),
+ zCc_ActiveCall(),
+ zCc_GetSpecSlave(ZCC_S_DACCM_S),
+ zCc_GetSpecSlave(ZCC_S_RINGBACK_S),
+ g_Cc_CallDetail.ringCid,
+ g_Cc_CallDetail.digits);
+
+ /* callwait ringback but he drop then we hookflash+1
+lastTone=6 Count=2 Held=1 Active=0 getSlave(DACCM)=0 getSlave(RINGBACK)=2 ringCid=0 dig[0]=F
+ */
+ if ((g_Cc_CallDetail.lastTone == ZCC_TONE_BSY_A) || (g_Cc_CallDetail.lastTone == ZCC_TONE_TKY_A))//æÒôºÍÃùº¿Òô£¬²»´¦Àí°´¼üÏûÏ¢
+ {
+ zCc_ClearDigits();
+ break;
+ }
+ callCnt = zCc_CallCount();
+ if ( (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A || callCnt == zCc_HeldCall()) //Ö»Óб£³Öºô½Ð£¬²¦ºÅ·¢Æðкô½Ð
+ && g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN
+ && 0 == zCc_ActiveCall())//·Å²¦ºÅÒô»òÒÑÓб£³Öºô½ÐʱÓû§²¦ºÅ,µÚÒ»¸ö×Ö·û£¬Åųýactive+heldʱÏ·¢F2
+ {
+ slave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
+ if (0 == slave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[0];
+ g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+ zCc_InitSlaveObj(0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
+ break;
+ }
+ else if ((g_Cc_CallDetail.lastTone == ZCC_TONE_SIL_A) && (0 != zCc_GetSpecSlave(ZCC_S_DACCM_S)))//¼ÌÐø²¦ºÅ
+ {
+ slave = zCc_GetSpecSlave(ZCC_S_DACCM_S);
+ g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
+ break;
+ }
+ else if ((g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN) && ((0 != zCc_ActiveCall())
+ ||((0 == zCc_ActiveCall()) && (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))))//·¢dtmf
+ {
+ if (0 != zCc_ActiveCall())
+ {
+ slave = zCc_GetCallSlave(0);
+ }
+ else
+ {
+ slave = zCc_GetSpecSlave(ZCC_S_RINGBACK_S);
+ }
+ g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
+ break;
+ }
+ else if ((0 == zCc_ActiveCall()) && (0 == zCc_GetSpecSlave(ZCC_S_RINGBACK_S))
+ && (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN))//·ÇÎÈ̬·Ç»ØÁåÒô״̬ÊÕµ½×Ö·û£¬¶ªÆú
+ {
+ zCc_ClearDigits();
+ return;
+ }
+ else
+ {
+ if (g_Cc_CallDetail.ringCid && (g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone == ZCC_TONE_CIDCW_A))//active+waiting+flashordtmf
+ {
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+ if (g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN)
+ {
+ slave = zCc_GetSpecSlave(ZCC_S_TALKING_S);
+ if (0 == slave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.evt[slave] = ZCC_DTMF_E;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
+ break;
+ }
+ }
+
+ sc_timer_delete(ZCCAPP_TIMER_DTMF_DETECT);
+ ret = zCc_DigitsMatch();
+ if ((ZCC_NO_RESULT != ret && ZCC_MATCHERR != ret && g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A)
+ ||(ZCC_MATCHERR == ret && g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A && 2 <= zCc_CallCount()))
+ {//call waitingÊÕµ½flash4£¬Í£Ö¹²¦ºÅÒô»Ö¸´ºô½ÐµÈ´ýÒô
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if (g_Cc_CallDetail.slaveObj[0].tone != ZCC_TONE_OFF_A)
+ {
+ zCc_InitSlaveObj(0);
+ }
+ if (0 != zCc_ActiveCall())
+ {
+ SLIC_Start_PCM();
+ }
+ if ((ZCC_FLASH_1 == ret || ZCC_FLASH_2 == ret) && (g_Cc_CallDetail.ringCid != 0))//½ÓÌýwaiting call£¬ºô½ÐµÈ´ýÒôÓ¦Çå¿Õ
+ {
+ g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone = ZCC_TONE_OFF_A;
+ }
+ }
+ zCc_DigitsMatchRltProc(ret);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState ZCC_DTMF_E \n",__FUNCTION__);
+ }
+
+ break;
+
+ case ZCC_SDIALLING_E: // ·¢³öÁËSIP INVITE »ò CC SETUP , ͨ¹ýÕâ¸öÏûÏ¢Éϱ¨ cid
+ if (0 != zCc_GetDialingSlave(0))
+ {
+ tmpslave = zCc_GetDialingSlave(0);
+ if (tmpslave != slave)
+ {
+ g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
+ zCc_InitSlaveObj(tmpslave);
+ }
+ }
+ break;
+
+ case ZCC_SRING_E:
+ case ZCC_SANS_E:
+ case ZCC_SINVITE_E:
+ case ZCC_CIDCW_E:
+ g_Cc_CallDetail.evt[slave] = ptMsgBuf->usMsgCmd;
+ break;
+
+ case ZCC_SDISCN_MT_E:
+ case ZCC_SDISCN_MO_E:
+ { //cov m
+ if(check_incoming_call_is_in_slave(ptMsgBuf)==0)
+ break;
+
+ g_Cc_CallDetail.evt[slave] = ptMsgBuf->usMsgCmd;
+
+ T_zCcApp_DsciInd *ptr = ptMsgBuf->aucDataBuf;
+
+ /* somebody drop the call
+ zCc_MSeizeState zCc_MSeizeState ptMsgBuf->usMsgCmd = 43
+ zCc_MSeizeState ==> get MT/MO cid=1 num=13088877803 stat=6 inMp=0 getCnt=2
+ zCc_MSeizeState slv=1 cid=0 held=1 stat=8
+ zCc_MSeizeState slv=2 cid=0 held=0 stat=8
+ zCc_STalkingState zCc_STalkingState g_Cc_CallDetail.evt[1] = 43
+ */
+ ccapp_log("==> get MT/MO cid=%d num=%s stat=%d inMp=%d getCnt=%d",
+ ptr->cid, ptr->num, ptr->state, ptr->inMpty,
+ zCc_CallCount());
+
+ for (tmpslave = 0; tmpslave < ZCC_SLAVES; tmpslave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[tmpslave].state != ZCC_S_IDLE_S)
+ {
+ ccapp_log(" slave=%d cid=%d held=%d stat=%d",
+ tmpslave,
+ g_Cc_CallDetail.slaveObj[tmpslave].cid,
+ g_Cc_CallDetail.slaveObj[tmpslave].heldcall,
+ g_Cc_CallDetail.slaveObj[tmpslave].state);
+ }
+ }
+
+ if(zCc_CallCount()<2)
+ break;
+
+ if(ptr->cid>=ZCC_SLAVES) //cov m
+ break;
+
+ if(g_Cc_CallDetail.slaveObj[ptr->cid].heldcall==0 &&
+ g_Cc_CallDetail.slaveObj[ptr->cid].confcall==0)
+ {
+ if(zCc_HeldCall())
+ {
+ zCc_SendAtChldReq(1);
+ break;
+ }
+ }
+
+ int incoming_call_cid = zCc_GetSpecSlave(ZCC_S_TRYING_S);
+ if(incoming_call_cid!=0 && incoming_call_cid!=ptr->cid)
+ zCc_SendAtChldReq(2);
+
+ #if 0
+ tmpslave = zCc_GetSpecSlave(ZCC_S_TRYING_S); // incoming call here and wait for to be accepted
+ ccapp_log("zCc_CallCount()=%d zCc_GetSpecSlave(ZCC_S_TRYING_S)=%d",
+ zCc_CallCount(),
+ tmpslave);
+ if(tmpslave!=0 && ptMsgBuf->usMsgCmd==ZCC_SDISCN_MO_E) // foreground drop, automaticly accept the incoming call
+ {
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zCc_SendAtChldReq(1);
+ break;
+ }
+
+ if(zCc_CallCount()<2)
+ break;
+
+ if(ptr->cid<0 || ptr->cid>=ZCC_SLAVES)
+ break;
+
+ if(g_Cc_CallDetail.slaveObj[ptr->cid].heldcall==0 &&
+ g_Cc_CallDetail.slaveObj[ptr->cid].confcall==0)
+ {
+ /*if(g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_DIALING_S ||
+ g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_RINGBACK_S ||
+ g_Cc_CallDetail.slaveObj[ptr->cid].state==ZCC_S_TALKING_S) */
+ if(zCc_HeldCall())
+ {
+ zCc_SendAtChldReq(1);
+ }
+ }
+ #endif
+ break;
+ }
+ case ZCC_RELEASE_E:
+ if(local_test_call_st==LocalTestCallST_Start)
+ {
+ SIGNAL_DATA tSig;
+
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+
+ memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type = RING_SIGNAL;
+ strcpy(g_Cc_CallDetail.number, "1234567890");
+ strncpy(tSig.cid, g_Cc_CallDetail.number,sizeof(tSig.cid)-1);
+ get_local_datetime(tSig.date_time);
+ ccapp_log("local test call RING_SIGNAL,number = %s\n",g_Cc_CallDetail.number);
+ SLIC_Play_Signal(0, 0, &tSig);
+ zCc_SetLedStatus("ledblink");
+
+ if(local_test_call_type == LocalTestCallType_LOOP) {
+ if (pthread_create(&slic_ring_test_pid, NULL, slic_ring_test_thread,0) != 0) //cov m
+ printf("slic_ring_test_thread create fail\n");
+ }
+
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.evt[slave]= ZCC_NO_E;
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ g_Cc_CallDetail.state = ZCC_M_RINGING_S;
+
+ local_test_call_st = LocalTestCallST_Ring;
+ zCc_ShowAllSlaveWithTips("testCall-ring");
+ break;
+ }
+ else if(local_test_call_st==LocalTestCallST_End)
+ {
+ zCc_ClearDigits();
+ zCc_InitSlaveObj(0);
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S)
+ zCc_InitSlaveObj(slave);
+ }
+
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ SLIC_Stop_PCM();
+ zCc_SetLedStatus("ledoff");
+
+ g_Cc_CallDetail.resourceReady = 0;
+ g_Cc_CallDetail.hookofffg = FALSE;
+ g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
+
+ //system("echo loop_0 >> /tmp/log.ccapp.vploop");
+ //system("( sleep 1 && at_cmd AT+VPLOOP=0 ) &");
+ sc_cfg_set("tz_vploop", "0");
+ ipc_send_message(MODULE_ID_CALL_CTRL_LOCAL,
+ MODULE_ID_AT_CTL,
+ MSG_CMD_SET_VPLOOP_REQ,
+ 0,
+ NULL,
+ 0);
+
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_DTMF_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_BUSYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_TKYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_IDLE);
+
+ local_test_call_st = LocalTestCallST_None;
+ zCc_ShowAllSlaveWithTips("testCall-end-none");
+ break;
+ }
+
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state != ZCC_S_IDLE_S && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)
+ {
+ g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
+ }
+ }
+ //if(slave == ZCC_SLAVES)
+ // return;
+ if (g_Cc_CallDetail.slaveObj[0].state != ZCC_S_IDLE_S)//slave0½öÓÃÓÚ·ÅÒô£¬²»¶ÔÓ¦ºô½Ð
+ {
+ zCc_InitSlaveObj(0);
+ }
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ //g_Cc_CallDetail.chupSent = FALSE;
+ //SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_PCM <---\n",__FUNCTION__);
+
+#ifndef TEST_CCAPP
+
+
+ sc_cfg_get("voip_status",voip_status,sizeof(voip_status));
+
+ if (0 != strcmp("ledoff" , voip_status ))
+#endif
+ {
+ zCc_SetLedStatus("ledoff");
+ }
+ g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
+ if (!(0 != zCc_GetSpecSlave(ZCC_S_TRYING_S) && (1 == zCc_CallCount())))//Õª»úʱµÄÀ´µç£¬²»Çå
+ {
+ g_Cc_CallDetail.resourceReady = 0;
+ }
+ zCc_ClearDigits();
+ g_Cc_CallDetail.hookofffg = FALSE;
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_DETECT);//ÊÕµ½ÉÁ¶Ï£¬µ±Ç°¶¨Ê±Æ÷¶¼ÐèҪֹͣ£¬ºóÐøÔÙÆô¶¯
+ sc_timer_delete(ZCCAPP_TIMER_DTMF_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_BUSYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_TKYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_IDLE);
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ g_Cc_CallDetail.slaveObj[slave].idle_second = 0;//hook off ldle timer is killed, time_cnt reset
+ }
+
+ break;
+ case ZCC_BUSYTONETIMER_E:
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].tone == ZCC_TONE_BSY_A)
+ break;
+ }
+ if(slave == ZCC_SLAVES)
+ return;
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_TKY_A;
+ sc_timer_create(ZCCAPP_TIMER_TKYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_TKYTONE_INTERVAL,
+ zCcApp_TkyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState sc_timer_create zCcApp_TkyToneTimer\n",__FUNCTION__);
+ if (!(0 == zCc_GetSpecSlave(ZCC_S_BSYT_S)
+ &&(g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_WAIT_RESOURCE_S
+ ||g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_TRYING_S)
+ && g_Cc_CallDetail.lastTone == ZCC_TONE_BSY_A))
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TKYT_S;
+ }
+ return;
+ case ZCC_HOOKOFFTIMER_E:
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DT_S)
+ break;
+ }
+ if(slave == ZCC_SLAVES)
+ return;
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
+ {
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState sc_timer_create zCcApp_BusyToneTimer22222\n",__FUNCTION__);
+ }
+ else
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ }
+ return;
+ case ZCC_HOOKOFF_IDLE_TIMER_E:
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DT_S)
+ {
+ g_Cc_CallDetail.slaveObj[slave].idle_second++;
+ if(g_Cc_CallDetail.slaveObj[slave].idle_second >= 5000/ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL)
+ {
+ int rt;
+ char hotline[ZDIAL_NUM_MAX-1];
+
+ memset(hotline, 0, sizeof(hotline));
+ rt = sc_cfg_get("dialog_hotline_str", hotline, sizeof(hotline)-1);
+ if(rt!=0 || strlen(hotline)<=0)
+ {
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_IDLE);
+ break;
+ }
+
+ strcpy(g_Cc_CallDetail.digits, hotline);
+ g_Cc_CallDetail.dCount = strlen(hotline);
+
+ MSG_BUF msgBuf = {0};
+ msgBuf.usMsgCmd = ZCC_DTMF_E;
+ msgBuf.src_id = MODULE_ID_SLIC;
+ msgBuf.aucDataBuf[0] = (UINT8)'#';
+ msgBuf.usDataLen = 1;
+ zCc_SendMsgToSub(&msgBuf);
+
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
+
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_DETECT);
+
+ ccapp_log("==> HOOKOFF_IDLE_TIMER send hotline=%s\n", hotline);
+ }
+ }
+ }
+ break;
+ case ZCC_DTMFTIMER_E:
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_DACCM_S)
+ break;
+ }
+ if(slave == ZCC_SLAVES)
+ return;
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_TIMEOUT_SIGN;
+ ret = zCc_DigitsMatch();
+ zCc_DigitsMatchRltProc(ret);
+ if (ZCC_MATCHERR != ret)
+ {
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_IDLE_S)//ss
+ {
+ zCc_SendSsReq(g_Cc_CallDetail.digits);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ }
+ else
+ {
+ zCc_SendAtDialReq(g_Cc_CallDetail.digits);
+ }
+ }
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ zCc_ClearDigits();
+ return;
+ case ZCC_TKYTIMER_E:
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].tone == ZCC_TONE_TKY_A)
+ break;
+ }
+ if(slave == ZCC_SLAVES)
+ return;
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
+ if (!(0 == zCc_GetSpecSlave(ZCC_S_TKYT_S)
+ &&(g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_WAIT_RESOURCE_S
+ ||g_Cc_CallDetail.slaveObj[slave].state== ZCC_S_TRYING_S)
+ && g_Cc_CallDetail.lastTone == ZCC_TONE_TKY_A))
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_SIL_S;
+ }
+ g_Cc_CallDetail.lastTone = ZCC_TONE_SIL_A;
+ return;
+ case ZCC_SSDIALTONETIMER_E:
+ zCc_InitSlaveObj(0);//·Å²¦ºÅÒôµÄslave0 Çå¿Õ
+ zCc_ClearDigits();
+ if (1 == zCc_CallCount()
+ && (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A))//µ±Ç°Ö»ÓÐһ·£¬Í£Ö¹²¦ºÅÒô
+ {
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if (1 == zCc_HeldCall())//Òѱ£³Ö£¬»Ö¸´
+ {
+ chldret = zCc_SendAtChldReq(2);
+ }
+ else if (0 != zCc_ActiveCall())
+ {
+ SLIC_Start_PCM();
+ }
+ }
+ else if (1 < zCc_CallCount() && (g_Cc_CallDetail.lastTone == ZCC_TONE_DIAL_A))//active/held mpty and held+waiting
+ {
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if((0 == zCc_HeldCall() && 0 != g_Cc_CallDetail.ringCid)//active+waiting »Ö¸´ÓïÒô£¬held+waiting, ²»»Ö¸´ÓïÒô£¬·Åºô½ÐµÈ´ýÒô
+ ||(0 != zCc_HeldCall() && 0 !=zCc_ActiveCall()))//active+held»Ö¸´ÓïÒô
+ {
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Start_PCM <---\n",__FUNCTION__);
+ }
+ }
+ return;
+ case ZCC_FLASH_E:
+ ccapp_log("ZCC_FLASH_E cnt=%d held=%d active=%d BefDial=%d",
+ zCc_CallCount(),
+ zCc_HeldCall(),
+ zCc_ActiveCall(),
+ zCc_MoBeforDialingCall());
+
+ if (!(zCc_CallCount() > 1 && g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN))//¶à·ºô½Ðʱ£¬ÐèÒªÅжÏflashÁ¬·¢Á½´ÎµÄ³¡¾°£¬²»Çå³ý
+ {
+ zCc_ClearDigits();
+ }
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_DETECT);//ÊÕµ½ÉÁ¶Ï£¬µ±Ç°¶¨Ê±Æ÷¶¼ÐèҪֹͣ£¬ºóÐøÔÙÆô¶¯
+ sc_timer_delete(ZCCAPP_TIMER_DTMF_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_BUSYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_TKYTONE_DETECT);
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+
+ callCnt = zCc_CallCount();
+
+ if (g_Cc_CallDetail.ringCid && (g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone == ZCC_TONE_CIDCW_A))//ºô½ÐµÈ´ý£¬¸ù¾ÝflashºóÃæµÄ×Ö·û¾ö¶¨ºóÐø²Ù×÷
+ {
+ if(g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
+ {
+ zCc_InitSlaveObj(0);
+ zCc_ClearDigits();
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if (0 != zCc_ActiveCall())
+ {
+ SLIC_Start_PCM();
+ }
+ break;
+ }
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
+ // slave[0] to play dial tone
+ sc_timer_create(ZCCAPP_TIMER_SSDIALTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_HOOKOFF_INTERVAL,
+ zCcApp_SsDialToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: sc_timer_create zCcApp_SsDialToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+ //g_Cc_CallDetail.slaveObj[g_Cc_CallDetail.ringCid].tone = ZCC_TONE_OFF_A;±£Áô¸Ã×ֶΣ¬ÓÃÓÚflash4µÈʧ°Üʱ»Ö¸´ºô½ÐµÈ´ýÒô
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_PCM2222\n",__FUNCTION__);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
+ break;
+ }
+
+ if ( callCnt==0 //·Å²¦ºÅÒô»¹Î´Íê³É²¦ºÅ»òÕª»ú䲦ºÅ·ÅæÒôº¿ÃùÒô¾²Òô
+ ||(callCnt ==1 && zCc_FlashClearCall() > 0)) //ÕÒµ½½¨Á¢ÖеÄÖ÷½ÐÒÔ¼°ÊÍ·ÅÖеĺô½Ð£¬ÊÍ·Å£¬²¢·Å²¦ºÅÒô
+ {
+ zCc_InitSlaveObj(0);
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
+ g_Cc_CallDetail.hookofffg = TRUE;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
+ break;
+ }
+
+ if (zCc_ActiveCall() == callCnt) //Ö»ÓÐactive call£¬±£³ÖËü£¬²¢·Å²¦ºÅÒô
+ {
+ if (callCnt > 1) // conf call, ·Å²¦ºÅÒô
+ {
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
+ g_Cc_CallDetail.digits[ZDIAL_NUM_MAX-1] = 1;// ¼Ç¼±¾´Î²Ù×÷ΪÕë¶Ôconf µÄ
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
+ }
+ else
+ {
+ chldret = zCc_SendAtChldReq(2);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
+ g_Cc_CallDetail.waitchldresult = 1;
+ }
+ break;
+ }
+
+ if (zCc_HeldCall() == callCnt) //Ö»ÓÐheld call£¬»Ö¸´
+ {
+ if (callCnt == 1 )
+ {
+ chldret = zCc_SendAtChldReq(2);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E\n",__FUNCTION__);
+ }
+ else
+ {
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
+ sc_timer_create(ZCCAPP_TIMER_SSDIALTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_HOOKOFF_INTERVAL,
+ zCcApp_SsDialToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:sc_timer_create zCcApp_SsDialToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+
+ }
+ break;
+ }
+ //active + held
+
+ if(g_Cc_CallDetail.digits[0] == ZCC_FLASH_SIGN)
+ {
+ zCc_InitSlaveObj(0);
+ zCc_ClearDigits();
+ SLIC_Stop_Signal(0,0);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if (0 != zCc_ActiveCall())
+ {
+ SLIC_Start_PCM();
+ }
+ break;
+ }
+
+ /*
+ zCc_MSeizeState befor=1 act=0 held=1 callCnt=2
+ zCc_MoBeforDialingCall slave[1]=8
+ zCc_MoBeforDialingCall slave[2]=4
+ */
+ ccapp_log("ZCC_FLASH_E befor=%d active=%d held=%d callCnt=%d",
+ zCc_MoBeforDialingCall(),
+ zCc_ActiveCall(),
+ zCc_HeldCall(),
+ callCnt);
+
+ if (((0 != zCc_MoBeforDialingCall())
+ && (0 != zCc_ActiveCall() || 0 != zCc_HeldCall())) //active or held + ½¨Á¢Öеĺô½Ð
+ ||(0 != zCc_MoBeforDialingCall() && 1 == callCnt))
+ {
+ /*if(g_Cc_CallDetail.digits[0]==ZCC_FLASH_SIGN &&
+ strlen(g_Cc_CallDetail.digits)<=3)
+ {
+ zCc_InitSlaveObj(0);
+ zCc_ClearDigits();
+ zCc_SendAtChldReq(2);
+ ccapp_log("get ZCC_FLASH_SIGN and return to old talk");
+ }*/
+
+ int cid = zCc_GetMoBeforDialingCallCID();
+ if(cid>=0 && zCc_HeldCall()!=0) // drop the beforeDialing call
+ {
+ zCc_InitSlaveObj(cid);
+ zCc_ClearDigits();
+ zCc_SendAtChldReq(1);
+ ccapp_log("drop the beforeDialing call cid=%d", cid);
+ }
+
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:ZCC_FLASH_E return\n",__FUNCTION__);
+ return;
+ }
+
+ g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ZCC_FLASH_SIGN;
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+ sc_timer_create(ZCCAPP_TIMER_SSDIALTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_HOOKOFF_INTERVAL,
+ zCcApp_SsDialToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:sc_timer_create zCcApp_SsDialToneTimer\n",__FUNCTION__);
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
+ break;
+
+ case ZCC_RESOURCE_READY_E:
+ g_Cc_CallDetail.evt[slave] = ZCC_RESOURCE_READY_E;
+ break;
+ /*ATÃüÁîÏìÓ¦£¬Ä¿Ç°Ö»ÓÐatdµÄÏìÓ¦ÐèÒª´¦Àí*/
+ case MSG_CMD_ATD_DIAL_RSP:
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ATD_rsp=%d\n",__FUNCTION__,((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result);
+ if(((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result == 0)
+ break;
+ slave = zCc_GetDialingSlave(1);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq:RECV ERROR\n",__FUNCTION__);
+ slave = zCc_GetDialingSlave(1);
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendAtDialReq sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ char num[ZDIAL_NUM_MAX+1];
+ strcpy(num, g_Cc_CallDetail.slaveObj[slave].number);
+
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+
+ if(zCc_find_held_cid()|| zCc_find_held_incoming_cid()) // restore prvious talk to active
+ {
+ zCc_SendAtChldReq(2);
+
+ char temp[200];
+ sprintf(temp, "echo \"%s get error dialout cid=%d num=%s\" > /tmp/log.ccapp.callout.err",
+ get_local_date_time(), slave, num);
+ soft_system(temp);
+ }
+ }
+ break;
+ /*case MSG_CMD_ATA_RSP:
+ case MSG_CMD_CHUP_RSP:
+ case MSG_CMD_VTS_RSP:
+ case MSG_CMD_ZIMSPLUS_RSP:
+ case MSG_CMD_CCFC_RSP:
+ case MSG_CMD_CLCK_RSP:
+ break;*/
+ case MSG_CMD_CHLD_RSP:
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s CHLD_rsp=%d\n",__FUNCTION__,((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result);
+ if(g_Cc_CallDetail.waitchldresult == 1 )
+ {
+ g_Cc_CallDetail.waitchldresult = 0;
+ if (((T_zCcapp_optRsp*)ptMsgBuf->aucDataBuf)->result == 0)
+ {
+ sc_timer_create(ZCCAPP_TIMER_SSDIALTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_HOOKOFF_INTERVAL,
+ zCcApp_SsDialToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:sc_timer_create zCcApp_SsDialToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.evt[0] = ZCC_DIAL_E;
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_MSeizeState:SLIC_Stop_PCM\n",__FUNCTION__);
+ }
+ }
+ break;
+
+ case ZCC_SEIZE_E: // ͻȜ
+ default:
+ // do nothing
+ break;
+ }
+}
+
+
+//get local time string , format"YYYY-MM-DD HH:MM:SS"
+char *get_local_date_time(void)
+{
+ time_t now;
+ struct tm *timenow;
+ static char localtimestr[32];
+
+ time(&now);
+ timenow = localtime(&now);
+ memset(localtimestr, 0, 32);
+ if(timenow)
+ snprintf(localtimestr, 32, "%04d-%02d-%02d %02d:%02d:%02d",
+ timenow->tm_year + 1900, timenow->tm_mon+1, timenow->tm_mday,
+ timenow->tm_hour, timenow->tm_min, timenow->tm_sec);
+ return localtimestr;
+}
+
+
+//get local time string , format"MMDDHHMM"
+char *get_local_datetime(char *buff)
+{
+ time_t now;
+ struct tm *timenow;
+ static char localtimestr[48];
+
+ memset(localtimestr, 0, sizeof(localtimestr));
+
+ time(&now);
+ timenow = localtime(&now);
+ if(timenow)
+ sprintf(localtimestr, "%02d%02d%02d%02d",
+ timenow->tm_mon+1, timenow->tm_mday,
+ timenow->tm_hour, timenow->tm_min);
+
+ if(buff!=NULL)
+ strcpy(buff, localtimestr);
+
+ return localtimestr;
+}
+
+
+int zCc_find_held_cid(void)
+{
+ int slavetmp;
+
+ for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slavetmp].heldcall!=0)
+ {
+ return slavetmp;
+ }
+ }
+
+ return 0;
+}
+
+int zCc_talking_count(void)
+{
+ int cnt = 0;
+ int slavetmp;
+
+ for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slavetmp].state==ZCC_S_TALKING_S)
+ cnt++;
+ }
+
+ return cnt;
+}
+
+
+int zCc_find_held_incoming_cid(void)
+{
+ int slavetmp;
+
+ for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slavetmp].state==ZCC_S_TRYING_S)
+ {
+ return slavetmp;
+ }
+ }
+
+ return 0;
+}
+
+
+int zCc_find_all_callout(int slave[ZCC_SLAVES])
+{
+ int n=0;
+
+ int i;
+ for (i = 1; i < ZCC_SLAVES; i++)
+ {
+ if (g_Cc_CallDetail.slaveObj[i].is_callout!=0)
+ {
+ slave[n] = i;
+ n++;
+ }
+ }
+
+ return n;
+}
+
+
+void zCc_hungup_all(int slave)
+{
+ int slavetmp;
+ if (!g_Cc_CallDetail.chupSent)
+ {
+ zCc_SendAtHangupReq();
+ for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
+ {
+ if (g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_DIALING_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_RINGBACK_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TALKING_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TRYING_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_WAIT_RESOURCE_S)
+ {
+ g_Cc_CallDetail.slaveObj[slavetmp].waitDSCI6 = 1;
+ }
+ }
+ if (!((zCc_CallCount() == 1) && ((ZCC_S_DACCM_S == g_Cc_CallDetail.slaveObj[slave].state)
+ || (ZCC_S_DIALING_S == g_Cc_CallDetail.slaveObj[slave].state)))
+ && !((zCc_CallCount() > 1) && (0 != zCc_MtInactiveCall()) && (0 != zCc_MoInactiveCall())))//·Çidle״̬¶¼ÊÇÕª»ú̬ÊÕµ½À´µçÇҾܽÓÀ´µç
+ {
+ g_Cc_CallDetail.chupSent = TRUE;//»¹ÓÐÆäËûºô½Ð£¬²»ÔÙÖØ¸´·¢chup
+ }
+ }
+}
+
+VOID zCc_RunMaster(MSG_BUF *ptMsgBuf)
+{
+ UINT8 slave = 0;
+ UINT8 slavetmp = 0;
+ SIGNAL_DATA tSig;
+ int held_call_cid;
+ int incoming_call_cid;
+
+ static int old_state = -1;
+ if(old_state != g_Cc_CallDetail.state)
+ {
+ ccapp_log("=======================\n");
+ ccapp_log("zCc_RunMaster state %d --> %d\n", old_state, g_Cc_CallDetail.state);
+ old_state = g_Cc_CallDetail.state;
+ }
+
+ memset(tSig.cid, 0, 32);
+
+ zCc_CheckSlaveState("start zCc_RunMaster");
+ switch (g_Cc_CallDetail.state)
+ {
+ case ZCC_M_RELEASE_S:
+ zCc_MReleaseState(ptMsgBuf);
+ break;
+
+ case ZCC_M_RINGING_S:
+ zCc_MRingingState(ptMsgBuf);
+ break;
+
+ case ZCC_M_SEIZE_S:
+ default:
+ zCc_MSeizeState(ptMsgBuf);
+ break;
+ }
+
+ zCc_CheckSlaveState("in zCc_RunSlave");
+ /* Now run the slaves. Since the slaves will always be run with the master , run them now. */
+ for (slave = 0; slave < ZCC_SLAVES; slave++)
+ {
+ zCc_RunSlave(slave);
+ g_Cc_CallDetail.evt[slave] = ZCC_NO_E;
+ }
+
+
+ /* Process sMsg. */
+ for (slave = 1; slave < ZCC_SLAVES; slave++)
+ {
+ if(g_Cc_CallDetail.slaveObj[slave].sMsg!=ZCC_SNO_M)
+ {
+ zCc_CheckSlaveState("in slaveObj[slave].sMsg");
+ ccapp_log("g_Cc_CallDetail.slaveObj[%d].sMsg=%d",
+ slave,
+ g_Cc_CallDetail.slaveObj[slave].sMsg);
+ }
+
+ switch (g_Cc_CallDetail.slaveObj[slave].sMsg)
+ {
+ case ZCC_SINV_M:
+ if (g_Cc_CallDetail.slaveObj[slave].state == ZCC_S_IDLE_S)//ss
+ {
+ zCc_SendSsReq(g_Cc_CallDetail.digits);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ }
+ else
+ {
+ zCc_SendAtDialReq(g_Cc_CallDetail.digits);
+ }
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ zCc_ClearDigits();
+ break;
+ case ZCC_SDTMF_M:
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s ZCC_SDTMF_M handling ptMsgBuf->aucDataBuf[0] = %d\n",__FUNCTION__,ptMsgBuf->aucDataBuf[0]);
+ zCc_SendAtDtmfReq((char*)(&(ptMsgBuf->aucDataBuf[0])));
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ if(g_Cc_CallDetail.waitchldresult == 0)//chld´¦Àí¹ý³ÌÖв»Çå³ý²¦ºÅ°´¼üadd by zpr
+ zCc_ClearDigits();
+ break;
+ case ZCC_SRING_M:
+ if (g_Cc_CallDetail.state == ZCC_M_RELEASE_S)// && g_Cc_CallDetail.ringCid)
+ {
+ g_Cc_CallDetail.state = ZCC_M_RINGING_S;
+ memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type = RING_SIGNAL;
+ //memcpy(tSig.cid, g_Cc_CallDetail.number, strlen(g_Cc_CallDetail.number));
+ strncpy(tSig.cid, g_Cc_CallDetail.number, sizeof(tSig.cid)-1);
+ get_local_datetime(tSig.date_time);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_RunMaster RING_SIGNAL,number = %s\n",__FUNCTION__,g_Cc_CallDetail.number);
+ SLIC_Play_Signal(0, 0, &tSig);
+ zCc_SetLedStatus("ledblink");
+ }
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ break;
+ case ZCC_SANS_M://ʲô³¡¾°?
+ if (zCc_CallCount() == 1)
+ {
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s : SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ }
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ break;
+ case ZCC_SDISCN_M:
+ held_call_cid = zCc_find_held_cid();
+ incoming_call_cid = zCc_GetSpecSlave(ZCC_S_TRYING_S);
+ ccapp_log("ZCC_SDISCN_M held_call_cid=%d incoming_call_cid=%d chupSent=%d",
+ held_call_cid,
+ incoming_call_cid,
+ g_Cc_CallDetail.chupSent);
+
+ if((held_call_cid!=0 ||incoming_call_cid!=0) && g_Cc_CallDetail.chupSent==FALSE)
+ {
+ int active_call_cid = 0;
+
+ for (slavetmp = 1; slavetmp < ZCC_SLAVES; slavetmp++)
+ {
+ if( (g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_DIALING_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_RINGBACK_S
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TALKING_S
+// || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_TRYING_S // incoming_call_cid
+ || g_Cc_CallDetail.slaveObj[slavetmp].state == ZCC_S_WAIT_RESOURCE_S) &&
+ g_Cc_CallDetail.slaveObj[slavetmp].heldcall==0)
+ {
+ active_call_cid = slavetmp;
+ break;
+ }
+ }
+
+ ccapp_log("ZCC_SDISCN_M active_call_cid=%d", active_call_cid);
+
+ if(active_call_cid!=0)
+ {
+ zCc_SendAtChldReq(10+active_call_cid);
+
+ g_Cc_CallDetail.chupSent = TRUE;
+ g_Cc_CallDetail.state = ZCC_M_RINGING_S;
+
+ /*MSG_BUF msgBuff = {0}; // let while(1) run one more time
+ msgBuff.usMsgCmd = ZCC_ASSIST_MSG_E;
+ msgBuff.src_id = MODULE_ID_SLIC;
+ zCc_SendMsgToSub(&msgBuff);
+
+ ccapp_log("sendMsg ZCC_ASSIST_MSG_E"); */
+ }
+ else
+ {
+ zCc_hungup_all(slave);
+ }
+ }
+ else
+ {
+ zCc_hungup_all(slave);
+ }
+
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (g_Cc_CallDetail.state == ZCC_M_RINGING_S
+ && g_Cc_CallDetail.ringCid == 0
+ && zCc_find_held_cid()==0
+ && zCc_find_held_incoming_cid()==0
+ && local_test_call_st==0)
+ {
+ g_Cc_CallDetail.state = ZCC_M_RELEASE_S;
+ SLIC_Stop_Signal(0, RING_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s : SLIC_Stop_Signal <---\n",__FUNCTION__);
+ }
+ /*else if (g_Cc_CallDetail.state == ZCC_M_SEIZE_S && g_Cc_CallDetail.ringCid > 0 && zCc_CallCount() == 1)
+ {
+ //תΪ½ÓÌý
+ ¹Ò»úºó¿ÉÒÔÖªµÀÀ´µç²¢½ÓÌý£¬ÎÞÐèÌØÊâ´¦Àí¡£
+ }*/
+ zCc_ControlTone();
+
+ // ´¦Àíslave·µ»ØµÄÏûÏ¢
+ zCc_CheckSlaveState("End zCc_RunMaster");
+}
+
+VOID zCc_RunSlave(UINT8 slave)
+{
+ if (g_Cc_CallDetail.evt[slave] == ZCC_NO_E)
+ {
+ return;
+ }
+
+ /* Call respective state function based on the current state. */
+ printf("[ccapp_debug]:Slave Run,slave:%d, state=%d,event=%d\n", slave, g_Cc_CallDetail.slaveObj[slave].state,g_Cc_CallDetail.evt[slave]);
+ zCcSlaveFsmFunc[g_Cc_CallDetail.slaveObj[slave].state](slave);
+}
+
+VOID zCc_SIdleState(UINT8 slave)
+{
+ UINT8 tmpslave = 0;
+ 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]);
+ g_Cc_CallDetail.slaveObj[slave].cid = slave;
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DIAL_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_DIAL_A;
+ g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.digits[0] != ZCC_FLASH_SIGN ? ZCC_S_DT_S : ZCC_S_DACCM_S;
+
+ if (g_Cc_CallDetail.hookofffg == TRUE)
+ {
+ g_Cc_CallDetail.hookofffg = FALSE;
+ sc_timer_create(ZCCAPP_TIMER_HOOKOFF_DETECT,
+ 0,
+ ZCCAPP_TIMER_HOOKOFF_INTERVAL,
+ zCcApp_HookOffTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState sc_timer_create zCcApp_HookOffTimer\n",__FUNCTION__);
+
+ g_Cc_CallDetail.slaveObj[slave].idle_second = 0;
+ sc_timer_create(ZCCAPP_TIMER_HOOKOFF_IDLE,
+ TIMER_FLAG_RESTART,
+ ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL,
+ zCcApp_HookOff_Idle_Timer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState sc_timer_create zCcApp_HookOff_Idle_Timer\n",__FUNCTION__);
+ }
+ break;
+ case ZCC_DTMF_E://held+dailing
+ if ( 0 != zCc_HeldCall() && 0 == zCc_ActiveCall())
+ {
+ sc_timer_delete(ZCCAPP_TIMER_SSDIALTONE_DETECT);
+ sc_timer_create(ZCCAPP_TIMER_DTMF_DETECT,
+ 0,
+ ZCCAPP_TIMER_DTMF_INTERVAL,
+ zCcApp_DtmfTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState sc_timer_create zCcApp_DtmfTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState handling ZCC_DTMF_E\n",__FUNCTION__);
+ }
+ break;
+ case ZCC_CIDCW_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
+ //lint -fallthrough
+ case ZCC_SINVITE_E:
+ zCc_ShowAllSlaveWithTips("zCc_SIdleState");
+ if (((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾÏ·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
+ || (0 != zCc_MoInactiveCall()))//
+ {
+ //zCc_InitSlaveObj(slave);¼ÌÐøµÈdsci6Éϱ¨
+ g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ return;
+ }
+
+ g_Cc_CallDetail.ringCid = slave;
+ if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
+ else
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
+ strcpy(g_Cc_CallDetail.slaveObj[slave].number, g_Cc_CallDetail.number);
+
+ if (g_Cc_CallDetail.resourceReady == 1)
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
+ }
+ else
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
+ }
+ break;
+
+ case ZCC_SRING_E://cid²»Æ¥ÅäµÄ³¡¾°
+ tmpslave = zCc_GetDialingSlave(0);
+ if (0 == tmpslave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
+ zCc_InitSlaveObj(tmpslave);
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_RINGBACK_S;
+ break;
+ case ZCC_SDISCN_MO_E://cid²»Æ¥ÅäµÄ³¡¾°
+ tmpslave = zCc_GetDialingSlave(0);
+ if (0 == tmpslave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.slaveObj[slave] = g_Cc_CallDetail.slaveObj[tmpslave];
+ zCc_InitSlaveObj(tmpslave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, tmpslave);
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0&& g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ }
+ return;
+ default:
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SIdleState:evt=%d\n",__FUNCTION__,g_Cc_CallDetail.evt[slave]);
+ break;
+ }
+}
+
+VOID zCc_SDtState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DTMF_E:
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_IDLE);
+ g_Cc_CallDetail.slaveObj[slave].idle_second = 0;
+
+ sc_timer_delete(ZCCAPP_TIMER_HOOKOFF_DETECT);
+
+ sc_timer_create(ZCCAPP_TIMER_DTMF_DETECT,
+ 0,
+ ZCCAPP_TIMER_DTMF_INTERVAL,
+ zCcApp_DtmfTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDtState sc_timer_create zCcApp_DtmfTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_SIL_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_DACCM_S;
+ break;
+
+ case ZCC_DISCN_E:
+ //zCc_ClearDigits();
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+
+ default://Ö»»áÊÇslave0£¬²»¿ÉÄÜÓëdsciµÄcid³åÍ»
+ break;
+ }
+}
+
+VOID zCc_SDaccmState(UINT8 slave)
+{
+ 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]);
+ UINT8 ret = 0;
+ UINT8 tmpslave = 0;
+
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DTMF_E:
+ sc_timer_delete(ZCCAPP_TIMER_DTMF_DETECT);
+ ret = zCc_DigitsMatch();
+ break;
+
+ case ZCC_DISCN_E:
+ zCc_ClearDigits();
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+ case ZCC_CIDCW_E:
+ case ZCC_SINVITE_E://ÒÔdsciµÄcidΪ׼£¬ÖØÐ¸ømoµÄºô½Ð·ÖÅäidle cid
+ tmpslave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
+ if (0 == tmpslave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.slaveObj[tmpslave] = g_Cc_CallDetail.slaveObj[slave];
+ zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDaccmState: reject mtcall\n",__FUNCTION__, slave);
+ return;
+ default:
+ return;
+ }
+
+ if(ret==ZCC_LOCAL_TEST_CALL)
+ {
+ SIGNAL_DATA tSig;
+ if(zCc_talking_count())
+ {
+ zCc_ClearDigits();
+ zCc_InitSlaveObj(slave);
+ return;
+ }
+
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ memset(&tSig, 0, sizeof(tSig));
+ tSig.signal_type= TONE_SIGNAL;
+ tSig.tone_type = TONE_CW;
+ SLIC_Play_Signal(0, 0, &tSig);
+
+ zCc_ClearDigits();
+
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.evt[slave]= ZCC_NO_E;
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SNO_M;
+
+ local_test_call_st = LocalTestCallST_Start;
+
+ zCc_ShowAllSlaveWithTips("testCall-start");
+ return ;
+ }
+
+ zCc_DigitsMatchRltProc(ret);
+}
+
+VOID zCc_SDialingState(UINT8 slave)
+{
+ UINT8 tmpslave = 0;
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_SRING_E:
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_RINGBACK_S;
+ break;
+
+ case ZCC_SANS_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState: SLIC_Start_PCM <---\n",__FUNCTION__);
+ break;
+
+ case ZCC_DISCN_E:
+ //zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ return;
+
+ case ZCC_SDISCN_MO_E:
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½ÐÇÒÒѹһúʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDialingState sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ }
+ return;
+ case ZCC_SDISCN_MT_E:
+ zCc_InitSlaveObj(slave);//Ö÷±»½Ð²¢·¢
+ //g_Cc_CallDetail.slaveObj[slave].waitDSCI6 = 0;
+ return;
+ case ZCC_CIDCW_E:
+ case ZCC_SINVITE_E://ÒÔdsciµÄcidΪ׼£¬ÖØÐ¸ømoµÄºô½Ð·ÖÅäidle cid
+ tmpslave = zCc_GetSpecSlave(ZCC_S_IDLE_S);
+ if (0 == tmpslave )
+ {
+ return;
+ }
+ g_Cc_CallDetail.slaveObj[tmpslave] = g_Cc_CallDetail.slaveObj[slave];
+ zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ g_Cc_CallDetail.slaveObj[slave].state = g_Cc_CallDetail.resourceReady?ZCC_S_TRYING_S:ZCC_S_WAIT_RESOURCE_S;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SDaccmState: reject mtcall\n",__FUNCTION__, slave);
+ return;
+
+ default:
+ return;
+ }
+}
+
+VOID zCc_SRingbackState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_SANS_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+
+ if(g_Cc_CallDetail.slaveObj[slave].is_callout)
+ SLIC_PolarityReverse(0, TRUE);
+
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Start_PCM2222\n",__FUNCTION__);
+ break;
+
+ case ZCC_DISCN_E:
+ //zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ return;
+
+ case ZCC_SDISCN_MO_E:
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0 && g_Cc_CallDetail.state == ZCC_M_SEIZE_S)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Stop_PCM\n",__FUNCTION__);
+ }
+ else
+ {
+ zCc_InitSlaveObj(slave);
+ if ( 0 == zCc_ActiveCall() && 0 == zCc_HeldCall())
+ {
+ SLIC_Stop_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Stop_PCM\n",__FUNCTION__);
+ }
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ }
+ return;
+ case ZCC_SDISCN_MT_E:
+ g_Cc_CallDetail.slaveObj[slave].waitDSCI6 = 0;
+ return;
+
+ case ZCC_DTMF_E: // ²¦ºÅ
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDTMF_M;///???
+ return;
+
+ case ZCC_RESOURCE_READY_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ SLIC_Start_PCM();//×ÊÔ´ÒÑ·ÖÅä£¬Íø²à·ÅÒô
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SRingbackState SLIC_Start_PCM\n",__FUNCTION__);
+ return;
+
+ default:
+ return;
+ }
+}
+
+VOID zCc_STalkingState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DISCN_E:
+ //zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ return;
+
+ case ZCC_SDISCN_MO_E:
+ case ZCC_SDISCN_MT_E:
+ //zCc_InitSlaveObj(slave);
+ if (zCc_CallCount() >= 2 || g_Cc_CallDetail.state == ZCC_M_RELEASE_S)//»¹Ê£¶àÓÚһ·ºô½Ð
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ break;
+ }
+ if (g_Cc_CallDetail.slaveObj[0].tone != ZCC_TONE_OFF_A)
+ {
+ zCc_InitSlaveObj(0);
+ }
+ if (1 == zCc_BusyToneAllowed() && g_Cc_CallDetail.slaveObj[slave].waitDSCI6 == 0)//ÓÐÆäËûºô½Ðʱ²»·ÅæÒô
+ {
+ sc_timer_create(ZCCAPP_TIMER_BUSYTONE_DETECT,
+ 0,
+ ZCCAPP_TIMER_BUSYTONE_INTERVAL,
+ zCcApp_BusyToneTimer,
+ NULL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STalkingState sc_timer_create zCcApp_BusyToneTimer\n",__FUNCTION__);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_BSY_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_BSYT_S;
+ g_Cc_CallDetail.slaveObj[slave].confcall = 0;
+ g_Cc_CallDetail.slaveObj[slave].heldcall = 0;
+ }
+ else
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ }
+ return;
+
+ case ZCC_DTMF_E: // ²¦ºÅ. µ÷ÕûÒôÁ¿µÄ´¦Àí´ýÔö¼Ó
+ if (g_Cc_CallDetail.slaveObj[slave].heldcall == 0)
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDTMF_M;///???
+ }
+ return;
+ default:
+ return;
+ }
+}
+
+VOID zCc_SWaitResourceState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_RESOURCE_READY_E:
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
+ break;
+
+ case ZCC_SDISCN_MT_E:
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+
+ default:
+ return;
+ }
+}
+
+VOID zCc_STryingState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_CNCT_E:
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SANS_M;
+ //lint -fallthrough
+ case ZCC_SANS_E: //CHLD=2, ÊÕµ½DSCIǨ״̬
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TALKING_S;
+ g_Cc_CallDetail.ringCid = 0;
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ SLIC_Start_PCM();
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState SLIC_Start_PCM\n",__FUNCTION__);
+ break;
+
+ case ZCC_SDISCN_MT_E:
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+
+ case ZCC_DISCN_E://trying ̬ÊÕµ½¹Ò»úÏûÏ¢£¬Ö»ÄÜÊÇÕª»ú̬À´µç(²»°üÀ¨ºô½ÐµÈ´ý)µÄ³¡¾°
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ SLIC_Stop_Signal(0, TONE_SIGNAL);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_STryingState: SLIC_Stop_Signal <---\n",__FUNCTION__);
+ g_Cc_CallDetail.lastTone = ZCC_TONE_OFF_A;
+ if (1 == zCc_CallCount() && (zCc_GetDiscSlave(ZCC_SDISCN_M) == 0)// Õª»ú̬À´µçʱ¹Ò»ú£¬Èç¹ûµ±Ç°Ö»ÓÐһ·ºô½Ð£¬»°»úתÈëÕñÁå
+ ||(2 == zCc_CallCount()
+ && (0 != zCc_GetSpecSlave(ZCC_S_DACCM_S)
+ ||0 != zCc_GetSpecSlave(ZCC_S_BSYT_S)
+ ||0 != zCc_GetSpecSlave(ZCC_S_TKYT_S)
+ ||0 != zCc_GetSpecSlave(ZCC_S_SIL_S))))//Õª»úºó£¬À´µç£¬ÔÙ²¦ºÅ£¬¹Ò»ú£¬Ò²ÐèÒªÕñÁå
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ }
+ else
+ {
+ //zCc_InitSlaveObj(slave);
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_OFF_A;
+ g_Cc_CallDetail.ringCid = 0;
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SDISCN_M;
+ }
+ return;
+
+ default:
+ return;
+ }
+}
+
+VOID zCc_SBsyToneState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DISCN_E:
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+ case ZCC_CIDCW_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
+ //lint -fallthrough
+ case ZCC_SINVITE_E:
+ if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾÏ·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
+ return;
+ }
+ g_Cc_CallDetail.ringCid = slave;
+
+ if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
+ else
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
+
+ if (g_Cc_CallDetail.resourceReady == 1)
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
+ }
+ else
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
+ }
+ break;
+ default:
+ return;
+ }
+}
+
+VOID zCc_STkytState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DISCN_E:
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+ case ZCC_CIDCW_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
+ //lint -fallthrough
+ case ZCC_SINVITE_E:
+ if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾÏ·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
+ return;
+ }
+ g_Cc_CallDetail.ringCid = slave;
+
+ if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
+ else
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
+
+ if (g_Cc_CallDetail.resourceReady == 1)
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
+ }
+ else
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
+ }
+ break;
+ default:
+ return;
+ }
+}
+
+VOID zCc_SSilState(UINT8 slave)
+{
+ 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]);
+ switch (g_Cc_CallDetail.evt[slave])
+ {
+ case ZCC_DISCN_E:
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ return;
+ case ZCC_CIDCW_E:
+ g_Cc_CallDetail.slaveObj[slave].tone = ZCC_TONE_CIDCW_A;
+ //lint -fallthrough
+ case ZCC_SINVITE_E:
+ if ((0 != zCc_GetDialingSlave(1)) || (0 != zCc_GetSpecSlave(ZCC_S_RINGBACK_S)))//ÓÐÒѾÏ·¢atd µÄºô½Ðʱ¾Ü¾øÐÂÀ´µç
+ {
+ zCc_InitSlaveObj(slave);
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_InitSlaveObj: slaveObj[%d] cleared\n",__FUNCTION__, slave);
+ g_Cc_CallDetail.evt[slave] = ZCC_DISCN_E;
+ return;
+ }
+ g_Cc_CallDetail.ringCid = slave;
+
+ if(g_Cc_CallDetail.evt[slave]==ZCC_CIDCW_E)
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = TRUE;
+ else
+ g_Cc_CallDetail.slaveObj[slave].is_cidcw = FALSE;
+
+ if (g_Cc_CallDetail.resourceReady == 1)
+ {
+ g_Cc_CallDetail.slaveObj[slave].sMsg = ZCC_SRING_M;
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_TRYING_S;
+ }
+ else
+ {
+ g_Cc_CallDetail.slaveObj[slave].state = ZCC_S_WAIT_RESOURCE_S;
+ }
+ break;
+
+ default:
+ return;
+ }
+}
+
+
diff --git a/ap/app/ccapp/cc_proc.h b/ap/app/ccapp/cc_proc.h
new file mode 100644
index 0000000..bc29aa2
--- /dev/null
+++ b/ap/app/ccapp/cc_proc.h
@@ -0,0 +1,194 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : cc
+* ÎÄ ¼þ Ãû : cc_proc.h
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ :ccÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éºê¡¢ÀàÐͶ¨Òå
+* ×÷ Õß :
+* °æ ±¾ :
+* Íê³ÉÈÕÆÚ :
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : 0001
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+#ifndef _CC_PROC_H
+#define _CC_PROC_H
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+//#include "Drvs_voiceprocess.h"
+#include "stdio.h"
+#include "at_msg.h"
+#include "os_type_def.h"
+#include "at_other_api.h"
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+#define ZAT_TAB_REPLACE ((unsigned char )(0xFC)) /* ÖÆ±í·ûÌæ»»·û */
+#define ZAT_NULL_FILL ((unsigned char )(0xFD)) /* ¿Õ´®Õ¼Î»·û */
+#define ZAT_SPACE_REPLACE ((unsigned char )(0xFE)) /* ¿Õ¸ñÌæ»»·û */
+
+#define ZCC_APP_AT_BUF_MAX_LEN 400
+#define ZCC_APP_AT_BUF_WAIT_TIME 300
+#define ZCC_MSG_DATA_MAXLEN 640
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef VOID (*pCcSlaveFsmFunc)(UINT8);
+
+#define SC_LEN 29
+#define SC_MAXLEN (SC_LEN-1) // ǰתºÅÂ볤¶È×î´óΪ SC_MAXLEN -5
+typedef struct
+{
+ UINT8 scName;
+ UINT8 scMinLen; //ÆÚÍûµÄ²¹³äÒµÎñ²Ù×÷Âë×îС³¤¶È
+ UINT8 scMaxLen; //ÆÚÍûµÄ²¹³äÒµÎñ²Ù×÷Âë×î´ó³¤¶È
+ char sc[SC_LEN];
+}T_zCc_ScTab;
+typedef enum
+{
+ CC_APP_AT_CMD_NONE,
+
+ CC_APP_AT_CMD_REQ_D,
+ CC_APP_AT_CMD_REQ_A,
+ CC_APP_AT_CMD_REQ_CHUP,
+ CC_APP_AT_CMD_REQ_ZLEDVOLTE,
+
+ CC_APP_AT_CMD_REQ_VTS,
+ CC_APP_AT_CMD_REQ_CMUT,
+ CC_APP_AT_CMD_REQ_CLVL,
+ CC_APP_AT_CMD_REQ_VOICELOOP,
+ CC_APP_AT_CMD_REQ_IMSPLUS,
+
+ CC_APP_AT_CMD_REQ_SET_CHLD,
+ CC_APP_AT_CMD_REQ_SET_CCFC,
+ CC_APP_AT_CMD_REQ_SET_CCWA,
+ CC_APP_AT_CMD_REQ_SET_CLCK,
+ CC_APP_AT_CMD_REQ_GET_CCFC,
+ CC_APP_AT_CMD_REQ_GET_CCWA,
+ CC_APP_AT_CMD_REQ_SET_CPWD,
+
+ CC_APP_AT_CMD_REQ_GET_CLCC,
+}E_CC_APP_AtReqCmdId;
+/* Define known events. Events are received from vTSP and SIP. */
+typedef enum {
+ ZCC_NO_E = 0,
+ //ZCC_RESET_E = 1,
+ ZCC_DTMF_E = 1,
+ //ZCC_DTMFLE_E = 2,
+ //ZCC_DTMFTE_E = 3,
+ ZCC_DIAL_E = 4,
+ ZCC_CNCT_E = 5,
+ ZCC_DISCN_E = 6,
+ ZCC_BSY_E = 7,
+ ZCC_MATCH_E = 8,
+ ZCC_TIMER_E = 16,
+
+ ZCC_SEIZE_E = 20,
+ ZCC_RELEASE_E = 21,
+ ZCC_FLASH_E = 22,
+
+ ZCC_CIDCW_E = 29,
+ ZCC_SINVITE_E = 42,
+ ZCC_SDISCN_MO_E = 43,
+ ZCC_SANS_E = 44,
+ ZCC_SRING_E = 45,
+ ZCC_SDIALLING_E = 46,
+ ZCC_BUSYTONETIMER_E = 47,
+ ZCC_HOOKOFFTIMER_E = 48,
+ ZCC_SSDIALTONETIMER_E = 49,
+ ZCC_DTMFTIMER_E = 50,
+ ZCC_TKYTIMER_E = 51,
+ ZCC_SDISCN_MT_E = 52,
+ ZCC_SDIAL_ERR_E = 53,
+ ZCC_HOOKOFF_IDLE_TIMER_E = 54,
+ ZCC_RESOURCE_READY_E = 115,
+ ZCC_ASSIST_MSG_E = 128
+} T_zCc_Event;/* ÏûÏ¢½á¹¹Ìå */
+
+
+typedef SINT32 (*zCcApp_RecvAtIndFun)(MSG_BUF *ptMsgBuf);
+typedef SINT32 (*zCcApp_AtIndProcFun)(MSG_BUF *ptMsgBuf);
+typedef struct
+{
+ int AtIndCmd;
+ zCcApp_RecvAtIndFun RecvAtIndProcFun;
+}T_CC_APP_RecvAtIndItem;
+
+SINT32 zCc_DsciIndProc(MSG_BUF *ptMsgBuf);
+//SINT32 zCc_CendIndProc(MSG_BUF *ptMsgBuf);
+SINT32 zCc_ZcpiIndProc(MSG_BUF *ptMsgBuf);
+SINT32 zCc_ZimsplusProc(MSG_BUF *ptMsgBuf);
+SINT32 zCc_ZvoicechnlProc(MSG_BUF *ptMsgBuf);
+
+
+typedef struct
+{
+ ULONG cmdId;
+ zCcApp_AtIndProcFun AtIndProcFun;
+}T_CC_APP_AtIndProcItem;
+
+
+
+extern char g_zCcApp_AtIndBuf[ZCC_APP_AT_BUF_MAX_LEN+1];
+SINT32 zCcApp_AtIndProc(char* AtBuff, SINT32 AtLen);
+VOID zCc_SendAtDialReq(PSTR pAtCmdPara);
+VOID zCc_SendAtDtmfReq(char* dtmfchar);
+SINT32 zCc_SendAtChldReq(int chldtype);
+VOID zCc_SendAtAnswerReq(VOID);
+VOID zCc_SendAtHangupReq(VOID);
+SINT32 zCc_RecvDsciInd(MSG_BUF *ptMsgBuf);
+SINT32 zCc_RecvZcpiInd(MSG_BUF *ptMsgBuf);
+SINT32 zCc_RecvImsplusInd(MSG_BUF *ptMsgBuf);
+SINT32 zCc_RecvZvoiceChnl(MSG_BUF *ptMsgBuf);
+VOID zCc_DigitsMatchRltProc(UINT8 ret);
+UINT8 zCc_DigitsMatch(VOID);
+VOID zCc_ClearDigits(VOID);
+VOID zCc_InitSlaveObj(UINT8 slave);
+VOID zCc_SIdleState(UINT8 slave);
+VOID zCc_SDtState(UINT8 slave);
+VOID zCc_SDaccmState(UINT8 slave);
+VOID zCc_SDialingState(UINT8 slave);
+VOID zCc_SRingbackState(UINT8 slave);
+VOID zCc_STalkingState(UINT8 slave);
+VOID zCc_SWaitResourceState(UINT8 slave);
+VOID zCc_STryingState(UINT8 slave);
+VOID zCc_SBsyToneState(UINT8 slave);
+VOID zCc_STkytState(UINT8 slave);
+VOID zCc_SSilState(UINT8 slave);
+VOID zCcApp_Dial(char *ptMsgBuf);
+SINT32 zCcApp_Answer(VOID);
+SINT32 zCcApp_Chup(VOID);
+SINT32 zCcApp_Vts(char* dtmfchar);
+SINT32 zCcApp_Chld(int chldtype);
+UINT8 zCc_CallCount(VOID);
+void zCcApp_SetAtChnlCmdId(E_CC_APP_AtReqCmdId AtCmdId);
+VOID zCc_RunSlave(UINT8 slave);
+VOID zCc_RunMaster(MSG_BUF *ptMsgBuf);
+SINT32 zCcApp_Ccfc(T_zCcapp_CcfcReq *ptccfcreq);
+SINT32 zCcApp_Clck(T_zCcapp_ClckReq *ptclckreq);
+SINT32 zCcApp_SetImsPlus(int rate, int setfg);
+SINT32 zCcApp_AtIndRspProc(MSG_BUF *ptMsgBuf);
+SINT32 zCc_RecvRsp(MSG_BUF *ptMsgBuf);
+LONG zCcApp_send_message(unsigned short Msg_cmd,unsigned short us_DataLen,unsigned char *pData);
+VOID zCc_SendAtImsPlusReq(int rate, int setfg);
+
+VOID zCc_CheckSlaveState(const char *tips);
+VOID zCc_ShowAllSlave(VOID);
+void zCcApp_Vts_CleanReq(void);
+void zCcApp_Vts_Rsp(void);
+
+#endif
diff --git a/ap/app/ccapp/cc_timer.c b/ap/app/ccapp/cc_timer.c
new file mode 100644
index 0000000..15a821a
--- /dev/null
+++ b/ap/app/ccapp/cc_timer.c
@@ -0,0 +1,103 @@
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : ccapp
+* ÎÄ ¼þ Ãû : cc_timer.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : ccapp¶¨Ê±Æ÷³¬Ê±´¦Àí
+* ×÷ Õß :
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2016-02-25
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : 0001
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+#include "cc_main.h"
+#include "cc_proc.h"
+#include "cc_com.h"
+#include "cc_timer.h"
+#include "string.h"
+VOID *zCcApp_HookOffTimer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_HOOKOFFTIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_HookOffTimer \n",__FUNCTION__);
+ return NULL;
+}
+
+VOID *zCcApp_HookOff_Idle_Timer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_HOOKOFF_IDLE_TIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_HookOff_Idle_Timer \n",__FUNCTION__);
+ return NULL;
+}
+
+VOID *zCcApp_DtmfTimer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_DTMFTIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_DtmfTimer \n",__FUNCTION__);
+
+ return NULL;
+}
+VOID *zCcApp_BusyToneTimer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_BUSYTONETIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_BusyToneTimer \n",__FUNCTION__);
+ return NULL;
+}
+VOID *zCcApp_TkyToneTimer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_TKYTIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_TkyToneTimer \n",__FUNCTION__);
+ return NULL;
+}
+VOID *zCcApp_SsDialToneTimer(VOID *arg)
+{
+ MSG_BUF tMsgBuf = {0};
+
+ tMsgBuf.src_id = MODULE_ID_CALL_CTRL;
+ tMsgBuf.usMsgCmd = ZCC_SSDIALTONETIMER_E;
+ tMsgBuf.usDataLen = 0;
+ zCc_SendMsgToSub(&tMsgBuf); /* ·¢¸øÖ÷Ïß³Ì */
+ zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s SsDialToneTimer \n",__FUNCTION__);
+ return NULL;
+}
+
diff --git a/ap/app/ccapp/cc_timer.h b/ap/app/ccapp/cc_timer.h
new file mode 100644
index 0000000..4b634f6
--- /dev/null
+++ b/ap/app/ccapp/cc_timer.h
@@ -0,0 +1,17 @@
+#ifndef _cc_timer_h_
+#define _cc_timer_h_
+
+
+#include "cc_com.h"
+#include "message.h"
+
+
+VOID *zCcApp_HookOffTimer(VOID *arg);
+VOID *zCcApp_HookOff_Idle_Timer(VOID *arg);
+VOID *zCcApp_DtmfTimer(VOID *arg);
+VOID *zCcApp_BusyToneTimer(VOID *arg);
+VOID *zCcApp_TkyToneTimer(VOID *arg);
+VOID *zCcApp_SsDialToneTimer(VOID *arg);
+
+#endif
+
diff --git a/ap/app/ccapp/libzte_log.c b/ap/app/ccapp/libzte_log.c
new file mode 100755
index 0000000..f4ee383
--- /dev/null
+++ b/ap/app/ccapp/libzte_log.c
@@ -0,0 +1,170 @@
+/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
+ LINUX ZTE LOG MODULE
+
+ GENERAL DESCRIPTION
+ print the log to the log file
+ *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
+
+ /*===========================================================================
+ INCLUDES
+ ===========================================================================*/
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <pthread.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "libzte_log.h"
+
+#include "softap_api.h"
+/*===========================================================================
+ DATA
+ ===========================================================================*/
+char para_buf[MAX_PARA_BUF]= {0};
+char log_buf[MAX_LOG_BUF]= {0};
+static int log_switch = 0;
+const off_t log_max_size = 2 * 1024 * 1024;
+
+pthread_mutex_t A_SmsMutexForLog;
+static int iSymbol = -1;
+/*===========================================================================
+ FUNCTIONS
+ ===========================================================================*/
+void zte_msg_print(const char *source_file,const unsigned int line,const char *fmt,...)
+{
+ va_list arg = {0};
+
+ if(NULL == source_file || NULL == fmt)
+ {
+ return ;
+ }
+ va_start(arg,fmt);
+ vsprintf(para_buf,fmt,arg);
+ va_end(arg);
+
+ printf("%s in FILE :%s,LINE :%d\n",para_buf,source_file,line);
+}
+
+extern int slog(char *mod, int prio, const char *fmt, ...);
+
+extern char *get_local_date_time(void);
+void zte_log_append(const char *source_file,const unsigned int line,
+ const char *log_file,const char *fmt,...)
+{
+ //printf("[ccapp]:");
+ //printf(fmt);
+ // printf("\n");
+ //slog("[ccapp]", 4, fmt);
+
+//if(access("/usr/ccapp_log_printf", F_OK)>=0)
+{
+ va_list arg = {0};
+ char log_buf[1024]= {0};
+
+ if(NULL == source_file || NULL == fmt)
+ {
+ return ;
+ }
+ va_start(arg,fmt);
+ vsprintf(log_buf,fmt,arg);
+ va_end(arg);
+
+ printf("%s %s %d %s\n",get_local_date_time(),source_file,line,log_buf);
+ return;
+}
+#if 0
+else if(access("/usr/ccapp_log_file", F_OK)>=0)
+{
+ char nv_buf[NV_LOG_BUF_LEN]= {0};
+ char log_path[256]={0};
+ va_list arg;
+ int nv_status ;
+ int fd;
+ time_t clock;
+ char time_buf[64]={0};
+
+ char log_path_old[300]={0};
+ struct stat statbuf;
+
+ if(-1 == iSymbol)
+ {
+ pthread_mutex_init(&A_SmsMutexForLog, NULL);
+ iSymbol = 0;
+ }
+
+ pthread_mutex_lock(&A_SmsMutexForLog);
+
+#if 0
+ if(0 == access("/data/zte_apps_data/log_enable.flg",F_OK))
+ {
+ return;
+ }
+#endif
+ if(NULL == source_file || NULL == fmt || NULL == log_file)
+ {
+ pthread_mutex_unlock(&A_SmsMutexForLog);
+ return ;
+ }
+ va_start(arg,fmt);
+ vsprintf(para_buf,fmt,arg);
+ va_end(arg);
+#if 0
+ sprintf(log_buf,"%s[` basename %s` %d H] '%s' %s%s%s","echo ",\
+ source_file,line,para_buf,OP_APPEND,LOG_DIR_PATH,log_file);
+ soft_system(log_buf);
+#endif
+
+#if 1
+ time(&clock);
+ sprintf(time_buf, "%s", ctime(&clock));
+ //set the final \n to \0
+ time_buf[strlen(time_buf)-1] = 0;
+ sprintf(log_path, "%s%s", LOG_DIR_PATH, log_file);
+ sprintf(log_buf,"%s %s %d %s\n", time_buf, source_file, line, para_buf);
+
+ if(0 == access(log_path, 0))
+ {
+ if (0 == stat(log_path, &statbuf)) {//cov m
+ if(statbuf.st_size > log_max_size)
+ {
+ sprintf(log_path_old, "%s%s_old", LOG_DIR_PATH, log_file);
+ if (0 == remove(log_path_old)) {
+ if (rename(log_path, log_path_old) != 0) {//cov m
+ printf("rename zte_log_append err\n");
+ }
+ }
+ }
+ }
+ }
+
+ if((fd=open(log_path, O_CREAT|O_WRONLY|O_APPEND, 0666))<0)//cov m
+ {
+ printf("can not open log: %s!\n", log_path);
+ pthread_mutex_unlock(&A_SmsMutexForLog);
+ return ;
+ }
+ write(fd, log_buf, strlen(log_buf));
+ close(fd);
+
+
+
+#endif
+ //printf("%s\n",para_buf);
+ pthread_mutex_unlock(&A_SmsMutexForLog);
+ return ;
+}
+#endif
+}
+void zte_system_call(const char *fmt,...)
+{
+ va_list arg = {0};
+
+ va_start(arg,fmt);
+ vsprintf(para_buf,fmt,arg);
+ va_end(arg);
+ soft_system(para_buf);
+}
diff --git a/ap/app/ccapp/libzte_log.h b/ap/app/ccapp/libzte_log.h
new file mode 100644
index 0000000..5486b71
--- /dev/null
+++ b/ap/app/ccapp/libzte_log.h
@@ -0,0 +1,99 @@
+/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
+ LINUX ZTE LOG MODULE
+
+ GENERAL DESCRIPTION
+ print the log to the log file
+ *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
+
+#ifndef _ZTE_LOG_
+#define _ZTE_LOG_
+ /*===========================================================================
+ INCLUDES
+ ===========================================================================*/
+#include<stdarg.h>
+#include<stdio.h>
+#include<stdlib.h>
+/*===========================================================================
+ DATA
+ ===========================================================================*/
+#define NV_LOG_BUF_LEN 5
+#define MAX_PARA_BUF 512
+#define MAX_LOG_BUF MAX_PARA_BUF+64
+//#define LOG_DIR_PATH "/tmp/zte_log/"
+//#define LOG_DIR_PATH "/usr/"
+#define LOG_DIR_PATH "/var/log"
+#define OP_APPEND ">>"
+
+/*------------suggested log name for every process-------------------*/
+#define LOG_GOAHEAD_LOG "goahead.log"
+#define LOG_WIFI_CONTROL_LOG "wifi_control.log"
+#define LOG_PPP_DIAL_LOG "ppp_dial.log"
+#define LOG_WAKEUP_MC_LOG "wakeup_maincontrol.log"
+#define LOG_ZTE_LAN_LOG "zte_lan.log"
+#define LOG_ZTE_LIBSOCKET_LOG "zte_libsocket.log"
+#define LOG_ZTE_MODC_LOG "zte_modc.log"
+#define LOG_ZTE_WMS_LOG "zte_wms.log"
+#define LOG_ZTE_PBM_LOG "zte_pbm.log"
+#define LOG_ZTE_AT_LOG "zte_at.log"
+#define LOG_ZTE_CFG_LOG "zte_cfg.log"
+#define LOG_ZTE_NV_LOG "zte_nv.log"
+#define LOG_ZTE_MC_LOG "zte_mc.log"
+#define LOG_ZTE_MDM_LOG "zte_mdm.log"
+#define LOG_ZTE_WAN_LOG "zte_wan.log"
+#define LOG_ZTE_QMI_LOG "zte_qmi.log"
+#define LOG_ZTE_SHARE_LOG "zte_share.log"
+#define LOG_ZTE_DAEMON_LOG "zte_daemon.log"
+#define LOG_ZTE_USSD_LOG "zte_ussd.log"
+#define LOG_ZTE_NTP_LOG "zte_ntp.log"
+#define LOG_ZTE_MF80_LOG "zte_mf80.log"
+#define LOG_ZTE_PRINTER_LOG "zte_printer.log"
+
+/*--------------------------------------------------------------------------------------------
+--------- ZTE_MSG just like qualcomm's MSG macro ----------
+--------------------------------------------------------------------------------------------*/
+#define ZTE_MSG(fmt,a,b,c) zte_msg_print(__FILE__,__LINE__,fmt,a,b,c)
+/*--------------------------------------------------------------------------------------------
+--------- @LOG_APPEND: this MARCO append the log to file tail ----------
+--------- @para: filename fmt ----------
+--------- @filename: the file log will be stored in ----------
+--------- @fmt :main log string ----------
+--------- @example: LOG_APPEND("logfile","hello MSG,%d,%d,%d",1,2,3) ----------
+--------- or LOG_APPEND("logfile","hello MSG") ----------
+---------------------------------------------------------------------------------------------*/
+
+#define LOG_APPEND(filename,...) zte_log_append(__FILE__,__LINE__,filename,__VA_ARGS__)
+
+#define SYS_CALL(...) zte_system_call(__VA_ARGS__)
+#define WCLOG(...) LOG_APPEND(LOG_WIFI_CONTROL_LOG,__VA_ARGS__) /*for wifi_control*/
+#define PDLOG(...) LOG_APPEND(LOG_PPP_DIAL_LOG,__VA_ARGS__) /*for ppp_dial----*/
+#define WEBLOG(...) LOG_APPEND(LOG_GOAHEAD_LOG,__VA_ARGS__) /*for goahead-----*/
+#define WMLOG(...) LOG_APPEND(LOG_WAKEUP_MC_LOG,__VA_ARGS__) /*for wakeup main control*/
+#define LANLOG(...) LOG_APPEND(LOG_ZTE_LAN_LOG,__VA_ARGS__) /*for lan control*/
+#define LIBSOCKETLOG(...) LOG_APPEND(LOG_ZTE_LIBSOCKET_LOG,__VA_ARGS__) /*for libsocket*/
+#define MODCLOG(...) LOG_APPEND(LOG_ZTE_MODC_LOG,__VA_ARGS__) /*for mode control*/
+#define WMSLOG(...) LOG_APPEND(LOG_ZTE_WMS_LOG,__VA_ARGS__) /*for wms*/
+#define PBMLOG(...) LOG_APPEND(LOG_ZTE_PBM_LOG,__VA_ARGS__) /*for pbm*/
+#define ATLOG(...) LOG_APPEND(LOG_ZTE_AT_LOG,__VA_ARGS__) /*for at server*/
+#define CFGLOG(...) LOG_APPEND(LOG_ZTE_CFG_LOG,__VA_ARGS__) /*for cfg*/
+#define ZTENVLOG(...) LOG_APPEND(LOG_ZTE_NV_LOG,__VA_ARGS__) /*for zte nv*/
+#define MCLOG(...) LOG_APPEND(LOG_ZTE_MC_LOG,__VA_ARGS__) /*for main control*/
+#define MDMLOG(...) LOG_APPEND(LOG_ZTE_MDM_LOG,__VA_ARGS__) /*for mdm*/
+#define WANLOG(...) LOG_APPEND(LOG_ZTE_WAN_LOG,__VA_ARGS__) /*for wan*/
+#define QMILOG(...) LOG_APPEND(LOG_ZTE_QMI_LOG,__VA_ARGS__) /*for qmi*/
+#define SHARELOG(...) LOG_APPEND(LOG_ZTE_SHARE_LOG,__VA_ARGS__) /*for qmi*/
+#define DAEMONLOG(...) LOG_APPEND(LOG_ZTE_DAEMON_LOG,__VA_ARGS__) /*for daemon*/
+#define USSDLOG(...) LOG_APPEND(LOG_ZTE_USSD_LOG,__VA_ARGS__) /*for ussd*/
+#define NTPLOG(...) LOG_APPEND(LOG_ZTE_NTP_LOG,__VA_ARGS__) /*for ntp*/
+#define MF80LOG(...) LOG_APPEND(LOG_ZTE_MF80_LOG,__VA_ARGS__) /*for mf80 adaptor*/
+#define PRINTERLOG(...) LOG_APPEND(LOG_ZTE_PRINTER_LOG,__VA_ARGS__) /*for usb printer*/
+
+void zte_log_append(const char *source_file,const unsigned int line,
+ const char *log_file,const char *fmt,...);
+void zte_msg_print(const char *filename,const unsigned int line,const char *fmt,...);
+void zte_system_call(const char *fmt,...);
+
+
+#define ccapp_log(fmt,...) zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s "fmt"\n", __FUNCTION__, ##__VA_ARGS__)
+
+
+#endif/*_ZTE_LOG_*/
diff --git a/ap/app/ccapp/slic_inf.c b/ap/app/ccapp/slic_inf.c
new file mode 100644
index 0000000..8733725
--- /dev/null
+++ b/ap/app/ccapp/slic_inf.c
@@ -0,0 +1,858 @@
+/***********************************************************************
+ *Project Linux H100
+ *Modual USRLINE
+ *FileName slc_inf.c
+ *Description user line driver interface
+ *-----------------------------------------------------------------------
+ *modify History:
+ *
+ * Data author version modify description
+ * 2004/12/10 jiang.yuelong 1.0 create
+ ************************************************************************/
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+/*lint -save -esym(18, LONG) */
+/*lint -restore */
+
+#include "slic_inf.h"
+#include "112.h"
+#include "libzte_log.h"
+
+static LONG SLIC_Fd;
+static S8 *SLIC_DeviceName = (S8 *)"/dev/slic";
+
+DWORD SLIC_Initial(VOID)
+{
+
+ SLIC_Fd = open(SLIC_DeviceName, O_RDONLY);
+ if(SLIC_Fd < 0)
+ {
+ printf("slctool: open device error.\n");
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+VOID SLIC_Release(VOID)
+{
+ close(SLIC_Fd);
+}
+
+VOID SLIC_DebugLevel(WORD wLevel)
+{
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+
+ //Tmp.unPara.wLevel = wLevel;
+
+ if (ioctl(SLIC_Fd, SLIC_DEBUG_LEVEL, (DWORD)&Tmp) < 0) {//cov m
+ printf("SLIC_DebugLevel ioctl fail\n");
+ }
+}
+
+DWORD SLIC_ResetPort(WORD wPort, BYTE bType)
+{
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (ioctl(SLIC_Fd, SLIC_PORT_RESET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Port_Lock(WORD wPort, BYTE bType)
+{
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (ioctl(SLIC_Fd, SLIC_PORT_LOCK, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Port_UnLock(WORD wPort, BYTE bType)
+{
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (ioctl(SLIC_Fd, SLIC_PORT_UNLOCK, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_FXS_PolarityReverse(WORD wPort)
+{
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+
+ if (ioctl(SLIC_Fd, SLIC_POLARITY_REVERSE, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+extern int get_polarity_reversal_flag(void);
+
+DWORD SLIC_PolarityReverse(WORD wPort, int is_active)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_POLARITY_REVERSE, (WORD) is_active) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ #else
+
+ SLIC_IOCTL_DATA Tmp;
+
+ if(get_polarity_reversal_flag()==0)
+ return SLIC_SUCCESS;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ Tmp.dwSize = (WORD)is_active;
+
+ if (ioctl(SLIC_Fd, SLIC_POLARITY_REVERSE, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+
+ return SLIC_SUCCESS;
+}
+
+
+DWORD SLIC_Play_Signal(WORD wPort, BYTE bType, SIGNAL_DATA *pSig)
+{
+#ifdef USE_SLIC_TW
+ if (!pSig)
+ {
+ return SLIC_FAIL;
+ }
+
+ if (ioctl(SLIC_Fd, SLIC_SIGNAL_START, (DWORD) pSig) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ #else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+
+ if (!pSig)
+ {
+ return SLIC_FAIL;
+ }
+
+ Tmp.pData = pSig;
+ Tmp.dwSize = sizeof(SIGNAL_DATA);
+
+ if (ioctl(SLIC_Fd, SLIC_SIGNAL_START, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+
+#endif
+ return SLIC_SUCCESS;
+
+}
+
+DWORD SLIC_Stop_Signal(WORD wPort, BYTE bType)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_SIGNAL_STOP, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (ioctl(SLIC_Fd, SLIC_SIGNAL_STOP, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+
+#endif
+ return SLIC_SUCCESS;
+}
+DWORD SLIC_Start_PCM()
+{
+ printf("ccapp:SLIC_Start_PCM! \n");
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_PCM_OPEN, NULL) < 0)
+ {
+ printf("ccapp:SLIC_Start_PCM fail!\n");
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ if (ioctl(SLIC_Fd, SLIC_PCM_OPEN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Stop_PCM()
+{
+ printf("[ccapp_debug]:SLIC_Stop_PCM!\n");
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_PCM_CLOSE, NULL) < 0)
+ {
+ printf("[ccapp_debug]:SLIC_Stop_PCM fail!\n");
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ if (ioctl(SLIC_Fd, SLIC_PCM_CLOSE, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_PCM_Set_NB()
+{
+ printf("ccapp:SLIC_PCM_Set_NB!\n");
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_PCM_SET_NB, NULL) < 0)
+ {
+ printf("ccapp:SLIC_PCM_Set_NB fail! \n");
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ if (ioctl(SLIC_Fd, SLIC_PCM_SET_NB, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ #endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_PCM_Set_WB()
+{
+#ifdef USE_SLIC_TW
+ printf("ccapp:SLIC_PCM_Set_WB!\n");
+ if (ioctl(SLIC_Fd, SLIC_PCM_SET_WB, NULL) < 0)
+ {
+ printf("ccapp:SLIC_PCM_Set_WB fail! \n");
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ if (ioctl(SLIC_Fd, SLIC_PCM_SET_WB, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+
+DWORD SLIC_SelectTimeSlot(WORD wPort, BYTE bType, BYTE bTX, BYTE bRX)
+{
+#ifdef USE_SLIC_TW
+#if 0
+ if (bType > 1)
+ {
+ return SLIC_FAIL;
+ }
+
+ if (ioctl(SLIC_Fd, SLIC_TIMESLOT_SET, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+
+ VpOptionTimeslotType timeslot={0};
+ timeslot.rx=bRX;
+ timeslot.tx=bTX;
+
+
+ if (ioctl(SLIC_Fd, SLIC_TIMESLOT_SET, (DWORD) ×lot) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+ //Tmp.unPara.stTimeSlot.bTx = bTX;
+ //Tmp.unPara.stTimeSlot.bRx = bRX;
+
+
+ if (bType > 1)
+ {
+ return SLIC_FAIL;
+ }
+
+ if (ioctl(SLIC_Fd, SLIC_TIMESLOT_SET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_ReleaseTimeSlot(WORD wPort, BYTE bType)
+{
+#ifdef USE_SLIC_TW
+ if (bType > 1)
+ {
+ return SLIC_FAIL;
+ }
+
+ if (ioctl(SLIC_Fd, SLIC_TIMESLOT_RELEASE, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (bType > 1)
+ {
+ return SLIC_FAIL;
+ }
+
+ if (ioctl(SLIC_Fd, SLIC_TIMESLOT_RELEASE, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_MsgRev(BYTE *bEvent, DWORD *pPayLoad)
+{
+#ifdef USE_SLIC_TW
+ LONG rev = 0;
+ MSG_DATA msg;
+ memset((VOID *)&msg,0,sizeof(msg));
+ rev = ioctl(SLIC_Fd, SLIC_MSG_REV, (DWORD) &msg);
+ if (rev < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ LONG rev = 0;
+ SLIC_IOCTL_DATA Tmp;
+ MSG_DATA msg;
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ memset((VOID *)&msg,0,sizeof(msg));
+
+ Tmp.pData = &msg;
+ Tmp.dwSize = sizeof(MSG_DATA);
+
+ rev = ioctl(SLIC_Fd, SLIC_MSG_REV, (DWORD) &Tmp);
+ if (rev < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ //*wPort = msg.wPort;
+ *bEvent = msg.bMsgId;
+ *pPayLoad = msg.dPayLoad;
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_MsgClr(VOID)
+{
+ if (ioctl(SLIC_Fd, SLIC_MSG_CLR, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_HookLowTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_HOOK_LOWLEN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_HOOK_LOWLEN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ #endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_HookHighTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_HOOK_HIGLEN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_HOOK_HIGLEN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_PreHookHighTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_PREHOOK_HIGLEN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_PREHOOK_HIGLEN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_FlashLowMinTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_LMIN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_LMIN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_FlashLowMaxTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_LMAX, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_LMAX, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_FlashHighFixTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_HFIX, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_FLASH_HFIX, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_DialLowMinTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_LMIN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_LMIN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_DialLowMaxTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_LMAX, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_LMAX, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_DialHighMinTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_HMIN, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_HMIN, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_DialHighFixTime(WORD wPort, WORD wTime)
+{
+#ifdef USE_SLIC_TW
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_HMAX, NULL) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = PORT_TYPE_FXS;
+ //Tmp.unPara.wTime= wTime;
+
+ if (ioctl(SLIC_Fd, SLIC_CFG_DIAL_HMAX, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Read_Codec(BYTE *pParm)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_Read_Codec not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+
+ Tmp.pData = pParm;
+ Tmp.dwSize = 2;
+
+ if (ioctl(SLIC_Fd, SLIC_CODEC_GET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+DWORD SLIC_Read_Codec_ALL(VOID)
+{
+#ifdef USE_SLIC_TW
+ int ret = 0;
+ ret = ioctl(SLIC_Fd, SLIC_CODEC_GETALL, NULL) ;
+ if (ret< 0)
+ {
+ printf("SLIC_Read_Codec_ALL error ret=%d \n", ret);
+
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+DWORD SLIC_Cfg_Codec(BYTE *pParm)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_Cfg_Codec not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ Tmp.pData = pParm;
+ Tmp.dwSize = 2;
+
+ if (ioctl(SLIC_Fd, SLIC_CODEC_SET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_112TestStart(WriteCmd_t *pCmd)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_LINE_TEST_START not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+
+ //Tmp.wPort = pCmd->port;
+ //Tmp.bPortType = pCmd->port_type;
+ //Tmp.pData = pCmd;
+ //Tmp.dwSize = sizeof(WriteCmd_t);
+
+ if (ioctl(SLIC_Fd, SLIC_LINE_TEST_START, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_112TestAbort( WORD wPort, BYTE bType )
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_LINE_TEST_ABORT not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (ioctl(SLIC_Fd, SLIC_LINE_TEST_ABORT, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_112TestRead( WORD wPort, BYTE bType, TestResult_t *pResBuf)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_LINE_TEST_READ not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (NULL == pResBuf)
+ {
+ return SLIC_FAIL;
+ }
+
+ Tmp.pData = pResBuf;
+ Tmp.dwSize = sizeof(TestResult_t);
+
+ if (ioctl(SLIC_Fd, SLIC_LINE_TEST_READ, (DWORD)&Tmp) < 0)
+ {
+ printf("Read error!!\n");
+ return SLIC_FAIL;
+ }
+ #endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Dev_Init()
+{
+ if (ioctl(SLIC_Fd, SLIC_DEV_INIT, 0) < 0)
+ {
+ return SLIC_FAIL;
+ }
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Read_Ram(BYTE *pParm)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_RAM_GET not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+
+ Tmp.pData = pParm;
+ Tmp.dwSize = 2;
+
+ if (ioctl(SLIC_Fd, SLIC_RAM_GET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+
+DWORD SLIC_Cfg_Ram(BYTE *pParm)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_RAM_SET not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ Tmp.pData = pParm;
+ Tmp.dwSize = 2;
+
+ if (ioctl(SLIC_Fd, SLIC_RAM_SET, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
+
+DWORD SLIC_Cfg_Electric(WORD wPort, BYTE bType, ELECTRIC_CFG_CUSTOMIZED *pElec)
+{
+#ifdef USE_SLIC_TW
+ printf(" SLIC_ELECTRIC_CFG not support!\n");
+ return SLIC_FAIL;
+#else
+ SLIC_IOCTL_DATA Tmp;
+
+ memset((VOID *)&Tmp,0,sizeof(Tmp));
+ //Tmp.wPort = wPort;
+ //Tmp.bPortType = bType;
+
+ if (NULL == pElec)
+ {
+ return SLIC_FAIL;
+ }
+
+ Tmp.pData = pElec;
+ Tmp.dwSize = sizeof(ELECTRIC_CFG_CUSTOMIZED);
+
+ if (ioctl(SLIC_Fd, SLIC_ELECTRIC_CFG, (DWORD) &Tmp) < 0)
+ {
+ return SLIC_FAIL;
+ }
+#endif
+ return SLIC_SUCCESS;
+}
diff --git a/ap/app/ccapp/slic_inf.h b/ap/app/ccapp/slic_inf.h
new file mode 100644
index 0000000..07fa4e0
--- /dev/null
+++ b/ap/app/ccapp/slic_inf.h
@@ -0,0 +1,70 @@
+/***********************************************************************
+ *Project Linux H100
+ *Modual USRLINE
+ *FileName slc_inf.h
+ *Description SLIC module interface
+ *-----------------------------------------------------------------------
+ *modify History:
+ *
+ * Data author version modify description
+ * 2004/12/10 jiang.yuelong 1.0 create
+ ************************************************************************/
+#ifndef _SLIC_INF_H
+#define _SLIC_INF_H
+
+#include "112.h"
+#include "slic_type.h"
+
+#define SLIC_SUCCESS (0)
+#define SLIC_FAIL (-1)
+
+
+DWORD SLIC_Initial(VOID);
+VOID SLIC_Release(VOID);
+DWORD SLIC_Dev_Init();
+DWORD SLIC_ReleasePort(WORD wPort, BYTE bType);
+DWORD SLIC_ResetPort(WORD wPort, BYTE bType);
+VOID SLIC_DebugLevel(WORD wLevel);
+DWORD SLIC_Show_Stat(WORD wPort, BYTE bType);
+DWORD SLIC_Show_Err(WORD wFlag);
+DWORD SLIC_Port_Lock(WORD wPort, BYTE bType);
+DWORD SLIC_Port_UnLock(WORD wPort, BYTE bType);
+DWORD SLIC_GetCallStatus(WORD wPort);
+DWORD SLIC_FXS_PolarityReverse(WORD wPort);
+DWORD SLIC_PolarityReverse(WORD wPort, int is_active);
+DWORD SLIC_FXS_StartCollect(WORD wPort);
+DWORD SLIC_FXS_StopCollect(WORD wPort);
+DWORD SLIC_Play_Signal(WORD wPort, BYTE bType, SIGNAL_DATA *pSig);
+DWORD SLIC_Stop_Signal(WORD wPort, BYTE bType);
+DWORD SLIC_SelectTimeSlot(WORD wPort, BYTE bType, BYTE bTX, BYTE bRX);
+DWORD SLIC_ReleaseTimeSlot(WORD wPort, BYTE bType);
+DWORD SLIC_MsgRev(BYTE *bEvent, DWORD *pPayLoad);
+DWORD SLIC_MsgClr(VOID);
+
+DWORD SLIC_Cfg_HookLowTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_HookHighTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_PreHookHighTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_FlashLowMinTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_FlashLowMaxTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_FlashHighFixTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_DialLowMinTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_DialLowMaxTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_DialHighMinTime(WORD wPort, WORD wTime);
+DWORD SLIC_Cfg_DialHighFixTime(WORD wPort, WORD wTime);
+
+DWORD SLIC_112TestStart(WriteCmd_t *pCmd);
+DWORD SLIC_112TestAbort( WORD wPort, BYTE bType );
+DWORD SLIC_112TestRead( WORD wPort, BYTE bType, TestResult_t *pResBuf);
+
+DWORD SLIC_Cfg_Codec(BYTE *pParm);
+DWORD SLIC_Read_Codec(BYTE *pParm);
+DWORD SLIC_Read_Ram(BYTE *pParm);
+DWORD SLIC_Cfg_Ram(BYTE *pParm);
+DWORD SLIC_Start_PCM();
+DWORD SLIC_Stop_PCM();
+DWORD SLIC_PCM_Set_NB();
+DWORD SLIC_PCM_Set_WB();
+DWORD SLIC_Read_Codec_ALL(VOID);
+
+
+#endif /* _SLIC_INF_H */
diff --git a/ap/app/ccapp/slic_tool.c b/ap/app/ccapp/slic_tool.c
new file mode 100644
index 0000000..aae8251
--- /dev/null
+++ b/ap/app/ccapp/slic_tool.c
@@ -0,0 +1,796 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <stdint.h>
+#include "slic_type.h"
+#include "slic_inf.h"
+#include <linux/volte_drv.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include "voice_lib.h"
+
+typedef struct
+{
+ WORD wToneId;
+ WORD wCadenceCount;
+
+ WORD wCadence1_rptcnt;
+ WORD wCadence1_on;
+ WORD wCadence1_off;
+ WORD wCadence1_Freq;
+ WORD wCadence1_2ndFreq;
+ WORD wCadence1_Amp;
+
+ WORD wCadence2_rptcnt;
+ WORD wCadence2_on;
+ WORD wCadence2_off;
+ WORD wCadence2_Freq;
+ WORD wCadence2_2ndFreq;
+ WORD wCadence2_Amp;
+
+ WORD wCadence3_rptcnt;
+ WORD wCadence3_on;
+ WORD wCadence3_off;
+ WORD wCadence3_Freq;
+ WORD wCadence3_2ndFreq;
+ WORD wCadence3_Amp;
+
+ WORD wCadence4_rptcnt;
+ WORD wCadence4_on;
+ WORD wCadence4_off;
+ WORD wCadence4_Freq;
+ WORD wCadence4_2ndFreq;
+ WORD wCadence4_Amp;
+
+ WORD wDura;
+ BYTE bRowStatus;
+ BYTE bReserve;
+}TONE_ATTR;
+
+/*TONE ID*/
+
+#define SIGNAL_RING (WORD)0x8100 /* ÕñÁå */
+#define SIGNAL_RING_TWO (WORD)0x8101 /* 2¶ÎÕñÁå */
+#define SIGNAL_RING_THREE (WORD)0x8102 /* 3¶ÎÕñÁå */
+#define SIGNAL_RING_FOUR (WORD)0x8103 /* 4¶ÎÕñÁå */
+#define SIGNAL_RING_LONG (WORD)0x8104 /* ³¤Ê±¼äÕñÁå */
+
+#define SIGNAL_TONE (WORD)0x8200 /* ·ÅÒô */
+#define SIGNAL_TONE_TWO (WORD)0x8201 /* 2¶Î·ÅÒô */
+#define SIGNAL_TONE_THREE (WORD)0x8202 /* 3¶Î·ÅÒô */
+#define SIGNAL_TONE_FOUR (WORD)0x8203 /* 4¶Î·ÅÒô */
+#define SIGNAL_TONE_LONG (WORD)0x8204 /* ³¤Ê±¼ä·ÅÒô */
+
+TONE_ATTR ToneAttr[] = {
+/*
+ToneId Cadence Cadence1 Cadence2 Cadence3 Cadence4 Dura RowStatus Rese*/
+{SIGNAL_RING, 1, 1,200,800,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_RING_TWO, 2, 1,100,800,25,0,100, 1,200,800,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_RING_THREE, 3, 1,100,800,25,0,100, 1,400,800,25,0,100, 1,200,800,25,0,100, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_RING_FOUR, 4, 1,100,800,25,0,100, 1,400,800,25,0,100, 1,300,300,25,0,100, 1,200,800,25,0,100, 12000, 1, 0},
+{SIGNAL_RING_LONG, 1, 1,6000,0,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+
+{SIGNAL_TONE, 1, 1,40,400,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_TONE_TWO, 2, 1,40,400,450,0,100, 1,100,800,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_TONE_THREE, 3, 1,40,400,450,0,100, 1,100,800,450,0,100, 1,200,800,450,0,100, 0,0,0,0,0,0, 12000, 1, 0},
+{SIGNAL_TONE_FOUR, 4, 1,40,400,450,0,100, 1,100,800,450,0,100, 1,300,300,450,0,100, 1,200,800,450,0,100, 12000, 1, 0},
+{SIGNAL_TONE_LONG, 1, 1,6000,0,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0},
+};
+ #define VOICE_TEST_CALL_DRV
+ #ifdef VOICE_TEST_CALL_DRV
+static int voice_fd = -1;
+static int volte_fd = -1;
+#else
+T_Voice_Para gsmhwpara = {
+ 8000, //8000;16000
+ 0, //// 0 gsm;1 td;2 wcdma;3 lte
+ 0//0 hardware dsp;1 soft amr lib
+};
+
+T_Voice_Para tdnbhwpara = {
+ 8000, //8000;16000
+ 1, //// 0 gsm;1 td;2 wcdma;3 lte
+ 0,//0 amr-nb;1 amr-wb
+ 0//0 hardware dsp;1 soft amr lib
+};
+
+T_Voice_Para tdnbsfpara = {
+ 8000, //8000;16000
+ 1, //// 0 gsm;1 td;2 wcdma;3 lte
+ 0,//0 amr-nb;1 amr-wb
+ 1//0 hardware dsp;1 soft amr lib
+};
+
+T_Voice_Para tdwbsfpara = {
+ 8000, //8000;16000
+ 1, //// 0 gsm;1 td;2 wcdma;3 lte
+ 1,//0 amr-nb;1 amr-wb
+ 1//0 hardware dsp;1 soft amr lib
+};
+#endif
+
+
+static VOID DataFormat(SIGNAL_DATA *pSig, TONE_ATTR *pAttr)
+{
+#if 0
+ pSig->wDura = pAttr->wDura;
+ pSig->bCadenceNum = pAttr->wCadenceCount;
+ pSig->wSignalID = pAttr->wToneId;
+
+ pSig->Cadence[0].wCadenceRptCnt = pAttr->wCadence1_rptcnt;
+ pSig->Cadence[0].wCadenceOn = pAttr->wCadence1_on;
+ pSig->Cadence[0].wCadenceOff = pAttr->wCadence1_off;
+ pSig->Cadence[0].wFreq1 = pAttr->wCadence1_Freq;
+ pSig->Cadence[0].wFreq2 = pAttr->wCadence1_2ndFreq;
+ pSig->Cadence[0].wAmp = pAttr->wCadence1_Amp;
+
+ pSig->Cadence[1].wCadenceRptCnt = pAttr->wCadence2_rptcnt;
+ pSig->Cadence[1].wCadenceOn = pAttr->wCadence2_on;
+ pSig->Cadence[1].wCadenceOff = pAttr->wCadence2_off;
+ pSig->Cadence[1].wFreq1 = pAttr->wCadence2_Freq;
+ pSig->Cadence[1].wFreq2 = pAttr->wCadence2_2ndFreq;
+ pSig->Cadence[1].wAmp = pAttr->wCadence2_Amp;
+
+ pSig->Cadence[2].wCadenceRptCnt = pAttr->wCadence3_rptcnt;
+ pSig->Cadence[2].wCadenceOn = pAttr->wCadence3_on;
+ pSig->Cadence[2].wCadenceOff = pAttr->wCadence3_off;
+ pSig->Cadence[2].wFreq1 = pAttr->wCadence3_Freq;
+ pSig->Cadence[2].wFreq2 = pAttr->wCadence3_2ndFreq;
+ pSig->Cadence[2].wAmp = pAttr->wCadence3_Amp;
+
+ pSig->Cadence[3].wCadenceRptCnt = pAttr->wCadence4_rptcnt;
+ pSig->Cadence[3].wCadenceOn = pAttr->wCadence4_on;
+ pSig->Cadence[3].wCadenceOff = pAttr->wCadence4_off;
+ pSig->Cadence[3].wFreq1 = pAttr->wCadence4_Freq;
+ pSig->Cadence[3].wFreq2 = pAttr->wCadence4_2ndFreq;
+ pSig->Cadence[3].wAmp = pAttr->wCadence4_Amp;
+#endif
+}
+static TONE_ATTR* GetToneData(WORD wTid)
+{
+ WORD i;
+ for (i = 0; i < sizeof(ToneAttr)/sizeof(TONE_ATTR); i++)
+ {
+ if (wTid == ToneAttr[i].wToneId)
+ {
+ return &ToneAttr[i];
+ }
+ }
+ return NULL;
+}
+
+static void SLIC_SelfTest(void)
+{
+ BYTE bBuf[16] = {0,};
+ WORD wSize = 0;
+ SIGNAL_DATA tSig;
+ DWORD dC = 0;
+#if 0
+ tSig.wDura = 6000; /*60s */
+ tSig.bCadenceNum = 1;
+ tSig.wSignalType = USL_RING_SIGNAL;
+ tSig.wSignalID = 0x8100;
+ tSig.Cadence[0].wCadenceOn = 100; /* 1s */
+ tSig.Cadence[0].wCadenceOff = 0; /* no off */
+ tSig.Cadence[0].wFreq1 = 25;
+ tSig.Cadence[0].wFreq2 = 0;
+ tSig.Cadence[0].wAmp = 100;
+#endif
+ /* chip test */
+ printf("\n check legerity chip");
+ bBuf[0] = 0x73;
+ wSize = 2;
+ SLIC_Read_Codec(bBuf);
+ if ((bBuf[0] != 0x2) && (bBuf[1] != 0xb2))
+ {
+ printf("\n read legerity ID error");
+ } else {
+ printf("\n read legerity ID success ID:0x%x 0x%x", bBuf[0], bBuf[1]);
+ }
+
+ /* ring test -self test mode */
+ printf("\n control port 1 ringing ");
+ SLIC_Play_Signal(0, 0, &tSig);
+ printf("\n press any key to stop port 1 ring");
+ while(!(dC = getchar())) { ;}
+ SLIC_Stop_Signal(0, 0);
+
+ printf("\n control port 2 ringing ");
+ SLIC_Play_Signal(1, 0, &tSig);
+ printf("\n press any key to stop port 2 ring");
+ while(!(dC = getchar())) { ;}
+ SLIC_Stop_Signal(1, 0);
+
+ SLIC_MsgClr();
+ SLIC_DebugLevel(0);
+ return;
+}
+/*lint -restore*/
+/*lint -save -e14*/
+int main(int argc, char** argv)
+{
+ SIGNAL_DATA tSig = {0};
+ DWORD wRev = 0;
+ WORD wPort = 0;
+ WORD wPort_type = 0;
+ WORD wTimeSlot = 0;
+ DWORD wTid = 0;
+ WORD wTime = 0;
+ WORD wLevel = 0;
+ TONE_ATTR *pToneAttr = NULL;
+
+ wRev = SLIC_Initial();
+ if (wRev == SLIC_FAIL)
+ {
+ printf("\n SLIC initial failed!");
+ exit(1);
+ }
+
+ if (argc < 2)
+ {
+ printf("\n Usage:%s cmd parm...", argv[0]);
+ exit(1);
+ }
+
+ if (0 == strcmp("reset", argv[1])) /* port reset */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s reset port type", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+ wRev = SLIC_ResetPort(wPort, wPort_type);
+ } else if (0 == strcmp("slotset", argv[1])) /*time slot set */
+ {
+ if (argc != 5)
+ {
+ printf("\n Usage:%s slotset port type timeslot\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+ wTimeSlot = atoi(argv[4]);
+ wRev = SLIC_SelectTimeSlot(wPort, wPort_type, wTimeSlot, wTimeSlot);
+
+ } else if (0 == strcmp("reverse", argv[1])) /* polarity reverse */
+ {
+ if (argc != 3)
+ {
+ printf("\n Usage:%s reverse port\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wRev = SLIC_FXS_PolarityReverse(wPort);
+ } else if (0 == strcmp("startring", argv[1])) /* start ring */
+ {
+ tSig.signal_type= RING_SIGNAL;
+ memcpy(tSig.cid, argv[2], 11);
+ printf("slictool startring cid %s", tSig.cid);
+ wRev = SLIC_Play_Signal(wPort, SLIC_PORT_TYPE, &tSig);
+ } else if (0 == strcmp("stopring", argv[1])) /* stop ring */
+ {
+ wRev = SLIC_Stop_Signal(0, SLIC_PORT_TYPE);
+ } else if (0 == strcmp("playtone", argv[1])) /* play tone */
+ {
+ tSig.signal_type = TONE_SIGNAL;
+ if(NULL != argv[2])
+ {
+ tSig.tone_type = atoi(argv[2]);
+ }
+ else
+ {
+ tSig.tone_type = TONE_DIAL;
+ }
+ printf("tone_type %d\n", tSig.tone_type);
+ wRev = SLIC_Play_Signal(0, wPort_type, &tSig);
+ }
+ else if (0 == strcmp("rcvmsg", argv[1])) /* rcvmsg */
+ {
+ while(1)
+ {
+ BYTE bEvent = 0;
+ DWORD pPayLoad = 0;
+ if (SLIC_FAIL == SLIC_MsgRev(&bEvent, &pPayLoad))
+ {
+ printf("SLIC: Error-->>SLIC_MsgRev Failed\n");
+ continue;
+ }
+ printf("SLIC: SLIC_MsgRev Event %d, payload %x\n", bEvent, pPayLoad);
+ }
+ }
+ else if (0 == strcmp("stoptone", argv[1])) /* stop tone */
+ {
+ wRev = SLIC_Stop_Signal(wPort, wPort_type);
+ }else if (0 == strcmp("startpcm", argv[1])) /* stop tone */
+ {
+ wRev = SLIC_Start_PCM();
+ } else if (0 == strcmp("stoppcm", argv[1])) /* stop tone */
+ {
+ wRev = SLIC_Stop_PCM();
+ } else if (0 == strcmp("pcmnb", argv[1])) /* stop tone */
+ {
+ wRev = SLIC_PCM_Set_NB();
+ } else if (0 == strcmp("pcmwb", argv[1])) /* stop tone */
+ {
+ wRev = SLIC_PCM_Set_WB();
+ } else if (0 == strcmp("lock", argv[1])) /* lock port */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s lock port type\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+ wRev = SLIC_Port_Lock(wPort, wPort_type);
+ } else if (0 == strcmp("unlock", argv[1])) /* unlock port */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s unlock port type\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+ wRev = SLIC_Port_UnLock(wPort, wPort_type);
+ } else if (0 == strcmp("codecset", argv[1])) /* codecset */
+ {
+ BYTE bBuf[256];
+ BYTE bTmp = 0;
+ BYTE bSize = 0;
+ DWORD bParm;
+ if (argc != 3)
+ {
+ printf("\n Usage:%s codecset parmstring\n", argv[0]);
+ exit(1);
+ }
+ sscanf(&(argv[2][bTmp]), "%x", &bParm);
+
+ bBuf[bSize++] = bParm;
+ printf("\n codecset addr %x\n", bBuf[0]);
+ for (bTmp = 0; argv[2][bTmp]!= 0; bTmp++)
+ {
+ if (argv[2][bTmp] != ' ')
+ {
+ printf("\n codecset argv[2][%d] %x\n", bTmp, argv[2][bTmp]);
+ continue;
+ }
+
+ sscanf(&(argv[2][bTmp]), "%x", &bParm);
+ bBuf[bSize++] = bParm;
+ }
+ printf("\n codecset value %x\n", bBuf[1]);
+ wRev = SLIC_Cfg_Codec(bBuf);
+ } else if (0 == strcmp("codecget", argv[1])) /* codecget */
+ {
+ BYTE bBuf[256];
+ BYTE bSize = 0;
+ DWORD bParm;
+ if (argc != 3)
+ {
+ printf("\n Usage:%s codecget address\n", argv[0]);
+ exit(1);
+ }
+ sscanf(&(argv[2][0]), "%x", &bParm);
+ bBuf[0] = bParm;
+
+ wRev = SLIC_Read_Codec(bBuf);
+ } else if (0 == strcmp("ramset", argv[1])) //ramset
+ {
+ BYTE bBuf[256];
+ BYTE bTmp = 0;
+ BYTE bSize = 0;
+ DWORD bParm;
+ if (argc != 3)
+ {
+ printf("\n Usage:%s ramset parmstring\n", argv[0]);
+ exit(1);
+ }
+ sscanf(&(argv[2][bTmp]), "%x", &bParm);
+ bBuf[bSize++] = (BYTE)bParm;
+ bBuf[bSize++] = (bParm>>8)&(0x07);
+
+ for (bTmp = 0; argv[2][bTmp]!= 0; bTmp++)
+ {
+ if (argv[2][bTmp] != ' ')
+ {
+ continue;
+ }
+
+ sscanf(&(argv[2][bTmp]), "%x", &bParm);
+ bBuf[bSize++] = (BYTE)bParm;
+ bBuf[bSize++] = (bParm>>8)&(0xff);
+ bBuf[bSize++] = (bParm>>16)&(0xff);
+ bBuf[bSize++] = (bParm>>24)&(0xff);
+ }
+ wRev = SLIC_Cfg_Ram(bBuf);
+
+ }else if (0 == strcmp("ramget", argv[1])) //ramget
+ {
+ BYTE bBuf[256];
+ BYTE bSize = 0;
+ DWORD dwParm;
+ WORD *pAddr = (WORD *)&bBuf[0];
+ if (argc != 3)
+ {
+ printf("\n Usage:%s ramget address\n", argv[0]);
+ exit(1);
+ }
+ sscanf(&(argv[2][0]), "%x", &dwParm);
+ *pAddr = (WORD)dwParm;
+ printf("read ram %d \n", (int)bBuf);
+ wRev = SLIC_Read_Ram(bBuf);
+
+ } else if (0 == strcmp("hooklow", argv[1])) /* config hook low time */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s hooklow port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_HookLowTime(wPort, wTime);
+ } else if (0 == strcmp("hookhigh", argv[1])) /* config hook high time */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s hookhigh port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_HookHighTime(wPort, wTime);
+ } else if (0 == strcmp("prehookhigh", argv[1])) /* config prehook time */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s prehookhigh port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_PreHookHighTime(wPort, wTime);
+ } else if (0 == strcmp("flashlowmin", argv[1])) /* config flash low min */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s flashlowmin port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_FlashLowMinTime(wPort, wTime);
+ } else if (0 == strcmp("flashlowmax", argv[1])) /* config flash low max */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s flashlowmax port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_FlashLowMaxTime(wPort, wTime);
+ } else if (0 == strcmp("flashfix", argv[1])) /* config flash high fix */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s flashfix port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_FlashHighFixTime(wPort, wTime);
+ } else if (0 == strcmp("diallowmin", argv[1])) /* config pulse low min */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s diallowmin port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_DialLowMinTime(wPort, wTime);
+ } else if (0 == strcmp("diallowmax", argv[1])) /* config pulse low max */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s diallowmax port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_DialLowMaxTime(wPort, wTime);
+ } else if (0 == strcmp("dialhighmin", argv[1])) /* config pulse high min */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s dialhighmin port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_DialHighMinTime(wPort, wTime);
+ } else if (0 == strcmp("dialhighfix", argv[1])) /* config pulse high fix */
+ {
+ if (argc != 4)
+ {
+ printf("\n Usage:%s dialhighfix port time\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wTime = atoi(argv[3]);
+ wRev = SLIC_Cfg_DialHighFixTime(wPort, wTime);
+ } else if (0 == strcmp("debuglvl", argv[1])) /* config debug level */
+ {
+ if (argc != 3)
+ {
+ printf("\n Usage:%s debuglvl level\n", argv[0]);
+ exit(1);
+ }
+ wLevel = atoi(argv[2]);
+ SLIC_DebugLevel(wLevel);
+ } else if (0 == strcmp("selftest", argv[1])) /* self test */
+ {
+ if (argc != 2)
+ {
+ printf("\n Usage:%s selftest\n", argv[0]);
+ exit(1);
+ }
+ SLIC_SelfTest();
+ }
+ else if (0 == strcmp("leg", argv[1])) /* chip initial */
+ {
+
+ if (argc != 3)
+ {
+ printf("\n Usage:%s leg num(1:init,other num :no init)\n", argv[0]);
+ exit(1);
+ }
+ wPort=atoi(argv[2]);
+ if(wPort==1)
+ {
+ wRev = SLIC_Dev_Init();
+ if(wRev==SLIC_FAIL)
+ printf("leg init fail!!\n");
+ else
+ printf("leg init success!\n");
+ }
+ else
+ exit(1);
+
+ }
+ else if (0 == strcmp("test", argv[1])) /* 112 test start */
+ {
+ WriteCmd_t Cmd = {0};
+ if (argc != 6)
+ {
+ printf("\n Usage:%s test port type item\n", argv[0]);
+ exit(1);
+ }
+
+ Cmd.port = atoi(argv[2]);
+ Cmd.port_type = atoi(argv[3]);
+ Cmd.item = atoi(argv[4]);
+ Cmd.obligate = atoi(argv[5]);
+ wRev = SLIC_112TestStart((WriteCmd_t *)&Cmd);
+ }
+ else if (0 == strcmp("readreg", argv[1])) /* codecget */
+ {
+ BYTE bBuf[256];
+ BYTE bSize = 1;
+ BYTE loopi;
+ if (argc != 4)
+ {
+ printf("\n Usage:%s codecget port type address size\n", argv[0]);
+ exit(1);
+ }
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+
+ for(loopi=0; loopi<=126; loopi++)
+ {
+ bBuf[0] = loopi;
+ wRev = SLIC_Read_Codec(bBuf);
+ if (wRev != SLIC_SUCCESS)
+ break;
+ }
+ }
+ else if (0 == strcmp("readram", argv[1]))
+ {
+ BYTE bSize = 4; //siliconlab 32176 readram 28bit once
+ WORD loopi;
+ union
+ {
+ DWORD wReturnvalue;
+ WORD wAddress_on10;
+ } xchange;
+
+ if (argc != 4)
+ {
+ printf("\n Usage:%s readram port port_type reg_10\n", argv[0]);
+ exit(1);
+ }
+
+ wPort = atoi(argv[2]);
+ wPort_type = atoi(argv[3]);
+
+ printf("____show all rams_____ \n");
+ for(loopi=0; loopi<=1565; loopi++)
+ {
+ xchange.wAddress_on10 = loopi;
+ wRev = SLIC_Read_Ram((BYTE *) &xchange.wAddress_on10);
+ if (wRev != SLIC_SUCCESS)
+ break;
+ }
+ }
+ else if (0 == strcmp("voice_test", argv[1])) /* rcvmsg */
+ {
+ #ifdef VOICE_TEST_CALL_DRV
+ int ret = 0;
+ // WORD codecpath = 0;
+ // WORD onoff = 0;
+ T_Voice_Para para = {0};
+ int slicflag = 0;
+ T_ZDrvVoice_Cfg cfg = {8000,1,160,16,0};
+ T_ZDrvVoice_Cfg cfgwb = {16000,1,320,16,0};
+
+ para.codec_path = atoi(argv[2]);//0 dsp ;1 soft
+ para.mode = atoi(argv[3]); // 0gsm,1 td;2 wcdma
+ para.codec_type = atoi(argv[3]); // 0 amr-nb;1 amr-wb
+ // onoff = atoi(argv[4]); // 0 off;1 on
+ printf("slctool: voice_test codec_path=%d,mode=%d!\n",para.codec_path,para.mode);
+
+
+
+ voice_fd = open("/dev/voice_device", O_RDONLY);
+ if(voice_fd < 0)
+ {
+ printf("slctool: open voice device error.\n");
+ exit(1); //cov m
+ }
+ //open volte
+
+ volte_fd = open("/dev/volte_device", O_RDONLY);
+ if(volte_fd < 0)
+ {
+ printf("slctool: open volte device error.\n");
+ exit(1); //cov m
+ }
+
+ //ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg);
+ // printf("slctool: volte set cfg fd=%d,ret=%d.\n",volte_fd,ret);
+
+
+
+ ret = ioctl(volte_fd,VOLTE_IOCTL_GET_SLIC_USE_FLAG,&slicflag);
+ printf("slctool: volte get slic flag=%d fd=%d,ret=%d.\n",slicflag,volte_fd,ret);
+
+ ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg);
+
+ close(volte_fd);
+
+ volte_fd = open("/dev/volte_device", O_RDONLY);
+ if(volte_fd < 0)
+ {
+ printf("slctool: open volte device error.\n");
+ exit(1); //cov m
+ }
+
+ //ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg);
+ // printf("slctool: volte set cfg fd=%d,ret=%d.\n",volte_fd,ret);
+ ret = ioctl(volte_fd,VOLTE_IOCTL_GET_SLIC_USE_FLAG,&slicflag);
+ printf("slctool: volte get slic flag=%d fd=%d,ret=%d.\n",slicflag,volte_fd,ret);
+
+ ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfgwb);
+
+ close(volte_fd);
+
+ ret = ioctl(voice_fd,VOICE_IOCTL_START,¶);
+ printf("slctool: voice start fd=%d,ret=%d.\n",voice_fd,ret);
+
+ usleep(1000000);
+
+ printf("slctool: bef voice stop fd=%d,ret=%d.\n",voice_fd,ret);
+
+ ret = ioctl(voice_fd,VOICE_IOCTL_STOP,¶);
+ printf("slctool: voice stop fd=%d,ret=%d.\n",voice_fd,ret);
+
+ close(voice_fd);
+
+
+ printf("voice test !\n");
+ #else
+
+ int ret = 0;
+ int sel;
+ T_Voice_Para *para;
+ sel = atoi(argv[2]);//0 gsm ;1 tdnbhw;2tdnbsf ;3tdwbsf
+ if (sel == 0){
+ para = &gsmhwpara;
+ }
+ else if(sel == 1){
+ para = &tdnbhwpara;
+ }
+ else if(sel == 2){
+ para = &tdnbsfpara;
+
+ }
+ else if(sel == 3){
+ para = &tdwbsfpara;
+ }
+ else{
+ printf("voice lib test invalid para\n");
+ exit(1);
+ }
+ ret = voice_open(para);
+ printf("slctool: voice_open,ret=%d.\n",ret);
+ usleep(1000000);
+
+
+ ret = voice_close(para);
+ #endif
+
+
+ }
+ else if (0 == strcmp("vploop", argv[1]))
+ {
+ int ret = 0;
+
+ int path = 0;
+ path = atoi(argv[2]);//0 hanset ;1 sp;2 headset;255 off
+ printf("slictool vploop path=%d \n",path);
+ if((path >=0)&&(path <=2)){
+ ret = SLIC_PCM_Set_NB();
+ if (ret != 0)
+ {
+ printf("SLIC_PCM_Set_NB Error ret=%d!\n",ret);
+ exit(1);
+ }
+ ret = SLIC_Start_PCM();
+ if (ret != 0)
+ {
+ printf("SLIC_Start_PCM Error ret=%d!\n",ret);
+ exit(1);
+ }
+ }
+ else if(path == 255){
+ ret = SLIC_Stop_PCM();
+ if (ret != 0)
+ {
+ printf("SLIC_Stop_PCM Error ret=%d!\n",ret);
+ exit(1);
+ }
+ SLIC_Release();
+
+ }
+
+ ret = voice_Vploop(&path);
+ if (ret != 0)
+ {
+ printf("vploop Error ret=%d!\n",ret);
+ exit(1);
+ }
+
+ }
+
+ else
+ {
+ printf("not support!\n");
+ }
+
+ if (wRev != SLIC_SUCCESS)
+ {
+ printf("\n Run Error!\n");
+ exit(1);
+ }
+
+ SLIC_Release();
+ return 0;
+}
+/*lint -restore*/
+
diff --git a/ap/app/ccapp/slic_type.h b/ap/app/ccapp/slic_type.h
new file mode 100644
index 0000000..6279fad
--- /dev/null
+++ b/ap/app/ccapp/slic_type.h
@@ -0,0 +1,218 @@
+/***********************************************************************
+ *Project Linux H100
+ *Modual USRLINE
+ *FileName slc_type.h
+ *Description SLIC module interface
+ *-----------------------------------------------------------------------
+ *modify History:
+ *
+ * Data author version modify description
+ * 2005/4/4 jiang.yuelong 1.0 create
+ ************************************************************************/
+#ifndef _SLIC_TYPE_H
+#define _SLIC_TYPE_H
+/*lint -save -e18*/
+typedef void VOID;
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+typedef unsigned int DWORD;
+typedef int LONG;
+typedef unsigned char* LPSTR;
+typedef char S8;
+
+typedef enum {
+ SLIC_UNKNOWN_CMD = -1, /* unknow cmd */
+
+ /* modified cmd*/
+ SLIC_DEV_INIT = 0, /* 0 ³õʼ»¯SLICоƬ */
+ SLIC_MSG_REV, /* 1 ½ÓÊÕÉϱ¨Ê¼þ*/
+ SLIC_TEST, /*2 ¿ªÊ¼ÕñÁå»ò·ÅÒô */
+ SLIC_SIGNAL_START, /* 3 ¿ªÊ¼ÕñÁå»ò·ÅÒô */
+ SLIC_SIGNAL_STOP, /*4 Í£Ö¹ÕñÁå»ò·ÅÒô */
+ SLIC_PCM_OPEN, /* 5 ´ò¿ªPCMͨ· */
+ SLIC_PCM_CLOSE, /* 6 ¹Ø±ÕPCMͨ· */
+ SLIC_PCM_SET_NB, /* 7 ÉèÖÃÕ´øÒôƵ */
+ SLIC_PCM_SET_WB, /* 8 ÉèÖÃ¿í´øÒôƵ */
+
+ /* original cmd*/
+ /* below cmd is used for ulc or slctool */
+ SLIC_INF_PRECFG, /* 9 */
+ SLIC_NOTUSED, /*10 for ioctl #define FIGETBSZ _IO(0x00,2) */
+ SLIC_PORT_RESET, /* 11 */
+ SLIC_MSG_CLR, /* 12 */
+ SLIC_DIAL_START, /* 13 */
+ SLIC_DIAL_STOP, /*14 */
+ SLIC_TIMESLOT_SET, /*15 */
+ SLIC_TIMESLOT_RELEASE, /* 16 */
+ SLIC_PORT_LOCK, /* 17*/
+ SLIC_PORT_UNLOCK, /* 18*/
+ SLIC_FSK_START, /* 19 */
+ SLIC_FSK_STO, /*20 */
+ SLIC_POLARITY_REVERSE, /*21 */
+ SLIC_DTMFCID_START, /* 22 */
+ SLIC_LINE_TEST_START, /* 23 start line test */
+ SLIC_LINE_TEST_ABORT, /* 24 stop line test */
+ SLIC_LINE_TEST_READ, /*25 read line test result */
+ SLIC_TIMEPARA_CFG, /* 26 config the time para used for hookon¡¢hookoff¡¢pulse dial and flash */
+ SLIC_ELECTRIC_CFG, /* 27 */
+
+ /* below cmd is only used for slctool for debug */
+ SLIC_DEBUG_LEVEL, /*28set the message print level */
+ SLIC_CFG_HOOK_LOWLEN, /* 29config the hookon time */
+ SLIC_CFG_HOOK_HIGLEN, /* 30 */
+ SLIC_CFG_FLASH_LMIN, /* 31*/
+ SLIC_CFG_FLASH_LMAX, /* 32 */
+ SLIC_CFG_FLASH_HFIX, /*33 */
+ SLIC_CFG_DIAL_HMIN, /*34 */
+ SLIC_CFG_DIAL_HMAX, /* 35 */
+ SLIC_CFG_DIAL_LMIN, /* 36*/
+ SLIC_CFG_DIAL_LMAX, /*37 */
+ SLIC_CFG_RINGCEASE, /* 38*/
+ SLIC_CFG_PREHOOK_HIGLEN, /* 39 */
+ SLIC_CFG_QUEUE_DELAY, /*40 */
+ SLIC_CODEC_GET, /*41 read the content of reg xxx */
+ SLIC_CODEC_SET, /* 42wrtie value X to reg xxx */
+ SLIC_RAM_GET, /* 43read the content of ram xxx */
+ SLIC_RAM_SET, /* 44wrtie value X to ram xxx */
+ SLIC_CODEC_GETALL, /*45 read all the reg */
+ SLIC_RAM_GETALL, /*46 read all the ram */
+ SLIC_GET_CHIP_NAME, /*47 */
+
+ SLIC_IOCTL_CMD_MAX,
+} SLIC_IOCTL_CMD;
+
+typedef enum {
+ EV_UNKONWN = -1,
+ EV_FXS_HOOKON, /*¹Ò»úʼþ*/
+ EV_FXS_HOOKOFF, /*Õª»úʼþ*/
+ EV_FXS_COLLECT_DIG, /*¼ì²âµ½°´¼ü£¬ÕýÔڲɼ¯ºÅÂë*/
+ EV_FXS_FLASH, /*ÅIJå»Éʼþ*/
+
+ EV_FXS_FIRST_RING,
+ EV_FXS_SIGNAL_CEASE,
+ EV_FXO_RING_START,
+ EV_FXO_RING_STOP,
+ EV_FXS_PRE_HOOKOFF,
+ EV_FXS_FIRST_TONE,
+ EV_FXS_TEST_DONE,
+ EV_FXS_TEST_ERROR,
+ EV_LT_RINGER_REN
+} SLIC_EVENT;
+
+typedef enum
+{
+ HOOKON,
+ HOOKOFF
+} USL_HOOKSTATE;
+
+
+typedef enum {
+ PORT_TYPE_FXS = 0,
+ PORT_TYPE_FXO = 1
+} SLIC_PORT_TYPE;
+
+#define SLIC_PORT_TYPE PORT_TYPE_FXS
+#define DAA_PORT_TYPE PORT_TYPE_FXO
+
+typedef struct
+{
+ BYTE bTx;
+ BYTE bRx;
+} TIME_SLOT;
+
+typedef union
+{
+ WORD wTime;
+ WORD wLevel;
+ WORD wImpe;
+ TIME_SLOT stTimeSlot;
+} SLIC_PARA_UNION;
+
+typedef struct
+{
+#if 0
+ WORD wPort;
+ BYTE bPortType;
+ SLIC_PARA_UNION unPara;
+#endif
+ VOID *pData;
+ DWORD dwSize;
+} SLIC_IOCTL_DATA;
+
+typedef struct
+{
+ WORD wCadenceRptCnt;
+ WORD wCadenceOn;
+ WORD wCadenceOff;
+ WORD wFreq1;
+ WORD wFreq2;
+ WORD wAmp;
+} CANDENCE_ATTR;
+
+typedef enum {
+ RING_SIGNAL = 0,
+ TONE_SIGNAL = 1
+} SLIC_SIGNAL_TYPE;
+
+typedef enum
+{
+ TONE_DIAL, /* ²¦ºÅÒô */
+ TONE_BUSY, /* æÒô */
+ TONE_RINGBACK, /* »ØÁåÒô */
+ TONE_CONGESTION, /* ×èÈûÒô*/
+ TONE_CW, /* ºô½ÐµÈ´ýÒô*/
+ TONE_TKY, /* Ð¥½ÐÒô*/
+ TONE_SERVICE_SUCCESS, /* ÉèÖóɹ¦Òô */
+ TONE_SERVICE_FAIL, /* ÉèÖÃʧ°ÜÒô */
+ /* ´ýÀ©Õ¹ */
+ TONE_MAX,
+} TONE_TYPE;
+
+typedef struct
+{
+ SLIC_SIGNAL_TYPE signal_type;
+ /* TONE_SIGNAL ±íʾTONEÒô */
+ /* RING_SIGNAL ±íʾÕñÁå */
+ char cid[32]; /* À´µçÏÔʾºÅÂë */
+ TONE_TYPE tone_type; /* toneÒôÀàÐÍ*/
+ char date_time[32];
+} SIGNAL_DATA;
+
+typedef struct
+{
+ //WORD wPort;
+ BYTE bMsgId;
+ DWORD dPayLoad;
+} MSG_DATA;
+
+typedef struct
+{
+ BYTE bCusRingVpk;
+ BYTE bCusDcVol;
+ BYTE bCusDcLoopCurr;
+ BYTE bScene;
+ BYTE bChange;
+}ELECTRIC_CFG_CUSTOMIZED;
+
+#define ELEC_HOOKON_VOLTAGE (1<<0)
+#define ELEC_LOOP_CURRENT (1<<1)
+#define ELEC_RING_VPK (1<<2)
+
+enum {
+ DB_SLIC_SINGLEPHONE_SHORTLOOP = 0,
+ DB_SLIC_MULTIPHONES_SHORTLOOP = 1,
+ DB_SLIC_LONGLOOP = 2,
+ DB_SLIC_ORIGINAL_FACTORY = 3,
+ DB_SLIC_CUSTOMIZED = 4
+};
+
+#ifdef USE_SLIC_TW
+typedef unsigned char uint8;
+/** Transmit/Receive Timeslot setting (timeslot and control) */
+typedef struct VpOptionTimeslotType {
+ uint8 tx; /**< 8-bit TX timeslot */
+ uint8 rx; /**< 8-bit RX timeslot */
+} VpOptionTimeslotType;
+#endif
+/*lint -restore*/
+#endif /* _SLIC_TYPE_H */
diff --git a/ap/app/ccapp/soft_timer.c b/ap/app/ccapp/soft_timer.c
new file mode 100644
index 0000000..5032f2f
--- /dev/null
+++ b/ap/app/ccapp/soft_timer.c
@@ -0,0 +1,493 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2008, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º soft_timer.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º ¶¨ÒåͨÓõÄÈí¼þ¶¨Ê±Æ÷Ï߳̿â
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V1.0
+* ×÷ Õߣº Ö£ÓñæÃ
+* Íê³ÉÈÕÆÚ£º 2010-09-02
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÈÕÆÚ£º2010-09-02
+* °æ ±¾ ºÅ£ºV1.0
+* ÐÞ ¸Ä ÈË£ºÖ£ÓñæÃ
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "soft_timer.h"
+
+/*
+#define SOFT_TIMER_DEBUG 1
+*/
+/********************************************
+ * Macro declaration
+ *******************************************/
+#define NEW_TIMER_STEP 10
+#define MAX_TIMER_POOL_NUM 33
+
+/********************************************
+ * static variables
+ *******************************************/
+static SOFT_TIMER g_timer_pool[MAX_TIMER_POOL_NUM] = {0};
+static SOFT_TIMER *g_pTimerHeader = NULL;
+static int g_timer_initialized = 0;
+
+pthread_mutex_t g_timer_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void* SoftTimer_Loop(void *args);
+
+/********************************************
+ * SoftTimer_Init
+ * initialize global variables
+ *******************************************/
+static int SoftTimer_Init(void)
+{
+ int result = 0;
+ pthread_attr_t attribute;
+ pthread_t stHandle;
+
+ if(0 == g_timer_initialized)
+ {
+ g_timer_initialized = 1;
+
+ pthread_attr_init(&attribute);
+ pthread_attr_setstacksize(&attribute, 32*1024);
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("Create soft timer first time, must create a thread now!\n");
+ #endif
+ result = pthread_create(&stHandle, &attribute, SoftTimer_Loop, NULL);
+ if(0 != result)
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("StartSoftTimer failed, create thread fail %d!\n", result);
+ #endif
+ return ERROR;
+ }
+
+ g_pTimerHeader = &g_timer_pool[0];
+ g_pTimerHeader->next = g_pTimerHeader;
+ g_pTimerHeader->prev = g_pTimerHeader;
+ g_pTimerHeader->used = 1;
+ }
+
+ return OK;
+}
+
+/********************************************
+ * SetBasicTimerEx
+ * call [setitimer] to set basic timer
+ *******************************************/
+static void SetBasicTimerEx(int value)
+{
+ struct itimerval stTimer = {0};
+ struct itimerval oldTimer = {0};
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SetBasicTimerEx: value=%d\n", value);
+ #endif
+
+ stTimer.it_value.tv_sec = value / 1000;
+ stTimer.it_value.tv_usec = (value * 1000) % 1000000;
+
+ //stTimer.it_interval.tv_sec = stTimer.it_value.tv_sec;
+ //stTimer.it_interval.tv_usec = stTimer.it_value.tv_usec;
+
+ setitimer(ITIMER_REAL, &stTimer, &oldTimer);
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SetBasicTimerEx: tv_sec=%d, tv_usec=%d\n", stTimer.it_value.tv_sec, stTimer.it_value.tv_usec);
+ printf("SetBasicTimerEx:oldTimer tv_sec=%d, tv_usec=%d\n", oldTimer.it_value.tv_sec, oldTimer.it_value.tv_usec);
+ #endif
+}
+
+/********************************************
+ * SoftTimer_Add
+ * add a soft timer to double linked list
+ *******************************************/
+static int SoftTimer_Add(SOFT_TIMER *pHeader, SOFT_TIMER *pItem)
+{
+ SOFT_TIMER *pTmp = pHeader;
+
+ if(NULL == pHeader || NULL == pItem)
+ {
+ return -1;
+ }
+
+ do
+ {
+ if(pTmp->timerValue <= pItem->timerValue)
+ {
+ pTmp = pTmp->next;
+ }
+ else
+ {
+ break;
+ }
+ } while(pTmp != pHeader);
+
+ if(pTmp != pHeader)
+ {
+ pItem->next = pTmp;
+ pItem->prev = pTmp->prev;
+ pTmp->prev->next = pItem;
+ pTmp->prev = pItem;
+ }
+ else
+ {
+ pItem->next = pTmp;
+ pItem->prev = pTmp->prev;
+ pTmp->prev->next = pItem;
+ pTmp->prev = pItem;
+ }
+
+ return 0;
+}
+
+/********************************************
+ * SoftTimer_Delete
+ * delete a soft timer from double linked list
+ *******************************************/
+static int SoftTimer_Delete(SOFT_TIMER *pHeader, SOFT_TIMER *pItem)
+{
+ if(NULL == pHeader || NULL == pItem)
+ {
+ return -1;
+ }
+
+ if(pItem == pHeader)
+ {
+ return 0;
+ }
+
+ pItem->prev->next = pItem->next;
+ pItem->next->prev = pItem->prev;
+
+ return 0;
+}
+
+/********************************************
+ * SoftTimer_GetSize
+ * get total size of double linked list
+ *******************************************/
+static int SoftTimer_GetSize(SOFT_TIMER *pHeader)
+{
+ int size = 0;
+ SOFT_TIMER *pTmp = pHeader->next;
+
+ while(pTmp != pHeader)
+ {
+ size++;
+ pTmp = pTmp->next;
+ }
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SoftTimer_GetSize: size=%d\n", size);
+ #endif
+ return size;
+}
+
+/********************************************
+ * SoftTimer_Adjust
+ * adjust soft-timer's value in the double linked list
+ *******************************************/
+static int SoftTimer_AdjustTimerValue(SOFT_TIMER *pHeader, int value)
+{
+ SOFT_TIMER *pTmp = pHeader->next;
+
+ while(pTmp != pHeader)
+ {
+ pTmp->timerValue -= value;
+ pTmp = pTmp->next;
+ }
+ return 0;
+}
+
+/********************************************
+ * SoftTimer_Handler
+ * handler of soft-timer
+ *******************************************/
+static void SoftTimer_Handler(void)
+{
+ int index;
+ SOFT_TIMER *pHeader = g_pTimerHeader;
+ SOFT_TIMER *pTmp = pHeader->next;
+ unsigned int curTime = 0;
+
+ curTime = (pTmp != pHeader?pTmp->timerValue:0);
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SoftTimer_Ops: curTime=%d\n", curTime);
+ #endif
+
+ pthread_mutex_lock(&g_timer_mutex);
+
+ while(pTmp != pHeader)
+ {
+ pTmp->timerValue -= curTime;
+ if(pTmp->timerValue <= 0)
+ {
+ pTmp->procCallBack(pTmp->args);
+
+ if(TIMER_FLAG_RESTART == pTmp->ucFlag)
+ {
+ pTmp->timerValue = pTmp->ulNextInterval;
+ }
+ else
+ {
+ pTmp->timerValue = -1;
+ }
+ pTmp->done = 1;
+ }
+ pTmp = pTmp->next;
+ }
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SoftTimer_Ops:[1] %d\n", SoftTimer_GetSize(pHeader));
+ #endif
+
+ for(index = 1; index < MAX_TIMER_POOL_NUM; index++)
+ {
+ if(g_timer_pool[index].used && g_timer_pool[index].done)
+ {
+ g_timer_pool[index].done = 0;
+
+ SoftTimer_Delete(pHeader, &g_timer_pool[index]);
+
+ if(g_timer_pool[index].timerValue > 0)
+ {
+ SoftTimer_Add(pHeader, &g_timer_pool[index]);
+ }
+ else
+ {
+ memset(&g_timer_pool[index], 0, sizeof(SOFT_TIMER));
+ }
+ }
+ }
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SoftTimer_Ops:[2] %d\n", SoftTimer_GetSize(pHeader));
+ #endif
+
+ SetBasicTimerEx(pHeader->next->timerValue);
+
+ pthread_mutex_unlock(&g_timer_mutex);
+
+ #ifdef SOFT_TIMER_DEBUG
+ printf("SoftTimer_Ops: nextTime=%d\n", pHeader->next->timerValue);
+ #endif
+
+ return;
+}
+
+/********************************************
+ * SoftTimer_Loop
+ * A thread entry for soft-timer!
+ *******************************************/
+static void* SoftTimer_Loop(void *args)
+{
+ struct sigaction act;
+
+ act.sa_handler =(void*) SoftTimer_Handler;
+ act.sa_flags = 0;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGALRM, &act, NULL);
+
+ while(1)
+ {
+ pause();
+ }
+}
+
+static void SoftTimer_Process(int freeIndex)
+{
+ ULONG ulResidue = 0;
+ ULONG ulQuotient = 0;
+ int oldTimeValue = 0;
+ int leftTimeValue = 0;
+
+ struct itimerval stTimer = {0};
+
+ if(0 == SoftTimer_GetSize(g_pTimerHeader))
+ {
+ SoftTimer_Add(g_pTimerHeader, &( g_timer_pool[freeIndex]));
+ SetBasicTimerEx(g_pTimerHeader->next->timerValue);
+ }
+ else
+ {
+ oldTimeValue = g_pTimerHeader->next->timerValue;
+ if(oldTimeValue > 0)
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("CreateSoftTimer: oldTimeValue=%d\n", oldTimeValue);
+ #endif
+ getitimer(ITIMER_REAL, &stTimer);
+ #ifdef SOFT_TIMER_DEBUG
+ printf("CreateSoftTimer: tv_sec=%d, tv_usec=%d\n", stTimer.it_value.tv_sec, stTimer.it_value.tv_usec);
+ #endif
+ leftTimeValue = stTimer.it_value.tv_sec * 1000 + (stTimer.it_value.tv_usec/1000);
+
+ ulResidue = leftTimeValue % NEW_TIMER_STEP;
+ if (0 != ulResidue)
+ {
+ ulQuotient = leftTimeValue / NEW_TIMER_STEP;
+ leftTimeValue = (ulQuotient + 1) * NEW_TIMER_STEP;
+ }
+ #ifdef SOFT_TIMER_DEBUG
+ printf("CreateSoftTimer: oldTimeValue=%d, leftTimeValue=%d\n", oldTimeValue, leftTimeValue);
+ #endif
+ if(oldTimeValue - leftTimeValue >= NEW_TIMER_STEP)
+ {
+ SoftTimer_AdjustTimerValue(g_pTimerHeader, oldTimeValue - leftTimeValue);
+ }
+
+ SoftTimer_Add(g_pTimerHeader, &( g_timer_pool[freeIndex]));
+ SetBasicTimerEx(g_pTimerHeader->next->timerValue);
+ }
+ }
+}
+
+/********************************************
+ * CreateSoftTimer
+ * create a new soft-timer!
+ *******************************************/
+LONG CreateSoftTimer(USHORT usTimerID,
+ UCHAR ucFlag,
+ ULONG ulInterval,
+ void * (*procCallBack)(void *),
+ void *args)
+{
+ int ucIndex = 0;
+ int freeIndex = 0;
+
+ ULONG ulResidue = 0;
+ ULONG ulQuotient = 0;
+
+ if (NULL == procCallBack)
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("CreateSoftTimer failed, procCallBack is NULL!\n");
+ #endif
+ return ERROR;
+ }
+
+ pthread_mutex_lock(&g_timer_mutex);
+
+ if(OK != SoftTimer_Init())
+ {
+ pthread_mutex_unlock(&g_timer_mutex);
+ return ERROR;
+ }
+
+ for(ucIndex = 1, freeIndex = 0; ucIndex < MAX_TIMER_POOL_NUM; ucIndex++)
+ {
+ /*same timer id exist, warning, return error*/
+ if (g_timer_pool[ucIndex].used && (usTimerID == g_timer_pool[ucIndex].usTimerID))
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("Same timer id 0x%04x exist!\n", usTimerID);
+ #endif
+ pthread_mutex_unlock(&g_timer_mutex);
+ return ERROR;
+ }
+ if ((0 == g_timer_pool[ucIndex].used) && (0 == freeIndex))
+ {
+ freeIndex = ucIndex;
+ }
+ }
+
+ /* No empty timer left */
+ if (0 == freeIndex)
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("StartSoftTimer 0x%04x failed, queue full!\n", usTimerID);
+ #endif
+ pthread_mutex_unlock(&g_timer_mutex);
+ return ERROR;
+ }
+
+ /* Adjust interval value, it must multiple of 10 */
+ ulResidue = ulInterval % NEW_TIMER_STEP;
+ if (0 != ulResidue)
+ {
+ ulQuotient = ulInterval / NEW_TIMER_STEP;
+ ulInterval = (ulQuotient + 1) * NEW_TIMER_STEP;
+ }
+
+ g_timer_pool[freeIndex].used = 1;
+ g_timer_pool[freeIndex].usTimerID = usTimerID;
+ g_timer_pool[freeIndex].ucFlag = ucFlag;
+ g_timer_pool[freeIndex].ulCurInterval = ulInterval;
+ g_timer_pool[freeIndex].ulNextInterval = ulInterval;
+ g_timer_pool[freeIndex].procCallBack = procCallBack;
+ g_timer_pool[freeIndex].args = args;
+ g_timer_pool[freeIndex].timerValue = ulInterval;
+
+ SoftTimer_Process(freeIndex);
+ #ifdef SOFT_TIMER_DEBUG
+ printf("CreateSoftTimer index %d success: \n"
+ "usTimerID = %d, \n"
+ "ucFlag = %d, \n"
+ "ulCurInterval = %ld, \n"
+ "ulNextInterval = %ld, \n"
+ "procCallBack = %p, \n"
+ "args = %p. \n",
+ freeIndex,
+ usTimerID,
+ ucFlag,
+ ulInterval,
+ ulInterval,
+ procCallBack,
+ args);
+ #endif
+ pthread_mutex_unlock(&g_timer_mutex);
+
+ return OK;
+}
+
+/********************************************
+ * DeleteSoftTimer
+ * delete a soft-timer!
+ *******************************************/
+LONG DeleteSoftTimer(USHORT usTimerID)
+{
+ UCHAR ucIndex = 0;
+
+ pthread_mutex_lock(&g_timer_mutex);
+
+ for(ucIndex = 1; ucIndex < MAX_TIMER_POOL_NUM; ucIndex++)
+ {
+ if(g_timer_pool[ucIndex].used && (usTimerID == g_timer_pool[ucIndex].usTimerID))
+ {
+ break;
+ }
+ }
+
+ if (ucIndex >= MAX_TIMER_POOL_NUM)
+ {
+ #ifdef SOFT_TIMER_DEBUG
+ printf("DeleteSoftTimer 0x%04x failed, not exist!\n", usTimerID);
+ #endif
+ pthread_mutex_unlock(&g_timer_mutex);
+ return ERROR;
+ }
+
+ SoftTimer_Delete(g_pTimerHeader, &( g_timer_pool[ucIndex]));
+ memset(&g_timer_pool[ucIndex], 0, sizeof(SOFT_TIMER));
+ #ifdef SOFT_TIMER_DEBUG
+ printf("DeleteSoftTimer 0x%04x success!\n", usTimerID);
+ #endif
+ pthread_mutex_unlock(&g_timer_mutex);
+ return OK;
+}
diff --git a/ap/app/ccapp/soft_timer.h b/ap/app/ccapp/soft_timer.h
new file mode 100644
index 0000000..6a72de0
--- /dev/null
+++ b/ap/app/ccapp/soft_timer.h
@@ -0,0 +1,80 @@
+/*********************************************************************************
+ * °æ±¾ËùÓÐ (C)2008ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
+ *
+ * ¹¦ÄÜ : ¶¨ÒåͨÓõĶ¨Ê±Æ÷¿â
+ * ×÷Õß : Ö£ÓñæÃ
+ * °æ±¾ : V1.0
+ * Íê³ÉÈÕÆÚ : 2008.05.05
+ * ÆäËü˵Ã÷ :
+ * ²ÎÊý :
+ * ÊäÈë :
+ * Êä³ö :
+ * ¸ü¸Ä¼Ç¼ :
+ * ʱ¼ä ×÷Õß ÄÚÈÝ
+ *-----------------------------------------------------------------------
+ * 08/05/05 Ö£ÓñæÃ ´´½¨
+ *
+ *
+***********************************************************************************/
+
+#ifndef _SOFT_TIMER_H_
+#define _SOFT_TIMER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "message.h"
+//#include "errorcode.h"
+//#include "zte_log.h"
+
+/*¶¨ÒåÓ²¼þ¶¨Ê±Æ÷µÄ²½³¤£¬10ms*/
+#define TIMER_STEP 10
+
+/*¶¨ÒåÈí¼þ¶¨Ê±Æ÷µÄ×î´ó¸öÊý*/
+#define MAX_SOFT_TIMER_NUM 32
+
+/*¶¨Ê±Æ÷ÀàÐͱê־λucFlagµÄºê*/
+#define TIMER_FLAG_ONCE 0 /*´Ë¶¨Ê±Æ÷Ö»´¥·¢Ò»´Î*/
+#define TIMER_FLAG_RESTART 1 /*´Ë¶¨Ê±Æ÷³ÖÐøÓÐЧ*/
+
+
+/*if the thread of soft timer is exist, 0 means not exist*/
+#define SOFT_TIMER_THREAD_NULL 0
+#define SOFT_TIMER_THREAD_EXIST 1
+
+/*¶¨ÒåÈí¼þ¶¨Ê±Æ÷µÄÊý¾Ý½á¹¹*/
+typedef struct tagSOFT_TIMER
+{
+ struct tagSOFT_TIMER *prev;
+ struct tagSOFT_TIMER *next;
+ int used;
+ int done;
+ int timerValue;
+
+ USHORT usTimerID; /*¶¨Ê±Æ÷ID,ÓÃÀ´Çø·Ö²»Í¬µÄÈí¼þ¶¨Ê±Æ÷, 0±êʶ*/
+ UCHAR ucFlag; /*¶¨Ê±Æ÷ÀàÐͱê־λ*/
+ UCHAR ucReserved; /*±£Áô×Ö¶Î*/
+ ULONG ulCurInterval; /*µ±Ç°¶¨Ê±Æ÷³¬Ê±Ê£Óàʱ¼ä£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)£¬±ØÐ붨ÒåΪӲ¼þ¶¨Ê±Æ÷²½³¤µÄ±¶Êý*/
+ ULONG ulNextInterval; /*³¬Ê±ºó¶¨Ê±Æ÷ÖØÖõļä¸ô£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)*/
+ void * (*procCallBack)(void *); /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýÖ¸Õë*/
+ void *args; /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýµÄ²ÎÊý*/
+}SOFT_TIMER;
+
+
+/*Íⲿ½Ó¿Úº¯ÊýÉùÃ÷*/
+LONG CreateSoftTimer(USHORT usTimerID,
+ UCHAR ucFlag,
+ ULONG ulInterval,
+ void * (*procCallBack)(void *),
+ void *args);
+
+LONG DeleteSoftTimer(USHORT usTimerID);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+