Add DS support.

Change-Id: Ib8bc4e171dd5ca526f8e151ff3d467097582a8cb
diff --git a/mbtk/include/mbtk/mbtk_device_info.h b/mbtk/include/mbtk/mbtk_device_info.h
deleted file mode 100755
index c5e5bce..0000000
--- a/mbtk/include/mbtk/mbtk_device_info.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-* MBTK Device Information Define Header.
-*
-* Author : lb
-* Date   : 2021/11/5 17:40:29
-*
-*/
-#ifndef MBTK_DEVICES_INFO_H
-#define MBTK_DEVICES_INFO_H
-
-#define MBTK_DEVICES_MANUFACTURER "LYNQ"
-
-#define MBTK_DEVICES_MODEL "LYNQ_L508TLC"
-
-#define MBTK_DEVICES_REVISION "L508TLCv02.02b06.00"
-
-
-#endif /* MBTK_DEVICES_INFO_H */
diff --git a/mbtk/include/mbtk/mbtk_ril_api.h b/mbtk/include/mbtk/mbtk_ril_api.h
index 845898f..e3fb15d 100755
--- a/mbtk/include/mbtk/mbtk_ril_api.h
+++ b/mbtk/include/mbtk/mbtk_ril_api.h
@@ -49,6 +49,26 @@
     MBTK_AT_PORT_DATA = ATPORTTYPE_2       // Data Call Port
 } ATPortType_enum;
 
+typedef enum
+{
+    MBTK_SIM_1 = 0,
+    MBTK_SIM_2,
+    MBTK_SIM_NUM,
+    MBTK_SIM_AUTO = 0xFF        // Auto sim(Current active sim.)
+} mbtk_sim_type_enum;
+
+typedef enum
+{
+    ATPORTID_NON = -1,
+    ATPORTID_SIM1_0 = 0,       // /tmp/atcmd_at
+    ATPORTID_SIM1_1,           // /tmp/atcmd_at_1
+    ATPORTID_SIM1_2,           // /tmp/atcmd_at_2
+    ATPORTID_SIM2_0,           // /tmp/atcmd_at1
+    ATPORTID_SIM2_1,           // /tmp/atcmd_at1_1
+    ATPORTID_SIM2_2,           // /tmp/atcmd_at1_2
+    ATPORTID_NUM
+} ATPortId_enum;
+
 typedef enum {
     MBTK_RIL_CID_NUL = 0,   // Auto set cid.
     MBTK_RIL_CID_DEF = MBTK_APN_CID_MIN,
@@ -681,6 +701,7 @@
 
 typedef struct
 {
+    mbtk_sim_type_enum sim_id : 8;
     uint16 cid;
     uint16 action;
     uint16 reason;
@@ -705,6 +726,7 @@
 
 typedef struct
 {
+    mbtk_sim_type_enum sim_id : 8;
     mbtk_net_reg_type_enum type : 8;
     mbtk_radio_technology_enum tech : 8;
     mbtk_net_reg_state_enum reg_state : 8;
@@ -716,11 +738,13 @@
 {
     mbtk_sim_card_type_enum sim_type : 8;
     mbtk_sim_state_enum sim_state : 8;
+    mbtk_sim_type_enum sim_id : 8;
 } mbtk_ril_sim_state_info_t;
 
 typedef struct
 {
     mbtk_radio_state_enum radio_state : 8;
+    mbtk_sim_type_enum sim_id : 8;
 } mbtk_ril_radio_state_info_t;
 
 typedef struct
@@ -730,12 +754,14 @@
 
 typedef struct
 {
+    mbtk_sim_type_enum sim_id : 8;
     uint8 urc_id;
     uint8 urc_data[5];
 } mbtk_ril_ecall_state_info_t;
 
 typedef struct
 {
+    mbtk_sim_type_enum sim_id : 8;
     uint16 pdu_len;
     uint8 pdu[1024];
 } mbtk_ril_sms_state_info_t;
@@ -814,6 +840,7 @@
 typedef struct
 {
     uint8 call_id;
+    mbtk_sim_type_enum sim_id : 8;
     mbtk_ril_call_dir_enum dir : 8;
     mbtk_ril_call_state_enum state : 8;
     mbtk_ril_call_num_type_enum num_type : 8;
@@ -1637,10 +1664,92 @@
 mbtk_ril_err_enum mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
-* get md version 
+* get md version
 */
 int mbtk_get_modem_version(mbtk_ril_handle* handle, void *modem_version);
 
+/*
+* Set dual sim switch.
+*
+*/
+mbtk_ril_err_enum mbtk_sim_switch_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+
+/*
+* Get dual sim switch.
+*
+*/
+mbtk_ril_err_enum mbtk_sim_switch_get(mbtk_ril_handle* handle, mbtk_sim_type_enum *sim_id);
+
+
+mbtk_ril_err_enum mbtk_ds_version_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *version);
+mbtk_ril_err_enum mbtk_ds_model_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *model);
+mbtk_ril_err_enum mbtk_ds_radio_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_radio_state_enum *radio_state);
+mbtk_ril_err_enum mbtk_ds_radio_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_radio_state_enum radio_state, bool reset_modem);
+mbtk_ril_err_enum mbtk_ds_cell_time_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char* time_str);
+mbtk_ril_err_enum mbtk_ds_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_state_enum *sim_state);
+mbtk_ril_err_enum mbtk_ds_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_card_type_enum *sim_card_type);
+mbtk_ril_err_enum mbtk_ds_imsi_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *imsi);
+mbtk_ril_err_enum mbtk_ds_iccid_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *iccid);
+mbtk_ril_err_enum mbtk_ds_phone_number_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *phone_number);
+mbtk_ril_err_enum mbtk_ds_sim_lock_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *lock_state);
+mbtk_ril_err_enum mbtk_ds_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_lock_info_t *lock_info);
+mbtk_ril_err_enum mbtk_ds_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_pin_puk_last_times_t *retry_times);
+mbtk_ril_err_enum mbtk_ds_plmn_list_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_plmn_info *plmn_list);
+mbtk_ril_err_enum mbtk_ds_available_net_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_info_array_t *net_array);
+mbtk_ril_err_enum mbtk_ds_net_sel_mode_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_net_info_t *net);
+mbtk_ril_err_enum mbtk_ds_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_info_t *net);
+mbtk_ril_err_enum mbtk_ds_current_band_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_band_info_t *band);
+mbtk_ril_err_enum mbtk_ds_current_band_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_band_info_t *band);
+mbtk_ril_err_enum mbtk_ds_cell_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_cell_info_array_t *cell_array);
+mbtk_ril_err_enum mbtk_ds_cell_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char *info, char *response);
+mbtk_ril_err_enum mbtk_ds_net_signal_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_signal_info_t *signal);
+mbtk_ril_err_enum mbtk_ds_net_reg_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_reg_info_t *reg);
+mbtk_ril_err_enum mbtk_ds_oos_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_oos_info_t *oos_info);
+mbtk_ril_err_enum mbtk_ds_oos_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_ril_oos_info_t *oos_info);
+mbtk_ril_err_enum mbtk_ds_wakeup_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int wakeup_state);
+mbtk_ril_err_enum mbtk_ds_apn_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_apn_info_array_t *apns);
+mbtk_ril_err_enum mbtk_ds_apn_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_apn_info_t *apn);
+mbtk_ril_err_enum mbtk_ds_data_call_start(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_call,
+            mbtk_data_call_item_state_enum def_route, mbtk_data_call_item_state_enum as_dns, int *retry_interval, int retry_interval_num,
+            int timeout, mbtk_ip_info_t *rsp_info);
+mbtk_ril_err_enum mbtk_ds_data_call_stop(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, int timeout);
+mbtk_ril_err_enum mbtk_ds_data_call_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip);
+mbtk_ril_err_enum mbtk_ds_sms_cmgf_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *sms_state);
+mbtk_ril_err_enum mbtk_ds_sms_cmgf_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int mode);
+mbtk_ril_err_enum mbtk_ds_sms_cmgs_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgs, char *resp);
+mbtk_ril_err_enum mbtk_ds_sms_cmgw_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgw, char *resp);
+mbtk_ril_err_enum mbtk_ds_sms_cmgd_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmdg);
+mbtk_ril_err_enum mbtk_ds_sms_cmgd_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmdg);
+mbtk_ril_err_enum mbtk_ds_sms_cmgl_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgl, char *resp);
+mbtk_ril_err_enum mbtk_ds_sms_csca_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char *buf);
+mbtk_ril_err_enum mbtk_ds_sms_csca_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * csca);
+mbtk_ril_err_enum mbtk_ds_sms_csmp_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * csmp);
+mbtk_ril_err_enum mbtk_ds_sms_cscb_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cscb);
+mbtk_ril_err_enum mbtk_ds_sms_cnmi_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+mbtk_ril_err_enum mbtk_ds_sms_cmss_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmss, char *resp);
+mbtk_ril_err_enum mbtk_ds_sms_cpms_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * mem);
+mbtk_ril_err_enum mbtk_ds_sms_cpms_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * mem, char* resp);
+mbtk_ril_err_enum mbtk_ds_sms_cmgr_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int index, char *resp);
+mbtk_ril_err_enum mbtk_ds_call_start(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char* phone_number);
+mbtk_ril_err_enum mbtk_ds_call_answer(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+mbtk_ril_err_enum mbtk_ds_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+mbtk_ril_err_enum mbtk_ds_a_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int phone_id);
+mbtk_ril_err_enum mbtk_ds_waiting_or_background_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+mbtk_ril_err_enum mbtk_ds_foreground_resume_background_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id);
+mbtk_ril_err_enum mbtk_ds_call_reg_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_call_info_t *reg);
+mbtk_ril_err_enum mbtk_ds_mute_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *mute_state);
+mbtk_ril_err_enum mbtk_ds_mute_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int mute_state);
+mbtk_ril_err_enum mbtk_ds_dtmf_send(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_call_dtmf_info_t *dtmf_character);
+mbtk_ril_err_enum mbtk_ds_centric_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int centric);
+mbtk_ril_err_enum mbtk_ds_centric_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *centric);
+mbtk_ril_err_enum mbtk_ds_net_reg_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_call_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_sms_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_radio_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_sim_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_pdp_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_signal_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ds_ecall_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb);
 
 #endif /* _MBTK_INFO_API_2_H */
 
diff --git a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
index 3ad1dd4..11cf8ec 100755
--- a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
+++ b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
@@ -20,8 +20,8 @@
 
 // Tag(4) + Packet_Length(2)
 #define RIL_SOCK_PACK_EXTRA_LEN 6
-// RIL_SOCK_PACK_EXTRA_LEN + at_port(1) + Index(2) + Type(2) + Id(2) + Error(2) + data_len(2)
-#define RIL_SOCK_PACK_LEN_MIN (RIL_SOCK_PACK_EXTRA_LEN + 11)
+// RIL_SOCK_PACK_EXTRA_LEN + at_port(1) + sim_id(1) + Index(2) + Type(2) + Id(2) + Error(2) + data_len(2)
+#define RIL_SOCK_PACK_LEN_MIN (RIL_SOCK_PACK_EXTRA_LEN + 12)
 
 #define RIL_MSG_INDEX_AUTO      (-1)         // automatically , refor to :  ril_index
 #define RIL_MSG_INDEX_INVALID   (0)       // Invalid msg index.
@@ -78,6 +78,8 @@
     RIL_MSG_ID_SIM_PINPUK_TIMES,
     // <string> PLMN
     RIL_MSG_ID_SIM_PLMN,
+    // <uint8>
+    RIL_MSG_ID_SIM_SWITCH,
 
     RIL_MSG_ID_SIM_END,
 
@@ -240,6 +242,7 @@
     uint16 msg_len;
 
     uint8 at_port;  // ATPortType_enum
+    uint8 sim_id;   // mbtk_sim_type_enum
     uint16 msg_index;   // Message index(Start from 1)
             // 0 : For unknown msg id
     uint16 msg_type;    // Refor to : ril_msg_type_enum
@@ -407,7 +410,7 @@
 
 void ril_msg_pack_free(ril_msg_pack_info_t* pack);
 
-ril_msg_pack_info_t* ril_msg_pack_creat(ATPortType_enum port, int msg_type, int msg_id, int msg_index, const void *data, int data_len);
+ril_msg_pack_info_t* ril_msg_pack_creat(mbtk_sim_type_enum sim_id, ATPortType_enum port, int msg_type, int msg_id, int msg_index, const void *data, int data_len);
 
 int ril_pack_send(int fd, ril_msg_pack_info_t *pack);
 
diff --git a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
index f881408..6e648ef 100755
--- a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
@@ -1,7 +1,7 @@
 /*
 *    mbtk_ril_api.c
 *
-*    MBTK ril API for v2.
+*    MBTK ril API for v2(Only for DS).
 *
 */
 /******************************************************************************
@@ -14,6 +14,7 @@
 2024/12/31     LiuBin      Auto open default port.
                            Add port index for open/close,close port only index is 0.
 2025/03/26     LiuBin      Add timeout for API(Default timeout is 10s).
+2025/04/22     LiuBin      Add DS(Dual Sim) support.
 ******************************************************************************/
 
 #include <stdio.h>
@@ -475,7 +476,7 @@
 * Return recv data length.
 * -1 : fail.
 */
-static mbtk_ril_err_enum ril_req_process(ATPortType_enum port,
+static mbtk_ril_err_enum ril_req_process(mbtk_sim_type_enum sim_id, ATPortType_enum port,
                              ril_msg_id_enum  id,
                              const void         *req,
                              int                req_len,
@@ -483,7 +484,7 @@
                              bool is_async,
                              int timeout)
 {
-    ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
+    ril_msg_pack_info_t* pack = ril_msg_pack_creat(sim_id, port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
     if(pack == NULL)
     {
         return MBTK_RIL_ERR_MEMORY;
@@ -795,7 +796,7 @@
 /*
 * Get platform version.
 */
-mbtk_ril_err_enum mbtk_version_get(mbtk_ril_handle* handle, void *version)
+mbtk_ril_err_enum mbtk_ds_version_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *version)
 {
     if(!ril_cli.ril_ready)
     {
@@ -813,13 +814,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VERSION, NULL, 0, version, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_VERSION, NULL, 0, version, FALSE, 0);
 }
 
 /*
 * Get platform version.
 */
-mbtk_ril_err_enum mbtk_model_get(mbtk_ril_handle* handle, void *model)
+mbtk_ril_err_enum mbtk_version_get(mbtk_ril_handle* handle, void *version)
+{
+    return mbtk_ds_version_get(handle, MBTK_SIM_AUTO, version);
+}
+
+/*
+* Get platform version.
+*/
+mbtk_ril_err_enum mbtk_ds_model_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *model)
 {
     if(!ril_cli.ril_ready)
     {
@@ -837,7 +846,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEL, NULL, 0, model, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_MODEL, NULL, 0, model, FALSE, 0);
+}
+
+/*
+* Get platform version.
+*/
+mbtk_ril_err_enum mbtk_model_get(mbtk_ril_handle* handle, void *model)
+{
+    return mbtk_ds_model_get(handle, MBTK_SIM_AUTO, model);
 }
 
 /*
@@ -861,7 +878,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_IMEI, NULL, 0, imei, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_IMEI, NULL, 0, imei, FALSE, 0);
 }
 
 
@@ -886,7 +903,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_SN, NULL, 0, sn, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_SN, NULL, 0, sn, FALSE, 0);
 }
 
 
@@ -911,7 +928,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MEID, NULL, 0, meid, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_MEID, NULL, 0, meid, FALSE, 0);
 }
 
 
@@ -937,7 +954,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, NULL, 0, volte_state, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_VOLTE, NULL, 0, volte_state, FALSE, 0);
 }
 
 /*
@@ -967,13 +984,13 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_VOLTE, &volte_state, 1, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_VOLTE, &volte_state, 1, NULL, FALSE, 0);
 }
 
 /*
 * Return radio state.
 */
-mbtk_ril_err_enum mbtk_radio_state_get(mbtk_ril_handle* handle, mbtk_radio_state_enum *radio_state)
+mbtk_ril_err_enum mbtk_ds_radio_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_radio_state_enum *radio_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -993,11 +1010,20 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE, 0);
     *radio_state = (mbtk_radio_state_enum)result;
     return err;
 }
 
+
+/*
+* Return radio state.
+*/
+mbtk_ril_err_enum mbtk_radio_state_get(mbtk_ril_handle* handle, mbtk_radio_state_enum *radio_state)
+{
+    return mbtk_ds_radio_state_get(handle, MBTK_SIM_AUTO, radio_state);
+}
+
 /*
 * Set radio state.
 *
@@ -1005,7 +1031,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_radio_state_set(mbtk_ril_handle* handle, mbtk_radio_state_enum radio_state, bool reset_modem)
+mbtk_ril_err_enum mbtk_ds_radio_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_radio_state_enum radio_state, bool reset_modem)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1027,10 +1053,23 @@
     buff[0] = (uint8)radio_state;
     buff[1] = reset_modem ? 1 : 0;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE, 0);
 }
 
 /*
+* Set radio state.
+*
+* Refor to : mbtk_radio_state_enum
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_radio_state_set(mbtk_ril_handle* handle, mbtk_radio_state_enum radio_state, bool reset_modem)
+{
+    return mbtk_ds_radio_state_set(handle, MBTK_SIM_AUTO, radio_state, reset_modem);
+}
+
+
+/*
 * Get system temperature.
 *
 * type[IN]:
@@ -1060,7 +1099,7 @@
 
     int16 result;
     uint8 temp_temp = (uint8)type;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE, 0);
     *temp = (int16)result;
     return err;
 }
@@ -1070,7 +1109,7 @@
 * Get time type.
 * "23/05/24,06:09:32+32" -> "23/05/24 06:09:32 +32 00"
 */
-mbtk_ril_err_enum mbtk_cell_time_get(mbtk_ril_handle* handle, char* time_str)
+mbtk_ril_err_enum mbtk_ds_cell_time_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char* time_str)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1089,7 +1128,7 @@
     }
 
     char buff[RIL_SOCK_MSG_LEN_MAX] = {0};
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE, 0);
     if(MBTK_RIL_ERR_SUCCESS == err)
     {
         memcpy(time_str,buff,strlen(buff));
@@ -1141,9 +1180,18 @@
 }
 
 /*
+* Get time type.
+* "23/05/24,06:09:32+32" -> "23/05/24 06:09:32 +32 00"
+*/
+mbtk_ril_err_enum mbtk_cell_time_get(mbtk_ril_handle* handle, char* time_str)
+{
+    return mbtk_ds_cell_time_get(handle, MBTK_SIM_AUTO, time_str);
+}
+
+/*
 * Get sim state.
 */
-mbtk_ril_err_enum mbtk_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_state_enum *sim_state)
+mbtk_ril_err_enum mbtk_ds_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_state_enum *sim_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1163,15 +1211,24 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE, 0);
     *sim_state = (mbtk_sim_state_enum)result;
     return err;
 }
 
 /*
+* Get sim state.
+*/
+mbtk_ril_err_enum mbtk_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_state_enum *sim_state)
+{
+    return mbtk_ds_sim_state_get(handle, MBTK_SIM_AUTO, sim_state);
+}
+
+
+/*
 * Get sim card type.
 */
-mbtk_ril_err_enum mbtk_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_card_type_enum *sim_card_type)
+mbtk_ril_err_enum mbtk_ds_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_card_type_enum *sim_card_type)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1191,15 +1248,23 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE, 0);
     *sim_card_type = (mbtk_sim_card_type_enum)result;
     return err;
 }
 
 /*
+* Get sim card type.
+*/
+mbtk_ril_err_enum mbtk_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_card_type_enum *sim_card_type)
+{
+    return mbtk_ds_sim_type_get(handle, MBTK_SIM_AUTO, sim_card_type);
+}
+
+/*
 * Get platform IMSI.
 */
-mbtk_ril_err_enum mbtk_imsi_get(mbtk_ril_handle* handle, void *imsi)
+mbtk_ril_err_enum mbtk_ds_imsi_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *imsi)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1217,13 +1282,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_IMSI, NULL, 0, imsi, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_IMSI, NULL, 0, imsi, FALSE, 0);
+}
+
+/*
+* Get platform IMSI.
+*/
+mbtk_ril_err_enum mbtk_imsi_get(mbtk_ril_handle* handle, void *imsi)
+{
+    return mbtk_ds_imsi_get(handle, MBTK_SIM_AUTO, imsi);
 }
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_iccid_get(mbtk_ril_handle* handle, void *iccid)
+mbtk_ril_err_enum mbtk_ds_iccid_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *iccid)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1241,13 +1314,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_ICCID, NULL, 0, iccid, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_ICCID, NULL, 0, iccid, FALSE, 0);
+}
+
+/*
+* Get platform ICCID.
+*/
+mbtk_ril_err_enum mbtk_iccid_get(mbtk_ril_handle* handle, void *iccid)
+{
+    return mbtk_ds_iccid_get(handle, MBTK_SIM_AUTO, iccid);
 }
 
 /*
 * Get current phone number.
 */
-mbtk_ril_err_enum mbtk_phone_number_get(mbtk_ril_handle* handle, void *phone_number)
+mbtk_ril_err_enum mbtk_ds_phone_number_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, void *phone_number)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1265,13 +1346,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PN, NULL, 0, phone_number, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_PN, NULL, 0, phone_number, FALSE, 0);
+}
+
+/*
+* Get current phone number.
+*/
+mbtk_ril_err_enum mbtk_phone_number_get(mbtk_ril_handle* handle, void *phone_number)
+{
+    return mbtk_ds_phone_number_get(handle, MBTK_SIM_AUTO, phone_number);
 }
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_get(mbtk_ril_handle* handle, int *lock_state)
+mbtk_ril_err_enum mbtk_ds_sim_lock_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *lock_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1291,16 +1380,23 @@
     }
 
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE, 0);
     *lock_state = result;
     return err;
 }
 
+/*
+* Get platform ICCID.
+*/
+mbtk_ril_err_enum mbtk_sim_lock_get(mbtk_ril_handle* handle, int *lock_state)
+{
+    return mbtk_ds_sim_lock_get(handle, MBTK_SIM_AUTO, lock_state);
+}
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_lock_info_t *lock_info)
+mbtk_ril_err_enum mbtk_ds_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_sim_lock_info_t *lock_info)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1318,13 +1414,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE, 0);
+}
+
+/*
+* Get platform ICCID.
+*/
+mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_lock_info_t *lock_info)
+{
+    return mbtk_ds_sim_lock_set(handle, MBTK_SIM_AUTO, lock_info);
 }
 
 /*
 * Get PIN’s number of remaining retry
 */
-mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_pin_puk_last_times_t *retry_times)
+mbtk_ril_err_enum mbtk_ds_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_pin_puk_last_times_t *retry_times)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1343,13 +1447,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE, 0);
+}
+
+/*
+* Get PIN’s number of remaining retry
+*/
+mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_pin_puk_last_times_t *retry_times)
+{
+    return mbtk_ds_sim_lock_retry_times_get(handle, MBTK_SIM_AUTO, retry_times);
 }
 
 /*
 * Get plmn list
 */
-mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_ril_handle* handle, mbtk_plmn_info *plmn_list)
+mbtk_ril_err_enum mbtk_ds_plmn_list_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_plmn_info *plmn_list)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1368,13 +1480,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SIM_PLMN, NULL, 0, plmn_list, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SIM_PLMN, NULL, 0, plmn_list, FALSE, 0);
+}
+
+/*
+* Get plmn list
+*/
+mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_ril_handle* handle, mbtk_plmn_info *plmn_list)
+{
+    return mbtk_ds_plmn_list_get(handle, MBTK_SIM_AUTO, plmn_list);
 }
 
 /*
 * Get available network.
 */
-mbtk_ril_err_enum mbtk_available_net_get(mbtk_ril_handle* handle, mbtk_net_info_array_t *net_array)
+mbtk_ril_err_enum mbtk_ds_available_net_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_info_array_t *net_array)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1393,13 +1513,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_AVAILABLE, NULL, 0, net_array, FALSE, -1);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_AVAILABLE, NULL, 0, net_array, FALSE, -1);
+}
+
+/*
+* Get available network.
+*/
+mbtk_ril_err_enum mbtk_available_net_get(mbtk_ril_handle* handle, mbtk_net_info_array_t *net_array)
+{
+    return mbtk_ds_available_net_get(handle, MBTK_SIM_AUTO, net_array);
 }
 
 /*
 * Set network select mode. (+COPS=...)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_set(mbtk_ril_handle* handle, const mbtk_net_info_t *net)
+mbtk_ril_err_enum mbtk_ds_net_sel_mode_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_net_info_t *net)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1417,13 +1545,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE, 0);
+}
+
+/*
+* Set network select mode. (+COPS=...)
+*/
+mbtk_ril_err_enum mbtk_net_sel_mode_set(mbtk_ril_handle* handle, const mbtk_net_info_t *net)
+{
+    return mbtk_ds_net_sel_mode_set(handle, MBTK_SIM_AUTO, net);
 }
 
 /*
 * Get network select mode. (+COPS?)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_net_info_t *net)
+mbtk_ril_err_enum mbtk_ds_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_info_t *net)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1442,7 +1578,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SEL_MODE, NULL, 0, net, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_SEL_MODE, NULL, 0, net, FALSE, 0);
+}
+
+/*
+* Get network select mode. (+COPS?)
+*/
+mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_net_info_t *net)
+{
+    return mbtk_ds_net_sel_mode_get(handle, MBTK_SIM_AUTO, net);
 }
 
 /*
@@ -1468,13 +1612,13 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
 }
 
 /*
 * Get platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band)
+mbtk_ril_err_enum mbtk_ds_current_band_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_band_info_t *band)
 {
     uint8 type = 1; // Get current bands.
     if(!ril_cli.ril_ready)
@@ -1494,13 +1638,22 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE, 0);
+}
+
+
+/*
+* Get platform current bands.
+*/
+mbtk_ril_err_enum mbtk_current_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band)
+{
+    return mbtk_ds_current_band_get(handle, MBTK_SIM_AUTO, band);
 }
 
 /*
 * Set platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_set(mbtk_ril_handle* handle, const mbtk_band_info_t *band)
+mbtk_ril_err_enum mbtk_ds_current_band_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_band_info_t *band)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1518,13 +1671,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE, 0);
+}
+
+/*
+* Set platform current bands.
+*/
+mbtk_ril_err_enum mbtk_current_band_set(mbtk_ril_handle* handle, const mbtk_band_info_t *band)
+{
+    return mbtk_ds_current_band_set(handle, MBTK_SIM_AUTO, band);
 }
 
 /*
 * Get current cell infomation.
 */
-mbtk_ril_err_enum mbtk_cell_get(mbtk_ril_handle* handle, mbtk_cell_info_array_t *cell_array)
+mbtk_ril_err_enum mbtk_ds_cell_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_cell_info_array_t *cell_array)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1543,7 +1704,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, NULL, 0, cell_array, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_CELL, NULL, 0, cell_array, FALSE, 0);
+}
+
+/*
+* Get current cell infomation.
+*/
+mbtk_ril_err_enum mbtk_cell_get(mbtk_ril_handle* handle, mbtk_cell_info_array_t *cell_array)
+{
+    return mbtk_ds_cell_get(handle, MBTK_SIM_AUTO, cell_array);
 }
 
 /*
@@ -1555,7 +1724,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_cell_set(mbtk_ril_handle* handle, char *info, char *response)
+mbtk_ril_err_enum mbtk_ds_cell_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char *info, char *response)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1573,13 +1742,27 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_CELL, info, strlen(info), response, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_CELL, info, strlen(info), response, FALSE, 0);
+}
+
+/*
+* Set cell info.
+*
+* at*CELL=<mode>,<act>,< band>,<freq>,<cellId>
+* at*cell=2,3,,40936,429   //
+* at*cell=0  //
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_cell_set(mbtk_ril_handle* handle, char *info, char *response)
+{
+    return mbtk_ds_cell_set(handle, MBTK_SIM_AUTO, info, response);
 }
 
 /*
 * Get current network signal.
 */
-mbtk_ril_err_enum mbtk_net_signal_get(mbtk_ril_handle* handle, mbtk_signal_info_t *signal)
+mbtk_ril_err_enum mbtk_ds_net_signal_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_signal_info_t *signal)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1598,13 +1781,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_SIGNAL, NULL, 0, signal, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_SIGNAL, NULL, 0, signal, FALSE, 0);
+}
+
+/*
+* Get current network signal.
+*/
+mbtk_ril_err_enum mbtk_net_signal_get(mbtk_ril_handle* handle, mbtk_signal_info_t *signal)
+{
+    return mbtk_ds_net_signal_get(handle, MBTK_SIM_AUTO, signal);
 }
 
 /*
 * Get current network register information.
 */
-mbtk_ril_err_enum mbtk_net_reg_get(mbtk_ril_handle* handle, mbtk_net_reg_info_t *reg)
+mbtk_ril_err_enum mbtk_ds_net_reg_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_net_reg_info_t *reg)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1623,13 +1814,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_REG, NULL, 0, reg, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_REG, NULL, 0, reg, FALSE, 0);
+}
+
+/*
+* Get current network register information.
+*/
+mbtk_ril_err_enum mbtk_net_reg_get(mbtk_ril_handle* handle, mbtk_net_reg_info_t *reg)
+{
+    return mbtk_ds_net_reg_get(handle, MBTK_SIM_AUTO, reg);
 }
 
 /*
 * oos get.
 */
-mbtk_ril_err_enum mbtk_oos_get(mbtk_ril_handle* handle, mbtk_ril_oos_info_t *oos_info)
+mbtk_ril_err_enum mbtk_ds_oos_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_oos_info_t *oos_info)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1648,13 +1847,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, NULL, 0, oos_info, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_OOS, NULL, 0, oos_info, FALSE, 0);
+}
+
+/*
+* oos get.
+*/
+mbtk_ril_err_enum mbtk_oos_get(mbtk_ril_handle* handle, mbtk_ril_oos_info_t *oos_info)
+{
+    return mbtk_ds_oos_get(handle, MBTK_SIM_AUTO, oos_info);
 }
 
 /*
 * oos set .
 */
-mbtk_ril_err_enum mbtk_oos_set(mbtk_ril_handle* handle, const mbtk_ril_oos_info_t *oos_info)
+mbtk_ril_err_enum mbtk_ds_oos_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, const mbtk_ril_oos_info_t *oos_info)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1672,7 +1879,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, oos_info, sizeof(mbtk_ril_oos_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_NET_OOS, oos_info, sizeof(mbtk_ril_oos_info_t), NULL, FALSE, 0);
+}
+
+/*
+* oos set .
+*/
+mbtk_ril_err_enum mbtk_oos_set(mbtk_ril_handle* handle, const mbtk_ril_oos_info_t *oos_info)
+{
+    return mbtk_ds_oos_set(handle, MBTK_SIM_AUTO, oos_info);
 }
 
 /*
@@ -1683,7 +1898,7 @@
 * 1~31 means suspend
 * Control the active reporting of some platform modems to reduce wakeup
 */
-mbtk_ril_err_enum mbtk_wakeup_state_set(mbtk_ril_handle* handle, int wakeup_state)
+mbtk_ril_err_enum mbtk_ds_wakeup_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int wakeup_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1701,13 +1916,26 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_POWERIND, &wakeup_state, sizeof(uint8), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DEV_POWERIND, &wakeup_state, sizeof(uint8), NULL, FALSE, 0);
+}
+
+/*
+* Set wakeup state.
+*
+* wakeup_state:(0~31)
+* 0 : means resume all
+* 1~31 means suspend
+* Control the active reporting of some platform modems to reduce wakeup
+*/
+mbtk_ril_err_enum mbtk_wakeup_state_set(mbtk_ril_handle* handle, int wakeup_state)
+{
+    return mbtk_ds_wakeup_state_set(handle, MBTK_SIM_AUTO, wakeup_state);
 }
 
 /*
 * Get all APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_get(mbtk_ril_handle* handle, mbtk_apn_info_array_t *apns)
+mbtk_ril_err_enum mbtk_ds_apn_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_apn_info_array_t *apns)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1726,14 +1954,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE, 0);
 }
 
+/*
+* Get all APN informations.
+*/
+mbtk_ril_err_enum mbtk_apn_get(mbtk_ril_handle* handle, mbtk_apn_info_array_t *apns)
+{
+    return mbtk_ds_apn_get(handle, MBTK_SIM_AUTO, apns);
+}
 
 /*
 * Set current APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_set(mbtk_ril_handle* handle, mbtk_apn_info_t *apn)
+mbtk_ril_err_enum mbtk_ds_apn_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_apn_info_t *apn)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1763,15 +1998,23 @@
         }
     }
 
-    err = ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), &return_cid, FALSE, 0);
+    err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), &return_cid, FALSE, 0);
     apn->cid = return_cid;
     return err;
 }
 
 /*
+* Set current APN informations.
+*/
+mbtk_ril_err_enum mbtk_apn_set(mbtk_ril_handle* handle, mbtk_apn_info_t *apn)
+{
+    return mbtk_ds_apn_set(handle, MBTK_SIM_AUTO, apn);
+}
+
+/*
 * Start data call.
 */
-mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_call,
+mbtk_ril_err_enum mbtk_ds_data_call_start(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_call,
             mbtk_data_call_item_state_enum def_route, mbtk_data_call_item_state_enum as_dns, int *retry_interval, int retry_interval_num,
             int timeout, mbtk_ip_info_t *rsp_info)
 {
@@ -1812,13 +2055,24 @@
         info.timeout = (uint16)10;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE, 0);
+}
+
+/*
+* Start data call.
+*/
+mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_call,
+            mbtk_data_call_item_state_enum def_route, mbtk_data_call_item_state_enum as_dns, int *retry_interval, int retry_interval_num,
+            int timeout, mbtk_ip_info_t *rsp_info)
+{
+    return mbtk_ds_data_call_start(handle, MBTK_SIM_AUTO, cid, auto_boot_call,
+                def_route, as_dns, retry_interval, retry_interval_num, timeout, rsp_info);
 }
 
 /*
 * Stop data call.
 */
-mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, int timeout)
+mbtk_ril_err_enum mbtk_ds_data_call_stop(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, int timeout)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1846,13 +2100,21 @@
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
     }
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE, 0);
+}
+
+/*
+* Stop data call.
+*/
+mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, int timeout)
+{
+    return mbtk_ds_data_call_stop(handle, MBTK_SIM_AUTO, cid, timeout);
 }
 
 /*
 * Get data call state.
 */
-mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
+mbtk_ril_err_enum mbtk_ds_data_call_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1880,13 +2142,21 @@
     info.type = MBTK_DATA_CALL_STATE;
     info.cid = cid;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE, 0);
+}
+
+/*
+* Get data call state.
+*/
+mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
+{
+    return mbtk_ds_data_call_state_get(handle, MBTK_SIM_AUTO, cid, ip);
 }
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_get(mbtk_ril_handle* handle, int *sms_state)
+mbtk_ril_err_enum mbtk_ds_sms_cmgf_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *sms_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1906,12 +2176,20 @@
     }
 
     uint8 state;
-    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE, 0);
+    mbtk_ril_err_enum err = ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE, 0);
     *sms_state = state;
     return err;
 }
 
 /*
+* Return sms cmgf.
+*/
+mbtk_ril_err_enum mbtk_sms_cmgf_get(mbtk_ril_handle* handle, int *sms_state)
+{
+    return mbtk_ds_sms_cmgf_get(handle, MBTK_SIM_AUTO, sms_state);
+}
+
+/*
 * Set sms cmgf.
 *
 * volte_state:
@@ -1920,7 +2198,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_set(mbtk_ril_handle* handle, int mode)
+mbtk_ril_err_enum mbtk_ds_sms_cmgf_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int mode)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1938,7 +2216,21 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE, 0);
+}
+
+/*
+* Set sms cmgf.
+*
+* volte_state:
+* 0 : PDU mode.
+* 1 :  text mode.
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cmgf_set(mbtk_ril_handle* handle, int mode)
+{
+    return mbtk_ds_sms_cmgf_set(handle, MBTK_SIM_AUTO, mode);
 }
 
 /*
@@ -1954,7 +2246,7 @@
 
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgs_set(mbtk_ril_handle* handle, char * cmgs, char *resp)
+mbtk_ril_err_enum mbtk_ds_sms_cmgs_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgs, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1972,7 +2264,25 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGS, cmgs, strlen(cmgs), resp, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGS, cmgs, strlen(cmgs), resp, FALSE, 0);
+}
+
+/*
+* Set sms cmgs.
+*
+if PDU mode (+CMGF=0):
++CMGS=<length><CR>
+PDU is given<ctrl-Z/ESC>
+
+if text mode (+CMGF=1):
++CMGS=<da>[,<toda>]<CR>
+text is entered<ctrl-Z/ESC>
+
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cmgs_set(mbtk_ril_handle* handle, char * cmgs, char *resp)
+{
+    return mbtk_ds_sms_cmgs_set(handle, MBTK_SIM_AUTO, cmgs, resp);
 }
 
 /*
@@ -1987,7 +2297,7 @@
 given<ctrl-Z/ESC>
 
 */
-mbtk_ril_err_enum mbtk_sms_cmgw_set(mbtk_ril_handle* handle, char * cmgw, char *resp)
+mbtk_ril_err_enum mbtk_ds_sms_cmgw_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgw, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2005,7 +2315,53 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGW, cmgw, strlen(cmgw), resp, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGW, cmgw, strlen(cmgw), resp, FALSE, 0);
+}
+
+/*
+* Set sms cmgw.
+*
+if text mode (+CMGF=1):
++CMGW=<oa/da>[,<tooa/toda>[,<stat>]]
+<CR>
+text is entered<ctrl-Z/ESC>
+if PDU mode (+CMGF=0):
++CMGW=<length>[,<stat>]<CR>PDU is
+given<ctrl-Z/ESC>
+
+*/
+mbtk_ril_err_enum mbtk_sms_cmgw_set(mbtk_ril_handle* handle, char * cmgw, char *resp)
+{
+    return mbtk_ds_sms_cmgw_set(handle, MBTK_SIM_AUTO, cmgw, resp);
+}
+
+
+/*
+* Set sms cmgd.
+*
+* +CMGD=<index>[,<delflag>]
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_ds_sms_cmgd_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmdg)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(cmdg == NULL || handle == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+    if(!at_port_check(port_info->port)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGD, cmdg, strlen(cmdg), NULL, FALSE, 0);
 }
 
 /*
@@ -2017,23 +2373,7 @@
 */
 mbtk_ril_err_enum mbtk_sms_cmgd_set(mbtk_ril_handle* handle, char * cmdg)
 {
-    if(!ril_cli.ril_ready)
-    {
-        return MBTK_RIL_ERR_NOT_INIT;
-    }
-
-    if(cmdg == NULL || handle == NULL)
-    {
-        LOGE("ARG error.");
-        return MBTK_RIL_ERR_PARAMETER;
-    }
-
-    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
-    if(!at_port_check(port_info->port)) {
-        return MBTK_RIL_ERR_PORT;
-    }
-
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, cmdg, strlen(cmdg), NULL, FALSE, 0);
+    return mbtk_ds_sms_cmgd_set(handle, MBTK_SIM_AUTO, cmdg);
 }
 
 /*
@@ -2043,7 +2383,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgd_get(mbtk_ril_handle* handle, char * cmdg)
+mbtk_ril_err_enum mbtk_ds_sms_cmgd_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmdg)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2061,9 +2401,20 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGD, NULL, 0, cmdg, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGD, NULL, 0, cmdg, FALSE, 0);
 }
 
+/*
+* Get sms cmgd.
+*
+* +CMGD: (XXX,XXX)(0-4)
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cmgd_get(mbtk_ril_handle* handle, char * cmdg)
+{
+    return mbtk_ds_sms_cmgd_get(handle, MBTK_SIM_AUTO, cmdg);
+}
 
 /*
 * Set sms cmgl.
@@ -2072,7 +2423,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgl_set(mbtk_ril_handle* handle, char * cmgl, char *resp)
+mbtk_ril_err_enum mbtk_ds_sms_cmgl_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmgl, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2090,13 +2441,26 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGL, cmgl, strlen(cmgl), resp, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGL, cmgl, strlen(cmgl), resp, FALSE, 0);
 }
 
 /*
+* Set sms cmgl.
+*
+* AT+CMGL[=<stat>]
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cmgl_set(mbtk_ril_handle* handle, char * cmgl, char *resp)
+{
+    return mbtk_ds_sms_cmgl_set(handle, MBTK_SIM_AUTO, cmgl, resp);
+}
+
+
+/*
 * Return sms csca.
 */
-mbtk_ril_err_enum mbtk_sms_csca_get(mbtk_ril_handle* handle, char *buf)
+mbtk_ril_err_enum mbtk_ds_sms_csca_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char *buf)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2114,7 +2478,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, NULL, 0, buf, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CSCA, NULL, 0, buf, FALSE, 0);
+}
+
+/*
+* Return sms csca.
+*/
+mbtk_ril_err_enum mbtk_sms_csca_get(mbtk_ril_handle* handle, char *buf)
+{
+    return mbtk_ds_sms_csca_get(handle, MBTK_SIM_AUTO, buf);
 }
 
 /*
@@ -2124,7 +2496,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csca_set(mbtk_ril_handle* handle, char * csca)
+mbtk_ril_err_enum mbtk_ds_sms_csca_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * csca)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2142,17 +2514,30 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCA, csca, strlen(csca), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CSCA, csca, strlen(csca), NULL, FALSE, 0);
 }
 
 /*
+* Set sms csca.
+*
+* AT+CSCA=<number> [,<type>]
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_csca_set(mbtk_ril_handle* handle, char * csca)
+{
+    return mbtk_ds_sms_csca_set(handle, MBTK_SIM_AUTO, csca);
+}
+
+
+/*
 * Set sms csmp.
 *
 * AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csmp_set(mbtk_ril_handle* handle, char * csmp)
+mbtk_ril_err_enum mbtk_ds_sms_csmp_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * csmp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2170,7 +2555,19 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSMP, csmp, strlen(csmp), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CSMP, csmp, strlen(csmp), NULL, FALSE, 0);
+}
+
+/*
+* Set sms csmp.
+*
+* AT+CSMP=[<fo>[,<vp>[,<pid>[,<dcs>]]]]
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_csmp_set(mbtk_ril_handle* handle, char * csmp)
+{
+    return mbtk_ds_sms_csmp_set(handle, MBTK_SIM_AUTO, csmp);
 }
 
 /*
@@ -2180,7 +2577,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cscb_set(mbtk_ril_handle* handle, char * cscb)
+mbtk_ril_err_enum mbtk_ds_sms_cscb_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cscb)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2198,7 +2595,19 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CSCB, cscb, strlen(cscb), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CSCB, cscb, strlen(cscb), NULL, FALSE, 0);
+}
+
+/*
+* Set sms cscb.
+*
+* AT+CSCB=<[<mode>[,<mids>[,<dcss>]]]>
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cscb_set(mbtk_ril_handle* handle, char * cscb)
+{
+    return mbtk_ds_sms_cscb_set(handle, MBTK_SIM_AUTO, cscb);
 }
 
 /*
@@ -2210,7 +2619,7 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cnmi_set(mbtk_ril_handle* handle)
+mbtk_ril_err_enum mbtk_ds_sms_cnmi_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2228,10 +2637,25 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CNMI, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CNMI, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
+* Set sms cnmi.
+*
+at+cnmi=1,2
+
+OK
+if sending fails:
++CMS ERROR: <err>
+*/
+mbtk_ril_err_enum mbtk_sms_cnmi_set(mbtk_ril_handle* handle)
+{
+    return mbtk_ds_sms_cnmi_set(handle, MBTK_SIM_AUTO);
+}
+
+
+/*
 * Set sms cmss.
 *
 +CMSS=<index>[,<da>[,<toda>]]
@@ -2242,7 +2666,7 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cmss_set(mbtk_ril_handle* handle, char * cmss, char *resp)
+mbtk_ril_err_enum mbtk_ds_sms_cmss_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * cmss, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2260,13 +2684,29 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMSS, cmss, strlen(cmss), resp, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMSS, cmss, strlen(cmss), resp, FALSE, 0);
+}
+
+/*
+* Set sms cmss.
+*
++CMSS=<index>[,<da>[,<toda>]]
+
+if sending successful:
++CMSS: <mr>
+OK
+if sending fails:
++CMS ERROR: <err>
+*/
+mbtk_ril_err_enum mbtk_sms_cmss_set(mbtk_ril_handle* handle, char * cmss, char *resp)
+{
+    return mbtk_ds_sms_cmss_set(handle, MBTK_SIM_AUTO, cmss, resp);
 }
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_get(mbtk_ril_handle* handle, char * mem)
+mbtk_ril_err_enum mbtk_ds_sms_cpms_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * mem)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2284,9 +2724,16 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, NULL, 0, mem, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CPMS, NULL, 0, mem, FALSE, 0);
 }
 
