Add Multiple AT channels supported for ril api v2

Change-Id: I53f574c85d07bd7b8e0dd15d2e596d23c8772907
diff --git a/mbtk/mbtk_rild_v2/inc/atchannel.h b/mbtk/mbtk_rild_v2/inc/atchannel.h
index b97cb27..43efd0e 100755
--- a/mbtk/mbtk_rild_v2/inc/atchannel.h
+++ b/mbtk/mbtk_rild_v2/inc/atchannel.h
@@ -22,6 +22,7 @@
 extern "C" {
 #endif
 #include "mbtk_type.h"
+#include "mbtk_ril_api.h"
 
 /* define AT_DEBUG to send AT traffic to /tmp/radio-at.log" */
 #define AT_DEBUG  0
@@ -44,7 +45,6 @@
                                           response */
 #define AT_ERROR_TIMEOUT_CLOSE    (-7)
 
-
 typedef enum
 {
     NO_RESULT,   /* no intermediate response expected */
@@ -87,8 +87,8 @@
  */
 typedef void (*ATUnsolHandler)(const char *s, const char *sms_pdu);
 
-int at_open(int at_fd, int uart_fd, ATUnsolHandler h);
-void at_close();
+int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h);
+void at_close(ATPortType_enum port);
 
 /* This callback is invoked on the command thread.
    You should reset or handshake here to avoid getting out of sync */
@@ -101,26 +101,26 @@
    channel is already closed */
 void at_set_on_reader_closed(void (*onClose)(void));
 
-int at_send_command_singleline (const char *command,
+int at_send_command_singleline (ATPortType_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse);
-int at_send_command_singleline_with_timeout (const char *command,
+int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec);
 
-int at_send_command_numeric (const char *command,
+int at_send_command_numeric (ATPortType_enum port, const char *command,
                              ATResponse **pp_outResponse);
 
-int at_send_command_multiline (const char *command,
+int at_send_command_multiline (ATPortType_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse);
 
 
-int at_handshake();
+int at_handshake(ATPortType_enum port);
 
-int at_send_command (const char *command, ATResponse **pp_outResponse);
+int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse);
 
-int at_send_command_sms (const char *command, const char *pdu,
+int at_send_command_sms (ATPortType_enum port, const char *command, const char *pdu,
                          const char *responsePrefix,
                          ATResponse **pp_outResponse);
 
@@ -136,8 +136,8 @@
 
 AT_CME_Error at_get_cme_error(const ATResponse *p_response);
 
-mbtk_ril_at_state_enum at_state_get();
-void at_state_set(mbtk_ril_at_state_enum state);
+mbtk_ril_at_state_enum at_state_get(ATPortType_enum port);
+void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state);
 bool at_rsp_check(ATResponse *p_response);
 
 #ifdef __cplusplus
diff --git a/mbtk/mbtk_rild_v2/inc/ril_info.h b/mbtk/mbtk_rild_v2/inc/ril_info.h
index c07e3f0..71e6bd7 100755
--- a/mbtk/mbtk_rild_v2/inc/ril_info.h
+++ b/mbtk/mbtk_rild_v2/inc/ril_info.h
@@ -35,6 +35,7 @@
 typedef struct
 {
     int fd;
+    ATPortType_enum port;
 
     uint32 ind_num;
     uint16 ind_register[IND_REGISTER_MAX];
@@ -52,12 +53,12 @@
     mbtk_sim_card_type_enum sim_type;
     int sock_listen_fd;
     int epoll_fd;
-    bool at_process;
+    bool at_process[ATPORTTYPE_NUM];
 
     list_node_t *sock_client_list;      // Refor to : sock_cli_info_t
-    mbtk_queue_node_t msg_queue;        // Refor to : ril_msg_queue_info_t
-    pthread_cond_t msg_cond;
-    pthread_mutex_t msg_mutex;
+    mbtk_queue_node_t msg_queue[ATPORTTYPE_NUM];        // Refor to : ril_msg_queue_info_t
+    pthread_cond_t msg_cond[ATPORTTYPE_NUM];
+    pthread_mutex_t msg_mutex[ATPORTTYPE_NUM];
 } ril_info_t;
 
 typedef struct {
@@ -119,12 +120,12 @@
 extern ril_info_t ril_info;
 
 
-mbtk_radio_state_enum ril_radio_state_get();
-mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset);
+mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port);
+mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset);
 
-mbtk_sim_state_enum ril_sim_state_get();
+mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port);
 
-void apn_auto_conf_from_prop();
+void apn_auto_conf_from_prop(ATPortType_enum port);
 
 bool is_ipv4(const char *ip);
 
diff --git a/mbtk/mbtk_rild_v2/src/atchannel.c b/mbtk/mbtk_rild_v2/src/atchannel.c
index fe96df1..8a19159 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -38,20 +38,20 @@
 #define HANDSHAKE_TIMEOUT_MSEC 500
 #define AT_BUFF_MAX 1024
 
-static pthread_t s_tid_reader;
-static int s_at_fd = -1;    /* fd of the AT channel */
+static pthread_t s_tid_reader[ATPORTTYPE_NUM];
+static int s_at_fd[ATPORTTYPE_NUM] = {-1};    /* fd of the AT channel */
 static int s_uart_fd = -1;    /* fd of the UART channel */
 
 static ATUnsolHandler s_unsolHandler;
 
 /* for input buffering */
 
-static char s_ATBuffer[MAX_AT_RESPONSE+1];
-static char *s_ATBufferCur = s_ATBuffer;
+static char s_ATBuffer[ATPORTTYPE_NUM][MAX_AT_RESPONSE+1];
+static char *s_ATBufferCur[ATPORTTYPE_NUM] = {s_ATBuffer[ATPORTTYPE_0], s_ATBuffer[ATPORTTYPE_1], s_ATBuffer[ATPORTTYPE_2]};
 static char s_UartBuffer[MAX_AT_RESPONSE+1];
 static char *s_UartBufferCur = s_UartBuffer;
 
-static mbtk_ril_at_state_enum at_state = RIL_AT_STATE_CLOSED;
+static mbtk_ril_at_state_enum at_state[ATPORTTYPE_NUM] = {RIL_AT_STATE_CLOSED};
 
 #if AT_DEBUG
 void  AT_DUMP(const char*  prefix, const char*  buff, int  len)
@@ -72,22 +72,22 @@
  */
 
 // "Wait" when AT process...
-static pthread_mutex_t s_commandmutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_commandcond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t s_commandmutex[ATPORTTYPE_NUM] = {PTHREAD_MUTEX_INITIALIZER};
+static pthread_cond_t s_commandcond[ATPORTTYPE_NUM] = {PTHREAD_COND_INITIALIZER};
 
-static ATCommandType s_type;
-static const char *s_responsePrefix = NULL;
-static const char *s_smsPDU = NULL;
-static ATResponse *sp_response = NULL;
-static char s_curr_at[AT_BUFF_MAX];
+static ATCommandType s_type[ATPORTTYPE_NUM];
+static const char *s_responsePrefix[ATPORTTYPE_NUM] = {NULL};
+static const char *s_smsPDU[ATPORTTYPE_NUM] = {NULL};
+static ATResponse *sp_response[ATPORTTYPE_NUM] = {NULL};
+static char s_curr_at[ATPORTTYPE_NUM][AT_BUFF_MAX];
 
 static void (*s_onTimeout)(void) = NULL;
 static void (*s_onReaderClosed)(void) = NULL;
 static int s_readerClosed;
 
-static void onReaderClosed();
-static int writeCtrlZ (const char *s);
-static int writeline (const char *s);
+static void onReaderClosed(ATPortType_enum port);
+static int writeCtrlZ (ATPortType_enum port, const char *s);
+static int writeline (ATPortType_enum port, const char *s);
 
 typedef struct
 {
@@ -137,7 +137,7 @@
 
 
 /** add an intermediate response to sp_response*/
-static void addIntermediate(const char *line)
+static void addIntermediate(ATPortType_enum port, const char *line)
 {
     ATLine *p_new;
 
@@ -151,8 +151,8 @@
     /* note: this adds to the head of the list, so the list
        will be in reverse order of lines received. the order is flipped
        again before passing on to the command issuer */
-    p_new->p_next = sp_response->p_intermediates;
-    sp_response->p_intermediates = p_new;
+    p_new->p_next = sp_response[port]->p_intermediates;
+    sp_response[port]->p_intermediates = p_new;
 }
 
 
@@ -170,7 +170,7 @@
     "NO ANSWER",
     "NO DIALTONE",
 };
-static int isFinalResponseError(const char *line)
+static int isFinalResponseError(ATPortType_enum port, const char *line)
 {
     size_t i;
 
@@ -182,7 +182,7 @@
         }
     }
 
-    if(!strncasecmp(s_curr_at, "ATD", 3) && strStartsWith(line, "NO CARRIER"))
+    if(!strncasecmp(s_curr_at[port], "ATD", 3) && strStartsWith(line, "NO CARRIER"))
     {
         return 1;
     }
@@ -220,9 +220,9 @@
  * See 27.007 annex B
  * WARNING: NO CARRIER and others are sometimes unsolicited
  */
-static int isFinalResponse(const char *line)
+static int isFinalResponse(ATPortType_enum port, const char *line)
 {
-    return isFinalResponseSuccess(line) || isFinalResponseError(line);
+    return isFinalResponseSuccess(line) || isFinalResponseError(port, line);
 }
 
 /**
@@ -252,12 +252,12 @@
 
 
 /** assumes s_commandmutex is held */
-static void handleFinalResponse(const char *line)
+static void handleFinalResponse(ATPortType_enum port, const char *line)
 {
-    sp_response->finalResponse = strdup(line);
+    sp_response[port]->finalResponse = strdup(line);
 
     //LOGD("AT complete (pthread_cond_signal): %s",line);
-    pthread_cond_signal(&s_commandcond);
+    pthread_cond_signal(&s_commandcond[port]);
 }
 
 static void handleUnsolicited(const char *line)
@@ -268,43 +268,43 @@
     }
 }
 
-static void processLine(const char *line)
+static void processLine(ATPortType_enum port, const char *line)
 {
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 //    LOGD("LINE : %s", line);
-    if (sp_response == NULL)
+    if (sp_response[port] == NULL)
     {
         /* no command pending */
         handleUnsolicited(line);
     }
     else if (isFinalResponseSuccess(line))
     {
-        sp_response->success = 1;
-        handleFinalResponse(line);
+        sp_response[port]->success = 1;
+        handleFinalResponse(port, line);
     }
-    else if (isFinalResponseError(line))
+    else if (isFinalResponseError(port, line))
     {
-        sp_response->success = 0;
-        handleFinalResponse(line);
+        sp_response[port]->success = 0;
+        handleFinalResponse(port, line);
     }
-    else if (s_smsPDU != NULL && 0 == strcmp(line, "> "))
+    else if (s_smsPDU[port] != NULL && 0 == strcmp(line, "> "))
     {
         // See eg. TS 27.005 4.3
         // Commands like AT+CMGS have a "> " prompt
-        writeCtrlZ(s_smsPDU);
-        s_smsPDU = NULL;
+        writeCtrlZ(port, s_smsPDU[port]);
+        s_smsPDU[port] = NULL;
     }
-    else switch (s_type)
+    else switch (s_type[port])
         {
             case NO_RESULT:
                 handleUnsolicited(line);
                 break;
             case NUMERIC:
-                if (sp_response->p_intermediates == NULL
+                if (sp_response[port]->p_intermediates == NULL
                     && isdigit(line[0])
                    )
                 {
-                    addIntermediate(line);
+                    addIntermediate(port, line);
                 }
                 else
                 {
@@ -314,8 +314,8 @@
                 }
                 break;
             case SINGLELINE:
-                if (sp_response->p_intermediates == NULL
-                    && strStartsWith (line, s_responsePrefix)
+                if (sp_response[port]->p_intermediates == NULL
+                    && strStartsWith (line, s_responsePrefix[port])
                    )
                 {
                     if(*line == '"')
@@ -331,12 +331,12 @@
                                 ptr--;
                             }
                         }
-                        addIntermediate(line_temp);
+                        addIntermediate(port, line_temp);
                         free(line_temp);
                     }
                     else
                     {
-                        addIntermediate(line);
+                        addIntermediate(port, line);
                     }
                 }
                 else
@@ -346,9 +346,9 @@
                 }
                 break;
             case MULTILINE:
