zw.wang | 96c5d4e | 2025-07-01 11:35:13 +0800 | [diff] [blame] | 1 | /**************************************************************************
|
| 2 | *
|
| 3 | * Copyright (c) 2013 ZTE Corporation.
|
| 4 | *
|
| 5 | ***************************************************************************
|
| 6 | * Ä£ ¿é Ãû : Cc
|
| 7 | * ÎÄ ¼þ Ãû : Cc_main.c
|
| 8 | * Ïà¹ØÎļþ :
|
| 9 | * ʵÏÖ¹¦ÄÜ : µç»°ÒµÎñÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
|
| 10 | * ×÷ Õß :
|
| 11 | * °æ ±¾ :
|
| 12 | * Íê³ÉÈÕÆÚ :
|
| 13 | * ÆäËü˵Ã÷ :
|
| 14 | **************************************************************************/
|
| 15 |
|
| 16 | /**************************************************************************
|
| 17 | * Ð޸ļǼ :
|
| 18 | ***************************************************************************/
|
| 19 |
|
| 20 | /**************************************************************************
|
| 21 | * #includeÇø
|
| 22 | **************************************************************************/
|
| 23 | #include <errno.h>
|
| 24 | //#include <signal.h>
|
| 25 | #include <stdio.h>
|
| 26 | #include <string.h>
|
| 27 | #include <stdlib.h>
|
| 28 | //#include <time.h>
|
| 29 | #include <fcntl.h>
|
| 30 | #include "cc_main.h"
|
| 31 | #include "cc_proc.h"
|
| 32 | #include "cc_com.h"
|
| 33 | #include "cc_at.h"
|
| 34 | #include <sys/types.h>
|
| 35 | #ifdef TEST_CCAPP
|
| 36 | #include "soft_timer.h"
|
| 37 | #endif
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 | /**************************************************************************
|
| 42 | * ³£Á¿¶¨ÒåÇø
|
| 43 | **************************************************************************/
|
| 44 | /**************************************************************************
|
| 45 | * Êý¾Ý½á¹¹¶¨ÒåÇø
|
| 46 | **************************************************************************/
|
| 47 | extern T_CC_APP_AtIndProcItem gCcAppAtIndProc[];
|
| 48 | extern SINT32 gCcAppRecvAtIndCnt;
|
| 49 | T_zCc_CallDetail g_Cc_CallDetail;
|
| 50 | char g_zCcApp_AtIndBuf[ZCC_APP_AT_BUF_MAX_LEN+1];
|
| 51 | /**************************************************************************
|
| 52 | * staticº¯ÊýÉùÃ÷Çø
|
| 53 | **************************************************************************/
|
| 54 | /**************************************************************************
|
| 55 | * È«¾Ö±äÁ¿¶¨ÒåÇø
|
| 56 | **************************************************************************/
|
| 57 | static SINT32 g_zCc_MsqId = NULL;
|
| 58 | //static SINT32 g_zCc_AtIndRspId = NULL;
|
| 59 | SINT32 g_zCc_AtRspId = NULL;
|
| 60 |
|
| 61 |
|
| 62 | static SINT32 g_zCc_getSlicEv_threadId = -1;
|
| 63 |
|
| 64 | int zCc_sleep(long ms)
|
| 65 | {
|
| 66 | struct timeval tv;
|
| 67 | tv.tv_sec = 0;
|
| 68 | tv.tv_usec = ms * 1000;
|
| 69 | return select(0, NULL, NULL, NULL, &tv);
|
| 70 | }
|
| 71 | VOID zCc_SlicMsgProc(MSG_BUF *ptMsgBuf)
|
| 72 | {
|
| 73 | assert(ptMsgBuf != NULL);
|
| 74 | //g_Cc_CallDetail.curEvt = ptMsgBuf->usMsgCmd;
|
| 75 | if (ptMsgBuf->usMsgCmd == ZCC_DTMF_E && g_Cc_CallDetail.dCount < ZDIAL_NUM_MAX)
|
| 76 | {
|
| 77 | g_Cc_CallDetail.digits[g_Cc_CallDetail.dCount++] = ptMsgBuf->aucDataBuf[0];
|
| 78 | ccapp_log("zCc_SlicMsgProc digit[%d]=%s", g_Cc_CallDetail.dCount, g_Cc_CallDetail.digits);
|
| 79 | printf("[ccapp_debug]:collect number digit[%d]=%s\n",g_Cc_CallDetail.dCount,g_Cc_CallDetail.digits);
|
| 80 | }
|
| 81 | }
|
| 82 |
|
| 83 | VOID zCc_SendMsgToSub(MSG_BUF *pMsg)
|
| 84 | {
|
| 85 | MSG_BUF *ptMsgBuf = (MSG_BUF*)malloc(sizeof(MSG_BUF));
|
| 86 | SINT32 iMsgQueueId = ZAT_INVALID_ID;
|
| 87 |
|
| 88 | if(ptMsgBuf == NULL)
|
| 89 | return;
|
| 90 | memcpy(ptMsgBuf, pMsg, sizeof(MSG_BUF));
|
| 91 |
|
| 92 | iMsgQueueId = msgget(MODULE_ID_CALL_CTRL_LOCAL, 0);
|
| 93 | if (iMsgQueueId != ZAT_INVALID_ID)
|
| 94 | {
|
| 95 | ptMsgBuf->lMsgType = MSG_TYPE_DEFAULT;
|
| 96 | ptMsgBuf->dst_id = MODULE_ID_CALL_CTRL_LOCAL;
|
| 97 | if (msgsnd(iMsgQueueId, ptMsgBuf, sizeof(MSG_BUF) - sizeof(LONG), 0) < 0)
|
| 98 | {
|
| 99 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendMsgToSub fail!!!\n",__FUNCTION__);
|
| 100 | }
|
| 101 | else
|
| 102 | {
|
| 103 | //zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCc_SendMsgToSub ptMsgBuf->usMsgCmd = %d, errno = %d <---\n",__FUNCTION__,ptMsgBuf->usMsgCmd,errno);
|
| 104 | }
|
| 105 | }
|
| 106 | free(ptMsgBuf);
|
| 107 | }
|
| 108 |
|
| 109 | void* zCcApp_AtIndReader(void * ptr)
|
| 110 | {
|
| 111 | int ret = -1;
|
| 112 | int ReadLen = -1;
|
| 113 | MSG_BUF QueueMsg = {0};
|
| 114 | while(1)
|
| 115 | {
|
| 116 | ReadLen = msgrcv(g_zCc_AtRspId,&QueueMsg, sizeof(MSG_BUF)-sizeof(LONG), 0, 0);
|
| 117 | if (ReadLen > 0)
|
| 118 | {
|
| 119 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s msgrcv QueueMsg.aucDataBuf = %d \n",__FUNCTION__,QueueMsg.usMsgCmd);
|
| 120 | ret = zCcApp_AtIndRspProc(&QueueMsg);
|
| 121 | }
|
| 122 | else
|
| 123 | {
|
| 124 | continue;
|
| 125 | }
|
| 126 |
|
| 127 | }
|
| 128 | }
|
| 129 |
|
| 130 | VOID zCc_AtRecvMsgProc(MSG_BUF *ptMsgBuf)
|
| 131 | {
|
| 132 | assert(ptMsgBuf != NULL);
|
| 133 | ULONG cmdId = ptMsgBuf->usMsgCmd;
|
| 134 | SINT32 i ;
|
| 135 | SINT32 ret = -1;
|
| 136 |
|
| 137 | for(i=0;i< gCcAppRecvAtIndCnt;i++)
|
| 138 | {
|
| 139 | if(cmdId == gCcAppAtIndProc[i].cmdId)
|
| 140 | {
|
| 141 | if(NULL!= gCcAppAtIndProc[i].AtIndProcFun)
|
| 142 | {
|
| 143 | ret = gCcAppAtIndProc[i].AtIndProcFun(ptMsgBuf);
|
| 144 | }
|
| 145 | break;
|
| 146 | }
|
| 147 | }
|
| 148 | }
|
| 149 |
|
| 150 | static VOID zCc_SetRj11LedStatus(char* LedStatus)
|
| 151 | {
|
| 152 | int ret = 0;
|
| 153 |
|
| 154 | cfg_set("cc_rj11_status", LedStatus);
|
| 155 |
|
| 156 | ret = ipc_send_message(MODULE_ID_CALL_CTRL, MODULE_ID_MMI, MSG_CMD_RJ11_STATUS_INFO, 0, NULL, 0);
|
| 157 | if (ret != 0) {
|
| 158 | printf("zCc_SetRj11LedStatus %s failed\n", LedStatus);
|
| 159 | } else {
|
| 160 | printf("zCc_SetRj11LedStatus %s success\n", LedStatus);
|
| 161 | }
|
| 162 | }
|
| 163 |
|
| 164 | VOID* zCcApp_getSlicEv_entry(VOID *pBUf)
|
| 165 | {
|
| 166 | MSG_BUF msgBuf = {0};
|
| 167 | unsigned char bEvent = EV_UNKONWN;
|
| 168 | DWORD dtmf1 = 0;
|
| 169 | char dtmf;
|
| 170 | const char *slic_event = NULL;
|
| 171 | int hook_on_count = 0;
|
| 172 | int hook_off_count = 0;
|
| 173 |
|
| 174 | while (1)
|
| 175 | {
|
| 176 | if (SLIC_SUCCESS == SLIC_MsgRev(&bEvent, &dtmf1))
|
| 177 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s zCcApp_getSlicEv_entry recv msg %d\n",__FUNCTION__,bEvent);
|
| 178 |
|
| 179 | printf("[ccapp_debug]: get slic event, bEvent = %d, dtmf1=%d\n",bEvent, dtmf1);
|
| 180 |
|
| 181 | switch (bEvent)
|
| 182 | {
|
| 183 | case EV_FXS_HOOKON:
|
| 184 | msgBuf.usMsgCmd = ZCC_RELEASE_E;
|
| 185 | msgBuf.src_id = MODULE_ID_SLIC;
|
| 186 | zCc_SendMsgToSub(&msgBuf); /* ·¢¹Ò»ú ʼþ¸øÖ÷Ïß³Ì */
|
| 187 | cfg_set("callback_number", "");
|
| 188 | if(hook_on_count == 1)
|
| 189 | {
|
| 190 | slic_event = "+SLIC EVENT: HOOKON\r\n";
|
| 191 | ipc_send_message(MODULE_ID_SLIC, MODULE_ID_AT_CTL, MSG_CMD_SEND_RSP_TO_OUTSIDE, strlen(slic_event), slic_event, 0);
|
| 192 | }
|
| 193 | hook_on_count = 1;
|
| 194 | break;
|
| 195 | case EV_FXS_HOOKOFF:
|
| 196 | msgBuf.usMsgCmd = ZCC_SEIZE_E;
|
| 197 | msgBuf.src_id = MODULE_ID_SLIC;
|
| 198 | zCc_SendMsgToSub(&msgBuf); /* ·¢Õª»úʼþ¸øÖ÷Ïß³Ì */
|
| 199 | if(hook_off_count == 1){
|
| 200 | slic_event = "+SLIC EVENT: HOOKOFF\r\n";
|
| 201 | ipc_send_message(MODULE_ID_SLIC, MODULE_ID_AT_CTL, MSG_CMD_SEND_RSP_TO_OUTSIDE, strlen(slic_event), slic_event, 0);
|
| 202 | }
|
| 203 | hook_off_count = 1;
|
| 204 | break;
|
| 205 | case EV_FXS_COLLECT_DIG:// '0'-'9', '*', '#'
|
| 206 | dtmf = dtmf1;
|
| 207 | msgBuf.usMsgCmd = ZCC_DTMF_E;
|
| 208 | msgBuf.src_id = MODULE_ID_SLIC;
|
| 209 | msgBuf.aucDataBuf[0] = (UINT8)(dtmf);
|
| 210 | msgBuf.usDataLen = 1;
|
| 211 | zCc_SendMsgToSub(&msgBuf); /* ·¢DTMF ʼþ¸øÖ÷Ïß³Ì */
|
| 212 | break;
|
| 213 | case EV_FXS_FLASH:
|
| 214 | msgBuf.usMsgCmd = ZCC_FLASH_E;
|
| 215 | msgBuf.src_id = MODULE_ID_SLIC;
|
| 216 | zCc_SendMsgToSub(&msgBuf); /* ·¢FLASH ʼþ¸øÖ÷Ïß³Ì */
|
| 217 | break;
|
| 218 | case EV_LT_RINGER_REN:
|
| 219 | if (dtmf1 == 1) {
|
| 220 | zCc_SetRj11LedStatus("ledon");
|
| 221 | } else {
|
| 222 | zCc_SetRj11LedStatus("ledoff");
|
| 223 | }
|
| 224 | break;
|
| 225 | default:/* ÆäËûʼþ¶ªÆú²»´¦Àí*/
|
| 226 | break;
|
| 227 | }
|
| 228 |
|
| 229 | //zCc_sleep(10);
|
| 230 | }
|
| 231 | }
|
| 232 |
|
| 233 | #define MAX_DIGIT_MAP_NUM 20
|
| 234 | #define MAX_DIGIT_MAP_WHOLE_LEN 256
|
| 235 | #define MAX_PHONE_NUM_SIZE 32
|
| 236 | char tz_digitmap[MAX_DIGIT_MAP_NUM][MAX_PHONE_NUM_SIZE+1];//phone list
|
| 237 | int frist_get_map = 0;
|
| 238 |
|
| 239 | //(2xxxxxx|3xxxxxx|4xxxxxx|5xxxxxx|7xxxxxx|0[1-9][0-9]xxxxxxx|00xxxxxxxxxxxxxx|6xxx|8xxx|1xxx|*xx|#xx)
|
| 240 | void get_digit_map_list()
|
| 241 | {
|
| 242 | int i = 0;
|
| 243 | int j = 0;
|
| 244 | char buff[256] = {0};
|
| 245 | char *str = NULL;
|
| 246 |
|
| 247 | //cfg_set("digitmap_str", "(2xxxxxx|3xxxxxx|4xxxxxx|5xxxxxx|7xxxxxx|0[1-9][0-9]xxxxxxx|00xxxxxxxxxxxxxx|6xxx|8xxx|1xxx|*xx|#xx)");
|
| 248 | //cfg_save();
|
| 249 | cfg_get_item("digitmap_str",buff,sizeof(buff));
|
| 250 | if (strlen(buff) == 0)
|
| 251 | return;
|
| 252 |
|
| 253 | str = buff;
|
| 254 | if(*str == '(')
|
| 255 | str++;
|
| 256 |
|
| 257 | while(*str != 0)
|
| 258 | {
|
| 259 | if(*str == '|')
|
| 260 | {
|
| 261 | tz_digitmap[i][j] = 0;
|
| 262 | i++;
|
| 263 | j = 0;
|
| 264 | }
|
| 265 | else if(*str == ')')
|
| 266 | {
|
| 267 | break;
|
| 268 | }
|
| 269 | else
|
| 270 | {
|
| 271 | tz_digitmap[i][j] = *str;
|
| 272 | j++;
|
| 273 | }
|
| 274 | str++;
|
| 275 | }
|
| 276 |
|
| 277 | }
|
| 278 |
|
| 279 | int digit_map_call(char *num)
|
| 280 | {
|
| 281 | int i = 0;
|
| 282 | int j = 0;
|
| 283 | int n = 0;
|
| 284 | char flag = 0;
|
| 285 | char switch_str[4] = {0};
|
| 286 | static char buff[32+1] = {0};
|
| 287 |
|
| 288 |
|
| 289 | cfg_get_item("digitmap_switch",switch_str,sizeof(switch_str));
|
| 290 | if(strcmp(switch_str, "0") == 0)
|
| 291 | {
|
| 292 | return 0;
|
| 293 | }
|
| 294 |
|
| 295 | if(0 == frist_get_map)
|
| 296 | {
|
| 297 | get_digit_map_list();
|
| 298 | frist_get_map = 1;
|
| 299 | }
|
| 300 |
|
| 301 | strncpy(buff, num,sizeof(buff)-1);
|
| 302 | //printf("buff:%s\n", buff);
|
| 303 |
|
| 304 |
|
| 305 | for(i = 0; i < MAX_DIGIT_MAP_NUM; i++)
|
| 306 | {
|
| 307 | if(strlen(tz_digitmap[i]) != 0)
|
| 308 | {
|
| 309 | while(((j+n) <= MAX_PHONE_NUM_SIZE) && (tz_digitmap[i][j] != 0) && (buff[j] != 0))
|
| 310 | {
|
| 311 | if(tz_digitmap[i][j+n] == '[' )
|
| 312 | {
|
| 313 | n++;
|
| 314 | while(((j+n) <= MAX_PHONE_NUM_SIZE) && tz_digitmap[i][j+n] != ']')
|
| 315 | {
|
| 316 | if(((j+n+2) <= MAX_PHONE_NUM_SIZE) && tz_digitmap[i][j+n+1] == '-')
|
| 317 | {
|
| 318 | if(tz_digitmap[i][j+n] <= buff[j] && buff[j] <= tz_digitmap[i][j+n+2])
|
| 319 | {
|
| 320 | //printf("digit_map:%c, %c, %c\n", tz_digitmap[i][j+n], tz_digitmap[i][j+n+2], buff[j]);
|
| 321 | flag = 1;
|
| 322 | }
|
| 323 | n+=3;
|
| 324 | }
|
| 325 | else
|
| 326 | {
|
| 327 | if(tz_digitmap[i][j+n] == buff[j])
|
| 328 | {
|
| 329 | flag = 1;
|
| 330 | }
|
| 331 | n++;
|
| 332 | }
|
| 333 | }
|
| 334 |
|
| 335 | if(flag == 0)
|
| 336 | {
|
| 337 | break;
|
| 338 | }
|
| 339 |
|
| 340 | flag = 0;
|
| 341 |
|
| 342 |
|
| 343 | }
|
| 344 | else
|
| 345 | {
|
| 346 | if(tz_digitmap[i][j+n] != buff[j])
|
| 347 | {
|
| 348 | if(!(tz_digitmap[i][j+n] == 'X' || tz_digitmap[i][j+n] == 'x'))
|
| 349 | break;
|
| 350 | }
|
| 351 | }
|
| 352 | j++;
|
| 353 | if(((j+n) <= MAX_PHONE_NUM_SIZE) && (tz_digitmap[i][j+n] == 0) && (buff[j] == 0))
|
| 354 | {
|
| 355 | //ccapp_log("digit_map_call do Match: %d, %s, %s\n", i, tz_digitmap[i], buff);
|
| 356 | return 1;
|
| 357 | }
|
| 358 | }
|
| 359 | }
|
| 360 | n = 0;
|
| 361 | j = 0;
|
| 362 | }
|
| 363 |
|
| 364 | return 0;
|
| 365 | }
|
| 366 |
|
| 367 | #ifdef TEST_CCAPP
|
| 368 | VOID* zCc_main(VOID * pbuf)
|
| 369 | {
|
| 370 | MSG_BUF QueueMsg = {0};
|
| 371 | int MainQeueId = -1;
|
| 372 | int ret = -1;
|
| 373 | UINT8 bMsgType =1;
|
| 374 | int fd = -1;
|
| 375 | pthread_attr_t AtIndReaderAttr;
|
| 376 | pthread_t AtIndReaderThreadId;
|
| 377 |
|
| 378 | pthread_attr_init(&AtIndReaderAttr);
|
| 379 | pthread_attr_setstacksize(&AtIndReaderAttr,4*1024);
|
| 380 | fd = zCcApp_GetAtIndFd();
|
| 381 | AtIndReaderThreadId = pthread_create(&AtIndReaderThreadId, NULL, zCcApp_AtIndReader, (void*)&fd);
|
| 382 | if(AtIndReaderThreadId < 0)
|
| 383 | {
|
| 384 | return NULL;
|
| 385 | }
|
| 386 | while (1)
|
| 387 | {
|
| 388 | ret = msgrcv(MainQeueId, &QueueMsg, sizeof(MSG_BUF), bMsgType, 0);
|
| 389 | if(ret == -1)
|
| 390 | {
|
| 391 | return NULL;
|
| 392 | }
|
| 393 | else
|
| 394 | {
|
| 395 | switch (QueueMsg.src_id)
|
| 396 | {
|
| 397 | case MODULE_ID_CALL_CTRL: // AT Ind msg
|
| 398 | zCc_AtRecvMsgProc(&QueueMsg);
|
| 399 | break;
|
| 400 |
|
| 401 | case MODULE_ID_SLIC: // message from slic
|
| 402 | default:
|
| 403 | zCc_SlicMsgProc(&QueueMsg);
|
| 404 | break;
|
| 405 | }
|
| 406 | zCc_RunMaster(&QueueMsg);
|
| 407 | }
|
| 408 | }
|
| 409 |
|
| 410 | }
|
| 411 | #endif
|
| 412 | #ifndef TEST_CCAPP
|
| 413 |
|
| 414 | static int polarity_reversal_flag = 0;
|
| 415 | int get_polarity_reversal_flag(void)
|
| 416 | {
|
| 417 | return polarity_reversal_flag;
|
| 418 | }
|
| 419 |
|
| 420 | void check_polarity_reversal_cfg(void)
|
| 421 | {
|
| 422 | int rt;
|
| 423 | char buf[32];
|
| 424 |
|
| 425 | memset(buf, 0, sizeof(buf));
|
| 426 | rt = cfg_get_item("polarity_reversal",buf,sizeof(buf));
|
| 427 | if (rt != 0 || strlen(buf) == 0)
|
| 428 | {
|
| 429 | cfg_set("polarity_reversal", "0");
|
| 430 | cfg_save();
|
| 431 |
|
| 432 | polarity_reversal_flag = 0;
|
| 433 | return ;
|
| 434 | }
|
| 435 |
|
| 436 | polarity_reversal_flag = atoi(buf);
|
| 437 | }
|
| 438 |
|
| 439 | void check_wb_mode_cfg(void)
|
| 440 | {
|
| 441 | int rt;
|
| 442 | int val;
|
| 443 | char buf[64];
|
| 444 |
|
| 445 | memset(buf, 0, sizeof(buf));
|
| 446 | rt = cfg_get_item("wb_mode",buf,sizeof(buf));
|
| 447 | if (rt != 0 || strlen(buf) == 0)
|
| 448 | {
|
| 449 | cfg_set("wb_mode", "1");
|
| 450 | cfg_save();
|
| 451 |
|
| 452 | val = 1;
|
| 453 | }
|
| 454 | else
|
| 455 | val = atoi(buf);
|
| 456 |
|
| 457 | sprintf(buf, "at_cmd AT+ZIMSAMRW=%d", (val==0)?0:1);
|
| 458 | soft_system(buf);
|
| 459 |
|
| 460 | sprintf(buf, "echo \"at_cmd AT+ZIMSAMRW=%d\" > /tmp/log.ZIMSAMRW", (val==0)?0:1);
|
| 461 | soft_system(buf);
|
| 462 | }
|
| 463 |
|
| 464 |
|
| 465 | int main(VOID)
|
| 466 | {
|
| 467 | MSG_BUF QueueMsg = {0};
|
| 468 | int ret = -1;
|
| 469 | pthread_t CcAppMainThreadId;
|
| 470 | pthread_attr_t AtIndReaderAttr;
|
| 471 | pthread_t AtIndReaderThreadId;
|
| 472 | SLIC_Initial();
|
| 473 | SLIC_Dev_Init();
|
| 474 | soft_system("at_cmd AT+ZIMSTEST=\"EMCALL_TO_NORMAL\",1 ");
|
| 475 |
|
| 476 | check_wb_mode_cfg();
|
| 477 | check_polarity_reversal_cfg();
|
| 478 |
|
| 479 | g_zCc_MsqId = msgget(MODULE_ID_CALL_CTRL_LOCAL, IPC_CREAT | 0600);
|
| 480 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s g_zCc_MsqId %d, errno:%d\n",__FUNCTION__,g_zCc_MsqId,errno);
|
| 481 | if (g_zCc_MsqId == ZAT_INVALID_ID)
|
| 482 | {
|
| 483 | return 0;
|
| 484 | }
|
| 485 |
|
| 486 | g_zCc_AtRspId = msgget(MODULE_ID_CALL_CTRL, IPC_CREAT | 0600);
|
| 487 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s g_zCc_AtRspId %d, errno:%d\n",__FUNCTION__,g_zCc_AtRspId,errno);
|
| 488 |
|
| 489 | if (g_zCc_AtRspId == ZAT_INVALID_ID)
|
| 490 | {
|
| 491 | return 0;
|
| 492 | }
|
| 493 |
|
| 494 | g_zCc_getSlicEv_threadId = pthread_create(&CcAppMainThreadId, NULL, zCcApp_getSlicEv_entry,0);
|
| 495 |
|
| 496 | if(g_zCc_getSlicEv_threadId!=0)
|
| 497 | {
|
| 498 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCc_getSlicEv error, errno = %d \n",__FUNCTION__,errno);
|
| 499 | return -1;
|
| 500 | }
|
| 501 | else
|
| 502 | {
|
| 503 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCc_getSlicEv succ\n",__FUNCTION__);
|
| 504 | }
|
| 505 |
|
| 506 | pthread_attr_init(&AtIndReaderAttr);
|
| 507 | pthread_attr_setstacksize(&AtIndReaderAttr,4*1024);
|
| 508 | ret = pthread_create(&AtIndReaderThreadId, NULL, zCcApp_AtIndReader, 0);
|
| 509 | pthread_attr_destroy(&AtIndReaderAttr); //kw 2
|
| 510 | if(ret != 0) //cov m
|
| 511 | {
|
| 512 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCcApp_AtIndReader error, errno = %d \n",__FUNCTION__,errno);
|
| 513 | return -1;
|
| 514 | }
|
| 515 | else
|
| 516 | {
|
| 517 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s pthread_create zCcApp_AtIndReader succ\n",__FUNCTION__);
|
| 518 | }
|
| 519 |
|
| 520 | zCc_SendAtImsPlusReq(1,1);//ÉèÖÃimsplusÉϱ¨
|
| 521 |
|
| 522 | while (1)
|
| 523 | {
|
| 524 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","BACK TO main\n");
|
| 525 | ret = msgrcv(g_zCc_MsqId, &QueueMsg, sizeof(MSG_BUF)-sizeof(LONG), 0, 0);
|
| 526 | if(ret==-1)
|
| 527 | {
|
| 528 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","%s msgrcv return ret= %d errno=%d\n",__FUNCTION__,ret, errno);
|
| 529 | continue;
|
| 530 | }
|
| 531 | else
|
| 532 | {
|
| 533 | switch (QueueMsg.src_id)
|
| 534 | {
|
| 535 | case MODULE_ID_SLIC: // message from slic
|
| 536 | zCc_SlicMsgProc(&QueueMsg);
|
| 537 | break;
|
| 538 | default: // AT Ind msg
|
| 539 | zte_log_append(__FILE__, __LINE__, "zte_ccapp.log","recv msg %d from at_ctl\n",QueueMsg.usMsgCmd);
|
| 540 | if (QueueMsg.usMsgCmd==MSG_CMD_ZIMSPLUS_IND
|
| 541 | ||QueueMsg.usMsgCmd==MSG_CMD_DSCI_IND
|
| 542 | ||QueueMsg.usMsgCmd==MSG_CMD_ZCPI
|
| 543 | ||QueueMsg.usMsgCmd==MSG_CMD_ZVOICECHNL)
|
| 544 | {
|
| 545 | zCc_CheckSlaveState("in zCc_AtRecvMsgProc");
|
| 546 | zCc_AtRecvMsgProc(&QueueMsg);
|
| 547 | }
|
| 548 | break;
|
| 549 | }
|
| 550 | if (QueueMsg.usMsgCmd==MSG_CMD_VTS_RSP)
|
| 551 | {
|
| 552 | zCcApp_Vts_Rsp();
|
| 553 | }
|
| 554 | zCc_RunMaster(&QueueMsg);
|
| 555 | }
|
| 556 | }
|
| 557 |
|
| 558 | return 0;
|
| 559 | }
|
| 560 | #endif
|
| 561 |
|