+/*
+* Return sms cmgf.
+*/
+mbtk_ril_err_enum mbtk_sms_cpms_get(mbtk_ril_handle* handle, char *mem)
+{
+    return mbtk_ds_sms_cpms_get(handle, MBTK_SIM_AUTO, mem);
+}
 
 /*
 * Set sms cpms.
@@ -2295,7 +2742,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_set(mbtk_ril_handle* handle, char * mem, char* resp)
+mbtk_ril_err_enum mbtk_ds_sms_cpms_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char * mem, char* resp)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2313,7 +2760,63 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CPMS, mem, strlen(mem), resp, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CPMS, mem, strlen(mem), resp, FALSE, 0);
+}
+
+/*
+* Set sms cpms.
+*
+* AT+CPMS=<mem1>[,<mem2>[,<mem3>]]
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_sms_cpms_set(mbtk_ril_handle* handle, char * mem, char* resp)
+{
+    return mbtk_ds_sms_cpms_set(handle, MBTK_SIM_AUTO, mem, resp);
+}
+
+
+/*
+* Set sms cm.
+*
+* +CMGR=<index>
+
+if PDU mode (+CMGF=0) ��command successful:
++CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
+OK
+if text mode (+CMGF=1), command successful and SMS-DELIVER:
++CMGR:<stat>,<oa>,[<alpha>],<scts>[,<tooa>,<fo>,<pid>,<dcs
+>, <sca>,<tosca>,<length>]<CR><LF><data>
+OK
+if text mode (+CMGF=1), command successful and SMS-SUBMIT:
++CMGR:
+<stat>,<da>,[<alpha>][,<toda>,<fo>,<pid>,<dcs>,[<vp>],
+<sca>,<tosca>,<length>]<CR><LF><data>
+OK
+otherwise:
++CMS ERROR: <err>
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_ds_sms_cmgr_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int index, char *resp)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(resp == NULL || handle == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+    if(!at_port_check(port_info->port)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_SMS_CMGR, &index, sizeof(uint8), resp, FALSE, 0);
 }
 
 /*
@@ -2340,23 +2843,7 @@
 */
 mbtk_ril_err_enum mbtk_sms_cmgr_set(mbtk_ril_handle* handle, int index, char *resp)
 {
-    if(!ril_cli.ril_ready)
-    {
-        return MBTK_RIL_ERR_NOT_INIT;
-    }
-
-    if(resp == NULL || handle == NULL)
-    {
-        LOGE("ARG error.");
-        return MBTK_RIL_ERR_PARAMETER;
-    }
-
-    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
-    if(!at_port_check(port_info->port)) {
-        return MBTK_RIL_ERR_PORT;
-    }
-
-    return ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGR, &index, sizeof(uint8), resp, FALSE, 0);
+    return mbtk_ds_sms_cmgr_set(handle, MBTK_SIM_AUTO, index, resp);
 }
 
 
@@ -2550,7 +3037,7 @@
 * call_start
 *
 */
-mbtk_ril_err_enum mbtk_call_start(mbtk_ril_handle* handle, char* phone_number)
+mbtk_ril_err_enum mbtk_ds_call_start(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, char* phone_number)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2568,7 +3055,43 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_START, phone_number, strlen(phone_number), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_START, phone_number, strlen(phone_number), NULL, FALSE, 0);
+}
+
+/*
+* call_start
+*
+*/
+mbtk_ril_err_enum mbtk_call_start(mbtk_ril_handle* handle, char* phone_number)
+{
+
+
+    return mbtk_ds_call_start(handle, MBTK_SIM_AUTO, phone_number);
+}
+
+/*
+* Answer the phone call.
+*
+*/
+mbtk_ril_err_enum mbtk_ds_call_answer(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(handle == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+    if(!at_port_check(port_info->port)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_ANSWER, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2577,6 +3100,16 @@
 */
 mbtk_ril_err_enum mbtk_call_answer(mbtk_ril_handle* handle)
 {
+    return mbtk_ds_call_answer(handle, MBTK_SIM_AUTO);
+}
+
+
+/*
+* Hang up all call.
+*
+*/
+mbtk_ril_err_enum mbtk_ds_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -2593,7 +3126,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_ANSWER, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_HANGUP, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2602,6 +3135,15 @@
 */
 mbtk_ril_err_enum mbtk_call_hang(mbtk_ril_handle* handle)
 {
+    return mbtk_ds_call_hang(handle, MBTK_SIM_AUTO);
+}
+
+/*
+* Hang up a call.
+*
+*/
+mbtk_ril_err_enum mbtk_ds_a_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int phone_id)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -2618,7 +3160,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_HANGUP_A, &phone_id, sizeof(uint8), NULL, FALSE, 0);
 }
 
 /*
@@ -2627,6 +3169,15 @@
 */
 mbtk_ril_err_enum mbtk_a_call_hang(mbtk_ril_handle* handle, int phone_id)
 {
+    return mbtk_ds_a_call_hang(handle, MBTK_SIM_AUTO, phone_id);
+}
+
+/*
+* Hang up waiting or background call.
+*
+*/
+mbtk_ril_err_enum mbtk_ds_waiting_or_background_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -2643,7 +3194,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_A, &phone_id, sizeof(uint8), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_HANGUP_B, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2652,30 +3203,14 @@
 */
 mbtk_ril_err_enum mbtk_waiting_or_background_call_hang(mbtk_ril_handle* handle)
 {
-    if(!ril_cli.ril_ready)
-    {
-        return MBTK_RIL_ERR_NOT_INIT;
-    }
-
-    if(handle == NULL)
-    {
-        LOGE("ARG error.");
-        return MBTK_RIL_ERR_PARAMETER;
-    }
-
-    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
-    if(!at_port_check(port_info->port)) {
-        return MBTK_RIL_ERR_PORT;
-    }
-
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_B, NULL, 0, NULL, FALSE, 0);
+    return mbtk_ds_waiting_or_background_call_hang(handle, MBTK_SIM_AUTO);
 }
 
 /*
 * Hang up foreground resume background call.
 *
 */
-mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang(mbtk_ril_handle* handle)
+mbtk_ril_err_enum mbtk_ds_foreground_resume_background_call_hang(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2693,13 +3228,22 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_HANGUP_C, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_HANGUP_C, NULL, 0, NULL, FALSE, 0);
+}
+
+/*
+* Hang up foreground resume background call.
+*
+*/
+mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang(mbtk_ril_handle* handle)
+{
+    return mbtk_ds_foreground_resume_background_call_hang(handle, MBTK_SIM_AUTO);
 }
 
 /*
 * Get current call phone number.
 */
-mbtk_ril_err_enum mbtk_call_reg_get(mbtk_ril_handle* handle, mbtk_call_info_t *reg)
+mbtk_ril_err_enum mbtk_ds_call_reg_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_call_info_t *reg)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2718,13 +3262,22 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_WAITIN, NULL, 0, reg, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_WAITIN, NULL, 0, reg, FALSE, 0);
 }
 
 /*
+* Get current call phone number.
+*/
+mbtk_ril_err_enum mbtk_call_reg_get(mbtk_ril_handle* handle, mbtk_call_info_t *reg)
+{
+    return mbtk_ds_call_reg_get(handle, MBTK_SIM_AUTO, reg);
+}
+
+
+/*
 * Return mute state.
 */
-mbtk_ril_err_enum mbtk_mute_state_get(mbtk_ril_handle* handle, int *mute_state)
+mbtk_ril_err_enum mbtk_ds_mute_state_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *mute_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2743,7 +3296,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, NULL, 0, mute_state, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_MUTE, NULL, 0, mute_state, FALSE, 0);
+}
+
+/*
+* Return mute state.
+*/
+mbtk_ril_err_enum mbtk_mute_state_get(mbtk_ril_handle* handle, int *mute_state)
+{
+    return mbtk_ds_mute_state_get(handle, MBTK_SIM_AUTO, mute_state);
 }
 
 /*
@@ -2755,7 +3316,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_mute_state_set(mbtk_ril_handle* handle, int mute_state)
+mbtk_ril_err_enum mbtk_ds_mute_state_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int mute_state)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2773,14 +3334,28 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_MUTE, &mute_state, sizeof(uint8), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_MUTE, &mute_state, sizeof(uint8), NULL, FALSE, 0);
+}
+
+/*
+* Set mute state.
+*
+* mute_state:
+* 0 : of mute.
+* 1 : on mute.
+*
+* Restarting takes effect after execution.
+*/
+mbtk_ril_err_enum mbtk_mute_state_set(mbtk_ril_handle* handle, int mute_state)
+{
+    return mbtk_ds_mute_state_set(handle, MBTK_SIM_AUTO, mute_state);
 }
 
 /*
 * Set DTMF character.
 *
 */
-mbtk_ril_err_enum mbtk_dtmf_send(mbtk_ril_handle* handle, mbtk_call_dtmf_info_t *dtmf_character)
+mbtk_ril_err_enum mbtk_ds_dtmf_send(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, mbtk_call_dtmf_info_t *dtmf_character)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2798,10 +3373,19 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE, 0);
 }
 
-mbtk_ril_err_enum mbtk_centric_set(mbtk_ril_handle* handle, int centric)
+/*
+* Set DTMF character.
+*
+*/
+mbtk_ril_err_enum mbtk_dtmf_send(mbtk_ril_handle* handle, mbtk_call_dtmf_info_t *dtmf_character)
+{
+    return mbtk_ds_dtmf_send(handle, MBTK_SIM_AUTO, dtmf_character);
+}
+
+mbtk_ril_err_enum mbtk_ds_centric_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int centric)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2819,10 +3403,15 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, &centric, 1, NULL, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_CENTRIC, &centric, 1, NULL, FALSE, 0);
 }
 
-mbtk_ril_err_enum mbtk_centric_get(mbtk_ril_handle* handle, int *centric)
+mbtk_ril_err_enum mbtk_centric_set(mbtk_ril_handle* handle, int centric)
+{
+    return mbtk_ds_centric_set(handle, MBTK_SIM_AUTO, centric);
+}
+
+mbtk_ril_err_enum mbtk_ds_centric_get(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id, int *centric)
 {
     if(!ril_cli.ril_ready)
     {
@@ -2841,10 +3430,13 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_CALL_CENTRIC, NULL, 0, centric, FALSE, 0);
+    return ril_req_process(sim_id, port_info->port, RIL_MSG_ID_CALL_CENTRIC, NULL, 0, centric, FALSE, 0);
 }
 