-                if (strStartsWith (line, s_responsePrefix))
+                if (strStartsWith (line, s_responsePrefix[port]))
                 {
-                    addIntermediate(line);
+                    addIntermediate(port, line);
                 }
                 else
                 {
@@ -357,12 +357,12 @@
                 break;
 
             default: /* this should never be reached */
-                LOGE("Unsupported AT command type %d\n", s_type);
+                LOGE("Unsupported AT command type %d\n", s_type[port]);
                 handleUnsolicited(line);
                 break;
         }
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 }
 
 
@@ -397,7 +397,7 @@
  * have buffered stdio.
  */
 
-static const char *readline()
+static const char *readline(ATPortType_enum port)
 {
     ssize_t count;
 
@@ -409,33 +409,33 @@
      * mean "buffer consumed completely". If it points to a character, than
      * the buffer continues until a \0
      */
-    if (*s_ATBufferCur == '\0')
+    if (*s_ATBufferCur[port] == '\0')
     {
         /* empty buffer */
-        s_ATBufferCur = s_ATBuffer;
-        *s_ATBufferCur = '\0';
-        p_read = s_ATBuffer;
+        s_ATBufferCur[port] = s_ATBuffer[port];
+        *s_ATBufferCur[port] = '\0';
+        p_read = s_ATBuffer[port];
     }
     else       /* *s_ATBufferCur != '\0' */
     {
         /* there's data in the buffer from the last read */
 
         // skip over leading newlines
-        while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n')
-            s_ATBufferCur++;
+        while (*s_ATBufferCur[port] == '\r' || *s_ATBufferCur[port] == '\n')
+            s_ATBufferCur[port]++;
 
-        p_eol = findNextEOL(s_ATBufferCur);
+        p_eol = findNextEOL(s_ATBufferCur[port]);
 
         if (p_eol == NULL)
         {
             /* a partial line. move it up and prepare to read more */
             size_t len;
 
-            len = strlen(s_ATBufferCur);
+            len = strlen(s_ATBufferCur[port]);
 
-            memmove(s_ATBuffer, s_ATBufferCur, len + 1);
-            p_read = s_ATBuffer + len;
-            s_ATBufferCur = s_ATBuffer;
+            memmove(s_ATBuffer[port], s_ATBufferCur[port], len + 1);
+            p_read = s_ATBuffer[port] + len;
+            s_ATBufferCur[port] = s_ATBuffer[port];
         }
         /* Otherwise, (p_eol !- NULL) there is a complete line  */
         /* that will be returned the while () loop below        */
@@ -443,19 +443,19 @@
 
     while (p_eol == NULL)
     {
-        if (0 == MAX_AT_RESPONSE - (p_read - s_ATBuffer))
+        if (0 == MAX_AT_RESPONSE - (p_read - s_ATBuffer[port]))
         {
             LOGE("ERROR: Input line exceeded buffer\n");
             /* ditch buffer and start over again */
-            s_ATBufferCur = s_ATBuffer;
-            *s_ATBufferCur = '\0';
-            p_read = s_ATBuffer;
+            s_ATBufferCur[port] = s_ATBuffer[port];
+            *s_ATBufferCur[port] = '\0';
+            p_read = s_ATBuffer[port];
         }
 
         do
         {
-            count = read(s_at_fd, p_read,
-                         MAX_AT_RESPONSE - (p_read - s_ATBuffer));
+            count = read(s_at_fd[port], p_read,
+                         MAX_AT_RESPONSE - (p_read - s_ATBuffer[port]));
             usleep(10000);
         }
         while (count < 0 && errno == EINTR);
@@ -467,10 +467,10 @@
             p_read[count] = '\0';
 
             // skip over leading newlines
-            while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n')
-                s_ATBufferCur++;
+            while (*s_ATBufferCur[port] == '\r' || *s_ATBufferCur[port] == '\n')
+                s_ATBufferCur[port]++;
 
-            p_eol = findNextEOL(s_ATBufferCur);
+            p_eol = findNextEOL(s_ATBufferCur[port]);
             p_read += count;
         }
         else if (count <= 0)
@@ -490,9 +490,9 @@
 
     /* a full line in the buffer. Place a \0 over the \r and return */
 
-    ret = s_ATBufferCur;
+    ret = s_ATBufferCur[port];
     *p_eol = '\0';
-    s_ATBufferCur = p_eol + 1; /* this will always be <= p_read,    */
+    s_ATBufferCur[port] = p_eol + 1; /* this will always be <= p_read,    */
     /* and there will be a \0 at *p_read */
 
     LOGD("AT< %s", ret);
@@ -603,19 +603,19 @@
 
 
 
-static void onReaderClosed()
+static void onReaderClosed(ATPortType_enum port)
 {
     LOGD("onReaderClosed()");
     if (s_onReaderClosed != NULL && s_readerClosed == 0)
     {
 
-        pthread_mutex_lock(&s_commandmutex);
+        pthread_mutex_lock(&s_commandmutex[port]);
 
         s_readerClosed = 1;
 
-        pthread_cond_signal(&s_commandcond);
+        pthread_cond_signal(&s_commandcond[port]);
 
-        pthread_mutex_unlock(&s_commandmutex);
+        pthread_mutex_unlock(&s_commandmutex[port]);
 
         s_onReaderClosed();
     }
@@ -632,11 +632,12 @@
 static void *readerLoop(void *arg)
 {
     UNUSED(arg);
+    ATPortType_enum *port = (ATPortType_enum*)arg;
     for (;;)
     {
         const char * line;
 
-        line = readline();
+        line = readline(*port);
 
         if (line == NULL)
         {
@@ -661,7 +662,7 @@
             // till next call to 'readline()' hence making a copy of line
             // before calling readline again.
             line1 = strdup(line);
-            line2 = readline();
+            line2 = readline(*port);
 
             if (line2 == NULL)
             {
@@ -677,11 +678,13 @@
         }
         else
         {
-            processLine(line);
+            processLine(*port, line);
         }
     }
 
-    onReaderClosed();
+    onReaderClosed(*port);
+
+    free(port);
 
     return NULL;
 }
@@ -689,6 +692,7 @@
 static void *readerUrcLoop(void *arg)
 {
     UNUSED(arg);
+    ATPortType_enum *port = (ATPortType_enum*)arg;
     for (;;)
     {
         const char *line;
@@ -703,7 +707,9 @@
         handleUnsolicited(line);
     }
 
-    onReaderClosed();
+    onReaderClosed(*port);
+
+    free(port);
 
     return NULL;
 }
@@ -716,13 +722,13 @@
  * This function exists because as of writing, android libc does not
  * have buffered stdio.
  */
-static int writeline (const char *s)
+static int writeline (ATPortType_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
     ssize_t written;
 
-    if (s_at_fd < 0 || s_readerClosed > 0)
+    if (s_at_fd[port] < 0 || s_readerClosed > 0)
     {
         return AT_ERROR_CHANNEL_CLOSED;
     }
@@ -731,15 +737,15 @@
 
     AT_DUMP( ">> ", s, strlen(s) );
 
-    memset(s_curr_at, 0x0, AT_BUFF_MAX);
-    memcpy(s_curr_at, s, strlen(s));
+    memset(s_curr_at[port], 0x0, AT_BUFF_MAX);
+    memcpy(s_curr_at[port], s, strlen(s));
 
     /* the main string */
     while (cur < len)
     {
         do
         {
-            written = write (s_at_fd, s + cur, len - cur);
+            written = write (s_at_fd[port], s + cur, len - cur);
         }
         while (written < 0 && errno == EINTR);
 
@@ -755,7 +761,7 @@
 
     do
     {
-        written = write (s_at_fd, "\r", 1);
+        written = write (s_at_fd[port], "\r", 1);
     }
     while ((written < 0 && errno == EINTR) || (written == 0));
 
@@ -767,13 +773,13 @@
     return 0;
 }
 
-static int writeCtrlZ (const char *s)
+static int writeCtrlZ (ATPortType_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
     ssize_t written;
 
-    if (s_at_fd < 0 || s_readerClosed > 0)
+    if (s_at_fd[port] < 0 || s_readerClosed > 0)
     {
         return AT_ERROR_CHANNEL_CLOSED;
     }
@@ -787,7 +793,7 @@
     {
         do
         {
-            written = write (s_at_fd, s + cur, len - cur);
+            written = write (s_at_fd[port], s + cur, len - cur);
         }
         while (written < 0 && errno == EINTR);
 
@@ -803,7 +809,7 @@
 
     do
     {
-        written = write (s_at_fd, "\032", 1);
+        written = write (s_at_fd[port], "\032", 1);
     }
     while ((written < 0 && errno == EINTR) || (written == 0));
 
@@ -815,16 +821,16 @@
     return 0;
 }
 
-static void clearPendingCommand()
+static void clearPendingCommand(ATPortType_enum port)
 {
-    if (sp_response != NULL)
+    if (sp_response[port] != NULL)
     {
-        at_response_free(sp_response);
+        at_response_free(sp_response[port]);
     }
 
-    sp_response = NULL;
-    s_responsePrefix = NULL;
-    s_smsPDU = NULL;
+    sp_response[port] = NULL;
+    s_responsePrefix[port] = NULL;
+    s_smsPDU[port] = NULL;
 }
 
 
@@ -832,22 +838,27 @@
  * Starts AT handler on stream "fd'
  * returns 0 on success, -1 on error
  */
-int at_open(int at_fd, int uart_fd, ATUnsolHandler h)
+int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h)
 {
     int ret;
     pthread_attr_t attr;
 
-    s_at_fd = at_fd;
+    s_at_fd[port] = at_fd;
     s_uart_fd = uart_fd;
     s_unsolHandler = h;
     s_readerClosed = 0;
-    s_responsePrefix = NULL;
-    s_smsPDU = NULL;
-    sp_response = NULL;
+    s_responsePrefix[port] = NULL;
+    s_smsPDU[port] = NULL;
+    sp_response[port] = NULL;
+
+    ATPortType_enum *at_port_ptr = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
+    ATPortType_enum *urc_port_ptr = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
+    *at_port_ptr = port;
+    *urc_port_ptr = port;
 
     pthread_attr_init (&attr);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    ret = pthread_create(&s_tid_reader, &attr, readerLoop, NULL);
+    ret = pthread_create(&s_tid_reader[port], &attr, readerLoop, at_port_ptr);
     if (ret < 0)
     {
         LOGE("AT thread create fail.");
@@ -855,7 +866,7 @@
     }
 
     pthread_t uart_tid_reader;
-    ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, NULL);
+    ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, urc_port_ptr);
     if (ret < 0)
     {
         LOGE("Uart thread create fail.");
@@ -866,27 +877,27 @@
 }
 
 /* FIXME is it ok to call this from the reader and the command thread? */
-void at_close()
+void at_close(ATPortType_enum port)
 {
     LOGD("at_close()");
-    if (s_at_fd >= 0)
+    if (s_at_fd[port] >= 0)
     {
-        close(s_at_fd);
+        close(s_at_fd[port]);
     }
     if (s_uart_fd >= 0)
     {
         close(s_uart_fd);
     }
-    s_at_fd = -1;
+    s_at_fd[port] = -1;
     s_uart_fd = -1;
 
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
     s_readerClosed = 1;
-    pthread_cond_signal(&s_commandcond);
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_cond_signal(&s_commandcond[port]);
+    pthread_mutex_unlock(&s_commandmutex[port]);
     /* the reader thread should eventually die */
 
-    at_state = RIL_AT_STATE_CLOSED;
+    at_state[port] = RIL_AT_STATE_CLOSED;
 }
 
 static ATResponse * at_response_new()
@@ -960,33 +971,33 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full_nolock (const char *command, ATCommandType type,
+static int at_send_command_full_nolock (ATPortType_enum port, const char *command, ATCommandType type,
                                         const char *responsePrefix, const char *smspdu,
                                         long long timeoutMsec, ATResponse **pp_outResponse)
 {
     int err = 0;
     bool tiemout_close = true;
     struct timespec ts;
-    if(at_state == RIL_AT_STATE_READY)
-        at_state = RIL_AT_STATE_BUSY;
+    if(at_state[port] == RIL_AT_STATE_READY)
+        at_state[port] = RIL_AT_STATE_BUSY;
 
-    if(sp_response != NULL)
+    if(sp_response[port] != NULL)
     {
         err = AT_ERROR_COMMAND_PENDING;
         goto error;
     }
 
-    err = writeline (command);
+    err = writeline (port, command);
 
     if (err < 0)
     {
         goto error;
     }
 
-    s_type = type;
-    s_responsePrefix = responsePrefix;
-    s_smsPDU = smspdu;
-    sp_response = at_response_new();
+    s_type[port] = type;
+    s_responsePrefix[port] = responsePrefix;
+    s_smsPDU[port] = smspdu;
+    sp_response[port] = at_response_new();
 
     if(timeoutMsec == 0)
     {
@@ -998,16 +1009,16 @@
         setTimespecRelative(&ts, timeoutMsec);
     }
 
-    while (sp_response->finalResponse == NULL && s_readerClosed == 0)
+    while (sp_response[port]->finalResponse == NULL && s_readerClosed == 0)
     {
         //LOGD("AT wait time:%lld",timeoutMsec);
         if (timeoutMsec != 0)
         {
-            err = pthread_cond_timedwait(&s_commandcond, &s_commandmutex, &ts);
+            err = pthread_cond_timedwait(&s_commandcond[port], &s_commandmutex[port], &ts);
         }
         else
         {
-            err = pthread_cond_wait(&s_commandcond, &s_commandmutex);
+            err = pthread_cond_wait(&s_commandcond[port], &s_commandmutex[port]);
         }
 
         //LOGD("AT continue:err - %d",err);
@@ -1027,16 +1038,16 @@
 
     if (pp_outResponse == NULL)
     {
-        at_response_free(sp_response);
+        at_response_free(sp_response[port]);
     }
     else
     {
         /* line reader stores intermediate responses in reverse order */
-        reverseIntermediates(sp_response);
-        *pp_outResponse = sp_response;
+        reverseIntermediates(sp_response[port]);
+        *pp_outResponse = sp_response[port];
     }
 
-    sp_response = NULL;
+    sp_response[port] = NULL;
 
     if(s_readerClosed > 0)
     {
@@ -1046,9 +1057,9 @@
 
     err = 0;
 error:
-    if(at_state == RIL_AT_STATE_BUSY)
-        at_state = RIL_AT_STATE_READY;
-    clearPendingCommand();
+    if(at_state[port] == RIL_AT_STATE_BUSY)
+        at_state[port] = RIL_AT_STATE_READY;
+    clearPendingCommand(port);
 
     return err;
 }
@@ -1058,13 +1069,13 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full (const char *command, ATCommandType type,
+static int at_send_command_full (ATPortType_enum port, const char *command, ATCommandType type,
                                  const char *responsePrefix, const char *smspdu,
                                  long long timeoutMsec, ATResponse **pp_outResponse)
 {
     int err;
 
-    if (0 != pthread_equal(s_tid_reader, pthread_self()))
+    if (0 != pthread_equal(s_tid_reader[port], pthread_self()))
     {
         /* cannot be called from reader thread */
         LOGE("cannot be called from reader thread.");
@@ -1072,18 +1083,18 @@
     }
 
     // Waitting for previous AT complete.
-    while(at_state == RIL_AT_STATE_BUSY)
+    while(at_state[port] == RIL_AT_STATE_BUSY)
     {
         usleep(10000);
     }
 
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 
-    err = at_send_command_full_nolock(command, type,
+    err = at_send_command_full_nolock(port, command, type,
                                       responsePrefix, smspdu,
                                       timeoutMsec, pp_outResponse);
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 
     if (err == AT_ERROR_TIMEOUT_CLOSE && s_onTimeout != NULL)
     {
@@ -1103,20 +1114,20 @@
  * if non-NULL, the resulting ATResponse * must be eventually freed with
  * at_response_free
  */
-int at_send_command (const char *command, ATResponse **pp_outResponse)
+int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse)
 {
-    return at_send_command_full (command, NO_RESULT, NULL,
+    return at_send_command_full (port, command, NO_RESULT, NULL,
                                  NULL, 0, pp_outResponse);
 }
 
 
-int at_send_command_singleline (const char *command,
+int at_send_command_singleline (ATPortType_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 NULL, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1133,13 +1144,13 @@
     return err;
 }
 
-int at_send_command_singleline_with_timeout (const char *command,
+int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 NULL, timeoutMsec, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1158,12 +1169,12 @@
 
 
 
-int at_send_command_numeric (const char *command,
+int at_send_command_numeric (ATPortType_enum port, const char *command,
                              ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, NUMERIC, NULL,
+    err = at_send_command_full (port, command, NUMERIC, NULL,
                                 NULL, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1181,14 +1192,14 @@
 }
 
 
-int at_send_command_sms (const char *command,
+int at_send_command_sms (ATPortType_enum port, const char *command,
                          const char *pdu,
                          const char *responsePrefix,
                          ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 pdu, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1206,13 +1217,13 @@
 }
 
 
-int at_send_command_multiline (const char *command,
+int at_send_command_multiline (ATPortType_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, MULTILINE, responsePrefix,
+    err = at_send_command_full (port, command, MULTILINE, responsePrefix,
                                 NULL, 0, pp_outResponse);
 
     return err;
@@ -1242,17 +1253,17 @@
  * Periodically issue an AT command and wait for a response.
  * Used to ensure channel has start up and is active
  */
-int at_handshake()
+int at_handshake(ATPortType_enum port)
 {
 //    int i;
     int err = 0;
 
-    if (0 != pthread_equal(s_tid_reader, pthread_self()))
+    if (0 != pthread_equal(s_tid_reader[port], pthread_self()))
     {
         /* cannot be called from reader thread */
         return AT_ERROR_INVALID_THREAD;
     }
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 
 #if 0
     for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++)
@@ -1267,7 +1278,7 @@
         }
     }
 #else
-    err = at_send_command_full_nolock("ATE0Q0V1", NO_RESULT,
+    err = at_send_command_full_nolock(port, "ATE0Q0V1", NO_RESULT,
                                           NULL, NULL, 0, NULL);
 #endif
 
@@ -1278,7 +1289,7 @@
         sleepMsec(HANDSHAKE_TIMEOUT_MSEC);
     }
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 
 
     return err;
@@ -1324,14 +1335,14 @@
     return ret;
 }
 
-mbtk_ril_at_state_enum at_state_get()
+mbtk_ril_at_state_enum at_state_get(ATPortType_enum port)
 {
-    return at_state;
+    return at_state[port];
 }
 
-void at_state_set(mbtk_ril_at_state_enum state)
+void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state)
 {
-    at_state = state;
+    at_state[port] = state;
 }
 
 bool at_rsp_check(ATResponse *p_response)
@@ -1342,8 +1353,8 @@
     return true;
 }
 
-void unused_func()
+void unused_func(ATPortType_enum port)
 {
-    isFinalResponse(NULL);
+    isFinalResponse(port, NULL);
 }
 
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 939585f..14284d7 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -70,7 +70,7 @@
 mbtk_ril_err_enum sms_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);

 mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);

 

-void data_call_retry(mbtk_ril_net_reg_state_info_t *reg_state);

+void data_call_retry(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state);

 

 void data_call_state_change_cb(int cid, bool action, bool auto_change, int reason);

 static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack);

@@ -79,14 +79,14 @@
 static void onATTimeout()

 {

     LOGI("AT channel timeout; closing\n");

-    at_close();

+    at_close(ATPORTTYPE_0);

 }

 

 /* Called on command or reader thread */

 static void onATReaderClosed()

 {

     LOGI("AT channel closed\n");

-    at_close();

+    at_close(ATPORTTYPE_0);

 }

 

 static void sock_cli_free_func(void *data)
@@ -235,9 +235,9 @@
     }
 }
 
-static void ril_error_pack_send(int fd, int ril_id, int msg_index, int err)

+static void ril_error_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, int err)

 {
-    ril_msg_pack_info_t* pack = ril_msg_pack_creat(RIL_MSG_TYPE_RSP, ril_id, msg_index, NULL, 0);

+    ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, NULL, 0);

     if(pack)
     {

         pack->err = (uint16)err;

@@ -250,9 +250,9 @@
     }
 }
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len)

+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len)

 {

-    ril_msg_pack_info_t* pack = ril_msg_pack_creat(RIL_MSG_TYPE_RSP, ril_id, msg_index, data, data_len);

+    ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, data, data_len);

     if(pack)
     {
         pack->err = (uint16)MBTK_RIL_ERR_SUCCESS;

@@ -274,7 +274,7 @@
 

 void ril_ind_pack_send(int fd, int msg_id, const void* data, int data_len)

 {
-    ril_msg_pack_info_t* pack = ril_msg_pack_creat(RIL_MSG_TYPE_IND, msg_id, RIL_MSG_INDEX_INVALID, data, data_len);

+    ril_msg_pack_info_t* pack = ril_msg_pack_creat(ATPORTTYPE_NON, RIL_MSG_TYPE_IND, msg_id, RIL_MSG_INDEX_INVALID, data, data_len);

     if(pack)
     {
         pack->err = (uint16)0;

@@ -2034,25 +2034,25 @@
 

 static void ril_at_ready_process()
 {
-    ril_info.radio_state = ril_radio_state_get();

+    ril_info.radio_state = ril_radio_state_get(ATPORTTYPE_0);

     if (ril_info.radio_state != MBTK_RADIO_STATE_FULL_FUNC)

     {
-        ril_radio_state_set(MBTK_RADIO_STATE_FULL_FUNC, FALSE);

+        ril_radio_state_set(ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);

     }

 
     if(ril_info.radio_state == MBTK_RADIO_STATE_FULL_FUNC)

     {

-        at_send_command("AT+CEREG=2", NULL);
+        at_send_command(ATPORTTYPE_0, "AT+CEREG=2", NULL);

     }
 
-    ril_info.sim_state = ril_sim_state_get();

+    ril_info.sim_state = ril_sim_state_get(ATPORTTYPE_0);

     if(ril_info.sim_state == MBTK_SIM_STATE_READY)

     {
         LOGD("SIM READY!");
-        at_send_command("AT+COPS=3", NULL);

+        at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);

 

         // Set APN from prop.

-        apn_auto_conf_from_prop();

+        apn_auto_conf_from_prop(ATPORTTYPE_0);

     }
     else
     {
@@ -2084,12 +2084,20 @@
 

 // Process AT URC data
 static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack)

-{
-    if(ril_info.msg_queue.count >= PACK_PROCESS_QUEUE_MAX)

-    {
-        LOGE("Packet process queue is full");

-        return -1;
-    }
+{

+    if(cli_info) {

+        if(ril_info.msg_queue[cli_info->port].count >= PACK_PROCESS_QUEUE_MAX)

+        {

+            LOGE("Packet process queue is full");

+            return -1;

+        }

+    } else {

+        if(ril_info.msg_queue[ATPORTTYPE_0].count >= PACK_PROCESS_QUEUE_MAX)

+        {

+            LOGE("Packet process queue is full");

+            return -1;

+        }

+    }

 
     ril_msg_queue_info_t *item = (ril_msg_queue_info_t*)malloc(sizeof(ril_msg_queue_info_t));

     if(!item)
@@ -2098,13 +2106,23 @@
         return -1;
     }
     item->cli_info = cli_info;
-    item->pack = pack;
-    mbtk_queue_put(&ril_info.msg_queue, item);

-
-    // If thread is waitting,continue it.
-    pthread_mutex_lock(&ril_info.msg_mutex);

-    pthread_cond_signal(&ril_info.msg_cond);

-    pthread_mutex_unlock(&ril_info.msg_mutex);

+    item->pack = pack;

+

+    if(cli_info) {

+        mbtk_queue_put(&(ril_info.msg_queue[cli_info->port]), item);

+

+        // If thread is waitting,continue it.

+        pthread_mutex_lock(&(ril_info.msg_mutex[cli_info->port]));

+        pthread_cond_signal(&(ril_info.msg_cond[cli_info->port]));

+        pthread_mutex_unlock(&(ril_info.msg_mutex[cli_info->port]));

+    } else { // URC message, is null.

+        mbtk_queue_put(&(ril_info.msg_queue[ATPORTTYPE_0]), item);

+

+        // If thread is waitting,continue it.

+        pthread_mutex_lock(&(ril_info.msg_mutex[ATPORTTYPE_0]));

+        pthread_cond_signal(&(ril_info.msg_cond[ATPORTTYPE_0]));

+        pthread_mutex_unlock(&(ril_info.msg_mutex[ATPORTTYPE_0]));

+    }

 
     return 0;
 }

@@ -2128,11 +2146,11 @@
                 ind_regisger(cli_info, pack->msg_id);

             }

 

-            ril_error_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, err);

+            ril_error_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, err);

 

             ril_msg_pack_free(pack);

         } else {

-            LOGD("Start process REQ(%s), Length : %d", id2str(pack->msg_id), pack->data_len);

+            LOGD("Start process REQ(%s, Port : %d), Length : %d", id2str(pack->msg_id), cli_info->port, pack->data_len);

             if(0 && pack->data_len > 0)

             {

                 log_hex("DATA", pack->data, pack->data_len);

@@ -2192,7 +2210,7 @@
         case RIL_MSG_ID_IND_NET_REG_STATE_CHANGE:

         {

             mbtk_ril_net_reg_state_info_t *reg_state = (mbtk_ril_net_reg_state_info_t*)msg->data;

-            data_call_retry(reg_state);

+            data_call_retry(ATPORTTYPE_0, reg_state);

             break;

         }

         default:
@@ -2286,6 +2304,10 @@
                             {
                                 memset(info, 0, sizeof(sock_cli_info_t));

                                 info->fd = client_fd;

+

+                                // Default AT port.

+                                info->port = ATPORTTYPE_0;

+

                                 list_add(ril_info.sock_client_list, info);

                                 LOG("Add New Client FD Into List.");

 

@@ -2304,17 +2326,20 @@
                         // Read and process every message.
                         mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;

                         ril_msg_pack_info_t** pack = ril_pack_recv(cli_info->fd, true, &err);

-
+

                         // Parse packet error,send error response to client.
                         if(pack == NULL)
                         {
-                            ril_error_pack_send(cli_info->fd, RIL_MSG_ID_UNKNOWN, RIL_MSG_INDEX_INVALID, err);

+                            ril_error_pack_send(cli_info->port, cli_info->fd, RIL_MSG_ID_UNKNOWN, RIL_MSG_INDEX_INVALID, err);

                         }
                         else
                         {
                             ril_msg_pack_info_t** pack_ptr = pack;

                             while(*pack_ptr)
-                            {
+                            {

+                                // Update AT port in the first.

+                                cli_info->port = (ATPortType_enum)((*pack_ptr)->at_port);

+

                                 pack_distribute(cli_info, *pack_ptr);
                                 // Not free,will free in pack_process() or packet process thread.
                                 //mbtk_info_pack_free(pack_ptr);
@@ -2346,17 +2371,18 @@
 

 static void* ril_process_thread(void* arg)

 {
-    UNUSED(arg);
+    UNUSED(arg);

+    ATPortType_enum *port = (ATPortType_enum*)arg;

     ril_msg_queue_info_t* item = NULL;

 
-    pthread_mutex_lock(&ril_info.msg_mutex);

+    pthread_mutex_lock(&(ril_info.msg_mutex[*port]));

     while(TRUE)
     {
-        if(mbtk_queue_empty(&ril_info.msg_queue))

+        if(mbtk_queue_empty(&(ril_info.msg_queue[*port])))

         {
-            LOG("Packet process wait...");
-            pthread_cond_wait(&ril_info.msg_cond, &ril_info.msg_mutex);

-            LOG("Packet process continue...");
+            LOG("[Port - %d]Packet process wait...", *port);

+            pthread_cond_wait(&(ril_info.msg_cond[*port]), &(ril_info.msg_mutex[*port]));

+            LOG("[Port - %d]Packet process continue...", *port);

         }
         else
         {
@@ -2365,18 +2391,18 @@
 
         // Process all information request.
         mbtk_ril_err_enum err;

-        while((item = (ril_msg_queue_info_t*)mbtk_queue_get(&ril_info.msg_queue)) != NULL)

+        while((item = (ril_msg_queue_info_t*)mbtk_queue_get(&(ril_info.msg_queue[*port]))) != NULL)

         {
             if(item->cli_info) { // REQ form client.
                 ril_msg_pack_info_t *pack = (ril_msg_pack_info_t*)item->pack;

                 LOGD("Process REQ %s.", id2str(pack->msg_id));

-                ril_info.at_process = true;

+                ril_info.at_process[*port] = true;

                 err = pack_req_process(item->cli_info, pack);
                 if(err != MBTK_RIL_ERR_SUCCESS)

                 {
-                    ril_error_pack_send(item->cli_info->fd, pack->msg_id, pack->msg_index, err);

+                    ril_error_pack_send(item->cli_info->port, item->cli_info->fd, pack->msg_id, pack->msg_index, err);

                 }
-                ril_info.at_process = false;

+                ril_info.at_process[*port] = false;

                 ril_msg_pack_free(pack);

                 free(item);
             } else { // REQ from myself.

@@ -2391,7 +2417,10 @@
             }
         }
     }
-    pthread_mutex_unlock(&ril_info.msg_mutex);

+    pthread_mutex_unlock(&(ril_info.msg_mutex[*port]));

+

+    free(port);

+

     return NULL;
 }

 

@@ -2521,9 +2550,9 @@
         goto error;
     }

 

-    mbtk_queue_init(&ril_info.msg_queue);

-    pthread_mutex_init(&ril_info.msg_mutex, NULL);

-    pthread_cond_init(&ril_info.msg_cond, NULL);

+    mbtk_queue_init(&(ril_info.msg_queue[ATPORTTYPE_0]));

+    pthread_mutex_init(&(ril_info.msg_mutex[ATPORTTYPE_0]), NULL);

+    pthread_cond_init(&(ril_info.msg_cond[ATPORTTYPE_0]), NULL);

 
     pthread_t info_pid, pack_pid/*, monitor_pid, urc_pid, bootconn_pid*/;

     pthread_attr_t thread_attr;
@@ -2539,12 +2568,22 @@
         LOGE("pthread_create() fail.");

         goto error;
     }
-
-    if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, NULL))

+

+    ATPortType_enum *port_0 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));

+    *port_0 = ATPORTTYPE_0;

+    if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_0))

     {
         LOGE("pthread_create() fail.");

         goto error;
-    }
+    }

+

+    ATPortType_enum *port_1 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));

