Add timeout for ril.

Change-Id: I693f8c4e2ad74a308a2f3ff3fd615accc088823e
diff --git a/mbtk/include/mbtk/mbtk_log.h b/mbtk/include/mbtk/mbtk_log.h
index 60b0cb1..acddb7c 100755
--- a/mbtk/include/mbtk/mbtk_log.h
+++ b/mbtk/include/mbtk/mbtk_log.h
@@ -63,6 +63,7 @@
 #define LOG_VERBOSE_LEVEL 8
 #endif
 
+#if 0
 #define LOGV(fmt, args ...) \
     do{ \
         char *file_ptr_1001 = __FILE__; \
@@ -132,6 +133,35 @@
         } \
         mbtk_log(LOG_ERR_LEVEL, "%s#%s: " fmt, ptr_1001 + 1, line_1001, ##args); \
     } while(0)
+
+#else
+
+#define LOGV(fmt, args ...) \
+    do{ \
+        mbtk_log(LOG_VERBOSE_LEVEL, "%s()#%d: " fmt, __FUNCTION__, __LINE__, ##args); \
+    } while(0)
+
+#define LOGI(fmt, args...) \
+    do{ \
+        mbtk_log(LOG_INFO_LEVEL, "%s()#%d: " fmt, __FUNCTION__, __LINE__, ##args); \
+    } while(0)
+
+#define LOGD(fmt, args...) \
+    do{ \
+        mbtk_log(LOG_DEBUG_LEVEL, "%s()#%d: " fmt, __FUNCTION__, __LINE__, ##args); \
+    } while(0)
+
+#define LOGW(fmt, args...) \
+    do{ \
+        mbtk_log(LOG_WARN_LEVEL, "%s()#%d: " fmt, __FUNCTION__, __LINE__, ##args); \
+    } while(0)
+
+#define LOGE(fmt, args...) \
+        do{ \
+            mbtk_log(LOG_ERR_LEVEL, "%s()#%d: " fmt, __FUNCTION__, __LINE__, ##args); \
+        } while(0)
+#endif
+
 #endif
 
 #define MBTK_SOURCE_INFO_PRINT(name) \
diff --git a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
index 3631b67..d4664d9 100755
--- a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
+++ b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
@@ -2,6 +2,7 @@
 #define MBTK_INFO_INCLUDE
 #include <netinet/in.h>
 #include <pthread.h>
+#include <time.h>
 
 #include "mbtk_type.h"
 #include "mbtk_list.h"
@@ -254,6 +255,8 @@
     bool is_waitting;
     pthread_cond_t cond;
     pthread_mutex_t mutex;
+    timer_t timer_id;
+    uint16 msg_index;
 } ril_cli_thread_info_t;
 
 typedef struct {
diff --git a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
index a68ea83..710173e 100755
--- a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
@@ -13,7 +13,7 @@
 2024/08/15     LiuBin      Initial version
 2024/12/31     LiuBin      Auto open default port.
                            Add port index for open/close,close port only index is 0.
-
+2025/03/26     LiuBin      Add timeout for API(Default timeout is 10s).
 ******************************************************************************/
 
 #include <stdio.h>
@@ -55,6 +55,7 @@
 } ril_cli_info_t;
 
 #define EPOLL_LISTEN_MAX 100
+#define RIL_TIMEOUT_DEF 10  // Second
 
 static ril_cli_info_t ril_cli;
 static int pthread_id_index = 1;
@@ -86,12 +87,50 @@
         pthread_mutex_init(&cli_thread->mutex, NULL);
         pthread_cond_init(&cli_thread->cond, NULL);
         cli_thread->is_waitting = FALSE;
+
         list_add(ril_cli.cli_thread_list, cli_thread);
     }
 
     return cli_thread;
 }
 
+static void timer_start(ril_cli_thread_info_t* cli_thread, int initial_sec) {
+    struct sigevent sev;
+    struct itimerspec its;
+
+    // 设置信号通知方式
+    sev.sigev_notify = SIGEV_SIGNAL;
+    sev.sigev_signo = SIGRTMIN;  // 使用实时信号
+    sev.sigev_value.sival_ptr = &(cli_thread->pid);
+
+    // 创建计时器
+    if (timer_create(CLOCK_MONOTONIC, &sev, &(cli_thread->timer_id)) == -1) {
+        LOGE("timer_create() fail.");
+        return;
+    }
+
+    // 配置计时器时间
+    its.it_value.tv_sec = initial_sec;
+    its.it_value.tv_nsec = 0;
+    its.it_interval.tv_sec = 0;  // 0 表示单次触发
+    its.it_interval.tv_nsec = 0;
+
+    // 启动计时器
+    if (timer_settime(cli_thread->timer_id, 0, &its, NULL) == -1) {
+        LOGE("timer_settime() fail.");
+    } else {
+        LOGD("Timer start : %s, msg_index - %d, timeout - %ds", cli_thread->name, cli_thread->msg_index, initial_sec);
+    }
+}
+
+static void timer_cancel(ril_cli_thread_info_t* cli_thread) {
+    if (timer_delete(cli_thread->timer_id) == -1) {
+        LOGE("timer_delete() fail.");
+    } else {
+        LOGD("Timer cancel : %s, msg_index - %d", cli_thread->name, cli_thread->msg_index);
+    }
+}
+
 static void ril_thread_wait(ril_cli_thread_info_t* cli_thread)
 {
     if(!cli_thread->is_waitting) {
@@ -109,23 +148,16 @@
 }
 
 
-static void ril_thread_continue(pthread_t pid)
+static void ril_thread_continue(ril_cli_thread_info_t* cli_thread)
 {
-    ril_cli_thread_info_t* cli_thread = NULL;
-    list_first(ril_cli.cli_thread_list);
-    while ((cli_thread = (ril_cli_thread_info_t*) list_next(ril_cli.cli_thread_list)))
-    {
-        if(pid == cli_thread->pid) {
-            break;
-        }
-    }
-
     if(cli_thread) { // Found cli thread in list.
         if(cli_thread->is_waitting) {
             LOGD("Thread(%s) will continue...", cli_thread->name);
             pthread_mutex_lock(&cli_thread->mutex);
             pthread_cond_signal(&cli_thread->cond);
             pthread_mutex_unlock(&cli_thread->mutex);
+
+            cli_thread->msg_index = RIL_MSG_INDEX_INVALID;
         } else {
             LOGD("Thread(%s) not continue...", cli_thread->name);
             cli_thread->is_waitting = TRUE;
@@ -135,6 +167,61 @@
     }
 }
 
+static void timer_handler(int signo, siginfo_t *info, void *context) {
+    pthread_t *pid = (pthread_t *)info->si_value.sival_ptr;
+
+//     LOGD("%d timer expired.", *pid);
+    ril_cli_thread_info_t* cli_thread = NULL;
+    list_first(ril_cli.cli_thread_list);
+    while ((cli_thread = (ril_cli_thread_info_t*) list_next(ril_cli.cli_thread_list)))
+    {
+        if(*pid == cli_thread->pid) {
+            break;
+        }
+    }
+
+    if(cli_thread) { // Found cli thread in list.
+        LOGD("Timer handler : %s, msg_index - %d", cli_thread->name, cli_thread->msg_index);
+
+        if(cli_thread->msg_index == RIL_MSG_INDEX_INVALID) {
+            LOGE("Invalid message index.");
+            return;
+        }
+
+        pthread_mutex_lock(&ril_cli.send_mutex);
+        ril_msg_info_t* msg = NULL;
+        list_first(ril_cli.msg_list);
+        while ((msg = (ril_msg_info_t*) list_next(ril_cli.msg_list)))
+        {
+            if(cli_thread->msg_index == msg->pack->msg_index) {
+                break;
+            }
+        }
+
+        if(NULL == msg) { // No found message in msg list.
+            LOGE("Unknown msg.[Cannot occur]");
+        } else if(!msg->is_async) {
+            LOGD("Msg : Index - %d, ID - %s", cli_thread->msg_index,
+                id2str(msg->pack->msg_id));
+
+            *(msg->rsp_data_len) = 0;
+            *(msg->rsp_err) = MBTK_RIL_ERR_TIMEOUT;
+
+            ril_thread_continue(cli_thread);
+
+            if(list_remove(ril_cli.msg_list, msg)) {
+                ril_msg_pack_free(msg->pack);
+                free(msg);
+            }
+        } else {
+            LOGE("is_async[Cannot occur]");
+        }
+        pthread_mutex_unlock(&ril_cli.send_mutex);
+    } else {
+        LOGE("No found cli thread[Cannot occur].");
+    }
+}
+
 static int ril_ind_process(ril_msg_pack_info_t* pack)
 {
     LOGD("IND - %s", id2str(pack->msg_id));
@@ -207,8 +294,8 @@
         }
     }
 
-    if(NULL == msg) { // No found message in msg list.
-        LOGW("Unknown msg : Index - %d, Type - %s, ID - %s, Result - %s ,Length - %d",
+    if(NULL == msg) { // No found message in msg list.(message error or has deleted from list because of timeout)
+        LOGW("Unknown msg or timeout : Index - %d, Type - %s, ID - %s, Result - %s ,Length - %d",
             pack->msg_index, type2str(pack->msg_type), id2str(pack->msg_id), err2str(pack->err),
             pack->data_len);
         pthread_mutex_unlock(&ril_cli.send_mutex);
@@ -235,7 +322,19 @@
         *(msg->rsp_err) = pack->err;
 
         if(!msg->is_async) {
-            ril_thread_continue(msg->pid);
+            ril_cli_thread_info_t* cli_thread = NULL;
+            list_first(ril_cli.cli_thread_list);
+            while ((cli_thread = (ril_cli_thread_info_t*) list_next(ril_cli.cli_thread_list)))
+            {
+                if(msg->pid == cli_thread->pid) {
+                    break;
+                }
+            }
+            // LOGD("msg_index - %d", cli_thread->msg_index);
+            if(cli_thread->msg_index > 0) {
+                timer_cancel(cli_thread);
+            }
+            ril_thread_continue(cli_thread);
         }
 
 rm_msg_from_list:
@@ -379,7 +478,8 @@
                              const void         *req,
                              int                req_len,
                              void               *rsp,
-                             bool is_async)
+                             bool is_async,
+                             int timeout)
 {
     ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
     if(pack == NULL)
@@ -416,6 +516,14 @@
     // Send pack to server success.
     if(ril_pack_send(ril_cli.cli_fd, pack) >= RIL_SOCK_PACK_LEN_MIN) {
         if(!is_async) { // Waitting for response for sync request.
+            if(timeout == 0) {
+                timeout = RIL_TIMEOUT_DEF;
+            }
+            if(timeout > 0) {
+                cli_thread->msg_index = pack->msg_index;
+                timer_start(cli_thread, timeout);
+            }
+
             ril_thread_wait(cli_thread);
         }
 
@@ -546,6 +654,17 @@
             goto error;
         }
 
+        struct sigaction sa;
+
+        // 配置信号处理
+        sa.sa_flags = SA_SIGINFO;
+        sa.sa_sigaction = timer_handler;
+        sigemptyset(&sa.sa_mask);
+        if (sigaction(SIGRTMIN, &sa, NULL) == -1) {
+            LOGE("sigaction() fail.");
+            goto error;
+        }
+
         ril_cli.ril_ready = FALSE;
 
         // Waitting mbtk_rild ready...
@@ -692,7 +811,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VERSION, NULL, 0, version, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VERSION, NULL, 0, version, FALSE, 0);
 }
 
 /*
@@ -716,7 +835,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEL, NULL, 0, model, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEL, NULL, 0, model, FALSE, 0);
 }
 
 /*
@@ -740,7 +859,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_IMEI, NULL, 0, imei, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_IMEI, NULL, 0, imei, FALSE, 0);
 }
 
 
@@ -765,7 +884,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_SN, NULL, 0, sn, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_SN, NULL, 0, sn, FALSE, 0);
 }
 
 
@@ -790,7 +909,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MEID, NULL, 0, meid, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MEID, NULL, 0, meid, FALSE, 0);
 }
 
 
@@ -815,7 +934,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, NULL, 0, volte_state, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, NULL, 0, volte_state, FALSE, 0);
 }
 
 /*
@@ -845,7 +964,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, &volte_state, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, &volte_state, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -870,7 +989,7 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE, 0);
     *radio_state = (mbtk_radio_state_enum)result;
     return err;
 }
@@ -904,7 +1023,7 @@
     buff[0] = (uint8)radio_state;
     buff[1] = reset_modem ? 1 : 0;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE, 0);
 }
 
 /*
@@ -936,7 +1055,7 @@
 
     int16 result;
     uint8 temp_temp = (uint8)type;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE, 0);
     *temp = (int16)result;
     return err;
 }
@@ -965,7 +1084,7 @@
     }
 
     char buff[RIL_SOCK_MSG_LEN_MAX] = {0};
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE, 0);
     if(MBTK_RIL_ERR_SUCCESS == err)
     {
         memcpy(time_str,buff,strlen(buff));
@@ -1038,7 +1157,7 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE, 0);
     *sim_state = (mbtk_sim_state_enum)result;
     return err;
 }
@@ -1065,7 +1184,7 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE, 0);
     *sim_card_type = (mbtk_sim_card_type_enum)result;
     return err;
 }
@@ -1091,7 +1210,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_IMSI, NULL, 0, imsi, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_IMSI, NULL, 0, imsi, FALSE, 0);
 }
 
 /*
@@ -1115,7 +1234,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_ICCID, NULL, 0, iccid, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_ICCID, NULL, 0, iccid, FALSE, 0);
 }
 
 /*
@@ -1139,7 +1258,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PN, NULL, 0, phone_number, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PN, NULL, 0, phone_number, FALSE, 0);
 }
 
 /*
@@ -1164,7 +1283,7 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE, 0);
     *lock_state = result;
     return err;
 }
@@ -1191,7 +1310,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -1215,7 +1334,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE, 0);
 }
 
 /*
@@ -1239,7 +1358,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PLMN, NULL, 0, plmn_list, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PLMN, NULL, 0, plmn_list, FALSE, 0);
 }
 
 /*
@@ -1263,7 +1382,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_AVAILABLE, NULL, 0, net_array, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_AVAILABLE, NULL, 0, net_array, FALSE, -1);
 }
 
 /*
@@ -1287,7 +1406,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -1311,7 +1430,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, NULL, 0, net, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, NULL, 0, net, FALSE, 0);
 }
 
 /*
@@ -1336,7 +1455,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
 }
 
 /*
@@ -1361,7 +1480,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
 }
 
 /*
@@ -1385,7 +1504,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -1409,7 +1528,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, NULL, 0, cell_array, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, NULL, 0, cell_array, FALSE, 0);
 }
 
 /*
@@ -1439,7 +1558,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, info, strlen(info), response, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, info, strlen(info), response, FALSE, 0);
 }
 
 /*
@@ -1463,7 +1582,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SIGNAL, NULL, 0, signal, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SIGNAL, NULL, 0, signal, FALSE, 0);
 }
 
 /*
@@ -1487,7 +1606,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_REG, NULL, 0, reg, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_REG, NULL, 0, reg, FALSE, 0);
 }
 
 /*
@@ -1511,7 +1630,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, NULL, 0, oos_info, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, NULL, 0, oos_info, FALSE, 0);
 }
 
 /*
@@ -1535,7 +1654,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, oos_info, sizeof(mbtk_ril_oos_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, oos_info, sizeof(mbtk_ril_oos_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -1564,7 +1683,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_POWERIND, &wakeup_state, sizeof(uint8), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_POWERIND, &wakeup_state, sizeof(uint8), NULL, FALSE, 0);
 }
 
 /*
@@ -1588,7 +1707,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE, 0);
 }
 
 
@@ -1625,7 +1744,7 @@
         }
     }
 
-    err = ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), &return_cid, FALSE);
+    err = ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), &return_cid, FALSE, 0);
     apn->cid = return_cid;
     return err;
 }
@@ -1674,7 +1793,7 @@
         info.timeout = (uint16)10;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE, 0);
 }
 
 /*
@@ -1708,7 +1827,7 @@
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
     }
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -1741,7 +1860,7 @@
     info.type = MBTK_DATA_CALL_STATE;
     info.cid = cid;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE, 0);
 }
 
 /*
@@ -1766,7 +1885,7 @@
     }
 
     uint8 state;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE, 0);
     *sms_state = state;
     return err;
 }
@@ -1798,7 +1917,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE, 0);
 }
 
 /*
@@ -1832,7 +1951,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGS, cmgs, strlen(cmgs), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGS, cmgs, strlen(cmgs), resp, FALSE, 0);
 }
 
 /*
@@ -1865,7 +1984,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGW, cmgw, strlen(cmgw), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGW, cmgw, strlen(cmgw), resp, FALSE, 0);
 }
 
 /*
@@ -1893,7 +2012,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, cmdg, strlen(cmdg), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, cmdg, strlen(cmdg), NULL, FALSE, 0);
 }
 
 /*
@@ -1921,7 +2040,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, NULL, 0, cmdg, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, NULL, 0, cmdg, FALSE, 0);
 }
 
 
@@ -1950,7 +2069,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGL, cmgl, strlen(cmgl), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGL, cmgl, strlen(cmgl), resp, FALSE, 0);
 }
 
 /*
@@ -1974,7 +2093,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, NULL, 0, buf, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, NULL, 0, buf, FALSE, 0);
 }
 
 /*
@@ -2002,7 +2121,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, csca, strlen(csca), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, csca, strlen(csca), NULL, FALSE, 0);
 }
 
 /*
@@ -2030,7 +2149,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSMP, csmp, strlen(csmp), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSMP, csmp, strlen(csmp), NULL, FALSE, 0);
 }
 
 /*
@@ -2058,7 +2177,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCB, cscb, strlen(cscb), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCB, cscb, strlen(cscb), NULL, FALSE, 0);
 }
 
 /*
@@ -2088,7 +2207,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CNMI, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CNMI, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2120,7 +2239,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMSS, cmss, strlen(cmss), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMSS, cmss, strlen(cmss), resp, FALSE, 0);
 }
 
 /*
@@ -2144,7 +2263,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, NULL, 0, mem, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, NULL, 0, mem, FALSE, 0);
 }
 
 
@@ -2173,7 +2292,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, mem, strlen(mem), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, mem, strlen(mem), resp, FALSE, 0);
 }
 
 /*
@@ -2216,7 +2335,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGR, &index, sizeof(uint8), resp, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGR, &index, sizeof(uint8), resp, FALSE, 0);
 }
 
 
@@ -2428,7 +2547,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_START, phone_number, strlen(phone_number), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_START, phone_number, strlen(phone_number), NULL, FALSE, 0);
 }
 
 /*
@@ -2453,7 +2572,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_ANSWER, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_ANSWER, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2478,7 +2597,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2503,7 +2622,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_A, &phone_id, sizeof(uint8), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_A, &phone_id, sizeof(uint8), NULL, FALSE, 0);
 }
 
 /*
@@ -2528,7 +2647,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_B, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_B, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2553,7 +2672,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_C, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_C, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2577,7 +2696,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_WAITIN, NULL, 0, reg, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_WAITIN, NULL, 0, reg, FALSE, 0);
 }
 
 /*
@@ -2601,7 +2720,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, NULL, 0, mute_state, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, NULL, 0, mute_state, FALSE, 0);
 }
 
 /*
@@ -2631,7 +2750,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, &mute_state, sizeof(uint8), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, &mute_state, sizeof(uint8), NULL, FALSE, 0);
 }
 
 /*
@@ -2656,7 +2775,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE, 0);
 }
 
 mbtk_ril_err_enum mbtk_centric_set(mbtk_ril_handle* handle, int centric)
@@ -2677,7 +2796,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, &centric, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, &centric, 1, NULL, FALSE, 0);
 }
 
 mbtk_ril_err_enum mbtk_centric_get(mbtk_ril_handle* handle, int *centric)
@@ -2698,7 +2817,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, NULL, 0, centric, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, NULL, 0, centric, FALSE, 0);
 }
 
 
@@ -2725,7 +2844,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -2750,7 +2869,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2781,7 +2900,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE, 0);
 }
 
 /*
@@ -2806,7 +2925,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE, 0);
 }
 
 
@@ -2832,7 +2951,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2857,7 +2976,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -2882,7 +3001,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE, 0);
 }
 
 /*
@@ -2907,7 +3026,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -2932,7 +3051,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -2959,7 +3078,7 @@
 
     memset(type, 0, sizeof(mbtk_ecall_dial_type_enum));
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE, 0);
 }
 
 /*
@@ -2984,7 +3103,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3011,7 +3130,7 @@
 
     memset(mode, 0, sizeof(mbtk_ecall_mode_type_enum));
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE, 0);
 }
 
 /*
@@ -3036,7 +3155,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -3063,7 +3182,7 @@
 
     uint32 type = cfg->type;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE, 0);
 }
 
 /*
@@ -3088,7 +3207,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE, 0);
 }
 
 /*
@@ -3113,7 +3232,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE, 0);
 }
 
 /*
@@ -3138,7 +3257,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3163,7 +3282,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE, 0);
 }
 
 #if 0
@@ -3227,7 +3346,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3249,7 +3368,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_NET_REG_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3271,7 +3390,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_CALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3293,7 +3412,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SMS_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3315,7 +3434,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_RADIO_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3337,7 +3456,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SIM_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3359,7 +3478,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_PDP_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3381,7 +3500,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3400,7 +3519,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_ECALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
diff --git a/mbtk/mbtk_rild_v2/src/ril_dev.c b/mbtk/mbtk_rild_v2/src/ril_dev.c
index 9f14bc6..f2de0f1 100755
--- a/mbtk/mbtk_rild_v2/src/ril_dev.c
+++ b/mbtk/mbtk_rild_v2/src/ril_dev.c
@@ -105,6 +105,9 @@
 static int req_version_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
+
+//    sleep(3);
+
     int err = at_send_command_multiline(port, "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){