-
+mbtk_ril_err_enum mbtk_centric_get(mbtk_ril_handle* handle, int *centric)
+{
+    return mbtk_ds_centric_get(handle, MBTK_SIM_AUTO, centric);
+}
 
 /*
 * Set msd item.
@@ -2868,7 +3460,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -2893,7 +3485,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -2924,7 +3516,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE, 0);
 }
 
 /*
@@ -2949,7 +3541,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE, 0);
 }
 
 
@@ -2975,7 +3567,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE, 0);
 }
 
 /*
@@ -3000,7 +3592,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -3026,7 +3618,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE, 0);
 }
 
 /*
@@ -3051,7 +3643,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3076,7 +3668,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3104,7 +3696,7 @@
 
     memset(type, 0, sizeof(mbtk_ecall_dial_type_enum));
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE, 0);
 }
 
 /*
@@ -3129,7 +3721,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3157,7 +3749,7 @@
 
     memset(mode, 0, sizeof(mbtk_ecall_mode_type_enum));
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE, 0);
 }
 
 /*
@@ -3182,7 +3774,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE, 0);
 }
 
 /*
@@ -3210,7 +3802,7 @@
 
     uint32 type = cfg->type;
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE, 0);
 }
 
 /*
@@ -3235,7 +3827,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE, 0);
 }
 
 /*
@@ -3260,7 +3852,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE, 0);
 }
 
 /*
@@ -3285,7 +3877,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE, 0);
 }
 
 /*
@@ -3310,7 +3902,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE, 0);
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE, 0);
 }
 
 int mbtk_get_modem_version(mbtk_ril_handle* handle, void *modem_version)
@@ -3319,7 +3911,7 @@
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
-    
+
     if(handle == NULL || modem_version == NULL)
     {
         LOGE("ARG error.");
@@ -3329,11 +3921,63 @@
     if(!at_port_check(port_info->port)) {
         return MBTK_RIL_ERR_PORT;
     }
-    
-    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MD_VERSION_REQ, NULL, 0, modem_version,FALSE, 0);
-        
+
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_DEV_MD_VERSION_REQ, NULL, 0, modem_version,FALSE, 0);
+
 }
 
+/*
+* Set dual sim switch.
+*
+*/
+mbtk_ril_err_enum mbtk_sim_switch_set(mbtk_ril_handle* handle, mbtk_sim_type_enum sim_id)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(sim_id != MBTK_SIM_1 && sim_id != MBTK_SIM_2)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+    if(!at_port_check(port_info->port)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_SIM_SWITCH, &sim_id, sizeof(mbtk_sim_type_enum), NULL, FALSE, 0);
+}
+
+/*
+* Get dual sim switch.
+*
+*/
+mbtk_ril_err_enum mbtk_sim_switch_get(mbtk_ril_handle* handle, mbtk_sim_type_enum *sim_id)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(sim_id == NULL || handle == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
+    memset(sim_id, 0x00, sizeof(mbtk_sim_type_enum));
+    ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+    if(!at_port_check(port_info->port)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    return ril_req_process(MBTK_SIM_1, port_info->port, RIL_MSG_ID_SIM_SWITCH, NULL, 0, sim_id, FALSE, 0);
+}
+
+
 #if 0
 /*
 * Set wakeup state.
@@ -3395,7 +4039,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(MBTK_SIM_1, ATPORTTYPE_0, RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3406,7 +4050,7 @@
 /*
 * Set net reg state change callback function.
 */
-mbtk_ril_err_enum mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_ds_net_reg_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
@@ -3417,7 +4061,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_NET_REG_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3426,10 +4070,48 @@
 }
 
 /*
+* Set net reg state change callback function.
+*/
+mbtk_ril_err_enum mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb)
+{
+    return mbtk_ds_net_reg_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set call state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_call_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
+    if(!ril_cli.ril_ready)
+    {
+        return MBTK_RIL_ERR_NOT_INIT;
+    }
+
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    if(MBTK_RIL_ERR_SUCCESS == ret)
+    {
+        ril_cli.cb[RIL_MSG_ID_IND_CALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+    }
+    return ret;
+}
+
+/*
 * Set call state change callback function.
 */
 mbtk_ril_err_enum mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
+    return mbtk_ds_call_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set sms state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_sms_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -3439,10 +4121,10 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        ril_cli.cb[RIL_MSG_ID_IND_CALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+        ril_cli.cb[RIL_MSG_ID_IND_SMS_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
     return ret;
 }
@@ -3452,6 +4134,14 @@
 */
 mbtk_ril_err_enum mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
+    return mbtk_ds_sms_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set radio state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_radio_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -3461,10 +4151,10 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        ril_cli.cb[RIL_MSG_ID_IND_SMS_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+        ril_cli.cb[RIL_MSG_ID_IND_RADIO_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
     return ret;
 }
@@ -3474,6 +4164,14 @@
 */
 mbtk_ril_err_enum mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
+    return mbtk_ds_radio_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set sim state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_sim_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -3483,10 +4181,10 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        ril_cli.cb[RIL_MSG_ID_IND_RADIO_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+        ril_cli.cb[RIL_MSG_ID_IND_SIM_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
     return ret;
 }
@@ -3496,6 +4194,14 @@
 */
 mbtk_ril_err_enum mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
+    return mbtk_ds_sim_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set pdp state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_pdp_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -3505,10 +4211,10 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        ril_cli.cb[RIL_MSG_ID_IND_SIM_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+        ril_cli.cb[RIL_MSG_ID_IND_PDP_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
     return ret;
 }
@@ -3518,6 +4224,14 @@
 */
 mbtk_ril_err_enum mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
+    return mbtk_ds_pdp_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
+/*
+* Set signal state change callback function.
+*/
+mbtk_ril_err_enum mbtk_ds_signal_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
+{
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
@@ -3527,10 +4241,10 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
-        ril_cli.cb[RIL_MSG_ID_IND_PDP_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
+        ril_cli.cb[RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
     }
     return ret;
 }
@@ -3540,24 +4254,10 @@
 */
 mbtk_ril_err_enum mbtk_signal_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
-    if(!ril_cli.ril_ready)
-    {
-        return MBTK_RIL_ERR_NOT_INIT;
-    }
-
-    if(!at_port_check(ATPORTTYPE_0)) {
-        return MBTK_RIL_ERR_PORT;
-    }
-
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
-    if(MBTK_RIL_ERR_SUCCESS == ret)
-    {
-        ril_cli.cb[RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
-    }
-    return ret;
+    return mbtk_ds_signal_state_change_cb_reg(MBTK_SIM_AUTO, cb);
 }
 
-mbtk_ril_err_enum mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_ds_ecall_state_change_cb_reg(mbtk_sim_type_enum sim_id, mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
@@ -3568,7 +4268,7 @@
         return MBTK_RIL_ERR_PORT;
     }
 
-    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
+    int ret = ril_req_process(sim_id, ATPORTTYPE_0, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE, -1);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_ECALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -3576,4 +4276,9 @@
     return ret;
 }
 
+mbtk_ril_err_enum mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb)
+{
+    return mbtk_ds_ecall_state_change_cb_reg(MBTK_SIM_AUTO, cb);
+}
+
 
diff --git a/mbtk/libmbtk_lib/ril/v2/ril_utils.c b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
index 33b25a8..fc9e723 100755
--- a/mbtk/libmbtk_lib/ril/v2/ril_utils.c
+++ b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
@@ -470,7 +470,7 @@
     }
 }
 
-ril_msg_pack_info_t* ril_msg_pack_creat(ATPortType_enum port, int msg_type, int msg_id, int msg_index, const void *data, int data_len)
+ril_msg_pack_info_t* ril_msg_pack_creat(mbtk_sim_type_enum sim_id, ATPortType_enum port, int msg_type, int msg_id, int msg_index, const void *data, int data_len)
 {
     ril_msg_pack_info_t *pack = (ril_msg_pack_info_t *)malloc(sizeof(ril_msg_pack_info_t));
     if(!pack)
@@ -481,6 +481,7 @@
 
     pack->tag = RIL_SOCK_PACKET_TAG;
     pack->at_port = (uint8)port;
+    pack->sim_id = (uint8)sim_id;
     if(msg_index < 0) {
         pack->msg_index = ril_index++;
     } else {
diff --git a/mbtk/mbtk_rild_v2/inc/atchannel.h b/mbtk/mbtk_rild_v2/inc/atchannel.h
index 43efd0e..997ef33 100755
--- a/mbtk/mbtk_rild_v2/inc/atchannel.h
+++ b/mbtk/mbtk_rild_v2/inc/atchannel.h
@@ -87,8 +87,8 @@
  */
 typedef void (*ATUnsolHandler)(const char *s, const char *sms_pdu);
 
-int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h);
-void at_close(ATPortType_enum port);
+int at_open(ATPortId_enum port, int at_fd, int uart_fd, ATUnsolHandler h);
+void at_close(ATPortId_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 (ATPortType_enum port, const char *command,
+int at_send_command_singleline (ATPortId_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse);
-int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
+int at_send_command_singleline_with_timeout (ATPortId_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec);
 
-int at_send_command_numeric (ATPortType_enum port, const char *command,
+int at_send_command_numeric (ATPortId_enum port, const char *command,
                              ATResponse **pp_outResponse);
 
-int at_send_command_multiline (ATPortType_enum port, const char *command,
+int at_send_command_multiline (ATPortId_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse);
 
 
-int at_handshake(ATPortType_enum port);
+int at_handshake(ATPortId_enum port);
 
-int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse);
+int at_send_command (ATPortId_enum port, const char *command, ATResponse **pp_outResponse);
 
-int at_send_command_sms (ATPortType_enum port, const char *command, const char *pdu,
+int at_send_command_sms (ATPortId_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(ATPortType_enum port);
-void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state);
+mbtk_ril_at_state_enum at_state_get(ATPortId_enum port);
+void at_state_set(ATPortId_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 558d3f9..3a41f0b 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;
+    mbtk_sim_type_enum sim_id;
     ATPortType_enum port;
 
     uint32 ind_num;
@@ -48,9 +49,10 @@
 } ril_msg_queue_info_t;
 
 typedef struct {
-    mbtk_radio_state_enum radio_state;
-    mbtk_sim_state_enum sim_state;
-    mbtk_sim_card_type_enum sim_type;
+    mbtk_sim_type_enum cur_sim_id;
+    mbtk_radio_state_enum radio_state[MBTK_SIM_NUM];
+    mbtk_sim_state_enum sim_state[MBTK_SIM_NUM];
+    mbtk_sim_card_type_enum sim_type[MBTK_SIM_NUM];
     int sock_listen_fd;
     int epoll_fd;
     bool at_process[ATPORTTYPE_NUM];
@@ -122,12 +124,12 @@
 extern ril_info_t ril_info;
 
 
-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_radio_state_enum ril_radio_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port);
+mbtk_ril_err_enum ril_radio_state_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_radio_state_enum state, bool reset);
 
-mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port);
+mbtk_sim_state_enum ril_sim_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
-void apn_auto_conf_from_prop(ATPortType_enum port);
+void apn_auto_conf_from_prop(mbtk_sim_type_enum sim_id, 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 80f8e68..54313d0 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -38,20 +38,21 @@
 #define HANDSHAKE_TIMEOUT_MSEC 500
 #define AT_BUFF_MAX 1024
 
-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 pthread_t s_tid_reader[ATPORTID_NUM];
+static int s_at_fd[ATPORTID_NUM] = {-1};    /* fd of the AT channel */
+static int s_uart_fd[MBTK_SIM_NUM] = {-1};    /* fd of the UART channel */
 
-static ATUnsolHandler s_unsolHandler;
+static ATUnsolHandler s_unsolHandler[MBTK_SIM_NUM];
 
 /* for input buffering */
 
-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 char s_ATBuffer[ATPORTID_NUM][MAX_AT_RESPONSE+1];
+static char *s_ATBufferCur[ATPORTID_NUM] = {s_ATBuffer[ATPORTID_SIM1_0], s_ATBuffer[ATPORTID_SIM1_0], s_ATBuffer[ATPORTID_SIM1_0],
+                                            s_ATBuffer[ATPORTID_SIM2_0], s_ATBuffer[ATPORTID_SIM2_0], s_ATBuffer[ATPORTID_SIM2_0]};
+static char s_UartBuffer[MBTK_SIM_NUM][MAX_AT_RESPONSE+1];
+static char *s_UartBufferCur[MBTK_SIM_NUM] = {s_UartBuffer[MBTK_SIM_1], s_UartBuffer[MBTK_SIM_2]};
 
-static mbtk_ril_at_state_enum at_state[ATPORTTYPE_NUM] = {RIL_AT_STATE_CLOSED};
+static mbtk_ril_at_state_enum at_state[ATPORTID_NUM] = {RIL_AT_STATE_CLOSED};
 
 #if AT_DEBUG
 void  AT_DUMP(const char*  prefix, const char*  buff, int  len)
@@ -72,22 +73,22 @@
  */
 
 // "Wait" when AT process...
-static pthread_mutex_t s_commandmutex[ATPORTTYPE_NUM] = {PTHREAD_MUTEX_INITIALIZER};
-static pthread_cond_t s_commandcond[ATPORTTYPE_NUM] = {PTHREAD_COND_INITIALIZER};
+static pthread_mutex_t s_commandmutex[ATPORTID_NUM] = {PTHREAD_MUTEX_INITIALIZER};
+static pthread_cond_t s_commandcond[ATPORTID_NUM] = {PTHREAD_COND_INITIALIZER};
 
-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 ATCommandType s_type[ATPORTID_NUM];
+static const char *s_responsePrefix[ATPORTID_NUM] = {NULL};
+static const char *s_smsPDU[ATPORTID_NUM] = {NULL};
+static ATResponse *sp_response[ATPORTID_NUM] = {NULL};
+static char s_curr_at[ATPORTID_NUM][AT_BUFF_MAX];
 
 static void (*s_onTimeout)(void) = NULL;
 static void (*s_onReaderClosed)(void) = NULL;
 static int s_readerClosed;
 
-static void onReaderClosed(ATPortType_enum port);
-static int writeCtrlZ (ATPortType_enum port, const char *s);
-static int writeline (ATPortType_enum port, const char *s);
+static void onReaderClosed(ATPortId_enum port);
+static int writeCtrlZ (ATPortId_enum port, const char *s);
+static int writeline (ATPortId_enum port, const char *s);
 
 typedef struct
 {
@@ -137,7 +138,7 @@
 
 
 /** add an intermediate response to sp_response*/
-static void addIntermediate(ATPortType_enum port, const char *line)
+static void addIntermediate(ATPortId_enum port, const char *line)
 {
     ATLine *p_new;
 
@@ -170,7 +171,7 @@
     "NO ANSWER",
     "NO DIALTONE",
 };
-static int isFinalResponseError(ATPortType_enum port, const char *line)
+static int isFinalResponseError(ATPortId_enum port, const char *line)
 {
     size_t i;
 
@@ -220,7 +221,7 @@
  * See 27.007 annex B
  * WARNING: NO CARRIER and others are sometimes unsolicited
  */
-static int isFinalResponse(ATPortType_enum port, const char *line)
+static int isFinalResponse(ATPortId_enum port, const char *line)
 {
     return isFinalResponseSuccess(line) || isFinalResponseError(port, line);
 }
@@ -252,7 +253,7 @@
 
 
 /** assumes s_commandmutex is held */
-static void handleFinalResponse(ATPortType_enum port, const char *line)
+static void handleFinalResponse(ATPortId_enum port, const char *line)
 {
     sp_response[port]->finalResponse = strdup(line);
 
@@ -260,22 +261,22 @@
     pthread_cond_signal(&s_commandcond[port]);
 }
 
-static void handleUnsolicited(const char *line)
+static void handleUnsolicited(ATPortId_enum port, const char *line)
 {
-    if (s_unsolHandler != NULL)
+    if (s_unsolHandler[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] != NULL)
     {
-        s_unsolHandler(line, NULL);
+        s_unsolHandler[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2](line, NULL);
     }
 }
 
-static void processLine(ATPortType_enum port, const char *line)
+static void processLine(ATPortId_enum port, const char *line)
 {
     pthread_mutex_lock(&s_commandmutex[port]);
 //    LOGD("LINE : %s", line);
     if (sp_response[port] == NULL)
     {
         /* no command pending */
-        handleUnsolicited(line);
+        handleUnsolicited(port, line);
     }
     else if (isFinalResponseSuccess(line))
     {
@@ -297,7 +298,7 @@
     else switch (s_type[port])
         {
             case NO_RESULT:
-                handleUnsolicited(line);
+                handleUnsolicited(port, line);
                 break;
             case NUMERIC:
                 if (sp_response[port]->p_intermediates == NULL
@@ -310,7 +311,7 @@
                 {
                     /* either we already have an intermediate response or
                        the line doesn't begin with a digit */
-                    handleUnsolicited(line);
+                    handleUnsolicited(port, line);
                 }
                 break;
             case SINGLELINE:
@@ -343,7 +344,7 @@
                 else
                 {
                     /* we already have an intermediate response */
-                    handleUnsolicited(line);
+                    handleUnsolicited(port, line);
                 }
                 break;
             case MULTILINE:
@@ -353,13 +354,13 @@
                 }
                 else
                 {
-                    handleUnsolicited(line);
+                    handleUnsolicited(port, line);
                 }
                 break;
 
             default: /* this should never be reached */
                 LOGE("Unsupported AT command type %d\n", s_type[port]);
-                handleUnsolicited(line);
+                handleUnsolicited(port, line);
                 break;
         }
 
@@ -398,7 +399,7 @@
  * have buffered stdio.
  */
 
-static const char *readline(ATPortType_enum port)
+static const char *readline(ATPortId_enum port)
 {
     ssize_t count;
 
@@ -500,7 +501,7 @@
     return ret;
 }
 
-static const char *readlineUrc(ATPortType_enum port)
+static const char *readlineUrc(ATPortId_enum port)
 {
     ssize_t count;
 
@@ -508,37 +509,40 @@
     char *p_eol = NULL;
     char *ret;
 
+    mbtk_sim_type_enum sim_id = port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2;
+
+
     /* this is a little odd. I use *s_ATBufferCur == 0 to
      * mean "buffer consumed completely". If it points to a character, than
      * the buffer continues until a \0
      */
-    if (*s_UartBufferCur == '\0')
+    if (*s_UartBufferCur[sim_id] == '\0')
     {
         /* empty buffer */
-        s_UartBufferCur = s_UartBuffer;
-        *s_UartBufferCur = '\0';
-        p_read = s_UartBuffer;
+        s_UartBufferCur[sim_id] = s_UartBuffer[sim_id];
+        *s_UartBufferCur[sim_id] = '\0';
+        p_read = s_UartBuffer[sim_id];
     }
     else       /* *s_ATBufferCur != '\0' */
     {
         /* there's data in the buffer from the last read */
 
         // skip over leading newlines
-        while (*s_UartBufferCur == '\r' || *s_UartBufferCur == '\n')
-            s_UartBufferCur++;
+        while (*s_UartBufferCur[sim_id] == '\r' || *s_UartBufferCur[sim_id] == '\n')
+            s_UartBufferCur[sim_id]++;
 
-        p_eol = findNextEOL(s_UartBufferCur);
+        p_eol = findNextEOL(s_UartBufferCur[sim_id]);
 
         if (p_eol == NULL)
         {
             /* a partial line. move it up and prepare to read more */
             size_t len;
 
-            len = strlen(s_UartBufferCur);
+            len = strlen(s_UartBufferCur[sim_id]);
 
-            memmove(s_UartBuffer, s_UartBufferCur, len + 1);
-            p_read = s_UartBuffer + len;
-            s_UartBufferCur = s_UartBuffer;
+            memmove(s_UartBuffer[sim_id], s_UartBufferCur[sim_id], len + 1);
+            p_read = s_UartBuffer[sim_id] + len;
+            s_UartBufferCur[sim_id] = s_UartBuffer[sim_id];
         }
         /* Otherwise, (p_eol !- NULL) there is a complete line  */
         /* that will be returned the while () loop below        */
@@ -546,19 +550,19 @@
 
     while (p_eol == NULL)
     {
-        if (0 == MAX_AT_RESPONSE - (p_read - s_UartBuffer))
+        if (0 == MAX_AT_RESPONSE - (p_read - s_UartBuffer[sim_id]))
         {
             LOGE("ERROR: Input line exceeded buffer\n");
             /* ditch buffer and start over again */
-            s_UartBufferCur = s_UartBuffer;
-            *s_UartBufferCur = '\0';
-            p_read = s_UartBuffer;
+            s_UartBufferCur[sim_id] = s_UartBuffer[sim_id];
+            *s_UartBufferCur[sim_id] = '\0';
+            p_read = s_UartBuffer[sim_id];
         }
 
         do
         {
-            count = read(s_uart_fd, p_read,
-                         MAX_AT_RESPONSE - (p_read - s_UartBuffer));
+            count = read(s_uart_fd[sim_id], p_read,
+                         MAX_AT_RESPONSE - (p_read - s_UartBuffer[sim_id]));
             usleep(10000);
         }
         while (count < 0 && errno == EINTR);
@@ -570,10 +574,10 @@
             p_read[count] = '\0';
 
             // skip over leading newlines
-            while (*s_UartBufferCur == '\r' || *s_UartBufferCur == '\n')
-                s_UartBufferCur++;
+            while (*s_UartBufferCur[sim_id] == '\r' || *s_UartBufferCur[sim_id] == '\n')
+                s_UartBufferCur[sim_id]++;
 
-            p_eol = findNextEOL(s_UartBufferCur);
+            p_eol = findNextEOL(s_UartBufferCur[sim_id]);
             p_read += count;
         }
         else if (count <= 0)
@@ -593,18 +597,17 @@
 
     /* a full line in the buffer. Place a \0 over the \r and return */
 
-    ret = s_UartBufferCur;
+    ret = s_UartBufferCur[sim_id];
     *p_eol = '\0';
-    s_UartBufferCur = p_eol + 1; /* this will always be <= p_read,    */
+    s_UartBufferCur[sim_id] = p_eol + 1; /* this will always be <= p_read,    */
     /* and there will be a \0 at *p_read */
 
-    LOGD("[Port-%d]URC< %s", port, ret);
+    LOGD("[Sim-%d,Port-%d]URC< %s", sim_id, port, ret);
     return ret;
 }
 
 
-
-static void onReaderClosed(ATPortType_enum port)
+static void onReaderClosed(ATPortId_enum port)
 {
     LOGD("onReaderClosed()");
     if (s_onReaderClosed != NULL && s_readerClosed == 0)
@@ -633,7 +636,7 @@
 static void *readerLoop(void *arg)
 {
     UNUSED(arg);
-    ATPortType_enum *port = (ATPortType_enum*)arg;
+    ATPortId_enum *port = (ATPortId_enum*)arg;
     for (;;)
     {
         const char * line;
@@ -673,9 +676,9 @@
                 break;
             }
 
-            if (s_unsolHandler != NULL)
+            if (s_unsolHandler[*port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] != NULL)
             {
-                s_unsolHandler (line1, line2);
+                s_unsolHandler[*port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] (line1, line2);
             }
             free(line1);
         }
@@ -695,7 +698,7 @@
 static void *readerUrcLoop(void *arg)
 {
     UNUSED(arg);
-    ATPortType_enum *port = (ATPortType_enum*)arg;
+    ATPortId_enum *port = (ATPortId_enum*)arg;
     for (;;)
     {
         const char *line;
@@ -707,7 +710,7 @@
             break;
         }
 
-        handleUnsolicited(line);
+        handleUnsolicited(*port, line);
     }
 
     onReaderClosed(*port);
@@ -725,7 +728,7 @@
  * This function exists because as of writing, android libc does not
  * have buffered stdio.
  */
-static int writeline (ATPortType_enum port, const char *s)
+static int writeline (ATPortId_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
@@ -776,7 +779,7 @@
     return 0;
 }
 
-static int writeCtrlZ (ATPortType_enum port, const char *s)
+static int writeCtrlZ (ATPortId_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
@@ -824,7 +827,7 @@
     return 0;
 }
 
-static void clearPendingCommand(ATPortType_enum port)
+static void clearPendingCommand(ATPortId_enum port)
 {
     if (sp_response[port] != NULL)
     {
@@ -841,21 +844,21 @@
  * Starts AT handler on stream "fd'
  * returns 0 on success, -1 on error
  */
-int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h)
+int at_open(ATPortId_enum port, int at_fd, int uart_fd, ATUnsolHandler h)
 {
     int ret;
     pthread_attr_t attr;
 
     s_at_fd[port] = at_fd;
-    s_uart_fd = uart_fd;
-    s_unsolHandler = h;
+    s_uart_fd[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] = uart_fd;
+    s_unsolHandler[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] = h;
     s_readerClosed = 0;
     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));
+    ATPortId_enum *at_port_ptr = (ATPortId_enum*)malloc(sizeof(ATPortId_enum));
+    ATPortId_enum *urc_port_ptr = (ATPortId_enum*)malloc(sizeof(ATPortId_enum));
     *at_port_ptr = port;
     *urc_port_ptr = port;
 
@@ -868,7 +871,7 @@
         return -1;
     }
 
-    if(port == ATPORTTYPE_0) { // URC only for ATPORTTYPE_0
+    if(port == ATPORTID_SIM1_0 || port == ATPORTID_SIM2_0) { // URC only for ATPORTTYPE_0
         pthread_t uart_tid_reader;
         ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, urc_port_ptr);
         if (ret < 0)
@@ -882,19 +885,19 @@
 }
 
 /* FIXME is it ok to call this from the reader and the command thread? */
-void at_close(ATPortType_enum port)
+void at_close(ATPortId_enum port)
 {
     LOGD("at_close()");
     if (s_at_fd[port] >= 0)
     {
         close(s_at_fd[port]);
     }
-    if (s_uart_fd >= 0)
+    if (s_uart_fd[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] >= 0)
     {
-        close(s_uart_fd);
+        close(s_uart_fd[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2]);
     }
     s_at_fd[port] = -1;
-    s_uart_fd = -1;
+    s_uart_fd[port < ATPORTID_SIM2_0 ? MBTK_SIM_1 : MBTK_SIM_2] = -1;
 
     pthread_mutex_lock(&s_commandmutex[port]);
     s_readerClosed = 1;
@@ -976,7 +979,7 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full_nolock (ATPortType_enum port, const char *command, ATCommandType type,
+static int at_send_command_full_nolock (ATPortId_enum port, const char *command, ATCommandType type,
                                         const char *responsePrefix, const char *smspdu,
                                         long long timeoutMsec, ATResponse **pp_outResponse)
 {
@@ -1074,7 +1077,7 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full (ATPortType_enum port, const char *command, ATCommandType type,
+static int at_send_command_full (ATPortId_enum port, const char *command, ATCommandType type,
                                  const char *responsePrefix, const char *smspdu,
                                  long long timeoutMsec, ATResponse **pp_outResponse)
 {
@@ -1119,14 +1122,14 @@
  * if non-NULL, the resulting ATResponse * must be eventually freed with
  * at_response_free
  */
-int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse)
+int at_send_command (ATPortId_enum port, const char *command, ATResponse **pp_outResponse)
 {
     return at_send_command_full (port, command, NO_RESULT, NULL,
                                  NULL, 0, pp_outResponse);
 }
 
 
-int at_send_command_singleline (ATPortType_enum port, const char *command,
+int at_send_command_singleline (ATPortId_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse)
 {
@@ -1149,7 +1152,7 @@
     return err;
 }
 
-int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
+int at_send_command_singleline_with_timeout (ATPortId_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec)
 {
@@ -1174,7 +1177,7 @@
 
 
 
-int at_send_command_numeric (ATPortType_enum port, const char *command,
+int at_send_command_numeric (ATPortId_enum port, const char *command,
                              ATResponse **pp_outResponse)
 {
     int err;
@@ -1197,7 +1200,7 @@
 }
 
 
-int at_send_command_sms (ATPortType_enum port, const char *command,
+int at_send_command_sms (ATPortId_enum port, const char *command,
                          const char *pdu,
                          const char *responsePrefix,
                          ATResponse **pp_outResponse)
@@ -1222,7 +1225,7 @@
 }
 
 
-int at_send_command_multiline (ATPortType_enum port, const char *command,
+int at_send_command_multiline (ATPortId_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse)
 {
@@ -1258,7 +1261,7 @@
  * Periodically issue an AT command and wait for a response.
  * Used to ensure channel has start up and is active
  */
-int at_handshake(ATPortType_enum port)
+int at_handshake(ATPortId_enum port)
 {
 //    int i;
     int err = 0;
@@ -1340,12 +1343,12 @@
     return ret;
 }
 
-mbtk_ril_at_state_enum at_state_get(ATPortType_enum port)
+mbtk_ril_at_state_enum at_state_get(ATPortId_enum port)
 {
     return at_state[port];
 }
 
-void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state)
+void at_state_set(ATPortId_enum port, mbtk_ril_at_state_enum state)
 {
     at_state[port] = state;
 }
@@ -1358,7 +1361,7 @@
     return true;
 }
 
-void unused_func(ATPortType_enum port)
+void unused_func(ATPortId_enum port)
 {
     isFinalResponse(port, NULL);
 }
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index a608201..e69ffce 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -97,28 +97,40 @@
 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(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state);

+void data_call_retry(mbtk_sim_type_enum sim_id, 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);

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

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

-int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err);

+int req_band_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_band_info_t* band, int *cme_err);

+int req_dual_sim_get(ATPortType_enum port, mbtk_sim_type_enum *sim_id, int *cme_err);

+

+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port)

+{

+    return (ATPortId_enum)(sim_id * ATPORTTYPE_NUM + port);

+}

 

 /* Called on command thread */

 static void onATTimeout()

 {

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

-    at_close(ATPORTTYPE_0);

-    at_close(ATPORTTYPE_1);

-    at_close(ATPORTTYPE_2);

+    at_close(ATPORTID_SIM1_0);

+    at_close(ATPORTID_SIM1_1);

+    at_close(ATPORTID_SIM1_2);

+    at_close(ATPORTID_SIM2_0);

+    at_close(ATPORTID_SIM2_1);

+    at_close(ATPORTID_SIM2_2);

 }

 

 /* Called on command or reader thread */

 static void onATReaderClosed()

 {

     LOGI("AT channel closed\n");

-    at_close(ATPORTTYPE_0);

-    at_close(ATPORTTYPE_1);

-    at_close(ATPORTTYPE_2);

+    at_close(ATPORTID_SIM1_0);

+    at_close(ATPORTID_SIM1_1);

+    at_close(ATPORTID_SIM1_2);

+    at_close(ATPORTID_SIM2_0);

+    at_close(ATPORTID_SIM2_1);

+    at_close(ATPORTID_SIM2_2);

 }

 

 static void sock_cli_free_func(void *data)
@@ -284,9 +296,9 @@
     }
 }
 
-static void ril_error_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, int err)

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

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

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

     if(pack)
     {

         pack->err = (uint16)err;

@@ -299,9 +311,9 @@
     }
 }
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len)

+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, 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(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, data, data_len);

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

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

@@ -321,9 +333,9 @@
     }
 }

 

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

+void ril_ind_pack_send(mbtk_sim_type_enum sim_id, int fd, int msg_id, const void* data, int 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);

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

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

@@ -353,7 +365,7 @@
             int i;
             for(i = 0; i < IND_REGISTER_MAX; i++) {
                 if(cli->ind_register[i] == msg_id) {

-                    ril_ind_pack_send(cli->fd, msg_id, data, data_len);

+                    ril_ind_pack_send(MBTK_SIM_1, cli->fd, msg_id, data, data_len);

                     break;
                 }
             }
@@ -402,11 +414,12 @@
 // *SIMDETEC:1,SIM

 // *EUICC:1

 // +CPIN: SIM PIN

-static void urc_sim_state_change_process(const char *s, const char *sms_pdu)

+static void urc_sim_state_change_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     mbtk_ril_sim_state_info_t state;

     memset(&state, 0, sizeof(mbtk_ril_sim_state_info_t));

     state.sim_type = MBTK_UNKNOWN;

+    state.sim_id = sim_id;

 

     char* tmp_s = memdup(s,strlen(s) + 1);

     char *line = tmp_s;

@@ -429,14 +442,14 @@
 

         if(tmp_str) {

             if(strcmp(tmp_str, "NOS") == 0) {

-                state.sim_type = ril_info.sim_type;

+                state.sim_type = ril_info.sim_type[sim_id];

                 state.sim_state = MBTK_SIM_STATE_ABSENT;

-                ril_info.sim_state = MBTK_SIM_STATE_ABSENT;

+                ril_info.sim_state[sim_id] = MBTK_SIM_STATE_ABSENT;

                 urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));

             } else if(strcmp(tmp_str, "SIM") == 0) {

-                state.sim_type = ril_info.sim_type;

+                state.sim_type = ril_info.sim_type[sim_id];

                 state.sim_state = MBTK_SIM_STATE_NOT_READY;

-                ril_info.sim_state = MBTK_SIM_STATE_NOT_READY;

+                ril_info.sim_state[sim_id] = MBTK_SIM_STATE_NOT_READY;

                 urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));

             }

         }

@@ -514,8 +527,8 @@
              state.sim_state = MBTK_SIM_STATE_ABSENT;

         }

 

-        state.sim_type = ril_info.sim_type;

-        ril_info.sim_state = state.sim_state;

+        state.sim_type = ril_info.sim_type[sim_id];

+        ril_info.sim_state[sim_id] = state.sim_state;

 

         urc_msg_distribute(true, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));

     } else if(strStartsWith(s, "*EUICC:")){

@@ -527,7 +540,7 @@
         {

             goto SIM_STATE_EXIT;

         }

-        ril_info.sim_type = (mbtk_sim_card_type_enum)tmp_int;

+        ril_info.sim_type[sim_id] = (mbtk_sim_card_type_enum)tmp_int;

     } else {

         LOGW("Unknown URC.");

     }

@@ -539,7 +552,7 @@
 // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0

 // +CALLDISCONNECT: 1

 // +CPAS: 4

-static void urc_call_state_change_process(const char *s, const char *sms_pdu)

+static void urc_call_state_change_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     char* tmp_s = memdup(s,strlen(s) + 1);

     char *line = tmp_s;

@@ -574,6 +587,7 @@
 

         LOGD("Found call id : %d", call_list[i].call_id);

 

+        call_list[i].sim_id = sim_id;

         if (at_tok_nextint(&line, &tmp_int) < 0)    // dir

         {

             goto CALL_STATE_EXIT;

@@ -635,6 +649,7 @@
         }

 

         call_list[i].state = MBTK_RIL_CALL_STATE_DISCONNECT;

+        call_list[i].sim_id = sim_id;

 

         urc_msg_distribute(false, RIL_MSG_ID_IND_CALL_STATE_CHANGE, &(call_list[i]), sizeof(mbtk_ril_call_state_info_t));

 

@@ -651,10 +666,11 @@
 }

 

 // *ECALLDATA: <urc_id>[,<urc_data>]

-static void urc_ecall_state_change_process(const char *s, const char *sms_pdu)

+static void urc_ecall_state_change_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     mbtk_ril_ecall_state_info_t ecall_state;

     memset(&ecall_state, 0, sizeof(mbtk_ril_ecall_state_info_t));

+    ecall_state.sim_id = sim_id;

 

     char* tmp_s = memdup(s,strlen(s) + 1);

     char *line = tmp_s;

@@ -685,11 +701,13 @@
 

 // +CMT: ,23

 // 0891683108200855F6240D91688189911196F10000221130717445230331D90C

