case RIL_REQUEST_RESET_RADIO: LOGD("got request RIL_REQUEST_RESET_RADIO"); #ifdef MODEM_RESET int type = ((int *)data)[0]; LOGD("======Reset type = %d, data[0]=%d========", type, ((int *)data)[0]); ATReset(type); #endif RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); break;
ATReset():
/* Called on command or reader thread * * AT reset function: * resetType: 0 means normal reset * 1 means reset when AP sleep, this time just need colse tty nodes , * and reopen them, and kernel has created noded success. */ static void ATReset(int resetType) { int fd = -1; ssize_t written; static int reset_num = 0; static int sleep_reset_num = 0; s_resetType = resetType; if(resetType == 0){ reset_num++; LOGI("AT channel normal reset , s_resetting=%d, reset_num=%d\n", s_resetting, reset_num); if(s_closed == 1){ LOGI("AT channel reset, but the ttynode is colsed, so nothing need to do\n"); return; } s_resetting = 1; pthread_mutex_lock(&s_reset_mutex); pthread_cond_wait(&s_reset_cond, &s_reset_mutex); pthread_mutex_unlock(&s_reset_mutex); //may be need wait 2s modem_PowerOn(); s_resetting = 0; pthread_mutex_lock(&s_state_mutex); pthread_cond_broadcast (&s_state_cond); pthread_mutex_unlock(&s_state_mutex); LOGI("*****completed reset operation,start to open tty node\n"); write2Kernel("*****completed reset operation,start to open tty node\n"); }else if(resetType == 1){ sleep_reset_num++; LOGI("AT channel AP sleep reset, s_resetting=%d, sleep_reset_num=%d\n", s_resetting, sleep_reset_num); RIL_requestTimedCallback(initializeCallback, NULL, &TIMEVAL_0); } return; }