lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /**************************************************************************
|
| 2 | *
|
| 3 | * Copyright (c) 2013 ZTE Corporation.
|
| 4 | *
|
| 5 | ***************************************************************************
|
| 6 | * Ä£ ¿é Ãû : CC
|
| 7 | * ÎÄ ¼þ Ãû : Cc_main.h
|
| 8 | * Ïà¹ØÎļþ :
|
| 9 | * ʵÏÖ¹¦ÄÜ : ATÃüÁî´¦ÀíÄ£¿éºê¡¢ÀàÐͶ¨Òå
|
| 10 | * ×÷ Õß :
|
| 11 | * °æ ±¾ :
|
| 12 | * Íê³ÉÈÕÆÚ :
|
| 13 | * ÆäËü˵Ã÷ :
|
| 14 | **************************************************************************/
|
| 15 |
|
| 16 | /**************************************************************************
|
| 17 | * Ð޸ļǼ :
|
| 18 | ***************************************************************************/
|
| 19 | /**************************************************************************
|
| 20 | * Ð޸ıàºÅ :
|
| 21 | * ÐÞ ¸Ä ÈË :
|
| 22 | * ÐÞ¸ÄÈÕÆÚ :
|
| 23 | * ÐÞ¸ÄÄÚÈÝ :
|
| 24 | **************************************************************************/
|
| 25 | #ifndef _CC_MAIN_H
|
| 26 | #define _CC_MAIN_H
|
| 27 |
|
| 28 | /**************************************************************************
|
| 29 | * #includeÇø
|
| 30 | **************************************************************************/
|
| 31 | #include "message.h"
|
| 32 | #include "softap_api.h"
|
| 33 | #include "cc_proc.h"
|
| 34 | #include "slic_type.h"
|
| 35 | #include "slic_inf.h"
|
| 36 | #include <time.h>
|
| 37 | #include "libzte_log.h"
|
| 38 | #ifndef TEST_CCAPP
|
| 39 | #include "sys/ipc.h"
|
| 40 | #include "signal.h"
|
| 41 | #endif
|
| 42 | #ifdef _OS_TOS
|
| 43 | #include "osa_api.h"
|
| 44 | #include "oss_api.h"
|
| 45 | #endif
|
| 46 | /**************************************************************************
|
| 47 | * ³£Á¿¶¨ÒåÇø
|
| 48 | **************************************************************************/
|
| 49 | typedef enum
|
| 50 | {
|
| 51 | ZCCAPP_TIMER_HOOKOFF_DETECT, /*Õª»úºóµÈ´ý²¦ºÅ¶¨Ê±Æ÷*/
|
| 52 | ZCCAPP_TIMER_DTMF_DETECT, /*²¦ºÅ¼ä¸ô¶¨Ê±Æ÷*/
|
| 53 | ZCCAPP_TIMER_BUSYTONE_DETECT, /*æÒô¶¨Ê±Æ÷*/
|
| 54 | ZCCAPP_TIMER_TKYTONE_DETECT, /*æÒôºóµÄÐ¥½ÐÒô¶¨Ê±Æ÷*/
|
| 55 | ZCCAPP_TIMER_SSDIALTONE_DETECT, /*²¹³äÒµÎñ²Ù×÷ʱÊÕµ½flashºóÆô²¦ºÅÒô¶¨Ê±Æ÷*/
|
| 56 | ZCCAPP_TIMER_HOOKOFF_IDLE,
|
| 57 | }T_zCc_TimerEv;
|
| 58 |
|
| 59 | typedef enum
|
| 60 | {
|
| 61 | ZCCAPP_ATIND_DSCI,
|
| 62 | ZCCAPP_ATIND_ZCPI,
|
| 63 | ZCCAPP_ATIND_IMSPLUS,
|
| 64 | ZCCAPP_ATIND_MODE
|
| 65 | }T_zCc_AtIndEv;
|
| 66 |
|
| 67 |
|
| 68 | #define ZCCAPP_TIMER_HOOKOFF_INTERVAL 10000
|
| 69 | #define ZCCAPP_TIMER_DTMF_INTERVAL 5000
|
| 70 | #define ZCCAPP_TIMER_BUSYTONE_INTERVAL 7000
|
| 71 | #define ZCCAPP_TIMER_TKYTONE_INTERVAL 60000
|
| 72 |
|
| 73 | #define ZCCAPP_TIMER_HOOKOFF_IDLE_INTERVAL 500
|
| 74 |
|
| 75 | /*
|
| 76 | * Number of slaves per master.
|
| 77 | * Two slaves are required for 3-party calls.
|
| 78 | */
|
| 79 | #define ZCC_SLAVES 8
|
| 80 | #define ZCC_MAXCID 7
|
| 81 | #define ZCC_MINCID 1
|
| 82 |
|
| 83 | #define ZDIAL_NUM_MAX 48
|
| 84 | #define ZCC_AT_CHNL_ID 70
|
| 85 | #define ZCC_FLASH_SIGN ('F')
|
| 86 | #define ZCC_TIMEOUT_SIGN ('T')
|
| 87 | /*
|
| 88 | * Define how focus flag in master state machine is interpreted.
|
| 89 | * XXX: Extend this for more than 3-party calls.
|
| 90 | */
|
| 91 | #define ZCC_FOCUS_0 (1 << 0)
|
| 92 | #define ZCC_FOCUS_1 (1 << 1)
|
| 93 | #define ZCC_FOCUS_2 (1 << 2)
|
| 94 | #define ZCC_FOCUS_PSTN (1 << 3)
|
| 95 | #define ZCC_FOCUS_BOTH (ZCC_FSM_FOCUS_0 + ZCC_FSM_FOCUS_1)
|
| 96 |
|
| 97 | /*
|
| 98 | * Various timeouts.
|
| 99 | * These timeouts are in units of ZCC_TIMER_E.
|
| 100 | */
|
| 101 | #define ZCC_BSYTMO (7000) /* Timeout in busy tone state */
|
| 102 | #define ZCC_TKYTMO (60000) /* Timeout in turkey tone state */
|
| 103 | //#define ZCC_FBSYTMO (40000) /* Timeout in fast busy tone state */
|
| 104 | #define ZCC_DACCMTMO (5000) /* Timeout (interdigit) in daccm state */
|
| 105 | #define ZCC_DTTMO (10000) /* Timeout in dialtone state */
|
| 106 | #define ZCC_RSTTMO (10) /* Timeout in master reset state */
|
| 107 | #define ZCC_RELTMO (10) /* Timeout in master release state */
|
| 108 | #define ZCC_RINGTMO (10) /* Timeout in master ringing state */
|
| 109 | #define ZCC_SEIZETMO (10) /* Timeout in master seize state */
|
| 110 | #define ZCC_RBTMO (40) /* Timeout in ringback state */
|
| 111 | #define ZCC_DIALTMO (30) /* Timeout in dial state */
|
| 112 | #define ZCC_PSTNSWTMO (5) /* Timeout in pstn switching state */
|
| 113 | #define ZCC_INTERDIGITSHORT (5) /* Timeout (interdigit short) in daccm state*/
|
| 114 | #define ZCC_WAIT_RESOURCETMO (8) /* Timeout in waiting for resource state */
|
| 115 |
|
| 116 | /* Define digits match results. */
|
| 117 | #define ZCC_NO_RESULT (0x00) /* need more digits */
|
| 118 | #define ZCC_CALL (0x01) /* all digits collected */
|
| 119 | #define ZCC_BAOC_REG (0x10)
|
| 120 | #define ZCC_BAOC_DEREG (0x11)
|
| 121 | #define ZCC_BOIC_REG (0x12)
|
| 122 | #define ZCC_BOIC_DEREG (0x13)
|
| 123 | #define ZCC_CFU_REG (0x20)
|
| 124 | #define ZCC_CFU_DEREG (0x21)
|
| 125 | #define ZCC_CFNRY_REG (0x22)
|
| 126 | #define ZCC_CFNRY_DEREG (0x23)
|
| 127 | #define ZCC_CFB_REG (0x24)
|
| 128 | #define ZCC_CFB_DEREG (0x25)
|
| 129 | #define ZCC_FLASH_1 (0x30) /* Release all active call and accept the other(held or waiting) call */
|
| 130 | #define ZCC_FLASH_2 (0x31) /* Place all active call on hold and accept the other(held or waiting) call */
|
| 131 | #define ZCC_FLASH_3 (0x32) /* Adds a held call to the conversation */
|
| 132 | #define ZCC_FLASH_4 (0x33) /* call transfer */
|
| 133 | #define ZCC_FLASH_0 (0x34) /* release waiting call */
|
| 134 | #define ZCC_LOCAL_TEST_CALL (0xFF-1)
|
| 135 | #define ZCC_MATCHERR (0xFF) /* wrong input */
|
| 136 |
|
| 137 |
|
| 138 | /* Define master state machine states. */
|
| 139 | typedef enum {
|
| 140 | ZCC_M_RELEASE_S = 0,
|
| 141 | ZCC_M_RINGING_S = 1,
|
| 142 | ZCC_M_SEIZE_S = 2
|
| 143 | } T_zCc_MasterState;
|
| 144 |
|
| 145 | /* Define slave state machine states.˳Ðò²»¿Éµ÷Õû */
|
| 146 | typedef enum {
|
| 147 | ZCC_S_IDLE_S = 0,
|
| 148 | ZCC_S_DT_S ,
|
| 149 | ZCC_S_DACCM_S ,
|
| 150 | ZCC_S_DIALING_S ,
|
| 151 | ZCC_S_RINGBACK_S ,// Ö÷½Ð¹ý³ÌÖеÄÕñÁå̬
|
| 152 | ZCC_S_BSYT_S ,
|
| 153 | ZCC_S_TKYT_S ,
|
| 154 | ZCC_S_SIL_S ,
|
| 155 | ZCC_S_TALKING_S ,
|
| 156 | ZCC_S_TRYING_S ,
|
| 157 | ZCC_S_WAIT_RESOURCE_S ,
|
| 158 | } T_zCc_SlaveState, T_zCc_CallState;
|
| 159 |
|
| 160 | /* Define known tone types. */
|
| 161 | typedef enum {
|
| 162 | ZCC_TONE_OFF_A = 0,
|
| 163 | ZCC_TONE_SIL_A = 1,
|
| 164 | ZCC_TONE_RB_A = 2,
|
| 165 | ZCC_TONE_BSY_A = 3,
|
| 166 | //ZCC_TONE_FBSY_A = 4,
|
| 167 | ZCC_TONE_TKY_A = 5,
|
| 168 | ZCC_TONE_DIAL_A = 6,
|
| 169 | ZCC_TONE_CIDCW_A = 7,
|
| 170 | }T_zCc_Tone;
|
| 171 |
|
| 172 |
|
| 173 | /* Define known messages to SIP. */
|
| 174 | typedef enum {
|
| 175 | ZCC_SNO_M = 0,
|
| 176 | ZCC_SBUSY_M = 1, /* When this node is busy */
|
| 177 | ZCC_SANS_M = 2, /* When this node answered */
|
| 178 | ZCC_SINV_M = 3, /* When to invite the other node */
|
| 179 | ZCC_SREG_M = 4, /* When to register */
|
| 180 | ZCC_SDISCN_M = 5, /* When this node disconnected */
|
| 181 | ZCC_SRING_M = 6, /* When this node starts ringing */
|
| 182 | ZCC_SRBANS_M = 7, /* When the other node answered */
|
| 183 | ZCC_SHOLD_M = 8, /* When the other node is put on hold */
|
| 184 | ZCC_SREINV_M = 9, /* When the other node is put off hold */
|
| 185 | ZCC_SMEDIA_M = 10, /* When a media message is received */
|
| 186 | ZCC_SDIGITS_M = 18, /* When a digits timeout occurs */
|
| 187 | ZCC_SDTMF_M = 19, /* When a DTMF relay occurs */
|
| 188 | ZCC_SRING_RSRC_READY_M = 119, /* When this mode start ringing for resource ready */
|
| 189 | } T_zCc_SResp;
|
| 190 |
|
| 191 | /**************************************************************************
|
| 192 | * Êý¾Ý½á¹¹¶¨ÒåÇø
|
| 193 | **************************************************************************/
|
| 194 | typedef struct
|
| 195 | {
|
| 196 | UINT8 curCmd;
|
| 197 | UINT8 curAtCmdSrc;
|
| 198 | }T_zCc_CurAtCmdInfo;
|
| 199 |
|
| 200 |
|
| 201 | /* Slave state machine object. */
|
| 202 | typedef struct {
|
| 203 | T_zCc_SlaveState state; /* This slave's state */
|
| 204 | T_zCc_SlaveState old_state;
|
| 205 | T_zCc_Tone tone; /* What tone to play */
|
| 206 | T_zCc_SResp sMsg; /* Action for SIP */
|
| 207 | UINT8 heldcall; /* When 1, the call is in held state */
|
| 208 | UINT16 confcall; /* When 1, the call is in conference */
|
| 209 | UINT8 waitDSCI6; /* hookon,wait DSCI6 */
|
| 210 | UINT8 cid; /* call id */
|
| 211 | UINT16 idle_second; /*if hookoff but no key is down, this var show the time for waiting key to input */
|
| 212 | CHAR number[ZDIAL_NUM_MAX];
|
| 213 | UINT8 is_callout;
|
| 214 | UINT8 is_cidcw;
|
| 215 | } T_zCc_SlaveObj;
|
| 216 |
|
| 217 | /* Master state machine object. */
|
| 218 | typedef struct {
|
| 219 | T_zCc_MasterState state; /* This master's state */
|
| 220 | T_zCc_SlaveObj slaveObj[ZCC_SLAVES];
|
| 221 | USHORT evt[ZCC_SLAVES];
|
| 222 | // UINT8 focus; /* Which slave in focus */
|
| 223 | UINT8 mode; /* Current mode */
|
| 224 | UINT8 chupSent;
|
| 225 | UINT8 ringCid; /* Ring the phone */
|
| 226 | UINT8 resourceReady; /* ZCPI: x,5 received */
|
| 227 | UINT8 dCount; /* Collected DTMF digits string */
|
| 228 | CHAR digits[ZDIAL_NUM_MAX];// dialled number
|
| 229 | CHAR number[ZDIAL_NUM_MAX];// calling number
|
| 230 | UINT8 confNum; /* total conference number */
|
| 231 | E_CC_APP_AtReqCmdId curAtCmdId;
|
| 232 | UINT8 hookofffg;
|
| 233 | UINT8 actCallNum; /* total active call number */
|
| 234 | UINT8 lastTone;
|
| 235 | UINT8 waitchldresult;
|
| 236 | T_zCc_MasterState old_state;
|
| 237 | } T_zCc_MasterObj, T_zCc_CallDetail;
|
| 238 |
|
| 239 | extern T_zCc_CallDetail g_Cc_CallDetail;
|
| 240 |
|
| 241 | extern T_zCc_CurAtCmdInfo *g_Cc_AtIndRspMsg;
|
| 242 | //typedef VOID (*zCc_SlicEvFunc)(UINT8 Para);
|
| 243 | VOID zCc_SendMsgToSub(MSG_BUF *pMsg);
|
| 244 | int zCc_sleep(long ms);
|
| 245 | VOID zCc_SendMsgToRspSub(MSG_BUF *pMsg);
|
| 246 |
|
| 247 | #endif
|
| 248 |
|