-static void urc_sms_state_change_process(const char *s, bool is_pdu)

+static void urc_sms_state_change_process(mbtk_sim_type_enum sim_id, const char *s, bool is_pdu)

 {

     static mbtk_ril_sms_state_info_t sms_info;

+    memset(&sms_info, 0, sizeof(mbtk_ril_sms_state_info_t));

+    sms_info.sim_id = sim_id;

+

     if(!is_pdu) {

-        memset(&sms_info, 0, sizeof(mbtk_ril_sms_state_info_t));

         char* tmp_s = memdup(s,strlen(s) + 1);

         char *line = tmp_s;

         char *tmp_str;

@@ -722,11 +740,12 @@
 // $CREG: 1, "8010", "000060a7", 0,, 2, 0

 // +CGREG: 1

 // +C5GREG: 1,"00280386","07e920010",11,1,"01"

-static void urc_net_reg_state_change_process(const char *s, const char *sms_pdu)

+static void urc_net_reg_state_change_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     mbtk_ril_net_reg_state_info_t state;

     memset(&state, 0, sizeof(mbtk_ril_net_reg_state_info_t));

     state.tech = MBTK_RADIO_TECH_UNKNOWN;

+    state.sim_id = sim_id;

 

     if(strStartsWith(s, "+CREG:"))

     {

@@ -784,7 +803,7 @@
     free(tmp_s);

 }

 

-static void urc_pdp_state_change_process(const char *s, const char *sms_pdu)

+static void urc_pdp_state_change_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     // "CONNECT"

     if(strStartsWith(s, "CONNECT"))

@@ -849,8 +868,8 @@
         // "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1

         mbtk_ril_pdp_state_info_t cgev_info;

         memset(&cgev_info, 0, sizeof(mbtk_ril_pdp_state_info_t));

+        cgev_info.sim_id = sim_id;

         int cid, reason = 0;

-        memset(&cgev_info, 0, sizeof(mbtk_ril_pdp_state_info_t));

         if (sscanf(s, "+CGEV: NW PDN DEACT %d", &cid) == 1) {

             cgev_info.cid = (uint16)cid;

             cgev_info.action = FALSE;

@@ -893,7 +912,7 @@
         LOGD("+CGEV:cid - %d, act - %d, auto_change - %d, reason - %d", cgev_info.cid, cgev_info.action,

             cgev_info.auto_change, cgev_info.reason);

         if(cgev_info.cid >= MBTK_APN_CID_MIN && cgev_info.cid <= MBTK_APN_CID_MAX) {

-            data_call_state_change_cb(cgev_info.cid, cgev_info.action, cgev_info.auto_change, cgev_info.reason);

+            data_call_state_change_cb(sim_id, cgev_info.cid, cgev_info.action, cgev_info.auto_change, cgev_info.reason);

             urc_msg_distribute(false, RIL_MSG_ID_IND_PDP_STATE_CHANGE, &cgev_info, sizeof(mbtk_ril_pdp_state_info_t));

         }

 

@@ -1089,7 +1108,7 @@
 }

 

 

-static void urc_cell_info_process(const char *s, const char *sms_pdu)

+static void urc_cell_info_process(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     // +EEMNRSVC: <mcc>,<lenOfMnc>,<mnc>,<tac>,<phyCellId>,<dlNrArfcn>,<dlScs>,<ulNrArfcn>,<ulScs>,<sulNrArfcn>,<sulScs>,<band>,<dlBandwidth>,<cellId>,<IsRedCapCell>,<longDRXCyclePresent>,<shortDRXCyclePresent>,<longDRXCycle>,<shortDRXCycle>,<pagingCycle>,

     // <rsrp>,<rsrq>,<sinr>,<rssi>,<qRxLevMin>,<qQualMin>,<srxlev>,

@@ -2005,7 +2024,7 @@
 }

 

 

-static void onUnsolicited(const char *s, const char *sms_pdu)

+static void onUnsolicited(mbtk_sim_type_enum sim_id, const char *s, const char *sms_pdu)

 {

     LOGV("URC : %s", s);

     // MBTK_AT_READY

@@ -2014,11 +2033,11 @@
     // Get PDU data.

     if(cmt_found) {

         cmt_found = FALSE;

-        urc_sms_state_change_process(s, true);

+        urc_sms_state_change_process(sim_id, s, true);

     } else if (strStartsWith(s, "MBTK_AT_READY")) { // AT ready.

 

     } else if(strStartsWith(s, "CONNECT") || strStartsWith(s, "+CGEV:")) {

-        urc_pdp_state_change_process(s, sms_pdu);

+        urc_pdp_state_change_process(sim_id, s, sms_pdu);

     } else if(strStartsWith(s, "+EEMNRSVC:") || strStartsWith(s, "+EEMNRINTER:")

         || strStartsWith(s, "+EEMNRINTERRAT:")

         || strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")

@@ -2027,7 +2046,7 @@
         || strStartsWith(s, "+EEMUMTSINTERRAT:") || strStartsWith(s, "+EEMGINFOBASIC:")

         || strStartsWith(s, "+EEMGINFOSVC:") || strStartsWith(s, "+EEMGINFOPS:")

         || strStartsWith(s, "+EEMGINFONC:")) {

-        urc_cell_info_process(s, sms_pdu);

+        urc_cell_info_process(sim_id, s, sms_pdu);

     }

     else if(strStartsWith(s, "*RADIOPOWER:")) // "*RADIOPOWER: 1"

     {

@@ -2039,6 +2058,7 @@
 

         mbtk_ril_radio_state_info_t state;

         memset(&state, 0, sizeof(mbtk_ril_radio_state_info_t));

+        state.sim_id = sim_id;

         if(*ptr == '1') {

             state.radio_state = MBTK_RADIO_STATE_FULL_FUNC;

         } else {

@@ -2058,29 +2078,29 @@
          || strStartsWith(s, "+CREG:")     // GMS/WCDMA/LTE CS registed.

          || strStartsWith(s, "+C5GREG:"))   // NR data registed.

     {

-        urc_net_reg_state_change_process(s, sms_pdu);

+        urc_net_reg_state_change_process(sim_id, s, sms_pdu);

     }

     // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0

     else if(strStartsWith(s, "+CLCC:")

         || strStartsWith(s, "+CPAS:")

         || strStartsWith(s, "+CALLDISCONNECT:"))

     {

-        urc_call_state_change_process(s, sms_pdu);

+        urc_call_state_change_process(sim_id, s, sms_pdu);

     }

     else if(strStartsWith(s, "*SIMDETEC:")

         || strStartsWith(s, "*EUICC:")

         || strStartsWith(s, "+CPIN:"))

     {

-        urc_sim_state_change_process(s, sms_pdu);

+        urc_sim_state_change_process(sim_id, s, sms_pdu);

     }

     else if(strStartsWith(s, "+CMT:"))

     {

         cmt_found = TRUE;

-        urc_sms_state_change_process(s, false);

+        urc_sms_state_change_process(sim_id, s, false);

     }

     else if(strStartsWith(s, "*ECALLDATA:"))

     {

-        urc_ecall_state_change_process(s, sms_pdu);

+        urc_ecall_state_change_process(sim_id, s, sms_pdu);

     }

 #if 0

     // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0

@@ -2386,6 +2406,16 @@
     }

 }

 

+static void onUnsolicited1(const char *s, const char *sms_pdu)

+{

+    onUnsolicited(MBTK_SIM_1, s, sms_pdu);

+}

+

+static void onUnsolicited2(const char *s, const char *sms_pdu)

+{

+    onUnsolicited(MBTK_SIM_2, s, sms_pdu);

+}

+

 static int openSocket(const char* sockname)

 {

     int sock = socket(AF_UNIX, SOCK_STREAM, 0);

@@ -2413,30 +2443,66 @@
 }

 

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

-    if (ril_info.radio_state != MBTK_RADIO_STATE_FULL_FUNC)

+{

+    // SIM1 radio state config.

+    ril_info.radio_state[MBTK_SIM_1] = ril_radio_state_get(MBTK_SIM_1, ATPORTTYPE_0);

+    if (ril_info.radio_state[MBTK_SIM_1] != MBTK_RADIO_STATE_FULL_FUNC)

     {
-        ril_radio_state_set(ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);

+        ril_radio_state_set(MBTK_SIM_1, ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);

     }

 
-    if(ril_info.radio_state == MBTK_RADIO_STATE_FULL_FUNC)

+    if(ril_info.radio_state[MBTK_SIM_1] == MBTK_RADIO_STATE_FULL_FUNC)

     {

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

-    }
-
-    ril_info.sim_state = ril_sim_state_get(ATPORTTYPE_0);

-    if(ril_info.sim_state == MBTK_SIM_STATE_READY)

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

+    }

+

+    // SIM2 radio state config.

+    ril_info.radio_state[MBTK_SIM_2] = ril_radio_state_get(MBTK_SIM_2, ATPORTTYPE_0);

+    if (ril_info.radio_state[MBTK_SIM_2] != MBTK_RADIO_STATE_FULL_FUNC)

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

+        ril_radio_state_set(MBTK_SIM_2, ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);

+    }

+
+    if(ril_info.radio_state[MBTK_SIM_2] == MBTK_RADIO_STATE_FULL_FUNC)

+    {

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

+    }

+

+    // SIM1 state config.

+    ril_info.sim_state[MBTK_SIM_1] = ril_sim_state_get(MBTK_SIM_1, ATPORTTYPE_0);

+    if(ril_info.sim_state[MBTK_SIM_1] == MBTK_SIM_STATE_READY)

+    {
+        LOGD("SIM1 READY!");

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

 

         // Set APN from prop.

-        apn_auto_conf_from_prop(ATPORTTYPE_0);

+        apn_auto_conf_from_prop(MBTK_SIM_1, ATPORTTYPE_0);

     }
     else
     {
-        LOGE("SIM NOT READY!");
+        LOGE("SIM1 NOT READY!");

+    }

+

+    // SIM2 state config.

+    ril_info.sim_state[MBTK_SIM_2] = ril_sim_state_get(MBTK_SIM_2, ATPORTTYPE_0);

+    if(ril_info.sim_state[MBTK_SIM_2] == MBTK_SIM_STATE_READY)

+    {
+        LOGD("SIM1 READY!");

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

+

+        // Set APN from prop.

+        apn_auto_conf_from_prop(MBTK_SIM_2, ATPORTTYPE_0);

+    }
+    else
+    {
+        LOGE("SIM1 NOT READY!");

+    }

+

+    if(req_dual_sim_get(ATPORTTYPE_0, &(ril_info.cur_sim_id), NULL)) {

+        LOGE("req_dual_sim_get() fail, so set to SIM1.");

+        ril_info.cur_sim_id = MBTK_SIM_1;

+    } else {

+        LOGD("Current SIM : %d", ril_info.cur_sim_id);

     }

 }

 

@@ -2526,7 +2592,7 @@
                 ind_regisger(cli_info, pack->msg_id);

             }

 

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

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

 

             ril_msg_pack_free(pack);

         } else {

@@ -2596,36 +2662,45 @@
                 at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);

 

                 // Set APN from prop.

-                apn_auto_conf_from_prop(ATPORTTYPE_0);

+                apn_auto_conf_from_prop(state->sim_id, ATPORTTYPE_0);

             }

         }

         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(ATPORTTYPE_0, reg_state);

+            data_call_retry(reg_state->sim_id, ATPORTTYPE_0, reg_state);

             break;

         }

         case RIL_URC_MSG_BAND_SET:

         {

             int cme_err = MBTK_RIL_ERR_CME_NON;

-            if(req_band_set(ATPORTTYPE_0, &band_info.band_support, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)

+            if(req_band_set(MBTK_SIM_1, ATPORTTYPE_0, &band_info.band_support, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)

             {

-                LOGE("Set band fail.");

+                LOGE("Set SIM1 band fail.");

             }

             else // Set band success.

             {

-                // log_hex("BAND-2", &band_set_info, sizeof(band_set_info_t));

-                band_info.band_set_success = TRUE;

-                if(band_info.band_area == MBTK_MODEM_BAND_AREA_CN) {

-                    property_set("persist.mbtk.band_config", "CN");

-                } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_EU) {

-                    property_set("persist.mbtk.band_config", "EU");

-                } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_SA) {

-                    property_set("persist.mbtk.band_config", "SA");

-                } else {

-                    property_set("persist.mbtk.band_config", "ALL");

+                LOGD("Set SIM1 band success.");

+                cme_err = MBTK_RIL_ERR_CME_NON;

+                if(req_band_set(MBTK_SIM_2, ATPORTTYPE_0, &band_info.band_support, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)

+                {

+                    LOGE("Set SIM2 band fail.");

                 }

-                LOGD("Set band success.");

+                else // Set band success.

+                {

+                    LOGD("Set SIM2 band success.");

+                    // log_hex("BAND-2", &band_set_info, sizeof(band_set_info_t));

+                    band_info.band_set_success = TRUE;

+                    if(band_info.band_area == MBTK_MODEM_BAND_AREA_CN) {

+                        property_set("persist.mbtk.band_config", "CN");

+                    } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_EU) {

+                        property_set("persist.mbtk.band_config", "EU");

+                    } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_SA) {

+                        property_set("persist.mbtk.band_config", "SA");

+                    } else {

+                        property_set("persist.mbtk.band_config", "ALL");

+                    }

+                }

             }

             break;

         }

@@ -2723,13 +2798,14 @@
 

                                 // Default AT port.

                                 info->port = ATPORTTYPE_0;

+                                info->sim_id = MBTK_SIM_1;

 

                                 list_add(ril_info.sock_client_list, info);

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

 

                                 // Send msg RIL_MSG_ID_IND_SER_STATE_CHANGE to client.

                                 mbtk_ril_ser_state_enum state = MBTK_RIL_SER_STATE_READY;

-                                ril_ind_pack_send(client_fd, RIL_MSG_ID_IND_SER_STATE_CHANGE, &state, 1);

+                                ril_ind_pack_send(MBTK_SIM_1, client_fd, RIL_MSG_ID_IND_SER_STATE_CHANGE, &state, 1);

                             }
                             else
                             {
@@ -2746,7 +2822,7 @@
                         // Parse packet error,send error response to client.
                         if(pack == NULL)
                         {
-                            ril_error_pack_send(cli_info->port, cli_info->fd, RIL_MSG_ID_UNKNOWN, RIL_MSG_INDEX_INVALID, err);

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

                         }
                         else
                         {
@@ -2755,6 +2831,11 @@
                             {

                                 // Update AT port in the first.

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

+                                cli_info->sim_id = (mbtk_sim_type_enum)((*pack_ptr)->sim_id);

+                                if(cli_info->sim_id == MBTK_SIM_AUTO) {

+                                    cli_info->sim_id = ril_info.cur_sim_id;

+                                    LOGD("Auto sim => %d", cli_info->sim_id);

+                                }

 

                                 pack_distribute(cli_info, *pack_ptr);
                                 // Not free,will free in pack_process() or packet process thread.
@@ -2878,7 +2959,7 @@
                 err = pack_req_process(item->cli_info, pack);
                 if(err != MBTK_RIL_ERR_SUCCESS)

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

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

                 }
                 ril_info.at_process[*port] = false;

                 ril_msg_pack_free(pack);

@@ -3029,7 +3110,7 @@
     }
 

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

-    *port_0 = ATPORTTYPE_0;

+    *port_0 = MBTK_AT_PORT_DEF;

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

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

@@ -3037,7 +3118,7 @@
     }

 

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

-    *port_1 = ATPORTTYPE_1;

+    *port_1 = MBTK_AT_PORT_VOICE;

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

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

@@ -3045,7 +3126,7 @@
     }

 

     ATPortType_enum *port_2 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));

-    *port_2 = ATPORTTYPE_2;

+    *port_2 = MBTK_AT_PORT_DATA;

     if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_2))

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

@@ -3158,34 +3239,88 @@
         return -1;

     }

 

+    int uart_sock1 = openSocket("/tmp/atcmd_urc1");

+    if(uart_sock1 < 0)

+    {

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

+        return -1;

+    }

+

+    int at_sock1 = openSocket("/tmp/atcmd_at1");

+    if(at_sock1 < 0)

+    {

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

+        return -1;

+    }

+

+    int at_sock1_1 = openSocket("/tmp/atcmd_at1_1");

+    if(at_sock1_1 < 0)

+    {

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

+        return -1;

+    }

+

+    int at_sock1_2 = openSocket("/tmp/atcmd_at1_2");

+    if(at_sock1_2 < 0)

+    {

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

+        return -1;

+    }

+

     at_set_on_reader_closed(onATReaderClosed);

     at_set_on_timeout(onATTimeout);

 

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

+    if(at_open(ATPORTID_SIM1_0, at_sock, uart_sock, onUnsolicited1))

     {

         LOGE("Start AT_0 thread fail.");

         return -1;

     }

 

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

+    if(at_open(ATPORTID_SIM1_1, at_sock_1, uart_sock, onUnsolicited1))

     {

         LOGE("Start AT_1 thread fail.");

         return -1;

     }

 

-    if(at_open(ATPORTTYPE_2, at_sock_2, uart_sock, onUnsolicited))

+    if(at_open(ATPORTID_SIM1_2, at_sock_2, uart_sock, onUnsolicited1))

     {

         LOGE("Start AT_1 thread fail.");

         return -1;

     }

 

-    if(at_handshake(ATPORTTYPE_0))

+    if(at_handshake(ATPORTID_SIM1_0))

     {

-        LOGE("AT handshake fail.");

+        LOGE("SIM1 AT handshake fail.");

         return -1;

     }

 

-    LOGD("AT OK.");

+    LOGD("SIM1 AT OK.");

+

+    if(at_open(ATPORTID_SIM2_0, at_sock1, uart_sock1, onUnsolicited2))

+    {

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

+        return -1;

+    }

+

+    if(at_open(ATPORTID_SIM2_1, at_sock1_1, uart_sock1, onUnsolicited2))

+    {

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

+        return -1;

+    }

+

+    if(at_open(ATPORTID_SIM2_2, at_sock1_2, uart_sock1, onUnsolicited2))

+    {

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

+        return -1;

+    }

+

+    if(at_handshake(ATPORTID_SIM2_0))

+    {

+        LOGE("SIM2 AT handshake fail.");

+        return -1;

+    }

+