+    *port_1 = ATPORTTYPE_1;

+    if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_1))

+    {
+        LOGE("pthread_create() fail.");

+        goto error;
+    }

 
     // Set Band
     // AT*BAND=15,78,147,482,134742231
@@ -2617,16 +2656,29 @@
         return -1;

     }

 

-    at_set_on_reader_closed(onATReaderClosed);

-    at_set_on_timeout(onATTimeout);

-

-    if(at_open(at_sock, uart_sock, onUnsolicited))

+    int at_sock_1 = openSocket("/tmp/atcmd_at_1");

+    if(at_sock_1 < 0)

     {

-        LOGE("Start AT thread fail.");

+        LOGE("Open AT Socket Fail[%d].", errno);

         return -1;

     }

 

-    if(at_handshake())

+    at_set_on_reader_closed(onATReaderClosed);

+    at_set_on_timeout(onATTimeout);

+

+    if(at_open(ATPORTTYPE_0, at_sock, uart_sock, onUnsolicited))

+    {

+        LOGE("Start AT_0 thread fail.");

+        return -1;

+    }

+

+    if(at_open(ATPORTTYPE_1, at_sock_1, uart_sock, onUnsolicited))

+    {

+        LOGE("Start AT_1 thread fail.");

+        return -1;

+    }