+    LOGD("SIM2 AT OK.");

 

     if(ril_server_start())

     {

diff --git a/mbtk/mbtk_rild_v2/src/ril_call.c b/mbtk/mbtk_rild_v2/src/ril_call.c
old mode 100644
new mode 100755
index ca80871..fe9d374
--- a/mbtk/mbtk_rild_v2/src/ril_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_call.c
@@ -17,21 +17,22 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /*
 ATDXXXXXXX;
 OK
 
 */
-static int req_call_start(ATPortType_enum port, char *phont_number, int *cme_err)
+static int req_call_start(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -48,10 +49,10 @@
 OK
 
 */
-static int req_answer_call(ATPortType_enum port, int *cme_err)
+static int req_answer_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=2", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=2", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -67,10 +68,10 @@
 OK
 
 */
-static int req_hangup_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "ATH", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "ATH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -86,12 +87,12 @@
 OK
 
 */
-static int req_hangup_a_call(ATPortType_enum port, int phone_id, int *cme_err)
+static int req_hangup_a_call(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -107,10 +108,10 @@
 OK
 
 */
-static int req_hangup_waiting_or_background_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_waiting_or_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=0", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=0", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -126,10 +127,10 @@
 OK
 
 */
-static int req_hangup_foreground_resume_background_call(ATPortType_enum port, int *cme_err)
+static int req_hangup_foreground_resume_background_call(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT+CHLD=1", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CHLD=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -145,13 +146,13 @@
 OK
 
 */
-static int req_waitin_call(ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
+static int req_waitin_call(mbtk_sim_type_enum sim_id, 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(port, "AT+CLCC", "+CLCC:", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CLCC", "+CLCC:", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -224,11 +225,11 @@
 
 OK
 */
-static int req_mute_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_mute_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline(port, "AT+CMUT?", "+CMUT:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CMUT?", "+CMUT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -258,13 +259,13 @@
 OK
 
 */
-static int req_mute_set(ATPortType_enum port, int state, int *cme_err)
+static int req_mute_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -280,13 +281,13 @@
 OK
 
 */
-static int req_dtmf_set(ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
+static int req_dtmf_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -297,11 +298,11 @@
     return err;
 }
 
-static int req_centric_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_centric_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int = 0;
-    int err = at_send_command_singleline(port, "AT+CEUS?", "+CEUS:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CEUS?", "+CEUS:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -331,13 +332,13 @@
 OK
 
 */
-static int req_centric_set(ATPortType_enum port, int state, int *cme_err)
+static int req_centric_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CEUS=%d", state);
     LOG("Set the centric command is = %s.\n", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -367,7 +368,7 @@
             else     // Set
             {
                 char *pn = (char*)(pack->data);
-                if(req_call_start(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_call_start(cli_info->sim_id, 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;
@@ -378,7 +379,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -387,7 +388,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-               if(req_answer_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+               if(req_answer_call(cli_info->sim_id, 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;
@@ -398,7 +399,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -412,7 +413,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_call(cli_info->sim_id, 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;
@@ -423,7 +424,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -443,7 +444,7 @@
             else
             {
                 uint8 phone_id = *(pack->data);
-                if(req_hangup_a_call(cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_a_call(cli_info->sim_id, 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;
@@ -454,7 +455,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -463,7 +464,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_waiting_or_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_waiting_or_background_call(cli_info->sim_id, 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;
@@ -474,7 +475,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -488,7 +489,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_foreground_resume_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_foreground_resume_background_call(cli_info->sim_id, 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;
@@ -499,7 +500,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -515,7 +516,7 @@
             {
                 mbtk_call_info_t reg;
                 memset(&reg, 0, sizeof(mbtk_call_info_t));
-                if(req_waitin_call(cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_waitin_call(cli_info->sim_id, 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;
@@ -526,7 +527,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
                 }
             }
             else     // Set
@@ -541,7 +542,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_mute_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_get(cli_info->sim_id, 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;
@@ -552,7 +553,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set mute state.
@@ -565,7 +566,7 @@
                     break;
                 }
 
-                if(req_mute_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_set(cli_info->sim_id, 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;
@@ -576,7 +577,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -591,7 +592,7 @@
             else     // Set
             {
                 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
-                if(req_dtmf_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_dtmf_set(cli_info->sim_id, 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;
@@ -602,7 +603,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -612,7 +613,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_centric_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_centric_get(cli_info->sim_id, 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;
@@ -623,7 +624,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(int));
                 }
             }
             else     // Set mute state.
@@ -636,7 +637,7 @@
                     break;
                 }
 
-                if(req_centric_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_centric_set(cli_info->sim_id, 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;
@@ -647,7 +648,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, 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 9aca13b..32f48bf 100755
--- a/mbtk/mbtk_rild_v2/src/ril_data_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_data_call.c
@@ -49,14 +49,15 @@
 int ril_cid_start = MBTK_APN_CID_MIN;
 
 
-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(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);
+static int req_apn_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
+static int req_apn_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err);
+static void apn_prop_get(mbtk_sim_type_enum sim_id, mbtk_apn_info_array_t *apns);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+static int req_data_call_start(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err);
+static int req_data_call_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
 void ril_state_change(ril_msg_id_enum msg_id, const void *data, int data_len);
 bool asr_auto_data_call_enable();
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /*
 IPv4 : 10.255.74.26
@@ -333,12 +334,12 @@
     }
 }
 
-void apn_auto_conf_from_prop(ATPortType_enum port)
+void apn_auto_conf_from_prop(mbtk_sim_type_enum sim_id, ATPortType_enum port)
 {
     mbtk_apn_info_array_t apns;
     int i = 0;
     memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-    apn_prop_get(&apns);
+    apn_prop_get(sim_id, &apns);
     while(i < apns.num) {
         // Update apn info in buffer.
         int cid = apns.apns[i].cid;
@@ -354,7 +355,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(port, &(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_set(sim_id, port, &(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGD("Set APN fail.");
         }
@@ -375,7 +376,7 @@
     }
 }
 
-static int apn_check_and_cid_reset(ATPortType_enum port, mbtk_apn_info_t *apn)
+static int apn_check_and_cid_reset(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_apn_info_t *apn)
 {
     // Delete apn
     if(str_empty(apn->apn)) {
@@ -389,7 +390,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(port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(sim_id, port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             return 0;
@@ -410,7 +411,7 @@
         int cme_err = MBTK_RIL_ERR_CME_NON;
 
         memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-        if(req_apn_get(port, TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(sim_id, port, TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             if(apn->cid == MBTK_RIL_CID_NUL) {
@@ -503,7 +504,7 @@
     return 0;
 }
 
-static void apn_prop_get(mbtk_apn_info_array_t *apns)
+static void apn_prop_get(mbtk_sim_type_enum sim_id, mbtk_apn_info_array_t *apns)
 {
     char prop_name[128] = {0};
     char prop_data[1024] = {0};
@@ -924,7 +925,7 @@
     }
 }
 
-void data_call_retry(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state)
+void data_call_retry(mbtk_sim_type_enum sim_id, 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.
@@ -962,7 +963,7 @@
 
                         // PDP active
                         int cme_err = MBTK_RIL_ERR_CME_NON;
-                        if(req_data_call_start(port, cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_start(sim_id, port, cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             LOGE("Restart data call fail.");
                             return;
@@ -978,7 +979,7 @@
                             // Get Ip informations.
                             // memset(&ip_info, 0, sizeof(ip_info));
                             cme_err = MBTK_RIL_ERR_CME_NON;
-                            if(req_data_call_state_get(port, cid, &(pdp_info.ip_info), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_state_get(sim_id, port, cid, &(pdp_info.ip_info), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                             {
                                 LOGE("Get net informations fail.");
                                 return;
@@ -1020,10 +1021,10 @@
 OK
 
 */
-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_get(mbtk_sim_type_enum sim_id, 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(port, "AT+CGDCONT?", "+CGDCONT:", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CGDCONT?", "+CGDCONT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -1124,7 +1125,7 @@
 OK
 
 */
-static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err)
+static int req_apn_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1134,7 +1135,7 @@
     // Delete apn
     if(str_empty(apn->apn)) {
         sprintf(cmd, "AT+CGDCONT=%d", apn->cid);
-        err = at_send_command(port, cmd, &response);
+        err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -1165,7 +1166,7 @@
             index += sprintf(cmd + index,"\"%s\"", apn->apn);
         }
 
-        err = at_send_command(port, cmd, &response);
+        err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -1189,7 +1190,7 @@
                 goto exit;
 
             sprintf(cmd, "AT*AUTHREQ=%d,%d,%s,%s",apn->cid,cmd_auth,apn->user,apn->pass);
-            err = at_send_command(port, cmd, &response);
+            err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
             if (err < 0 || response->success == 0){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -1214,7 +1215,7 @@
 OK
 
 */
-static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err)
+static int req_data_call_start(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1225,7 +1226,7 @@
     cgact_wait.act = true;
 
     sprintf(cmd, "AT+CGACT=1,%d", cid);
-    err = at_send_command(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1244,7 +1245,7 @@
 OK
 
 */
-static int req_data_call_stop(ATPortType_enum port, mbtk_ril_cid_enum cid, int timeout, int *cme_err)
+static int req_data_call_stop(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_cid_enum cid, int timeout, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1263,7 +1264,7 @@
     cgact_wait.act = false;
 
     sprintf(cmd, "AT+CGACT=0,%d", cid);
-    err = at_send_command(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1285,7 +1286,7 @@
 OK
 
 */
-static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
+static int req_data_call_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -1293,7 +1294,7 @@
 
     sprintf(cmd, "AT+CGCONTRDP=%d", cid);
 
-    err = at_send_command_multiline(port, cmd, "+CGCONTRDP:", &response);
+    err = at_send_command_multiline(portType_2_portId(sim_id, port), cmd, "+CGCONTRDP:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1435,7 +1436,7 @@
     return err;
 }
 
-void data_call_state_change_cb(int cid, bool action, bool auto_change, int reason)
+void data_call_state_change_cb(mbtk_sim_type_enum sim_id, int cid, bool action, bool auto_change, int reason)
 {
     // Will restart data call.
     if(auto_change && !action) {
@@ -1467,7 +1468,7 @@
             {
                 mbtk_apn_info_array_t apns;
                 memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-                if(req_apn_get(cli_info->port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_apn_get(cli_info->sim_id, 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;
@@ -1479,18 +1480,18 @@
                 else
                 {
                     LOGD("size - %d", 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));
+                    ril_rsp_pack_send(cli_info->sim_id, 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;
                 mbtk_ril_cid_enum return_cid = apn->cid;
-                if(apn_check_and_cid_reset(cli_info->port, apn)) {
+                if(apn_check_and_cid_reset(cli_info->sim_id, cli_info->port, apn)) {
                     err = MBTK_RIL_ERR_CID;
                 } else {
                     if(apn_conf_support(apn->cid)) {
-                        if(req_apn_set(cli_info->port, apn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_apn_set(cli_info->sim_id, 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;
@@ -1506,7 +1507,7 @@
                             }
 
                             return_cid = apn->cid;
-                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &return_cid, sizeof(mbtk_ril_cid_enum));
+                            ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &return_cid, sizeof(mbtk_ril_cid_enum));
                         }
                     } else {
                         err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -1554,7 +1555,7 @@
                             int index = 0;
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_CONNECTING;
 data_call_retry:
-                            if(req_data_call_start(cli_info->port, call_info->cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_start(cli_info->sim_id, 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]);
@@ -1580,7 +1581,7 @@
 
                                 // Get Ip informations.
                                 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(req_data_call_state_get(cli_info->sim_id, cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                                 {
                                     LOGE("Get net informations fail.");
                                     err = MBTK_RIL_ERR_NET_CONF;
@@ -1599,7 +1600,7 @@
                                     // Data call success, valid will be true.
                                     info_list[call_info->cid - 1].valid = TRUE;
 
-                                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
                                 }
                             }
                         }
@@ -1612,7 +1613,7 @@
                         }
 
                         info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTING;
-                        if(req_data_call_stop(cli_info->port, call_info->cid, call_info->timeout, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_stop(cli_info->sim_id, 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;
@@ -1636,12 +1637,12 @@
                             }
 
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTED;
-                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                            ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_state_get(cli_info->sim_id, 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;
@@ -1652,7 +1653,7 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                            ril_rsp_pack_send(cli_info->sim_id, 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 763ed41..d34143e 100755
--- a/mbtk/mbtk_rild_v2/src/ril_dev.c
+++ b/mbtk/mbtk_rild_v2/src/ril_dev.c
@@ -17,7 +17,8 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /*
 AT+CGSN
@@ -25,10 +26,10 @@
 
 OK
 */
-static int req_imei_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_imei_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric(port, "AT+CGSN", &response);
+    int err = at_send_command_numeric(portType_2_portId(sim_id, port), "AT+CGSN", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates) {
         *cme_err = at_get_cme_error(response);
@@ -48,11 +49,11 @@
 OK
 
 */
-static int req_sn_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_sn_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+MRD_SN=R", "+MRD_SN:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, 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,13 +103,13 @@
 OK
 
 */
-static int req_version_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_version_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
 
 //    sleep(3);
 
-    int err = at_send_command_multiline(port, "ATI", "", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -149,10 +150,10 @@
 OK
 
 */
-static int req_model_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_model_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline(port, "ATI", "", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -190,7 +191,7 @@
 
 OK
 */
-static int req_volte_set(ATPortType_enum port, int state, int *cme_err)
+static int req_volte_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[30] = {0};
@@ -202,7 +203,7 @@
     {
         strcpy(cmd, "AT+ACONFIG=\"IMSD=0\"");
     }
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -221,11 +222,11 @@
 
 OK
 */
-static int req_volte_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_volte_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+ACONFIG?", "", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+ACONFIG?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -267,15 +268,15 @@
 OK
 
 */
-static int req_temp_get(ATPortType_enum port, mbtk_temp_type_enum type, int16 *temp, int *cme_err)
+static int req_temp_get(mbtk_sim_type_enum sim_id, 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(port, "AT*SOCTEMP", "*SOCTEMP:", &response);
+        err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*SOCTEMP", "*SOCTEMP:", &response);
     } else { // RF
-        err = at_send_command_singleline(port, "AT*RFTEMP", "*RFTEMP:", &response);
+        err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*RFTEMP", "*RFTEMP:", &response);
     }
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -319,11 +320,11 @@
 OK
 
 */
-static int req_cell_time_get(ATPortType_enum port, char *data, int *cme_err)
+static int req_cell_time_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+CCLK?", "+CCLK:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CCLK?", "+CCLK:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -357,14 +358,14 @@
 6: turn off full secondary receive.
 -1: fail
 */
-mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port)
+mbtk_radio_state_enum ril_radio_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
     char *line;
     int ret;
 
-    err = at_send_command_singleline(port, "AT+CFUN?", "+CFUN:", &p_response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CFUN?", "+CFUN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -382,21 +383,21 @@
 
     at_response_free(p_response);
 
-    ril_info.radio_state = (mbtk_radio_state_enum)ret;
+    ril_info.radio_state[sim_id] = (mbtk_radio_state_enum)ret;
 
-    return ril_info.radio_state;
+    return ril_info.radio_state[sim_id];
 done:
     at_response_free(p_response);
     return MBTK_RADIO_STATE_UNKNOWN;
 }
 
-mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset)
+mbtk_ril_err_enum ril_radio_state_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_radio_state_enum state, bool reset)
 {
     int err;
     ATResponse *p_response = NULL;
     mbtk_ril_err_enum ret = MBTK_RIL_ERR_UNKNOWN;
 
-    if(state == ril_info.radio_state) {
+    if(state == ril_info.radio_state[sim_id]) {
         LOGE("Radio state is same.");
         //return MBTK_RIL_ERR_PARAMETER;
         return MBTK_RIL_ERR_SUCCESS;
@@ -410,21 +411,21 @@
     } else {
         snprintf(cmd, sizeof(cmd), "AT+CFUN=%d", state);
     }
-    err = at_send_command(port, cmd, &p_response);
+    err = at_send_command(portType_2_portId(sim_id, 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(port) == MBTK_RADIO_STATE_FULL_FUNC) { // success
-            ril_info.radio_state = MBTK_RADIO_STATE_FULL_FUNC;
+        if(ril_radio_state_get(sim_id, port) == MBTK_RADIO_STATE_FULL_FUNC) { // success
+            ril_info.radio_state[sim_id] = MBTK_RADIO_STATE_FULL_FUNC;
             ret = MBTK_RIL_ERR_SUCCESS;
             LOGD("Radio open success.");
         } else {
             LOGW("Radio open fail.");
         }
     } else {
-        ril_info.radio_state = state;
+        ril_info.radio_state[sim_id] = state;
         ret = MBTK_RIL_ERR_SUCCESS;
         LOGD("Set radio state to %d success.", state);
     }
@@ -453,7 +454,7 @@
 bit4 - PS DATA
 
 */
-static int req_powerind_set(ATPortType_enum port, uint8 state, int *cme_err)
+static int req_powerind_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, uint8 state, int *cme_err)
 {
     ATResponse *response = NULL;
     int err = -1;
@@ -462,7 +463,7 @@
     {
         char cmd[100] = {0};
         sprintf(cmd, "AT*POWERIND=%d", state);
-        err = at_send_command(port, cmd, &response);
+        err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
         if (err < 0 || response->success == 0){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -474,10 +475,10 @@
     return err;
 }
 
-static int req_md_version_get(ATPortType_enum port,void *data, int *cme_err)
+static int req_md_version_get(mbtk_sim_type_enum sim_id, ATPortType_enum port,void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline(port,"AT*CGMR", "", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT*CGMR", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates)
     {
@@ -541,7 +542,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get IMEI
             {
                 char imei[20] = {0};
-                if(req_imei_get(cli_info->port, imei, &cme_err) || strlen(imei) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imei_get(cli_info->sim_id, 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;
@@ -552,7 +553,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
                 }
             }
             else     // Set IMEI(Unsupport).
@@ -567,7 +568,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char sn[20] = {0};
-                if(req_sn_get(cli_info->port, sn, &cme_err) || strlen(sn) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sn_get(cli_info->sim_id, 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;
@@ -578,7 +579,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
                 }
             }
             else     // Set
@@ -607,7 +608,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char version[50] = {0};
-                if(req_version_get(cli_info->port, version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_version_get(cli_info->sim_id, 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;
@@ -618,7 +619,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
                 }
             }
             else     // Set
@@ -633,7 +634,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char model[50] = {0};
-                if(req_model_get(cli_info->port, model, &cme_err) || strlen(model) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_model_get(cli_info->sim_id, 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;
@@ -644,7 +645,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
                 }
             }
             else     // Set
@@ -659,7 +660,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_volte_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_get(cli_info->sim_id, 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;
@@ -670,7 +671,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -684,7 +685,7 @@
                 }
 
                 uint8 on = *(pack->data);
-                if(req_volte_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_set(cli_info->sim_id, 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;
@@ -695,7 +696,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
 
                     // Restart is required to take effect.
                     // LOG("Will reboot system...");
@@ -708,7 +709,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(cli_info->port, type, &temp, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_temp_get(cli_info->sim_id, 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;
@@ -719,7 +720,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
                 }
             } else {
                 err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -732,7 +733,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get Time
             {
                 char time[100] = {0};
-                if(req_cell_time_get(cli_info->port, time, &cme_err) || strlen(time) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_time_get(cli_info->sim_id, 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;
@@ -743,7 +744,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
                 }
             }
             else     // Set Time
@@ -757,7 +758,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_radio_state_enum radio_state = ril_radio_state_get(cli_info->port);
+                mbtk_radio_state_enum radio_state = ril_radio_state_get(cli_info->sim_id, cli_info->port);
                 if(radio_state == MBTK_RADIO_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -765,7 +766,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -774,9 +775,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(cli_info->port, radio_state, reset);
+                    err = ril_radio_state_set(cli_info->sim_id, cli_info->port, radio_state, reset);
                     if(MBTK_RIL_ERR_SUCCESS == err) {
-                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 } else {
                     err = MBTK_RIL_ERR_FORMAT;
@@ -794,7 +795,7 @@
             else     // Set powerind state.
             {
                 uint8 state = *(pack->data);
-                if(req_powerind_set(cli_info->port, state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_powerind_set(cli_info->sim_id, 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;
@@ -806,7 +807,7 @@
                 else
                 {
                     // pack_rsp_send(cli_info->fd, MBTK_INFO_ID_WAKEUP_STA_RSP, NULL, 0);
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -816,7 +817,7 @@
                 if(pack->data_len == 0 || pack->data == NULL)   // Get VERSION
                 {
                     char version[50] = {0};
-                    if(req_md_version_get(cli_info->port,version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_md_version_get(cli_info->sim_id, 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;
@@ -827,7 +828,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen((char*)version));
+                        ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen((char*)version));
                     }
                 }
                 break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_ecall.c b/mbtk/mbtk_rild_v2/src/ril_ecall.c
index ae8dcd7..3a13b61 100755
--- a/mbtk/mbtk_rild_v2/src/ril_ecall.c
+++ b/mbtk/mbtk_rild_v2/src/ril_ecall.c
@@ -40,9 +40,11 @@
 
 static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
-static int cfg_ecalldata_get(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
+
+static int cfg_ecalldata_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
@@ -51,7 +53,7 @@
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type);
-    err = at_send_command_singleline(port, cmd, "*ECALLDATA:", &response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, port), cmd, "*ECALLDATA:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -91,14 +93,14 @@
     return err;
 }
 
-static int cfg_ecalldata_set(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
+static int cfg_ecalldata_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -110,14 +112,14 @@
     return err;
 }
 
-static int cfg_ecalltimer_set(ATPortType_enum port, const char* type, uint32 value, int *cme_err)
+static int cfg_ecalltimer_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -129,12 +131,12 @@
     return err;
 }
 
-static int req_ecall_msdcfg(ATPortType_enum port, mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_msdcfg(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -145,10 +147,10 @@
     return err;
 }
 
-static int req_ecall_msdgen(ATPortType_enum port, int *cme_err)
+static int req_ecall_msdgen(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT*ECALLMSDGEN", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT*ECALLMSDGEN", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -159,12 +161,12 @@
     return err;
 }
 
-static int req_ecall_msd_set(ATPortType_enum port, const uint8 *msd, int *cme_err)
+static int req_ecall_msd_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -175,11 +177,11 @@
     return err;
 }
 
-static int req_ecall_msd_get(ATPortType_enum port, uint8 *msd, int *cme_err)
+static int req_ecall_msd_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, uint8 *msd, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT*ECALLMSD?", "*ECALLMSD:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*ECALLMSD?", "*ECALLMSD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -209,10 +211,10 @@
     return err;
 }
 
-static int req_ecall_push(ATPortType_enum port, int *cme_err)
+static int req_ecall_push(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command(port, "AT*ECALLPUSH", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT*ECALLPUSH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -230,12 +232,12 @@
 OK
 
 */
-static int req_ecall_only_get(ATPortType_enum port, mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_get(mbtk_sim_type_enum sim_id, 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(port, "AT*ECALLONLY?", "*ECALLONLY:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*ECALLONLY?", "*ECALLONLY:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -296,12 +298,12 @@
 OK
 
 */
-static int req_ecall_only_set(ATPortType_enum port, const mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -316,12 +318,12 @@
 AT*ECALLREG=0/1
 
 */
-static int req_ecall_reg_set(ATPortType_enum port, uint8 reg, int *cme_err)
+static int req_ecall_reg_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -339,11 +341,11 @@
 OK
 
 */
-static int req_ecall_dial_state_get(ATPortType_enum port, mbtk_ecall_dial_type_enum *type, int *cme_err)
+static int req_ecall_dial_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ecall_dial_type_enum *type, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline(port, "AT+CECALL?", "+CECALL:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CECALL?", "+CECALL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -374,12 +376,12 @@
 AT+CECALL=<ecalltype>
 OK
 */
-static int req_ecall_dial_start(ATPortType_enum port, mbtk_ecall_dial_type_enum type, int *cme_err)
+static int req_ecall_dial_start(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -398,11 +400,11 @@
 OK
 
 */
-static int req_ecall_mode_get(ATPortType_enum port, mbtk_ecall_mode_type_enum *mode, int *cme_err)
+static int req_ecall_mode_get(mbtk_sim_type_enum sim_id, 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(port, "AT*ECALLMODE?", "*ECALLMODE:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*ECALLMODE?", "*ECALLMODE:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -445,7 +447,7 @@
 OK
 
 */
-static int req_ecall_mode_set(ATPortType_enum port, mbtk_ecall_mode_type_enum mode, int *cme_err)
+static int req_ecall_mode_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ecall_mode_type_enum mode, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
@@ -454,7 +456,7 @@
     } else {
         sprintf(cmd, "AT*ECALLMODE=\"ERA\"");
     }
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -479,7 +481,7 @@
 OK
 
 */
-static int req_ecall_cfg_get(ATPortType_enum port, uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
+static int req_ecall_cfg_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
@@ -489,7 +491,7 @@
     cfg->type = type;
 
     if(type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
+        if(cfg_ecalldata_get(sim_id, port, MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -498,7 +500,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
+        if(cfg_ecalldata_get(sim_id, port, MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -507,7 +509,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
+        if(cfg_ecalldata_get(sim_id, port, MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -516,7 +518,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
+        if(cfg_ecalldata_get(sim_id, port, MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -525,7 +527,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
+        if(cfg_ecalldata_get(sim_id, port, MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -536,7 +538,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(port, "AT*ECALLTIMER?", "*ECALLTIMER:", &response);
+        err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*ECALLTIMER?", "*ECALLTIMER:", &response);
         if (err < 0 || response->success == 0 || !response->p_intermediates){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -653,7 +655,7 @@
 AT*ECALLTIMER=dereg,300
 OK
 */
-static int req_ecall_cfg_set(ATPortType_enum port, const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_cfg_set(mbtk_sim_type_enum sim_id, 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) {
@@ -668,7 +670,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
+        if(cfg_ecalldata_set(sim_id, 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;
@@ -676,7 +678,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
+        if(cfg_ecalldata_set(sim_id, 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;
@@ -684,7 +686,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
+        if(cfg_ecalldata_set(sim_id, 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;
@@ -692,7 +694,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
+        if(cfg_ecalldata_set(sim_id, 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;
@@ -700,7 +702,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
+        if(cfg_ecalldata_set(sim_id, 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;
@@ -709,14 +711,14 @@
 
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CALLBACK)
     {
-        if(cfg_ecalltimer_set(port, "callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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(port, "cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, port, "cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
@@ -724,49 +726,49 @@
 
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_DEREG)
     {
-        if(cfg_ecalltimer_set(port, "dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_TIMER_DIAL)
     {
-        if(cfg_ecalltimer_set(port, "dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_TIMER_REDIAL)
     {
-        if(cfg_ecalltimer_set(port, "redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_TIMER_SMS)
     {
-        if(cfg_ecalltimer_set(port, "sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_REDIALCNT)
     {
-        if(cfg_ecalltimer_set(port, "redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_SMSPROCESS)
     {
-        if(cfg_ecalltimer_set(port, "smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
+        if(cfg_ecalltimer_set(sim_id, 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_SMSMSDCNT)
     {
-        if(cfg_ecalltimer_set(port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
+        if(cfg_ecalltimer_set(sim_id, port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
@@ -781,12 +783,12 @@
 OK
 
 */
-static int req_ecall_spkmute_set(ATPortType_enum port, int mute, int *cme_err)
+static int req_ecall_spkmute_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -805,11 +807,11 @@
 OK
 
 */
-static int req_ecall_sms_num_get(ATPortType_enum port, uint8 *number, int *cme_err)
+static int req_ecall_sms_num_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, uint8 *number, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -844,12 +846,12 @@
 OK
 
 */
-static int req_ecall_sms_num_set(ATPortType_enum port, const uint8 *number, int *cme_err)
+static int req_ecall_sms_num_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -865,12 +867,12 @@
 OK
 
 */
-static int req_ecall_gain_set(ATPortType_enum port, mbtk_ecall_gain_info_t *gain, int *cme_err)
+static int req_ecall_gain_set(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -899,7 +901,7 @@
             else     // Set
             {
                 mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
-                if(req_ecall_msdcfg(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdcfg(cli_info->sim_id, 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;
@@ -910,7 +912,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -919,7 +921,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msdgen(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdgen(cli_info->sim_id, 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;
@@ -930,7 +932,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -945,7 +947,7 @@
             memset(msd, 0, sizeof(msd));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msd_get(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_get(cli_info->sim_id, 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;
@@ -956,13 +958,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_set(cli_info->sim_id, 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;
@@ -973,7 +975,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -982,7 +984,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_push(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_push(cli_info->sim_id, 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;
@@ -993,7 +995,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -1008,7 +1010,7 @@
             {
                 mbtk_ecall_only_info_t only_info;
                 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
-                if(req_ecall_only_get(cli_info->port, &only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_get(cli_info->sim_id, 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;
@@ -1019,13 +1021,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_set(cli_info->sim_id, 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;
@@ -1036,7 +1038,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1050,7 +1052,7 @@
             else
             {
                 uint8 reg = pack->data[0];
-                if(req_ecall_reg_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_reg_set(cli_info->sim_id, 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;
@@ -1061,7 +1063,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1071,7 +1073,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_dial_type_enum type;
-                if(req_ecall_dial_state_get(cli_info->port, &type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_state_get(cli_info->sim_id, 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;
@@ -1082,13 +1084,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_start(cli_info->sim_id, 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;
@@ -1099,7 +1101,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1109,7 +1111,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_mode_type_enum mode;
-                if(req_ecall_mode_get(cli_info->port, &mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_get(cli_info->sim_id, 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;
@@ -1120,13 +1122,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_set(cli_info->sim_id, 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;
@@ -1137,7 +1139,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1152,7 +1154,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(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_set(cli_info->sim_id, 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;
@@ -1163,13 +1165,13 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, *type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_get(cli_info->sim_id, 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;
@@ -1180,7 +1182,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
+                        ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
                     }
                 }
             }
@@ -1192,7 +1194,7 @@
             memset(number, 0, sizeof(number));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_sms_num_get(cli_info->port, number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_get(cli_info->sim_id, 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;
@@ -1203,13 +1205,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_set(cli_info->sim_id, 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;
@@ -1220,7 +1222,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1241,7 +1243,7 @@
                     break;
                 }
 
-                if(req_ecall_spkmute_set(cli_info->port, mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_spkmute_set(cli_info->sim_id, 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;
@@ -1252,7 +1254,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1266,7 +1268,7 @@
             else     // Set
             {
                 mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
-                if(req_ecall_gain_set(cli_info->port, gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_gain_set(cli_info->sim_id, 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;
@@ -1277,7 +1279,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, 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 7042954..7935352 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -23,7 +23,9 @@
 mbtk_cell_pack_info_t cell_info;
 
 extern ril_band_info_t band_info;
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
+
 
 static bool net_support_check(uint32 net_type, uint32 net_flag)
 {
@@ -37,10 +39,10 @@
 
 OK
 */
-static int req_available_net_get(ATPortType_enum port, mbtk_net_info_array_t* nets, int *cme_err)
+static int req_available_net_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_net_info_array_t* nets, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_singleline(port, "AT+COPS=?", "+COPS:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+COPS=?", "+COPS:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -135,14 +137,14 @@
 OK
 
 */
-static int req_net_sel_mode_get(ATPortType_enum port, mbtk_net_info_t *net, int *cme_err)
+static int req_net_sel_mode_get(mbtk_sim_type_enum sim_id, 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(port, "AT+COPS?", "+COPS:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+COPS?", "+COPS:", &response);
     //LOG("req_net_sel_mode_get() 00");
     //sleep(1);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -221,7 +223,7 @@
 OK
 
 */
-static int req_net_sel_mode_set(ATPortType_enum port, mbtk_net_info_t* net, int *cme_err)
+static int req_net_sel_mode_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_net_info_t* net, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -238,7 +240,7 @@
         }
      }
 
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 
     if (err < 0 || response->success == 0) {
         if(cme_err) {
@@ -257,7 +259,7 @@
 OK
 
 */
-int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
+int req_band_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
@@ -352,7 +354,7 @@
         }
         if(band->net_pref == 0xFF) { // No change net_pref.
             int tmp_int;
-            err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
+            err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*BAND?", "*BAND:", &response);
             if (err < 0 || response->success == 0 || !response->p_intermediates){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -394,7 +396,7 @@
             }
         }
     }
-    err = at_send_command(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 
     if (err < 0 || response->success == 0){
         if(cme_err) {
@@ -479,13 +481,13 @@
     65536 ?C FDDLTE _BAND_17
     524288 ?C FDDLTE _BAND_20
 */
-static int req_band_get(ATPortType_enum port, mbtk_band_info_t *band, int *cme_err)
+static int req_band_get(mbtk_sim_type_enum sim_id, 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(port, "AT*BAND?", "*BAND:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*BAND?", "*BAND:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -626,13 +628,13 @@
 OK
 
 */
-static int req_net_signal_get(ATPortType_enum port, mbtk_signal_info_t *signal, int *cme_err)
+static int req_net_signal_get(mbtk_sim_type_enum sim_id, 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(port, "AT+CSQ", "+CSQ:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, 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);
@@ -654,7 +656,7 @@
     signal->rssi = (uint8)tmp_int;
     at_response_free(response);
 
-    err = at_send_command_singleline(port, "AT+CESQ", "+CESQ:", &response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, 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);
@@ -736,7 +738,7 @@
     }
 
     at_response_free(response);
-    err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, 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);
@@ -811,12 +813,12 @@
 
 
 */
-static int req_net_reg_get(ATPortType_enum port, mbtk_net_reg_info_t *reg, int *cme_err)
+static int req_net_reg_get(mbtk_sim_type_enum sim_id, 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(port, "AT+CREG=3", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+CREG=3", &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -825,7 +827,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline(port, "AT+CREG?", "+CREG:", &response);
+    err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CREG?", "+CREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -875,7 +877,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline(port, "AT+CEREG?", "+CEREG:", &response);
+    err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CEREG?", "+CEREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -924,7 +926,7 @@
         reg->type = (uint8)tmp_int;
     } else if(reg->data_state == 0 && (band_info.net_support & MBTK_NET_SUPPORT_5G)) {
         at_response_free(response);
-        err = at_send_command_multiline(port, "AT+C5GREG?", "+C5GREG:", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+C5GREG?", "+C5GREG:", &response);
         if (err < 0 || response->success == 0 || !response->p_intermediates){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -975,7 +977,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline(port, "AT+CIREG?", "+CIREG:", &response);
+    err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CIREG?", "+CIREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         reg->ims_state = (uint8)0;
         err = 0;
@@ -1207,13 +1209,13 @@
 OK
 
 */
-static int req_cell_info_get(ATPortType_enum port, int *cme_err)
+static int req_cell_info_get(mbtk_sim_type_enum sim_id, 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(port, "AT+EEMOPT=1", &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), "AT+EEMOPT=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1224,7 +1226,7 @@
     cell_info.running = true;
     cell_info.cell_list.num = 0;
 
-    err = at_send_command_singleline(port, "AT+EEMGINFO?", "+EEMGINFO:", &response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+EEMGINFO?", "+EEMGINFO:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1315,7 +1317,7 @@
     return buff_size;
 }
 
-static int req_cell_info_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cell_info_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[500] = {0};
@@ -1328,7 +1330,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(port, cmd, "", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, port), cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -1374,7 +1376,7 @@
 ƽ̨±¾ÉíÊÇÓÐÒ»Ì×¼ä¸ôËÑÍø£¬Ò²ÓÐÀúʷƵµãÓÅÏÈ´¦ÀíµÄÂß¼­£¨²»ÐèÒªÎÒÃǽøÐд¦Àí£©£¬
 Ìṩ¸øÎÒÃǵÄAT+OOSPPÖ¸ÁîÊÇÈÃÎÒÃÇ¿ÉÒÔ×Ô¶¨ÒåËÑÍø¼ä¸ô
 */
-static int req_oos_set(ATPortType_enum port, const mbtk_ril_oos_info_t* oos_info, int *cme_err)
+static int req_oos_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, const mbtk_ril_oos_info_t* oos_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
@@ -1407,7 +1409,7 @@
     }
 
     LOGI("Set the oos command is = [%s]\n", cmd);
-    err = at_send_command(port, cmd, &response);
+    err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1425,11 +1427,11 @@
 ¹Ø£º
 +OOSPP:0
 */
-static int req_oos_get(ATPortType_enum port, mbtk_ril_oos_info_t *oos_info, int *cme_err)
+static int req_oos_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_ril_oos_info_t *oos_info, int *cme_err)
 {
     ATResponse *response = NULL;
 
-    int err = at_send_command_singleline(port, "AT+OOSPP?", "+OOSPP:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+OOSPP?", "+OOSPP:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -1501,7 +1503,7 @@
             {
                 mbtk_net_info_array_t net_array;
                 memset(&net_array, 0, sizeof(mbtk_net_info_array_t));
-                if(req_available_net_get(cli_info->port, &net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_available_net_get(cli_info->sim_id, 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;
@@ -1512,7 +1514,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
                 }
             }
             else     // Set
@@ -1528,7 +1530,7 @@
             {
                 mbtk_net_info_t info;
                 memset(&info, 0, sizeof(mbtk_net_info_t));
-                if(req_net_sel_mode_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_get(cli_info->sim_id, 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;
@@ -1539,13 +1541,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_set(cli_info->sim_id, 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;
@@ -1556,7 +1558,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1574,7 +1576,7 @@
                     if(*(pack->data)) { // Get current bands.
                         mbtk_band_info_t band;
                         memset(&band, 0x0, sizeof(mbtk_band_info_t));
-                        if(req_band_get(cli_info->port, &band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_band_get(cli_info->sim_id, 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;
@@ -1585,10 +1587,10 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
+                            ril_rsp_pack_send(cli_info->sim_id, 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->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support, sizeof(mbtk_band_info_t));
+                        ril_rsp_pack_send(cli_info->sim_id, 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;
@@ -1599,7 +1601,7 @@
                         break;
                     }
 
-                    if(req_band_set(cli_info->port, band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_band_set(cli_info->sim_id, 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;
@@ -1610,7 +1612,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 }
             }
@@ -1622,7 +1624,7 @@
             {
                 mbtk_signal_info_t signal;
                 memset(&signal, 0, sizeof(mbtk_signal_info_t));
-                if(req_net_signal_get(cli_info->port, &signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_signal_get(cli_info->sim_id, 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;
@@ -1633,7 +1635,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
                 }
             }
             else     // Set
@@ -1649,7 +1651,7 @@
             {
                 mbtk_net_reg_info_t net_reg;
                 memset(&net_reg, 0, sizeof(mbtk_net_reg_info_t));
-                if(req_net_reg_get(cli_info->port, &net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_reg_get(cli_info->sim_id, 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;
@@ -1660,7 +1662,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
                 }
             }
             else     // Set
@@ -1674,7 +1676,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)   // Get net cell.
             {
-                if(req_cell_info_get(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_get(cli_info->sim_id, 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;
@@ -1687,7 +1689,7 @@
                 {
                     LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
                     LOGD("data_len = %d", 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));
+                    ril_rsp_pack_send(cli_info->sim_id, 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
@@ -1695,7 +1697,7 @@
                 char *mem = (char*)(pack->data);
                 int len = pack->data_len;
                 char reg[100] = {0};
-                if(req_cell_info_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_set(cli_info->sim_id, 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;
@@ -1705,7 +1707,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -1716,7 +1718,7 @@
             {
                 mbtk_ril_oos_info_t oos_info;
                 memset(&oos_info, 0, sizeof(mbtk_ril_oos_info_t));
-                if(req_oos_get(cli_info->port, &oos_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_oos_get(cli_info->sim_id, cli_info->port, &oos_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;
@@ -1728,13 +1730,13 @@
                 else
                 {
                     LOG("req_oos_get() success,cell number: %d", oos_info.state);
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &oos_info, sizeof(mbtk_ril_oos_info_t));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &oos_info, sizeof(mbtk_ril_oos_info_t));
                 }
             }
             else     // Set net oos.
             {
                 mbtk_ril_oos_info_t *oos_info = (mbtk_ril_oos_info_t*)(pack->data);
-                if(req_oos_set(cli_info->port, oos_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_oos_set(cli_info->sim_id, cli_info->port, oos_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;
@@ -1744,7 +1746,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_pb.c b/mbtk/mbtk_rild_v2/src/ril_pb.c
index 1d93cc9..e6b7c23 100755
--- a/mbtk/mbtk_rild_v2/src/ril_pb.c
+++ b/mbtk/mbtk_rild_v2/src/ril_pb.c
@@ -17,7 +17,8 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 //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 fc9221e..a0fc554 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sim.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sim.c
@@ -17,10 +17,11 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /** Returns SIM_NOT_READY on error */
-mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port)
+mbtk_sim_state_enum ril_sim_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
@@ -28,7 +29,7 @@
     char *cpinLine;
     char *cpinResult;
 
-    err = at_send_command_singleline(port, "AT+CPIN?", "+CPIN:", &p_response);
+    err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CPIN?", "+CPIN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -144,7 +145,7 @@
     at_response_free(p_response);
     p_response = NULL;
     cpinResult = NULL;
-    ril_info.sim_state = ret;
+    ril_info.sim_state[sim_id] = ret;
     return ret;
 }
 
@@ -154,11 +155,11 @@
 
 OK
 */
-static int req_sim_type_get(ATPortType_enum port, uint8 *type, int *cme_err)
+static int req_sim_type_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, uint8 *type, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT*EUICC?", "*EUICC:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT*EUICC?", "*EUICC:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -191,11 +192,11 @@
 
 OK
 */
-static int req_iccid_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_iccid_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+ICCID", "+ICCID:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+ICCID", "+ICCID:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -228,11 +229,11 @@
 OK
 
 */
-static int req_phone_number_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_phone_number_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+CNUM?", "+CNUM:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, 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 +279,10 @@
 OK
 
 */
-static int req_imsi_get(ATPortType_enum port, void *data, int *cme_err)
+static int req_imsi_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric(port, "AT+CIMI", &response);
+    int err = at_send_command_numeric(portType_2_portId(sim_id, port), "AT+CIMI", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -294,12 +295,12 @@
     return err;
 }
 
-static int req_sim_lock_state_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_sim_lock_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char cmd[64]={0};
 
-    int err = at_send_command_singleline(port, "AT+CLCK=SC,2", "+CLCK:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, 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 +344,12 @@
 
 *
 */
-static int req_sim_lock_switch(ATPortType_enum port, bool enable, uint8* pin, int *cme_err)
+static int req_sim_lock_switch(mbtk_sim_type_enum sim_id, 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(port, cmd, "+CLCK:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, 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 +394,22 @@
     return err;
 }
 
-static int req_sim_pin_change(ATPortType_enum port, uint8* old_pin, uint8 *new_pin, int *cme_err)
+static int req_sim_pin_change(mbtk_sim_type_enum sim_id, 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(port, &state, cme_err) || *cme_err != MBTK_RIL_ERR_CME_NON)
+    if(req_sim_lock_state_get(sim_id, 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(port, TRUE, new_pin, cme_err);
+        return req_sim_lock_switch(sim_id, 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(port, cmd, &response);
+        err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -422,12 +423,12 @@
     return err;
 }
 
-static int req_sim_pin_verify(ATPortType_enum port, uint8* pin, int *cme_err)
+static int req_sim_pin_verify(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -440,12 +441,12 @@
     return err;
 }
 
-static int req_sim_puk_verify(ATPortType_enum port, uint8* puk, uint8* pin, int *cme_err)
+static int req_sim_puk_verify(mbtk_sim_type_enum sim_id, 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(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -458,29 +459,29 @@
     return err;
 }
 
-static int req_sim_lock_set(ATPortType_enum port, mbtk_sim_lock_info_t *lock_info, int *cme_err)
+static int req_sim_lock_set(mbtk_sim_type_enum sim_id, 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(port, FALSE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(sim_id, port, FALSE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_ENABLE:
         {
-            return req_sim_lock_switch(port, TRUE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(sim_id, port, TRUE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_CHANGE:
         {
-            return req_sim_pin_change(port, lock_info->pin1, lock_info->pin2, cme_err);
+            return req_sim_pin_change(sim_id, port, lock_info->pin1, lock_info->pin2, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PIN:
         {
-            return req_sim_pin_verify(port, lock_info->pin1, cme_err);
+            return req_sim_pin_verify(sim_id, port, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PUK:
         {
-            return req_sim_puk_verify(port, lock_info->puk, lock_info->pin1, cme_err);
+            return req_sim_puk_verify(sim_id, port, lock_info->puk, lock_info->pin1, cme_err);
         }
         default:
         {
@@ -498,12 +499,12 @@
 
 OK
 */
-static int req_pin_puk_last_times_get(ATPortType_enum port, mbtk_pin_puk_last_times_t *times, int *cme_err)
+static int req_pin_puk_last_times_get(mbtk_sim_type_enum sim_id, 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(port, "AT+EPIN?", "+EPIN:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+EPIN?", "+EPIN:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -558,11 +559,11 @@
 
 OK
 */
-static int req_plmn_get(ATPortType_enum port, mbtk_plmn_info *info, int *cme_err)
+static int req_plmn_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_plmn_info *info, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_multiline(port, "AT+CPOL?", "+CPOL:", &response);
+    int err = at_send_command_multiline(portType_2_portId(sim_id, port), "AT+CPOL?", "+CPOL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -614,6 +615,69 @@
     return err;
 }
 
+/*
+>AT+SWITCHSIM?
+<+SWITCHSIM: 0
+
+<OK
+*/
+int req_dual_sim_get(ATPortType_enum port, mbtk_sim_type_enum *sim_id, int *cme_err)
+{
+    ATResponse *response = NULL;
+//    char *tmp_ptr = NULL;
+    int err = at_send_command_singleline(portType_2_portId(MBTK_SIM_1, port), "AT+SWITCHSIM?", "+SWITCHSIM:", &response);
+
+    if (err < 0 || response->success == 0 || !response->p_intermediates){
+        if(cme_err) {
+            *cme_err = at_get_cme_error(response);
+        }
+        goto exit;
+    }
+
+    char *line = response->p_intermediates->line;
+    err = at_tok_start(&line);
+    if (err < 0)
+    {
+        goto exit;
+    }
+    int tmp_int = -1;
+    err = at_tok_nextint(&line, &tmp_int);
+    if (err < 0)
+    {
+        goto exit;
+    }
+    if(tmp_int != -1)
+        *sim_id = tmp_int;
+    goto exit;
+exit:
+    at_response_free(response);
+    return err;
+}
+
+/*
+>AT+SWITCHSIM?
+<+SWITCHSIM: 0
+
+<OK
+*/
+static int req_dual_sim_set(ATPortType_enum port, mbtk_sim_type_enum sim_id, int *cme_err)
+{
+    int err = -1;
+    ATResponse *response = NULL;
+
+    char cmd[64] = {0};
+    snprintf(cmd, sizeof(cmd), "AT+SWITCHSIM=%d", sim_id);
+    err = at_send_command(portType_2_portId(MBTK_SIM_1, port), cmd, &response);
+    if (err < 0 || response->success == 0){
+        *cme_err = at_get_cme_error(response);
+        goto exit;
+    }
+
+exit:
+    at_response_free(response);
+    return err;
+}
+
 //void net_list_free(void *data);
 // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
 // Otherwise, do not call pack_error_send().
@@ -627,7 +691,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_sim_state_enum state = ril_sim_state_get(cli_info->port);
+                mbtk_sim_state_enum state = ril_sim_state_get(cli_info->sim_id, cli_info->port);
                 if(state == MBTK_SIM_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -635,7 +699,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -650,7 +714,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 uint8 sim_card_type;
-                if(req_sim_type_get(cli_info->port, &sim_card_type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_type_get(cli_info->sim_id, 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 +725,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
                 }
             }
             else     // Set
@@ -676,7 +740,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char imsi[20] = {0};
-                if(req_imsi_get(cli_info->port, imsi, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imsi_get(cli_info->sim_id, 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 +751,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
                 }
             }
             else     // Set
@@ -702,7 +766,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char pn[50] = {0};
-                if(req_phone_number_get(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_phone_number_get(cli_info->sim_id, 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 +777,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
                 }
             }
             else     // Set
@@ -728,7 +792,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char iccid[50] = {0};
-                if(req_iccid_get(cli_info->port, iccid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_iccid_get(cli_info->sim_id, 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 +803,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
                 }
             }
             else     // Set
@@ -754,7 +818,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 int state;
-                if(req_sim_lock_state_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_state_get(cli_info->sim_id, 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 +829,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, 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(cli_info->port, lock_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_set(cli_info->sim_id, 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 +846,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -792,7 +856,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_pin_puk_last_times_t last_times;
-                if(req_pin_puk_last_times_get(cli_info->port, &last_times, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_pin_puk_last_times_get(cli_info->sim_id, 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 +867,7 @@
                 }
                 else
                 {
-                    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));
+                    ril_rsp_pack_send(cli_info->sim_id, 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 +883,7 @@
             {
                 mbtk_plmn_info info;
                 memset(&info, 0, sizeof(mbtk_plmn_info));
-                if(req_plmn_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_plmn_get(cli_info->sim_id, 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 +894,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
                 }
             }
             else     // Set
@@ -840,6 +904,45 @@
             }
             break;
         }
+        case RIL_MSG_ID_SIM_SWITCH:
+        {
+            if(pack->data_len == 0 || pack->data == NULL)
+            {
+                mbtk_sim_type_enum sim_id;
+                if(req_dual_sim_get(cli_info->port, &sim_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;
+                    } else {
+                        err = MBTK_RIL_ERR_UNKNOWN;
+                    }
+                    LOG("Get SWITCHSIM fail.");
+                }
+                else
+                {
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &sim_id, sizeof(mbtk_sim_type_enum));
+                }
+            }
+            else     // Set
+            {
+                mbtk_sim_type_enum *sim_id = (mbtk_sim_type_enum*)pack->data;
+                if(req_dual_sim_set(cli_info->port, *sim_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;
+                    } else {
+                        err = MBTK_RIL_ERR_UNKNOWN;
+                    }
+                    LOG("Set SWITCHSIM fail.");
+                }
+                else
+                {
+                    ril_info.cur_sim_id = *sim_id;
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                }
+            }
+            break;
+        }
         default:
         {
             err = MBTK_RIL_ERR_REQ_UNKNOWN;
diff --git a/mbtk/mbtk_rild_v2/src/ril_sms.c b/mbtk/mbtk_rild_v2/src/ril_sms.c
index 8ed30f4..50c7acd 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sms.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sms.c
@@ -17,7 +17,8 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(mbtk_sim_type_enum sim_id, ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+ATPortId_enum portType_2_portId(mbtk_sim_type_enum sim_id, ATPortType_enum port);
 
 /*
 AT+CMGF?
@@ -26,11 +27,11 @@
 OK
 
 */
-static int req_cmgf_get(ATPortType_enum port, int *state, int *cme_err)
+static int req_cmgf_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+CMGF?", "", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CMGF?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -61,7 +62,7 @@
 
 OK
 */
-static int req_cmgf_set(ATPortType_enum port, int state, int *cme_err)
+static int req_cmgf_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int state, int *cme_err)
 {
     LOGD("req_cmgf_set()-------------start");
     LOGD("state:%d",state);
@@ -77,7 +78,7 @@
     }
 
     LOGD("req_cmgf_set()----cmd:%s", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -91,7 +92,7 @@
 }
 
 /*set AT+CNMI=1,2*/
-static int req_cnmi_set(ATPortType_enum port, int *cme_err)
+static int req_cnmi_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int *cme_err)
 {
     printf("req_cnmi_set()-------------start3\n");
     ATResponse *response = NULL;
@@ -100,7 +101,7 @@
 	strcpy(cmd, "AT+CNMI=1,2");
 
     printf("req_cnmi_set()----cmd:%s\n", cmd);
-    int err = at_send_command(port, cmd, &response);
+    int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 
     if (err < 0 || response->success == 0) {
 		printf("err:%d, response->success:%d \n", err, response->success);
@@ -123,12 +124,12 @@
 OK
 
 */
-static int req_cpms_get(ATPortType_enum port, char *reg, int *cme_err)
+static int req_cpms_get(mbtk_sim_type_enum sim_id, 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(port, "AT+CPMS?", "", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CPMS?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -170,7 +171,7 @@
 OK
 
 */
-static int req_cpms_set(ATPortType_enum port, const char *mem, char *reg, int len, int *cme_err)
+static int req_cpms_set(mbtk_sim_type_enum sim_id, 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 +193,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(port, cmd, "+CPMS:", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, port), cmd, "+CPMS:", &response);
         if (err < 0 || response->success == 0){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -226,7 +227,7 @@
 */
 #define MBTK_AT_MAX_SMS_NUM 4
 #define MBTK_AT_SMS_MAX_LEN 160*MBTK_AT_MAX_SMS_NUM
-static int req_cmgs_set(ATPortType_enum port, char *cmgs, char *reg, int len, int *cme_err)
+static int req_cmgs_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *cmgs, char *reg, int len, int *cme_err)
 {
     LOGD("req_cmgs_set()----------------start");
     LOGD("cmgs:%s", cmgs);
@@ -260,7 +261,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(port, cmd, data, "+CMGS: ", &response);
+		int err = at_send_command_sms(portType_2_portId(sim_id, port), cmd, data, "+CMGS: ", &response);
 		LOGD("err:%d, response:%d", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -279,7 +280,7 @@
     return err;
 }
 
-static int req_cmgw_set(ATPortType_enum port, char *cmgw,int len, int *cme_err)
+static int req_cmgw_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *cmgw,int len, int *cme_err)
 {
     printf("req_cmgw_set()----------------start\n");
     printf("cmgw:%s\n", cmgw);
@@ -305,7 +306,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(port, cmd, data, "+CMGW: ", &response);
+		int err = at_send_command_sms(portType_2_portId(sim_id, port), cmd, data, "+CMGW: ", &response);
 		printf("err:%d, response:%d\n", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -328,7 +329,7 @@
 
 +MMSG: 1, 0
 */
-static int req_cmgd_set(ATPortType_enum port, char *cmgd, int len, int *cme_err)
+static int req_cmgd_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *cmgd, int len, int *cme_err)
 {
     printf("0req_cmgd_set()--------------start\n");
     printf("cmgd:%s\n", cmgd);
@@ -345,7 +346,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(port, cmd, &response);
+		int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -370,11 +371,11 @@
 OK
 
 */
-static int req_cmgd_get(ATPortType_enum port, char *reg, int *cme_err)
+static int req_cmgd_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *reg, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+CMGD=?", "+CMGD:", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CMGD=?", "+CMGD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -418,7 +419,7 @@
 
 */
 
-static int req_cmgl_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cmgl_set(mbtk_sim_type_enum sim_id, 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);
@@ -461,7 +462,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(port, cmd, "", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, 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");
@@ -532,11 +533,11 @@
 +CSCA: "+8613800280500",145
 OK
 */
-static int req_csca_get(ATPortType_enum port, char *req, int *cme_err)
+static int req_csca_get(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *req, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline(port, "AT+CSCA?", "", &response);
+    int err = at_send_command_singleline(portType_2_portId(sim_id, port), "AT+CSCA?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -563,7 +564,7 @@
     return err;
 }
 
-static int req_csca_set(ATPortType_enum port, char *csca, int len, int *cme_err)
+static int req_csca_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *csca, int len, int *cme_err)
 {
     printf("req_csca_set()--------------start\n");
     printf("csca:%s\n", csca);
@@ -580,7 +581,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(port, cmd, &response);
+		int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -596,7 +597,7 @@
     return err;
 }
 
-static int req_csmp_set(ATPortType_enum port, char *csmp, int len, int *cme_err)
+static int req_csmp_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *csmp, int len, int *cme_err)
 {
     printf("req_csmp_set()-------------------start\n");
     printf("csmp:%s\n", csmp);
@@ -613,7 +614,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(port, cmd, &response);
+		int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -629,7 +630,7 @@
     return err;
 }
 
-static int req_cscb_set(ATPortType_enum port, char *cscb,int len, int *cme_err)
+static int req_cscb_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, char *cscb,int len, int *cme_err)
 {
     printf("req_cscb_set()----------------start\n");
     printf("cscb:%s\n", cscb);
@@ -646,7 +647,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(port, cmd, &response);
+		int err = at_send_command(portType_2_portId(sim_id, port), cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -667,7 +668,7 @@
 +CMSS: 81
 OK
 */
-static int req_cmss_set(ATPortType_enum port, const char *cmss, char *reg, int len, int *cme_err)
+static int req_cmss_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, const char *cmss, char *reg, int len, int *cme_err)
 {
     printf("req_cmss_set()----------------start\n");
     printf("cmss:%s\n", cmss);
@@ -690,7 +691,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(port, cmd, "+CMSS:", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, port), cmd, "+CMSS:", &response);
 		if (err < 0 || response->success == 0){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -735,7 +736,7 @@
 
 OK
 */
-static int req_cmgr_set(ATPortType_enum port, int index, char *reg, int *cme_err)
+static int req_cmgr_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, int index, char *reg, int *cme_err)
 {
     printf("0req_cmgr_set()-------------------start\n");
     printf("index:%d\n", index);
@@ -748,7 +749,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(port, cmd, "", &response);
+        err = at_send_command_multiline(portType_2_portId(sim_id, 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");
@@ -800,7 +801,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_cmgf_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_get(cli_info->sim_id, 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;
@@ -811,7 +812,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -824,7 +825,7 @@
                     break;
                 }
 
-                if(req_cmgf_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_set(cli_info->sim_id, 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;
@@ -835,7 +836,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -845,7 +846,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // SET at+cnmi=1,2.
             {
 //                int state;
-                if(req_cnmi_set(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cnmi_set(cli_info->sim_id, 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;
@@ -856,7 +857,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
 			break;
@@ -866,7 +867,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[100] = {0};
-                if(req_cpms_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_get(cli_info->sim_id, 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;
@@ -877,7 +878,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -887,7 +888,7 @@
                 char reg[100] = {0};
                 LOGD("mem:%s, len:%d", pack->data, pack->data_len);
 
-                if(req_cpms_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_set(cli_info->sim_id, 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;
@@ -899,7 +900,7 @@
                 else
                 {
                     LOGD("cpms_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -917,7 +918,7 @@
 				char reg[50] ={0};
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgs, len);
 
-                if(req_cmgs_set(cli_info->port, cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgs_set(cli_info->sim_id, 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;
@@ -928,7 +929,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -946,7 +947,7 @@
                 char reg[128] = {0};
                 LOGD("mbtk_sms,cmgs:%s, len:%d", cmss, len);
 
-                if(req_cmss_set(cli_info->port, cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmss_set(cli_info->sim_id, 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;
@@ -958,7 +959,7 @@
                 else
                 {
                     LOGD("req_cmss_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -980,7 +981,7 @@
                     break;
                 }
 
-                if(req_cmgr_set(cli_info->port, index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgr_set(cli_info->sim_id, 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;
@@ -991,7 +992,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -1008,7 +1009,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgw:%s,len:%d", cmgw, len);
 
-                if(req_cmgw_set(cli_info->port, cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgw_set(cli_info->sim_id, 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;
@@ -1019,7 +1020,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1029,7 +1030,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[1024] = {0};
-                if(req_cmgd_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_get(cli_info->sim_id, 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;
@@ -1040,7 +1041,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -1049,7 +1050,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgd, len);
 
-                if(req_cmgd_set(cli_info->port, cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_set(cli_info->sim_id, 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;
@@ -1060,7 +1061,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
 
             }
@@ -1079,7 +1080,7 @@
                 char reg[5*1024] = {0};
                 char reg1[1024+1] = {0};
 
-                if(req_cmgl_set(cli_info->port, cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgl_set(cli_info->sim_id, 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;
@@ -1091,7 +1092,7 @@
                 else
                 {
                     memcpy(reg1, reg, 1024);
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
                 }
             }
             break;
@@ -1101,7 +1102,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char csca[50]={0};
-                if(req_csca_get(cli_info->port, csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_get(cli_info->sim_id, 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;
@@ -1112,7 +1113,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
                 }
                 err = MBTK_RIL_ERR_UNSUPPORTED;
             }
@@ -1121,7 +1122,7 @@
 				char *csca = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csca_set(cli_info->port, csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_set(cli_info->sim_id, 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;
@@ -1132,7 +1133,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1148,7 +1149,7 @@
 				char *csmp = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csmp_set(cli_info->port, csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csmp_set(cli_info->sim_id, 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;
@@ -1159,7 +1160,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1175,7 +1176,7 @@
 				char *cscb = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_cscb_set(cli_info->port, cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cscb_set(cli_info->sim_id, 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;
@@ -1186,7 +1187,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_servicesd_v2/src/led_control_service.c b/mbtk/mbtk_servicesd_v2/src/led_control_service.c
old mode 100644
new mode 100755
index f0cc84c..c6c9c59
--- a/mbtk/mbtk_servicesd_v2/src/led_control_service.c
+++ b/mbtk/mbtk_servicesd_v2/src/led_control_service.c
@@ -101,13 +101,13 @@
         return MBTK_RESULT_FAIL;
     }
 
-    return MBTK_RESULT_SUCCESS;    
+    return MBTK_RESULT_SUCCESS;
 }
 
 static void* led_control_thread_run()
 {
     int i,numEvents;
-    
+
     int epoll_fd = epoll_create(2);
     if(epoll_fd < 0)
     {
@@ -138,7 +138,7 @@
                     ev_cli.data.fd = events[i].data.fd;
                     ev_cli.events = EPOLLIN | EPOLLERR | EPOLLET;
                     epoll_ctl(epoll_fd, EPOLL_CTL_DEL, events[i].data.fd, &ev_cli);
-                
+
                     close(events[i].data.fd);
                     sock_cli_fds[index] = -1;
                 }
@@ -154,7 +154,7 @@
                     int client_fd = -1;
                      while(1)
                      {
-                         struct sockaddr_un cliaddr;                                               
+                         struct sockaddr_un cliaddr;
                          socklen_t clilen = sizeof(cliaddr);
                          client_fd = accept(events[i].data.fd, (struct sockaddr *) &cliaddr, &clilen);
                          if(client_fd <= 0)
@@ -177,7 +177,7 @@
                                  }
                                  i++;
                              }
-                    
+
                              if(i >= 2) {
                                  LOGE("Client is full.");
                                  break;
@@ -193,13 +193,13 @@
                                  LOGE("Set flags error:%d", errno);
                              }
                          }
-                    
+
                          memset(&ev_cli,0,sizeof(struct epoll_event));
                          ev_cli.data.fd = client_fd;
                          ev_cli.events = event;//EPOLLIN | EPOLLERR | EPOLLET;
                          epoll_ctl(epoll_fd, EPOLL_CTL_ADD, client_fd, &ev_cli);
                      }
-                     
+
                 }
                 else if (events[i].data.fd > 0) // data grcv
                 {
@@ -272,7 +272,7 @@
         LOGE("listen() fail[%d].", errno);
         goto error;
     }
-    
+
     pthread_attr_t thread_attr;
     pthread_t led_control_thread_id;
     pthread_attr_init(&thread_attr);
@@ -330,9 +330,9 @@
            else
            {
                net_led_lte = FALSE;
-           }            
+           }
         }
-        
+
         if(FALSE == net_led_gms_wcdma && FALSE == net_led_lte)
         {
            mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);
@@ -365,7 +365,7 @@
         {
             mbtk_net_led_set(MBTK_NET_LED_CALL_DISCONNECT);
         }
-        
+
     }
 }
 
@@ -377,8 +377,8 @@
         LOGE("[led]mbtk_ril_open(MBTK_AT_PORT_DEF/ATPORTTYPE_0) fail.");
         goto error;
     }
-    
-    mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
+
+    mbtk_ril_handle* handle_1 = mbtk_ril_open(MBTK_AT_PORT_VOICE);
     if(handle_1 == NULL) {
         LOGE("mbtk_ril_open(ATPORTTYPE_1) fail.");
         goto error;
@@ -404,8 +404,8 @@
             i++;
         }
     }
-    mbtk_ril_close(ATPORTTYPE_1);
-    
+    mbtk_ril_close(MBTK_AT_PORT_VOICE);
+
     ret = mbtk_net_reg_state_change_cb_reg(led_net_reg_state_change_cb);
     if(ret != MBTK_RIL_ERR_SUCCESS)
     {
@@ -424,7 +424,7 @@
 
 error:
     mbtk_ril_close(MBTK_AT_PORT_DEF);
-    mbtk_ril_close(ATPORTTYPE_1);
+    mbtk_ril_close(MBTK_AT_PORT_VOICE);
     return MBTK_RESULT_FAIL;
 }
 
@@ -638,7 +638,7 @@
 static void* net_led_thread_run(void* arg)
 {
     mbtk_net_led_type status = MBTK_NET_LED_CLOSE;
-    
+
     while(1)
     {
         status = mbtk_net_led_get();
diff --git a/mbtk/mbtk_utils/at.c b/mbtk/mbtk_utils/at.c
index 1e8f91b..a776aba 100755
--- a/mbtk/mbtk_utils/at.c
+++ b/mbtk/mbtk_utils/at.c
@@ -477,6 +477,7 @@
 
     char *at_cmd = NULL;
     bool echo = FALSE;
+    char *dev = NULL;
     if(argc == 1) {
         at_mode = AT_MODE_SOCK_1;
     } else if(argc == 2) {
@@ -485,6 +486,9 @@
             at_cmd = argv[1];
         } else if(!strncasecmp(argv[1], "/dev/", 5)) {
             at_mode = AT_MODE_DEV_1;
+        } else if(!strncasecmp(argv[1], "/tmp/", 5)) {
+            at_mode = AT_MODE_SOCK_1;
+            dev = argv[1];
         } else {
             help();
             return -1;
@@ -522,7 +526,11 @@
 #endif
 
     if(at_mode == AT_MODE_SOCK_1 || at_mode == AT_MODE_SOCK_2) {
-        at_fd = openSocket("/tmp/atcmdmbtk");
+        if(dev == NULL) {
+            at_fd = openSocket("/tmp/atcmdmbtk");
+        } else {
+            at_fd = openSocket(dev);
+        }
     } else {
 #if 0
         at_fd = at_open(argv[1]);
diff --git a/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c b/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c
index dbdce3e..a3d8d5a 100755
--- a/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c
+++ b/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c
@@ -82,21 +82,21 @@
         {
             LOGI("Exit by SIGINT.\n");
 //            thread_exit_with_wait();
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
         {
             LOGI("Exit by SIGQUIT.\n");
 //            thread_exit_with_wait();
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGTERM:// 默认kill   (同 SIGKILL ,但 SIGKILL 不可捕获)
         {
             LOGI("Exit by SIGTERM.\n");
 //            thread_exit_with_wait();
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
@@ -176,7 +176,7 @@
     //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
     //test2(1, "2400:3200::1");
 
-    mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
+    mbtk_ril_handle* handle_1 = mbtk_ril_open(MBTK_AT_PORT_VOICE);
     if(handle_1 == NULL) {
         printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
         return -1;
@@ -509,7 +509,7 @@
             else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
                 help();
             } else if(!strcasecmp(cmd, "q")) {
-                mbtk_ril_close(ATPORTTYPE_1);
+                mbtk_ril_close(MBTK_AT_PORT_VOICE);
                 break;
             } else {
                 printf("\n");
@@ -520,7 +520,7 @@
 //    thread_exit_with_wait();
 
 //exit:
-    mbtk_ril_close(ATPORTTYPE_1);
+    mbtk_ril_close(MBTK_AT_PORT_VOICE);
 
     LOG("Client exec complete.");
 
diff --git a/mbtk/test/libmbtk_ril/mbtk_ril_test.c b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
index db7fff2..f8bedb6 100755
--- a/mbtk/test/libmbtk_ril/mbtk_ril_test.c
+++ b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
@@ -123,7 +123,8 @@
 {
     if(data) {
         mbtk_ril_net_reg_state_info_t *state = (mbtk_ril_net_reg_state_info_t*)data;
-        printf("net reg state change : type - %d, tech - %d, reg_state - %d, TAG - %llx, ci - %llx\n", state->type,
+        printf("net reg state change : sim_id - %d, type - %d, tech - %d, reg_state - %d, TAG - %llx, ci - %llx\n",
+            state->sim_id, state->type,
             state->tech, state->reg_state, state->tac, state->ci);
     }
 }
@@ -132,7 +133,8 @@
 {
     if(data) {
         mbtk_ril_call_state_info_t *state = (mbtk_ril_call_state_info_t*)data;
-        printf("call state change : call_id-%d, dir-%d, state-%d, num_type-%d,number-%s\n", state->call_id,
+        printf("call state change : sim_id - %d, call_id-%d, dir-%d, state-%d, num_type-%d, number-%s\n",
+            state->sim_id, state->call_id,
             state->dir, state->state, state->num_type, state->call_number);
     }
 }
@@ -141,7 +143,7 @@
 {
     if(data) {
         mbtk_ril_sms_state_info_t *state = (mbtk_ril_sms_state_info_t*)data;
-        printf("SMS PDU(%d) : %s\n", state->pdu_len, state->pdu);
+        printf("sms state change : sim_id - %d, SMS PDU(%d) : %s\n", state->sim_id, state->pdu_len, state->pdu);
     }
 }
 
@@ -149,7 +151,7 @@
 {
     if(data) {
         mbtk_ril_radio_state_info_t *state = (mbtk_ril_radio_state_info_t*)data;
-        printf("radio state change : %d\n", state->radio_state);
+        printf("radio state change : sim_id - %d, radio_state - %d\n", state->sim_id, state->radio_state);
     }
 }
 
@@ -157,7 +159,7 @@
 {
     if(data) {
         mbtk_ril_sim_state_info_t *state = (mbtk_ril_sim_state_info_t*)data;
-        printf("sim state change : type - %d, state - %d\n", state->sim_type, state->sim_state);
+        printf("sim state change : sim_id - %d, type - %d, state - %d\n", state->sim_id, state->sim_type, state->sim_state);
     }
 }
 
@@ -165,8 +167,8 @@
 {
     if(data) {
         mbtk_ril_pdp_state_info_t *state = (mbtk_ril_pdp_state_info_t*)data;
-        printf("pdp state change : cid - %d, action - %d, reason-%d, auto_change - %d\n",
-            state->cid, state->action, state->reason, state->auto_change);
+        printf("pdp state change : sim_id - %d, cid - %d, action - %d, reason-%d, auto_change - %d\n",
+            state->sim_id, state->cid, state->action, state->reason, state->auto_change);
         if(state->ip_info_valid) {
             if(state->ip_info.ipv4.valid) {
                 // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
@@ -261,7 +263,7 @@
     if(data)
     {
         mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
-        printf("ecall state change : urc_id - %d, urc_data - %s\n", ecall_data->urc_id, ecall_data->urc_data);
+        printf("ecall state change : sim_id - %d, urc_id - %d, urc_data - %s\n", ecall_data->sim_id, ecall_data->urc_id, ecall_data->urc_data);
     }
 }
 
@@ -278,7 +280,7 @@
             thread_exit_with_wait();
 #endif
             mbtk_ril_close(MBTK_AT_PORT_DEF);
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
@@ -288,7 +290,7 @@
             thread_exit_with_wait();
 #endif
             mbtk_ril_close(MBTK_AT_PORT_DEF);
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGTERM:// 默认kill   (同 SIGKILL ,但 SIGKILL 不可捕获)
@@ -298,7 +300,7 @@
             thread_exit_with_wait();
 #endif
             mbtk_ril_close(MBTK_AT_PORT_DEF);
-            mbtk_ril_close(ATPORTTYPE_1);
+            mbtk_ril_close(MBTK_AT_PORT_VOICE);
             exit(0);
         }
         case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
@@ -384,7 +386,7 @@
         return -1;
     }
 
-    mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
+    mbtk_ril_handle* handle_1 = mbtk_ril_open(MBTK_AT_PORT_VOICE);
     if(handle_1 == NULL) {
         printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
         return -1;
@@ -1629,7 +1631,7 @@
     thread_exit_with_wait();
 exit:
 #endif
-    mbtk_ril_close(ATPORTTYPE_1);
+    mbtk_ril_close(MBTK_AT_PORT_VOICE);
     mbtk_ril_close(MBTK_AT_PORT_DEF);
 
     LOG("Client exec complete.");