+

+    if(at_handshake(ATPORTTYPE_0))

     {

         LOGE("AT handshake fail.");

         return -1;

diff --git a/mbtk/mbtk_rild_v2/src/ril_call.c b/mbtk/mbtk_rild_v2/src/ril_call.c
index 3891143..e35775a 100755
--- a/mbtk/mbtk_rild_v2/src/ril_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_call.c
@@ -17,21 +17,21 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 ATDXXXXXXX;
 OK
 
 */
-static int req_call_start(char *phont_number, int *cme_err)
+static int req_call_start(ATPortType_enum port, char *phont_number, int *cme_err)
 {
     ATResponse *response = NULL;
 //    int tmp_int;
 //    char *tmp_str = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "ATD%s;", phont_number);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -48,10 +48,10 @@
 OK
 
 */
-static int req_answer_call(int *cme_err)
+static int req_answer_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=2", &response);
+    int err = at_send_command(port, "AT+CHLD=2", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -67,10 +67,10 @@
 OK
 
 */
-static int req_hangup_call(int *cme_err)
+static int req_hangup_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("ATH", &response);
+    int err = at_send_command(port, "ATH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -86,12 +86,12 @@
 OK
 
 */
-static int req_hangup_a_call(int phone_id, int *cme_err)
+static int req_hangup_a_call(ATPortType_enum port, int phone_id, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CHLD=1%d", phone_id);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -107,10 +107,10 @@
 OK
 
 */
-static int req_hangup_waiting_or_background_call(int *cme_err)
+static int req_hangup_waiting_or_background_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=0", &response);
+    int err = at_send_command(port, "AT+CHLD=0", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -126,10 +126,10 @@
 OK
 
 */
-static int req_hangup_foreground_resume_background_call(int *cme_err)
+static int req_hangup_foreground_resume_background_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=1", &response);
+    int err = at_send_command(port, "AT+CHLD=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -145,13 +145,13 @@
 OK
 
 */
-static int req_waitin_call(mbtk_call_info_t *reg, int *cme_err)
+static int req_waitin_call(ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_str = NULL;
 
-    int err = at_send_command_multiline("AT+CLCC", "+CLCC:", &response);
+    int err = at_send_command_multiline(port, "AT+CLCC", "+CLCC:", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -224,11 +224,11 @@
 
 OK
 */
-static int req_mute_get(int *state, int *cme_err)
+static int req_mute_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+CMUT?", "+CMUT:", &response);
+    int err = at_send_command_singleline(port, "AT+CMUT?", "+CMUT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -258,13 +258,13 @@
 OK
 
 */
-static int req_mute_set(int state, int *cme_err)
+static int req_mute_set(ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CMUT=%d", state);
     LOG("Set the mute command is = %s.\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -280,13 +280,13 @@
 OK
 
 */
-static int req_dtmf_set(mbtk_call_dtmf_info_t *state, int *cme_err)
+static int req_dtmf_set(ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration);
     LOG("Set the DTMF command is = %s.\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -315,7 +315,7 @@
             else     // Set
             {
                 char *pn = (char*)(pack->data);
-                if(req_call_start(pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_call_start(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -326,7 +326,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -335,7 +335,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-               if(req_answer_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+               if(req_answer_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -346,7 +346,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -360,7 +360,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -371,7 +371,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -391,7 +391,7 @@
             else
             {
                 uint8 phone_id = *(pack->data);
-                if(req_hangup_a_call(phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_a_call(cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -402,7 +402,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -411,7 +411,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_waiting_or_background_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_waiting_or_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -422,7 +422,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -436,7 +436,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_foreground_resume_background_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_foreground_resume_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -447,7 +447,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -463,7 +463,7 @@
             {
                 mbtk_call_info_t reg;
                 memset(&reg, 0, sizeof(mbtk_call_info_t));
-                if(req_waitin_call(&reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_waitin_call(cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -474,7 +474,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
                 }
             }
             else     // Set
@@ -489,7 +489,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_mute_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -500,7 +500,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set mute state.
@@ -513,7 +513,7 @@
                     break;
                 }
 
-                if(req_mute_set(on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -524,7 +524,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -539,7 +539,7 @@
             else     // Set
             {
                 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
-                if(req_dtmf_set(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_dtmf_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -550,7 +550,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_data_call.c b/mbtk/mbtk_rild_v2/src/ril_data_call.c
index aef3ac9..210141b 100755
--- a/mbtk/mbtk_rild_v2/src/ril_data_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_data_call.c
@@ -24,12 +24,12 @@
 ril_cgact_wait_t cgact_wait;
 static ril_data_call_info_t info_list[MBTK_APN_CID_MAX];
 
-static int req_apn_get(bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
-static int req_apn_set(mbtk_apn_info_t *apn, int *cme_err);
+static int req_apn_get(ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
+static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err);
 static void apn_prop_get(mbtk_apn_info_array_t *apns);
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
-static int req_data_call_start(mbtk_ril_cid_enum cid, int *cme_err);
-static int req_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err);
+static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
 
 /*
 IPv4 : 10.255.74.26
@@ -269,7 +269,7 @@
 }
 
 
-void apn_auto_conf_from_prop()
+void apn_auto_conf_from_prop(ATPortType_enum port)
 {
     mbtk_apn_info_array_t apns;
     int i = 0;
@@ -289,7 +289,7 @@
             info_list[cid - 1].apn_info.as_dns, info_list[cid - 1].apn_info.apn);
 
         int cme_err = MBTK_RIL_ERR_CME_NON;
-        if(req_apn_set(&(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_set(port, &(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGD("Set APN fail.");
         }
@@ -319,7 +319,7 @@
     return TRUE;
 }
 
-static int apn_check_and_cid_reset(mbtk_apn_info_t *apn)
+static int apn_check_and_cid_reset(ATPortType_enum port, mbtk_apn_info_t *apn)
 {
     // Delete apn
     if(str_empty(apn->apn)) {
@@ -333,7 +333,7 @@
         mbtk_apn_info_array_t apns;
         int cme_err = MBTK_RIL_ERR_CME_NON;
         memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-        if(req_apn_get(FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             return 0;
@@ -360,7 +360,7 @@
             start_cid = MBTK_APN_CID_MIN;
         }
         memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-        if(req_apn_get(TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(port, TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             if(apn->cid == MBTK_RIL_CID_NUL) {
@@ -764,7 +764,7 @@
     }
 }
 
-void data_call_retry(mbtk_ril_net_reg_state_info_t *reg_state)
+void data_call_retry(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state)
 {
     LOGV("NET_REG_STATE_CHANGE : type - %d, tech - %d, reg_state - %d", reg_state->type, reg_state->tech, reg_state->reg_state);
     // Only for 2g/3g/4g data domain.
@@ -790,7 +790,7 @@
 
                         // PDP active
                         int cme_err = MBTK_RIL_ERR_CME_NON;
-                        if(req_data_call_start(cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_start(port, cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             LOGE("Restart data call fail.");
                             return;
@@ -806,7 +806,7 @@
                             // Get Ip informations.
                             memset(&ip_info, 0, sizeof(ip_info));
                             cme_err = MBTK_RIL_ERR_CME_NON;
-                            if(req_data_call_state_get(cid, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_state_get(port, cid, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                             {
                                 LOGE("Get net informations fail.");
                                 return;
@@ -842,10 +842,10 @@
 OK
 
 */
-static int req_apn_get(bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err)
+static int req_apn_get(ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:", &response);
+    int err = at_send_command_multiline(port, "AT+CGDCONT?", "+CGDCONT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -950,7 +950,7 @@
 OK
 
 */
-static int req_apn_set(mbtk_apn_info_t *apn, int *cme_err)
+static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -960,7 +960,7 @@
     // Delete apn
     if(str_empty(apn->apn)) {
         sprintf(cmd, "AT+CGDCONT=%d", apn->cid);
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -991,7 +991,7 @@
             index += sprintf(cmd + index,"\"%s\"", apn->apn);
         }
 
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -1014,7 +1014,7 @@
                 goto exit;
 
             sprintf(cmd, "AT*AUTHREQ=%d,%d,%s,%s",apn->cid,cmd_auth,apn->user,apn->pass);
-            err = at_send_command(cmd, &response);
+            err = at_send_command(port, cmd, &response);
             if (err < 0 || response->success == 0){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -1039,7 +1039,7 @@
 OK
 
 */
-static int req_data_call_start(mbtk_ril_cid_enum cid, int *cme_err)
+static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1050,7 +1050,7 @@
     cgact_wait.act = true;
 
     sprintf(cmd, "AT+CGACT=1,%d", cid);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1068,7 +1068,7 @@
 OK
 
 */
-static int req_data_call_stop(mbtk_ril_cid_enum cid, int timeout, int *cme_err)
+static int req_data_call_stop(ATPortType_enum port, mbtk_ril_cid_enum cid, int timeout, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1080,7 +1080,7 @@
     cgact_wait.act = false;
 
     sprintf(cmd, "AT+CGACT=0,%d", cid);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1101,7 +1101,7 @@
 OK
 
 */
-static int req_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
+static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -1109,7 +1109,7 @@
 
     sprintf(cmd, "AT+CGCONTRDP=%d", cid);
 
-    err = at_send_command_multiline(cmd, "+CGCONTRDP:", &response);
+    err = at_send_command_multiline(port, cmd, "+CGCONTRDP:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1274,7 +1274,7 @@
             {
                 mbtk_apn_info_array_t apns;
                 memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-                if(req_apn_get(FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_apn_get(cli_info->port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1286,17 +1286,17 @@
                 else
                 {
                     LOGD("size - %d", sizeof(mbtk_apn_info_array_t));
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &apns, sizeof(mbtk_apn_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &apns, sizeof(mbtk_apn_info_array_t));
                 }
             }
             else     // Set
             {
                 mbtk_apn_info_t *apn = (mbtk_apn_info_t*)pack->data;
-                if(apn_check_and_cid_reset(apn)) {
+                if(apn_check_and_cid_reset(cli_info->port, apn)) {
                     err = MBTK_RIL_ERR_CID;
                 } else {
                     if(apn_conf_support(apn->cid)) {
-                        if(req_apn_set(apn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_apn_set(cli_info->port, apn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1311,7 +1311,7 @@
                                 LOGE("Save APN fail.");
                             }
 
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                         }
                     } else {
                         err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -1352,7 +1352,7 @@
                             int index = 0;
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_CONNECTING;
 data_call_retry:
-                            if(req_data_call_start(call_info->cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_start(cli_info->port, call_info->cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                             {
                                 if(call_info->retry_interval[index] > 0) {
                                     LOGD("Start data call fail, will retry in %d s.", call_info->retry_interval[index]);
@@ -1378,7 +1378,7 @@
 
                                 // Get Ip informations.
                                 cme_err = MBTK_RIL_ERR_CME_NON;
-                                if(req_data_call_state_get(call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                                if(req_data_call_state_get(cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                                 {
                                     LOGD("Get net informations fail.");
                                     err = MBTK_RIL_ERR_NET_CONF;
@@ -1393,13 +1393,13 @@
 
                                     info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_CONNECTED;
 
-                                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
                                 }
                             }
                         }
                     } else if(call_info->type == MBTK_DATA_CALL_STOP) {
                         info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTING;
-                        if(req_data_call_stop(call_info->cid, call_info->timeout, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_stop(cli_info->port, call_info->cid, call_info->timeout, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1423,12 +1423,12 @@
                             }
 
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTED;
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                         }
                     } else {
                         mbtk_ip_info_t ip_info;
                         memset(&ip_info, 0, sizeof(ip_info));
-                        if(req_data_call_state_get(call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_state_get(cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1439,7 +1439,7 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
                         }
                     }
                 }
diff --git a/mbtk/mbtk_rild_v2/src/ril_dev.c b/mbtk/mbtk_rild_v2/src/ril_dev.c
index 4d267de..d2d8c9f 100755
--- a/mbtk/mbtk_rild_v2/src/ril_dev.c
+++ b/mbtk/mbtk_rild_v2/src/ril_dev.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+CGSN
@@ -25,10 +25,10 @@
 
 OK
 */
-static int req_imei_get(void *data, int *cme_err)
+static int req_imei_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric("AT+CGSN", &response);
+    int err = at_send_command_numeric(port, "AT+CGSN", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates) {
         *cme_err = at_get_cme_error(response);
@@ -48,11 +48,11 @@
 OK
 
 */
-static int req_sn_get(void *data, int *cme_err)
+static int req_sn_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+MRD_SN=R", "+MRD_SN:", &response);
+    int err = at_send_command_singleline(port, "AT+MRD_SN=R", "+MRD_SN:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -102,10 +102,10 @@
 OK
 
 */
-static int req_version_get(void *data, int *cme_err)
+static int req_version_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("ATI", "", &response);
+    int err = at_send_command_multiline(port, "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -146,10 +146,10 @@
 OK
 
 */
-static int req_model_get(void *data, int *cme_err)
+static int req_model_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("ATI", "", &response);
+    int err = at_send_command_multiline(port, "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -187,7 +187,7 @@
 
 OK
 */
-static int req_volte_set(int state, int *cme_err)
+static int req_volte_set(ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[30] = {0};
@@ -199,7 +199,7 @@
     {
         strcpy(cmd, "AT+ACONFIG=\"IMSD=0\"");
     }
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -218,11 +218,11 @@
 
 OK
 */
-static int req_volte_get(int *state, int *cme_err)
+static int req_volte_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+ACONFIG?", "", &response);
+    int err = at_send_command_singleline(port, "AT+ACONFIG?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -264,15 +264,15 @@
 OK
 
 */
-static int req_temp_get(mbtk_temp_type_enum type, int16 *temp, int *cme_err)
+static int req_temp_get(ATPortType_enum port, mbtk_temp_type_enum type, int16 *temp, int *cme_err)
 {
     ATResponse *response = NULL;
     int err = -1;
     int tmp_int;
     if(type == MBTK_TEMP_TYPE_SOC) { // Soc
-        err = at_send_command_singleline("AT*SOCTEMP", "*SOCTEMP:", &response);
+        err = at_send_command_singleline(port, "AT*SOCTEMP", "*SOCTEMP:", &response);
     } else { // RF
-        err = at_send_command_singleline("AT*RFTEMP", "*RFTEMP:", &response);
+        err = at_send_command_singleline(port, "AT*RFTEMP", "*RFTEMP:", &response);
     }
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -316,11 +316,11 @@
 OK
 
 */
-static int req_cell_time_get(char *data, int *cme_err)
+static int req_cell_time_get(ATPortType_enum port, char *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CCLK?", "+CCLK:", &response);
+    int err = at_send_command_singleline(port, "AT+CCLK?", "+CCLK:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -354,14 +354,14 @@
 6: turn off full secondary receive.
 -1: fail
 */
-mbtk_radio_state_enum ril_radio_state_get()
+mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
     char *line;
     int ret;
 
-    err = at_send_command_singleline("AT+CFUN?", "+CFUN:", &p_response);
+    err = at_send_command_singleline(port, "AT+CFUN?", "+CFUN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -387,7 +387,7 @@
     return MBTK_RADIO_STATE_UNKNOWN;
 }
 
-mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset)
+mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset)
 {
     int err;
     ATResponse *p_response = NULL;
@@ -407,13 +407,13 @@
     } else {
         snprintf(cmd, sizeof(cmd), "AT+CFUN=%d", state);
     }
-    err = at_send_command(cmd, &p_response);
+    err = at_send_command(port, cmd, &p_response);
     if (err || !p_response->success) {
         goto done;
     }
 
     if(state == MBTK_RADIO_STATE_FULL_FUNC) { // +CFUN=1
-        if(ril_radio_state_get() == MBTK_RADIO_STATE_FULL_FUNC) { // success
+        if(ril_radio_state_get(port) == MBTK_RADIO_STATE_FULL_FUNC) { // success
             ril_info.radio_state = MBTK_RADIO_STATE_FULL_FUNC;
             ret = MBTK_RIL_ERR_SUCCESS;
             LOGD("Radio open success.");
@@ -446,7 +446,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get IMEI
             {
                 char imei[20] = {0};
-                if(req_imei_get(imei, &cme_err) || strlen(imei) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imei_get(cli_info->port, imei, &cme_err) || strlen(imei) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -457,7 +457,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
                 }
             }
             else     // Set IMEI(Unsupport).
@@ -472,7 +472,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char sn[20] = {0};
-                if(req_sn_get(sn, &cme_err) || strlen(sn) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sn_get(cli_info->port, sn, &cme_err) || strlen(sn) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -483,7 +483,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
                 }
             }
             else     // Set
@@ -512,7 +512,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char version[50] = {0};
-                if(req_version_get(version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_version_get(cli_info->port, version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -523,7 +523,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
                 }
             }
             else     // Set
@@ -538,7 +538,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char model[50] = {0};
-                if(req_model_get(model, &cme_err) || strlen(model) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_model_get(cli_info->port, model, &cme_err) || strlen(model) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -549,7 +549,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
                 }
             }
             else     // Set
@@ -564,7 +564,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_volte_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -575,7 +575,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -589,7 +589,7 @@
                 }
 
                 uint8 on = *(pack->data);
-                if(req_volte_set(on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -600,7 +600,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
 
                     // Restart is required to take effect.
                     // LOG("Will reboot system...");
@@ -613,7 +613,7 @@
             if(pack->data && pack->data_len == sizeof(uint8)) {
                 int16 temp;
                 mbtk_temp_type_enum type = (mbtk_temp_type_enum)(*(pack->data));
-                if(req_temp_get(type, &temp, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_temp_get(cli_info->port, type, &temp, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -624,7 +624,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
                 }
             } else {
                 err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -637,7 +637,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get Time
             {
                 char time[100] = {0};
-                if(req_cell_time_get(time, &cme_err) || strlen(time) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_time_get(cli_info->port, time, &cme_err) || strlen(time) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -648,7 +648,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
                 }
             }
             else     // Set Time
@@ -662,7 +662,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_radio_state_enum radio_state = ril_radio_state_get();
+                mbtk_radio_state_enum radio_state = ril_radio_state_get(cli_info->port);
                 if(radio_state == MBTK_RADIO_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -670,7 +670,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -679,9 +679,9 @@
                 if(pack->data && pack->data_len == 2) {
                     mbtk_radio_state_enum radio_state = (mbtk_radio_state_enum)(*(pack->data));
                     bool reset = *(pack->data + 1);
-                    err = ril_radio_state_set(radio_state, reset);
+                    err = ril_radio_state_set(cli_info->port, radio_state, reset);
                     if(MBTK_RIL_ERR_SUCCESS == err) {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 } else {
                     err = MBTK_RIL_ERR_FORMAT;
diff --git a/mbtk/mbtk_rild_v2/src/ril_ecall.c b/mbtk/mbtk_rild_v2/src/ril_ecall.c
index 3c61159..60b64c5 100755
--- a/mbtk/mbtk_rild_v2/src/ril_ecall.c
+++ b/mbtk/mbtk_rild_v2/src/ril_ecall.c
@@ -19,9 +19,9 @@
 
 static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
-static int cfg_ecalldata_get(mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
+static int cfg_ecalldata_get(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
@@ -30,7 +30,7 @@
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type);
-    err = at_send_command_singleline(cmd, "*ECALLDATA:", &response);
+    err = at_send_command_singleline(port, cmd, "*ECALLDATA:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -70,14 +70,14 @@
     return err;
 }
 
-static int cfg_ecalldata_set(mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
+static int cfg_ecalldata_set(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d,%d", type, value / 20);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -89,14 +89,14 @@
     return err;
 }
 
-static int cfg_ecalltimer_set(const char* type, uint32 value, int *cme_err)
+static int cfg_ecalltimer_set(ATPortType_enum port, const char* type, uint32 value, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=%s,%d", type, value);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -108,12 +108,12 @@
     return err;
 }
 
-static int req_ecall_msdcfg(mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_msdcfg(ATPortType_enum port, mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLMSDCFG=%d,\"%s\",0", cfg_info->item_type, cfg_info->data);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -124,10 +124,10 @@
     return err;
 }
 
-static int req_ecall_msdgen(int *cme_err)
+static int req_ecall_msdgen(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT*ECALLMSDGEN", &response);
+    int err = at_send_command(port, "AT*ECALLMSDGEN", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -138,12 +138,12 @@
     return err;
 }
 
-static int req_ecall_msd_set(const uint8 *msd, int *cme_err)
+static int req_ecall_msd_set(ATPortType_enum port, const uint8 *msd, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLMSD=\"%s\"", msd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -154,11 +154,11 @@
     return err;
 }
 
-static int req_ecall_msd_get(uint8 *msd, int *cme_err)
+static int req_ecall_msd_get(ATPortType_enum port, uint8 *msd, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLMSD?", "*ECALLMSD:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLMSD?", "*ECALLMSD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -188,10 +188,10 @@
     return err;
 }
 
-static int req_ecall_push(int *cme_err)
+static int req_ecall_push(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT*ECALLPUSH", &response);
+    int err = at_send_command(port, "AT*ECALLPUSH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -209,12 +209,12 @@
 OK
 
 */
-static int req_ecall_only_get(mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_get(ATPortType_enum port, mbtk_ecall_only_info_t *only_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT*ECALLONLY?", "*ECALLONLY:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLONLY?", "*ECALLONLY:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -275,12 +275,12 @@
 OK
 
 */
-static int req_ecall_only_set(const mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_set(ATPortType_enum port, const mbtk_ecall_only_info_t *only_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLONLY=%d,%s,%s", only_info->active,only_info->test_num,only_info->reconfig_num);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -295,12 +295,12 @@
 AT*ECALLREG=0/1
 
 */
-static int req_ecall_reg_set(uint8 reg, int *cme_err)
+static int req_ecall_reg_set(ATPortType_enum port, uint8 reg, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[30] = {0};
     sprintf(cmd, "AT*ECALLREG=%d", reg);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -318,11 +318,11 @@
 OK
 
 */
-static int req_ecall_dial_state_get(mbtk_ecall_dial_type_enum *type, int *cme_err)
+static int req_ecall_dial_state_get(ATPortType_enum port, mbtk_ecall_dial_type_enum *type, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+CECALL?", "+CECALL:", &response);
+    int err = at_send_command_singleline(port, "AT+CECALL?", "+CECALL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -353,12 +353,12 @@
 AT+CECALL=<ecalltype>
 OK
 */
-static int req_ecall_dial_start(mbtk_ecall_dial_type_enum type, int *cme_err)
+static int req_ecall_dial_start(ATPortType_enum port, mbtk_ecall_dial_type_enum type, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT+CECALL=%d", type);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -377,11 +377,11 @@
 OK
 
 */
-static int req_ecall_mode_get(mbtk_ecall_mode_type_enum *mode, int *cme_err)
+static int req_ecall_mode_get(ATPortType_enum port, mbtk_ecall_mode_type_enum *mode, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLMODE?", "*ECALLMODE:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLMODE?", "*ECALLMODE:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -424,7 +424,7 @@
 OK
 
 */
-static int req_ecall_mode_set(mbtk_ecall_mode_type_enum mode, int *cme_err)
+static int req_ecall_mode_set(ATPortType_enum port, mbtk_ecall_mode_type_enum mode, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
@@ -433,7 +433,7 @@
     } else {
         sprintf(cmd, "AT*ECALLMODE=\"ERA\"");
     }
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -458,7 +458,7 @@
 OK
 
 */
-static int req_ecall_cfg_get(uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
+static int req_ecall_cfg_get(ATPortType_enum port, uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
@@ -468,7 +468,7 @@
     cfg->type = type;
 
     if(type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -477,7 +477,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -486,7 +486,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -495,7 +495,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -504,7 +504,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -515,7 +515,7 @@
     if(type & (MBTK_ECALL_CFG_TIMER_CALLBACK | MBTK_ECALL_CFG_TIMER_CLEARDOWN | MBTK_ECALL_CFG_TIMER_DEREG
                 | MBTK_ECALL_CFG_TIMER_DIAL | MBTK_ECALL_CFG_TIMER_REDIAL | MBTK_ECALL_CFG_TIMER_SMS
                 | MBTK_ECALL_CFG_REDIALCNT | MBTK_ECALL_CFG_SMSPROCESS | MBTK_ECALL_CFG_SMSMSDCNT)) {
-        err = at_send_command_singleline("AT*ECALLTIMER?", "*ECALLTIMER:", &response);
+        err = at_send_command_singleline(port, "AT*ECALLTIMER?", "*ECALLTIMER:", &response);
         if (err < 0 || response->success == 0 || !response->p_intermediates){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -632,7 +632,7 @@
 AT*ECALLTIMER=dereg,300
 OK
 */
-static int req_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_cfg_set(ATPortType_enum port, const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
 {
     int err = 0;
     if(ecall_mode == MBTK_ECALL_MODE_TYPE_EU) {
@@ -647,7 +647,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -655,7 +655,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -663,7 +663,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -671,7 +671,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -679,7 +679,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -688,63 +688,63 @@
 
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CALLBACK)
     {
-        if(cfg_ecalltimer_set("callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CLEARDOWN)
     {
-        if(cfg_ecalltimer_set("cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG)
     {
-        if(cfg_ecalltimer_set("dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL)
     {
-        if(cfg_ecalltimer_set("dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL)
     {
-        if(cfg_ecalltimer_set("redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS)
     {
-        if(cfg_ecalltimer_set("sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT)
     {
-        if(cfg_ecalltimer_set("redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
+        if(cfg_ecalltimer_set(port, "redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS)
     {
-        if(cfg_ecalltimer_set("smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
+        if(cfg_ecalltimer_set(port, "smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT)
     {
-        if(cfg_ecalltimer_set("smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
+        if(cfg_ecalltimer_set(port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
@@ -759,12 +759,12 @@
 OK
 
 */
-static int req_ecall_spkmute_set(int mute, int *cme_err)
+static int req_ecall_spkmute_set(ATPortType_enum port, int mute, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*ECALLMUTESPK=%d", mute);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -783,11 +783,11 @@
 OK
 
 */
-static int req_ecall_sms_num_get(uint8 *number, int *cme_err)
+static int req_ecall_sms_num_get(ATPortType_enum port, uint8 *number, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -822,12 +822,12 @@
 OK
 
 */
-static int req_ecall_sms_num_set(const uint8 *number, int *cme_err)
+static int req_ecall_sms_num_set(ATPortType_enum port, const uint8 *number, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*ECALLSMSNUM=%s", number);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -843,12 +843,12 @@
 OK
 
 */
-static int req_ecall_gain_set(mbtk_ecall_gain_info_t *gain, int *cme_err)
+static int req_ecall_gain_set(ATPortType_enum port, mbtk_ecall_gain_info_t *gain, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -877,7 +877,7 @@
             else     // Set
             {
                 mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
-                if(req_ecall_msdcfg(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdcfg(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -888,7 +888,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -897,7 +897,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msdgen(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdgen(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -908,7 +908,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -923,7 +923,7 @@
             memset(msd, 0, sizeof(msd));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msd_get(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_get(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -934,13 +934,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
                 }
             }
             else     // Set
             {
                 memcpy(msd, pack->data, pack->data_len);
-                if(req_ecall_msd_set(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_set(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -951,7 +951,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -960,7 +960,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_push(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_push(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -971,7 +971,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -986,7 +986,7 @@
             {
                 mbtk_ecall_only_info_t only_info;
                 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
-                if(req_ecall_only_get(&only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_get(cli_info->port, &only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -997,13 +997,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t));
                 }
             }
             else     // Set
             {
                 mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data);
-                if(req_ecall_only_set(only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_set(cli_info->port, only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1014,7 +1014,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1028,7 +1028,7 @@
             else
             {
                 uint8 reg = pack->data[0];
-                if(req_ecall_reg_set(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_reg_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1039,7 +1039,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1049,7 +1049,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_dial_type_enum type;
-                if(req_ecall_dial_state_get(&type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_state_get(cli_info->port, &type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1060,13 +1060,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
                 }
             }
             else
             {
                 mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0];
-                if(req_ecall_dial_start(type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_start(cli_info->port, type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1077,7 +1077,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1087,7 +1087,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_mode_type_enum mode;
-                if(req_ecall_mode_get(&mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_get(cli_info->port, &mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1098,13 +1098,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
                 }
             }
             else
             {
                 mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0];
-                if(req_ecall_mode_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1115,7 +1115,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1130,7 +1130,7 @@
             {
                 if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set
                     mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data;
-                    if(req_ecall_cfg_set(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_set(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1141,13 +1141,13 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 } else { // Get
                     mbtk_ecall_cfg_info_t cfg_info;
                     memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t));
                     uint32 *type = (uint32*)(pack->data);
-                    if(req_ecall_cfg_get(*type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_get(cli_info->port, *type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1158,7 +1158,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
                     }
                 }
             }
@@ -1170,7 +1170,7 @@
             memset(number, 0, sizeof(number));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_sms_num_get(number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_get(cli_info->port, number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1181,13 +1181,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
                 }
             }
             else     // Set
             {
                 memcpy(number, pack->data, pack->data_len);
-                if(req_ecall_sms_num_set(number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_set(cli_info->port, number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1198,7 +1198,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1219,7 +1219,7 @@
                     break;
                 }
 
-                if(req_ecall_spkmute_set(mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_spkmute_set(cli_info->port, mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1230,7 +1230,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1244,7 +1244,7 @@
             else     // Set
             {
                 mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
-                if(req_ecall_gain_set(gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_gain_set(cli_info->port, gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1255,7 +1255,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index 8aacb7c..837f1cc 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -23,7 +23,7 @@
 mbtk_cell_pack_info_t cell_info;
 
 extern ril_band_info_t band_info;
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+COPS=?
@@ -32,10 +32,10 @@
 
 OK
 */
-static int req_available_net_get(mbtk_net_info_array_t* nets, int *cme_err)
+static int req_available_net_get(ATPortType_enum port, mbtk_net_info_array_t* nets, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_singleline("AT+COPS=?", "+COPS:", &response);
+    int err = at_send_command_singleline(port, "AT+COPS=?", "+COPS:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -130,14 +130,14 @@
 OK
 
 */
-static int req_net_sel_mode_get(mbtk_net_info_t *net, int *cme_err)
+static int req_net_sel_mode_get(ATPortType_enum port, mbtk_net_info_t *net, int *cme_err)
 {
     //LOG("req_net_sel_mode_get() 0");
     //sleep(1);
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
+    int err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
     //LOG("req_net_sel_mode_get() 00");
     //sleep(1);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -216,7 +216,7 @@
 OK
 
 */
-static int req_net_sel_mode_set(mbtk_net_info_t* net, int *cme_err)
+static int req_net_sel_mode_set(ATPortType_enum port, mbtk_net_info_t* net, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -233,7 +233,7 @@
         }
      }
 
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         if(cme_err) {
@@ -252,7 +252,7 @@
 OK
 
 */
-static int req_band_set(mbtk_band_info_t* band, int *cme_err)
+static int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
@@ -305,7 +305,7 @@
 
         if(band->net_pref == 0xFF) { // No change net_pref.
             int tmp_int;
-            err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
+            err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
             if (err < 0 || response->success == 0 || !response->p_intermediates){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -336,7 +336,7 @@
             sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band);
         }
     }
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0){
         if(cme_err) {
@@ -417,13 +417,13 @@
     65536 ?C FDDLTE _BAND_17
     524288 ?C FDDLTE _BAND_20
 */
-static int req_band_get(mbtk_band_info_t *band, int *cme_err)
+static int req_band_get(ATPortType_enum port, mbtk_band_info_t *band, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
 
     log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t));
-    int err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
+    int err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -533,13 +533,13 @@
 OK
 
 */
-static int req_net_signal_get(mbtk_signal_info_t *signal, int *cme_err)
+static int req_net_signal_get(ATPortType_enum port, mbtk_signal_info_t *signal, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_ptr = NULL;
     // AT+EEMOPT=1 in the first.
-    int err = at_send_command_singleline("AT+CSQ", "+CSQ:", &response);
+    int err = at_send_command_singleline(port, "AT+CSQ", "+CSQ:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -561,7 +561,7 @@
     signal->rssi = (uint8)tmp_int;
     at_response_free(response);
 
-    err = at_send_command_singleline("AT+CESQ", "+CESQ:", &response);
+    err = at_send_command_singleline(port, "AT+CESQ", "+CESQ:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -618,7 +618,7 @@
     signal->rsrp = (uint8)tmp_int;
 
     at_response_free(response);
-    err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
+    err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -693,12 +693,12 @@
 
 
 */
-static int req_net_reg_get(mbtk_net_reg_info_t *reg, int *cme_err)
+static int req_net_reg_get(ATPortType_enum port, mbtk_net_reg_info_t *reg, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_str = NULL;
-    int err = at_send_command("AT+CREG=3", &response);
+    int err = at_send_command(port, "AT+CREG=3", &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -707,7 +707,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CREG?", "+CREG:", &response);
+    err = at_send_command_multiline(port, "AT+CREG?", "+CREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -757,7 +757,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CEREG?", "+CEREG:", &response);
+    err = at_send_command_multiline(port, "AT+CEREG?", "+CEREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -807,7 +807,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CIREG?", "+CIREG:", &response);
+    err = at_send_command_multiline(port, "AT+CIREG?", "+CIREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         reg->ims_state = (uint8)0;
         err = 0;
@@ -1039,13 +1039,13 @@
 OK
 
 */
-static int req_cell_info_get(int *cme_err)
+static int req_cell_info_get(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     int buff_size = 0;
     // AT+EEMOPT=1 in the first.
-    int err = at_send_command("AT+EEMOPT=1", &response);
+    int err = at_send_command(port, "AT+EEMOPT=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1056,7 +1056,7 @@
     cell_info.running = true;
     cell_info.cell_list.num = 0;
 
-    err = at_send_command_singleline("AT+EEMGINFO?", "+EEMGINFO:", &response);
+    err = at_send_command_singleline(port, "AT+EEMGINFO?", "+EEMGINFO:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1147,7 +1147,7 @@
     return buff_size;
 }
 
-static int req_cell_info_set(const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cell_info_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[500] = {0};
@@ -1160,7 +1160,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -1202,7 +1202,7 @@
             {
                 mbtk_net_info_array_t net_array;
                 memset(&net_array, 0, sizeof(mbtk_net_info_array_t));
-                if(req_available_net_get(&net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_available_net_get(cli_info->port, &net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1213,7 +1213,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
                 }
             }
             else     // Set
@@ -1229,7 +1229,7 @@
             {
                 mbtk_net_info_t info;
                 memset(&info, 0, sizeof(mbtk_net_info_t));
-                if(req_net_sel_mode_get(&info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1240,13 +1240,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
                 }
             }
             else     // Set
             {
                 mbtk_net_info_t *info = (mbtk_net_info_t*)pack->data;
-                if(req_net_sel_mode_set(info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_set(cli_info->port, info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1257,7 +1257,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1275,7 +1275,7 @@
                     if(*(pack->data)) { // Get current bands.
                         mbtk_band_info_t band;
                         memset(&band, 0x0, sizeof(mbtk_band_info_t));
-                        if(req_band_get(&band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_band_get(cli_info->port, &band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1286,10 +1286,10 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
                         }
                     } else { // Get support bands.
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
                     }
                 } else { // Set current bands.
                     mbtk_band_info_t* band = (mbtk_band_info_t*)pack->data;
@@ -1300,7 +1300,7 @@
                         break;
                     }
 
-                    if(req_band_set(band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_band_set(cli_info->port, band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1311,7 +1311,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 }
             }
@@ -1323,7 +1323,7 @@
             {
                 mbtk_signal_info_t signal;
                 memset(&signal, 0, sizeof(mbtk_signal_info_t));
-                if(req_net_signal_get(&signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_signal_get(cli_info->port, &signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1334,7 +1334,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
                 }
             }
             else     // Set
@@ -1350,7 +1350,7 @@
             {
                 mbtk_net_reg_info_t net_reg;
                 memset(&net_reg, 0, sizeof(mbtk_net_reg_info_t));
-                if(req_net_reg_get(&net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_reg_get(cli_info->port, &net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1361,7 +1361,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
                 }
             }
             else     // Set
@@ -1375,7 +1375,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)   // Get net cell.
             {
-                if(req_cell_info_get(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_get(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1387,7 +1387,7 @@
                 else
                 {
                     LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
                 }
             }
             else     // Lock cell
@@ -1395,7 +1395,7 @@
                 char *mem = (char*)(pack->data);
                 int len = pack->data_len;
                 char reg[100] = {0};
-                if(req_cell_info_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1405,7 +1405,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_pb.c b/mbtk/mbtk_rild_v2/src/ril_pb.c
index 522f578..1d93cc9 100755
--- a/mbtk/mbtk_rild_v2/src/ril_pb.c
+++ b/mbtk/mbtk_rild_v2/src/ril_pb.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 //void net_list_free(void *data);
 // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
diff --git a/mbtk/mbtk_rild_v2/src/ril_sim.c b/mbtk/mbtk_rild_v2/src/ril_sim.c
index 78ef0f0..fc9221e 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sim.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sim.c
@@ -17,10 +17,10 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /** Returns SIM_NOT_READY on error */
-mbtk_sim_state_enum ril_sim_state_get()
+mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
@@ -28,7 +28,7 @@
     char *cpinLine;
     char *cpinResult;
 
-    err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response);
+    err = at_send_command_singleline(port, "AT+CPIN?", "+CPIN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -154,11 +154,11 @@
 
 OK
 */
-static int req_sim_type_get(uint8 *type, int *cme_err)
+static int req_sim_type_get(ATPortType_enum port, uint8 *type, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*EUICC?", "*EUICC:", &response);
+    int err = at_send_command_singleline(port, "AT*EUICC?", "*EUICC:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -191,11 +191,11 @@
 
 OK
 */
-static int req_iccid_get(void *data, int *cme_err)
+static int req_iccid_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+ICCID", "+ICCID:", &response);
+    int err = at_send_command_singleline(port, "AT+ICCID", "+ICCID:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -228,11 +228,11 @@
 OK
 
 */
-static int req_phone_number_get(void *data, int *cme_err)
+static int req_phone_number_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CNUM?", "+CNUM:", &response);
+    int err = at_send_command_singleline(port, "AT+CNUM?", "+CNUM:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -278,10 +278,10 @@
 OK
 
 */
-static int req_imsi_get(void *data, int *cme_err)
+static int req_imsi_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric("AT+CIMI", &response);
+    int err = at_send_command_numeric(port, "AT+CIMI", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -294,12 +294,12 @@
     return err;
 }
 
-static int req_sim_lock_state_get(int *state, int *cme_err)
+static int req_sim_lock_state_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char cmd[64]={0};
 
-    int err = at_send_command_singleline("AT+CLCK=SC,2", "+CLCK:", &response);
+    int err = at_send_command_singleline(port, "AT+CLCK=SC,2", "+CLCK:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -343,12 +343,12 @@
 
 *
 */
-static int req_sim_lock_switch(bool enable, uint8* pin, int *cme_err)
+static int req_sim_lock_switch(ATPortType_enum port, bool enable, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     snprintf(cmd, sizeof(cmd), "AT+CLCK=SC,%d,%s", enable ? 1 : 0, pin);
-    int err = at_send_command_singleline(cmd, "+CLCK:", &response);
+    int err = at_send_command_singleline(port, cmd, "+CLCK:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -393,22 +393,22 @@
     return err;
 }
 
-static int req_sim_pin_change(uint8* old_pin, uint8 *new_pin, int *cme_err)
+static int req_sim_pin_change(ATPortType_enum port, uint8* old_pin, uint8 *new_pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[128]={0};
     int err = 0;
     int state;
-    if(req_sim_lock_state_get(&state, cme_err) || *cme_err != MBTK_RIL_ERR_CME_NON)
+    if(req_sim_lock_state_get(port, &state, cme_err) || *cme_err != MBTK_RIL_ERR_CME_NON)
     {
         return -1;
     }
 
     if(state == 0) { // Sim lock not open.
-        return req_sim_lock_switch(TRUE, new_pin, cme_err);
+        return req_sim_lock_switch(port, TRUE, new_pin, cme_err);
     } else {// Change password.
         snprintf(cmd, sizeof(cmd), "AT+CPWD=SC,%s,%s", old_pin, new_pin);
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -422,12 +422,12 @@
     return err;
 }
 
-static int req_sim_pin_verify(uint8* pin, int *cme_err)
+static int req_sim_pin_verify(ATPortType_enum port, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     sprintf(cmd, "AT+CPIN=%s", pin);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -440,12 +440,12 @@
     return err;
 }
 
-static int req_sim_puk_verify(uint8* puk, uint8* pin, int *cme_err)
+static int req_sim_puk_verify(ATPortType_enum port, uint8* puk, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     sprintf(cmd, "AT+CPIN=%s,%s", puk, pin);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -458,29 +458,29 @@
     return err;
 }
 
-static int req_sim_lock_set(mbtk_sim_lock_info_t *lock_info, int *cme_err)
+static int req_sim_lock_set(ATPortType_enum port, mbtk_sim_lock_info_t *lock_info, int *cme_err)
 {
     switch(lock_info->type)
     {
         case MBTK_SIM_LOCK_TYPE_DISABLE:
         {
-            return req_sim_lock_switch(FALSE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(port, FALSE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_ENABLE:
         {
-            return req_sim_lock_switch(TRUE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(port, TRUE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_CHANGE:
         {
-            return req_sim_pin_change(lock_info->pin1, lock_info->pin2, cme_err);
+            return req_sim_pin_change(port, lock_info->pin1, lock_info->pin2, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PIN:
         {
-            return req_sim_pin_verify(lock_info->pin1, cme_err);
+            return req_sim_pin_verify(port, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PUK:
         {
-            return req_sim_puk_verify(lock_info->puk, lock_info->pin1, cme_err);
+            return req_sim_puk_verify(port, lock_info->puk, lock_info->pin1, cme_err);
         }
         default:
         {
@@ -498,12 +498,12 @@
 
 OK
 */
-static int req_pin_puk_last_times_get(mbtk_pin_puk_last_times_t *times, int *cme_err)
+static int req_pin_puk_last_times_get(ATPortType_enum port, mbtk_pin_puk_last_times_t *times, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+EPIN?", "+EPIN:", &response);
+    int err = at_send_command_singleline(port, "AT+EPIN?", "+EPIN:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -558,11 +558,11 @@
 
 OK
 */
-static int req_plmn_get(mbtk_plmn_info *info, int *cme_err)
+static int req_plmn_get(ATPortType_enum port, mbtk_plmn_info *info, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_multiline("AT+CPOL?", "+CPOL:", &response);
+    int err = at_send_command_multiline(port, "AT+CPOL?", "+CPOL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -627,7 +627,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_sim_state_enum state = ril_sim_state_get();
+                mbtk_sim_state_enum state = ril_sim_state_get(cli_info->port);
                 if(state == MBTK_SIM_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -635,7 +635,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -650,7 +650,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 uint8 sim_card_type;
-                if(req_sim_type_get(&sim_card_type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_type_get(cli_info->port, &sim_card_type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -661,7 +661,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
                 }
             }
             else     // Set
@@ -676,7 +676,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char imsi[20] = {0};
-                if(req_imsi_get(imsi, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imsi_get(cli_info->port, imsi, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -687,7 +687,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
                 }
             }
             else     // Set
@@ -702,7 +702,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char pn[50] = {0};
-                if(req_phone_number_get(pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_phone_number_get(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -713,7 +713,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
                 }
             }
             else     // Set
@@ -728,7 +728,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char iccid[50] = {0};
-                if(req_iccid_get(iccid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_iccid_get(cli_info->port, iccid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -739,7 +739,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
                 }
             }
             else     // Set
@@ -754,7 +754,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 int state;
-                if(req_sim_lock_state_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_state_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -765,13 +765,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set
             {
                 mbtk_sim_lock_info_t *lock_info = (mbtk_sim_lock_info_t*)pack->data;
-                if(req_sim_lock_set(lock_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_set(cli_info->port, lock_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -782,7 +782,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -792,7 +792,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_pin_puk_last_times_t last_times;
-                if(req_pin_puk_last_times_get(&last_times, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_pin_puk_last_times_get(cli_info->port, &last_times, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -803,7 +803,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &last_times, sizeof(mbtk_pin_puk_last_times_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &last_times, sizeof(mbtk_pin_puk_last_times_t));
                 }
             }
             else     // Set
@@ -819,7 +819,7 @@
             {
                 mbtk_plmn_info info;
                 memset(&info, 0, sizeof(mbtk_plmn_info));
-                if(req_plmn_get(&info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_plmn_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -830,7 +830,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
                 }
             }
             else     // Set
diff --git a/mbtk/mbtk_rild_v2/src/ril_sms.c b/mbtk/mbtk_rild_v2/src/ril_sms.c
index c2c87d6..bb64f34 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sms.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sms.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+CMGF?
@@ -26,11 +26,11 @@
 OK
 
 */
-static int req_cmgf_get(int *state, int *cme_err)
+static int req_cmgf_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CMGF?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CMGF?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -61,7 +61,7 @@
 
 OK
 */
-static int req_cmgf_set(int state, int *cme_err)
+static int req_cmgf_set(ATPortType_enum port, int state, int *cme_err)
 {
     LOGD("req_cmgf_set()-------------start");
     LOGD("state:%d",state);
@@ -77,7 +77,7 @@
     }
 
     LOGD("req_cmgf_set()----cmd:%s", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -91,7 +91,7 @@
 }
 
 /*set AT+CNMI=1,2*/
-static int req_cnmi_set(int *cme_err)
+static int req_cnmi_set(ATPortType_enum port, int *cme_err)
 {
     printf("req_cnmi_set()-------------start3\n");
     ATResponse *response = NULL;
@@ -100,7 +100,7 @@
 	strcpy(cmd, "AT+CNMI=1,2");
 
     printf("req_cnmi_set()----cmd:%s\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
 		printf("err:%d, response->success:%d \n", err, response->success);
@@ -123,12 +123,12 @@
 OK
 
 */
-static int req_cpms_get(char *reg, int *cme_err)
+static int req_cpms_get(ATPortType_enum port, char *reg, int *cme_err)
 {
 	printf("req_cpms_get------------start(3)\n");
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CPMS?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CPMS?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -170,7 +170,7 @@
 OK
 
 */
-static int req_cpms_set(const char *mem, char *reg, int len, int *cme_err)
+static int req_cpms_set(ATPortType_enum port, const char *mem, char *reg, int len, int *cme_err)
 {
     printf("req_cpms_set(2)----------------start\n");
     printf("mem:%s\n", mem);
@@ -192,7 +192,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(cmd, "+CPMS:", &response);
+        err = at_send_command_multiline(port, cmd, "+CPMS:", &response);
         if (err < 0 || response->success == 0){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -224,7 +224,7 @@
 
 
 */
-static int req_cmgs_set(char *cmgs, char *reg, int len, int *cme_err)
+static int req_cmgs_set(ATPortType_enum port, char *cmgs, char *reg, int len, int *cme_err)
 {
     LOGD("req_cmgs_set()----------------start");
     LOGD("cmgs:%s", cmgs);
@@ -262,7 +262,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(cmd, data, "+CMGS: ", &response);
+		int err = at_send_command_sms(port, cmd, data, "+CMGS: ", &response);
 		LOGD("err:%d, response:%d", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -281,7 +281,7 @@
     return err;
 }
 
-static int req_cmgw_set(char *cmgw,int len, int *cme_err)
+static int req_cmgw_set(ATPortType_enum port, char *cmgw,int len, int *cme_err)
 {
     printf("req_cmgw_set()----------------start\n");
     printf("cmgw:%s\n", cmgw);
@@ -307,7 +307,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(cmd, data, "+CMGW: ", &response);
+		int err = at_send_command_sms(port, cmd, data, "+CMGW: ", &response);
 		printf("err:%d, response:%d\n", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -330,7 +330,7 @@
 
 +MMSG: 1, 0
 */
-static int req_cmgd_set(char *cmgd, int len, int *cme_err)
+static int req_cmgd_set(ATPortType_enum port, char *cmgd, int len, int *cme_err)
 {
     printf("0req_cmgd_set()--------------start\n");
     printf("cmgd:%s\n", cmgd);
@@ -347,7 +347,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -372,11 +372,11 @@
 OK
 
 */
-static int req_cmgd_get(char *reg, int *cme_err)
+static int req_cmgd_get(ATPortType_enum port, char *reg, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CMGD=?", "+CMGD:", &response);
+    int err = at_send_command_singleline(port, "AT+CMGD=?", "+CMGD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -420,7 +420,7 @@
 
 */
 
-static int req_cmgl_set(const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cmgl_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
 {
     printf("req_cmgl_set(2)-----------------start\n");
     printf("cmgl:%s\n", cmgl);
@@ -463,7 +463,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
             printf("at_send_command_multiline() is err-----------------\n");
@@ -534,11 +534,11 @@
 +CSCA: "+8613800280500",145
 OK
 */
-static int req_csca_get(char *req, int *cme_err)
+static int req_csca_get(ATPortType_enum port, char *req, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CSCA?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CSCA?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -565,7 +565,7 @@
     return err;
 }
 
-static int req_csca_set(char *csca, int len, int *cme_err)
+static int req_csca_set(ATPortType_enum port, char *csca, int len, int *cme_err)
 {
     printf("req_csca_set()--------------start\n");
     printf("csca:%s\n", csca);
@@ -582,7 +582,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -598,7 +598,7 @@
     return err;
 }
 
-static int req_csmp_set(char *csmp, int len, int *cme_err)
+static int req_csmp_set(ATPortType_enum port, char *csmp, int len, int *cme_err)
 {
     printf("req_csmp_set()-------------------start\n");
     printf("csmp:%s\n", csmp);
@@ -615,7 +615,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -631,7 +631,7 @@
     return err;
 }
 
-static int req_cscb_set(char *cscb,int len, int *cme_err)
+static int req_cscb_set(ATPortType_enum port, char *cscb,int len, int *cme_err)
 {
     printf("req_cscb_set()----------------start\n");
     printf("cscb:%s\n", cscb);
@@ -648,7 +648,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -669,7 +669,7 @@
 +CMSS: 81
 OK
 */
-static int req_cmss_set(const char *cmss, char *reg, int len, int *cme_err)
+static int req_cmss_set(ATPortType_enum port, const char *cmss, char *reg, int len, int *cme_err)
 {
     printf("req_cmss_set()----------------start\n");
     printf("cmss:%s\n", cmss);
@@ -692,7 +692,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(cmd, "+CMSS:", &response);
+        err = at_send_command_multiline(port, cmd, "+CMSS:", &response);
 		if (err < 0 || response->success == 0){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -737,7 +737,7 @@
 
 OK
 */
-static int req_cmgr_set(int index, char *reg, int *cme_err)
+static int req_cmgr_set(ATPortType_enum port, int index, char *reg, int *cme_err)
 {
     printf("0req_cmgr_set()-------------------start\n");
     printf("index:%d\n", index);
@@ -750,7 +750,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
             printf("at_send_command_multiline() is err-----------------\n");
@@ -802,7 +802,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_cmgf_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -813,7 +813,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -826,7 +826,7 @@
                     break;
                 }
 
-                if(req_cmgf_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -837,7 +837,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -847,7 +847,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // SET at+cnmi=1,2.
             {
 //                int state;
-                if(req_cnmi_set(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cnmi_set(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -858,7 +858,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
 			break;
@@ -868,7 +868,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[100] = {0};
-                if(req_cpms_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -879,7 +879,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -889,7 +889,7 @@
                 char reg[100] = {0};
                 LOGD("mem:%s, len:%d", pack->data, pack->data_len);
 
-                if(req_cpms_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -901,7 +901,7 @@
                 else
                 {
                     LOGD("cpms_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -919,7 +919,7 @@
 				char reg[50] ={0};
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgs, len);
 
-                if(req_cmgs_set(cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgs_set(cli_info->port, cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -930,7 +930,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -948,7 +948,7 @@
                 char reg[128] = {0};
                 LOGD("mbtk_sms,cmgs:%s, len:%d", cmss, len);
 
-                if(req_cmss_set(cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmss_set(cli_info->port, cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -960,7 +960,7 @@
                 else
                 {
                     LOGD("req_cmss_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -982,7 +982,7 @@
                     break;
                 }
 
-                if(req_cmgr_set(index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgr_set(cli_info->port, index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -993,7 +993,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -1010,7 +1010,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgw:%s,len:%d", cmgw, len);
 
-                if(req_cmgw_set(cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgw_set(cli_info->port, cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1021,7 +1021,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1031,7 +1031,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[1024] = {0};
-                if(req_cmgd_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1042,7 +1042,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -1051,7 +1051,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgd, len);
 
-                if(req_cmgd_set(cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_set(cli_info->port, cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1062,7 +1062,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
 
             }
@@ -1081,7 +1081,7 @@
                 char reg[5*1024] = {0};
                 char reg1[1024+1] = {0};
 
-                if(req_cmgl_set(cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgl_set(cli_info->port, cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1093,7 +1093,7 @@
                 else
                 {
                     memcpy(reg1, reg, 1024);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
                 }
             }
             break;
@@ -1103,7 +1103,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char csca[50]={0};
-                if(req_csca_get(csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_get(cli_info->port, csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1114,7 +1114,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
                 }
                 err = MBTK_RIL_ERR_UNSUPPORTED;
             }
@@ -1123,7 +1123,7 @@
 				char *csca = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csca_set(csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_set(cli_info->port, csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1134,7 +1134,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1150,7 +1150,7 @@
 				char *csmp = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csmp_set(csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csmp_set(cli_info->port, csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1161,7 +1161,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1177,7 +1177,7 @@
 				char *cscb = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_cscb_set(cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cscb_set(cli_info->port, cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1188,7 +1188,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;