Add Multiple AT channels supported for ril api v2

Change-Id: I53f574c85d07bd7b8e0dd15d2e596d23c8772907
diff --git a/mbtk/Make.defines b/mbtk/Make.defines
index 335f66e..bc19908 100755
--- a/mbtk/Make.defines
+++ b/mbtk/Make.defines
@@ -47,6 +47,7 @@
 	-I$(BUILD_ROOT)/include/ql

 

 # -DCONFIG_AB_SYSTEM

+# 	-DMBTK_DUMP_SUPPORT

 DEFINE = \

 	-DMBTK_SUPPORT \

 	-DMARVELL_EXTENDED \

diff --git a/mbtk/include/mbtk/mbtk_ril_api.h b/mbtk/include/mbtk/mbtk_ril_api.h
index 2d1e3db..5315ab1 100755
--- a/mbtk/include/mbtk/mbtk_ril_api.h
+++ b/mbtk/include/mbtk/mbtk_ril_api.h
@@ -31,8 +31,22 @@
 #define RIL_MAX_NUMBER_LEN 40
 #define MBTK_ECALL_MSD_LEN_MAX      600
 
+typedef void mbtk_ril_handle;
+
 typedef void (*mbtk_ril_callback_func)(const void* data, int data_len);
 
+typedef enum
+{
+    ATPORTTYPE_NON = -1,
+    ATPORTTYPE_0 = 0,       // /tmp/atcmd_at
+    ATPORTTYPE_1,           // /tmp/atcmd_at_1
+    ATPORTTYPE_2,           // /tmp/atcmd_at_2
+
+    ATPORTTYPE_NUM,
+
+    MBTK_AT_PORT_DEF = ATPORTTYPE_0
+} ATPortType_enum;
+
 typedef enum {
     MBTK_RIL_CID_NUL = 0,   // Auto set cid.
     MBTK_RIL_CID_DEF = MBTK_APN_CID_MIN,
@@ -49,6 +63,8 @@
     MBTK_RIL_ERR_SUCCESS = 0,
     MBTK_RIL_ERR_INITED,
     MBTK_RIL_ERR_NOT_INIT,
+    MBTK_RIL_ERR_PORT,          // AT port error.
+    MBTK_RIL_ERR_PORT_NOT_CLOSE, // Has at port not close.
     MBTK_RIL_ERR_PARAMETER,     // Parameter error.
     MBTK_RIL_ERR_FORMAT,       // Packet format error.
     MBTK_RIL_ERR_SEND_PACK,    // Packet send fail.
@@ -809,39 +825,39 @@
 
 int ipv6_2_str(const void *ipv6, void *ipv6_str);
 
-mbtk_ril_err_enum mbtk_ril_init();
+mbtk_ril_handle* mbtk_ril_open(ATPortType_enum port);
 
-mbtk_ril_err_enum mbtk_ril_deinit();
+mbtk_ril_err_enum mbtk_ril_close(ATPortType_enum port);
 
 /*
 * Get platform version.
 */
-mbtk_ril_err_enum mbtk_version_get(void *version);
+mbtk_ril_err_enum mbtk_version_get(mbtk_ril_handle* handle, void *version);
 
 /*
 * Get platform model.
 */
-mbtk_ril_err_enum mbtk_model_get(void *model);
+mbtk_ril_err_enum mbtk_model_get(mbtk_ril_handle* handle, void *model);
 
 /*
 * Get platform IMEI.
 */
-mbtk_ril_err_enum mbtk_imei_get(void *imei);
+mbtk_ril_err_enum mbtk_imei_get(mbtk_ril_handle* handle, void *imei);
 
 /*
 * Get platform SN.
 */
-mbtk_ril_err_enum mbtk_sn_get(void *sn);
+mbtk_ril_err_enum mbtk_sn_get(mbtk_ril_handle* handle, void *sn);
 
 /*
 * Get platform MEID.
 */
-mbtk_ril_err_enum mbtk_meid_get(void *meid);
+mbtk_ril_err_enum mbtk_meid_get(mbtk_ril_handle* handle, void *meid);
 
 /*
 * Return VoLTE state.
 */
-mbtk_ril_err_enum mbtk_volte_state_get(int *volte_state);
+mbtk_ril_err_enum mbtk_volte_state_get(mbtk_ril_handle* handle, int *volte_state);
 
 /*
 * Set VoLTE state.
@@ -852,12 +868,12 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_volte_state_set(int volte_state);
+mbtk_ril_err_enum mbtk_volte_state_set(mbtk_ril_handle* handle, int volte_state);
 
 /*
 * Return radio state.
 */
-mbtk_ril_err_enum mbtk_radio_state_get(mbtk_radio_state_enum *radio_state);
+mbtk_ril_err_enum mbtk_radio_state_get(mbtk_ril_handle* handle, mbtk_radio_state_enum *radio_state);
 
 /*
 * Set radio state.
@@ -866,7 +882,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_radio_state_set(mbtk_radio_state_enum radio_state, bool reset_modem);
+mbtk_ril_err_enum mbtk_radio_state_set(mbtk_ril_handle* handle, mbtk_radio_state_enum radio_state, bool reset_modem);
 
 /*
 * Get system temperature.
@@ -877,78 +893,78 @@
 * temp[OUT]:
 *   temperature in celsius.
 */
-mbtk_ril_err_enum mbtk_temp_get(mbtk_temp_type_enum type, int* temp);
+mbtk_ril_err_enum mbtk_temp_get(mbtk_ril_handle* handle, mbtk_temp_type_enum type, int* temp);
 
 /*
 * 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(char* time_str);
+mbtk_ril_err_enum mbtk_cell_time_get(mbtk_ril_handle* handle, char* time_str);
 
 /*
 * Get platform IMSI.
 */
-mbtk_ril_err_enum mbtk_imsi_get(void *imsi);
+mbtk_ril_err_enum mbtk_imsi_get(mbtk_ril_handle* handle, void *imsi);
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_iccid_get(void *iccid);
+mbtk_ril_err_enum mbtk_iccid_get(mbtk_ril_handle* handle, void *iccid);
 
 /*
 * Get current phone number.
 */
-mbtk_ril_err_enum mbtk_phone_number_get(void *phone_number);
+mbtk_ril_err_enum mbtk_phone_number_get(mbtk_ril_handle* handle, void *phone_number);
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_get(int *lock_state);
+mbtk_ril_err_enum mbtk_sim_lock_get(mbtk_ril_handle* handle, int *lock_state);
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_sim_lock_info_t *lock_info);
+mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_lock_info_t *lock_info);
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_pin_puk_last_times_t *retry_times);
+mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_pin_puk_last_times_t *retry_times);
 
 /*
 * Get available network.
 */
-mbtk_ril_err_enum mbtk_available_net_get(mbtk_net_info_array_t *net_array);
+mbtk_ril_err_enum mbtk_available_net_get(mbtk_ril_handle* handle, mbtk_net_info_array_t *net_array);
 
 /*
 * Set network select mode. (+COPS=...)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_set(const mbtk_net_info_t *net);
+mbtk_ril_err_enum mbtk_net_sel_mode_set(mbtk_ril_handle* handle, const mbtk_net_info_t *net);
 
 /*
 * Get network select mode. (+COPS?)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_net_info_t *net);
+mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_net_info_t *net);
 
 /*
 * Get platform support bands.
 */
-mbtk_ril_err_enum mbtk_support_band_get(mbtk_band_info_t *band);
+mbtk_ril_err_enum mbtk_support_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band);
 
 /*
 * Get platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_get(mbtk_band_info_t *band);
+mbtk_ril_err_enum mbtk_current_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band);
 
 /*
 * Set platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_set(const mbtk_band_info_t *band);
+mbtk_ril_err_enum mbtk_current_band_set(mbtk_ril_handle* handle, const mbtk_band_info_t *band);
 
 /*
 * Get current cell infomation.
 */
-mbtk_ril_err_enum mbtk_cell_get(mbtk_cell_info_array_t *cell_list);
+mbtk_ril_err_enum mbtk_cell_get(mbtk_ril_handle* handle, mbtk_cell_info_array_t *cell_list);
 
 /*
 * Set cell info.
@@ -959,50 +975,50 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_cell_set(char *info, char *response);
+mbtk_ril_err_enum mbtk_cell_set(mbtk_ril_handle* handle, char *info, char *response);
 
 /*
 * Get current APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_get(mbtk_apn_info_array_t *apns);
+mbtk_ril_err_enum mbtk_apn_get(mbtk_ril_handle* handle, mbtk_apn_info_array_t *apns);
 
 /*
 * Set current APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_set(const mbtk_apn_info_t *apn);
+mbtk_ril_err_enum mbtk_apn_set(mbtk_ril_handle* handle, const mbtk_apn_info_t *apn);
 
 /*
 * Start data call.
 */
-mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_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);
 
 /*
 * Stop data call.
 */
-mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_cid_enum cid, int timeout);
+mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, int timeout);
 
 /*
 * Get data call state.
 */
-mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip);
+mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip);
 
 /*
 * Get current network signal.
 */
-mbtk_ril_err_enum mbtk_net_signal_get(mbtk_signal_info_t *signal);
+mbtk_ril_err_enum mbtk_net_signal_get(mbtk_ril_handle* handle, mbtk_signal_info_t *signal);
 
 /*
 * Get current network register information.
 */
-mbtk_ril_err_enum mbtk_net_reg_get(mbtk_net_reg_info_t *reg);
+mbtk_ril_err_enum mbtk_net_reg_get(mbtk_ril_handle* handle, mbtk_net_reg_info_t *reg);
 
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_get(int *volte_state);
+mbtk_ril_err_enum mbtk_sms_cmgf_get(mbtk_ril_handle* handle, int *volte_state);
 
 /*
 * Set sms cmgf.
@@ -1013,7 +1029,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_set(int mode);
+mbtk_ril_err_enum mbtk_sms_cmgf_set(mbtk_ril_handle* handle, int mode);
 
 /*
 * Set sms cmgs.
@@ -1028,7 +1044,7 @@
 
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgs_set(char * cmgs, char *resp);
+mbtk_ril_err_enum mbtk_sms_cmgs_set(mbtk_ril_handle* handle, char * cmgs, char *resp);
 
 /*
 * Set sms cmgw.
@@ -1042,7 +1058,7 @@
 given<ctrl-Z/ESC>
 
 */
-mbtk_ril_err_enum mbtk_sms_cmgw_set(char * cmgw, char *resp);
+mbtk_ril_err_enum mbtk_sms_cmgw_set(mbtk_ril_handle* handle, char * cmgw, char *resp);
 
 /*
 * Set sms cmgd.
@@ -1051,7 +1067,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgd_set(char * cmdg);
+mbtk_ril_err_enum mbtk_sms_cmgd_set(mbtk_ril_handle* handle, char * cmdg);
 
 /*
 * Set sms cmgl.
@@ -1060,12 +1076,12 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgl_set(char * cmgl, char *resp);
+mbtk_ril_err_enum mbtk_sms_cmgl_set(mbtk_ril_handle* handle, char * cmgl, char *resp);
 
 /*
 * Return sms csca.
 */
-mbtk_ril_err_enum mbtk_sms_csca_get(char *buf);
+mbtk_ril_err_enum mbtk_sms_csca_get(mbtk_ril_handle* handle, char *buf);
 
 /*
 * Set sms csca.
@@ -1074,7 +1090,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csca_set(char * csca);
+mbtk_ril_err_enum mbtk_sms_csca_set(mbtk_ril_handle* handle, char * csca);
 
 /*
 * Set sms csmp.
@@ -1083,7 +1099,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csmp_set(char * csmp);
+mbtk_ril_err_enum mbtk_sms_csmp_set(mbtk_ril_handle* handle, char * csmp);
 
 /*
 * Set sms cscb.
@@ -1092,7 +1108,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cscb_set(char * cscb);
+mbtk_ril_err_enum mbtk_sms_cscb_set(mbtk_ril_handle* handle, char * cscb);
 
 /*
 * Set sms cnmi.
@@ -1103,7 +1119,7 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cnmi_set();
+mbtk_ril_err_enum mbtk_sms_cnmi_set(mbtk_ril_handle* handle);
 
 /*
 * Set sms cmss.
@@ -1116,12 +1132,12 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cmss_set(char * cmss, char *resp);
+mbtk_ril_err_enum mbtk_sms_cmss_set(mbtk_ril_handle* handle, char * cmss, char *resp);
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_get(char * mem);
+mbtk_ril_err_enum mbtk_sms_cpms_get(mbtk_ril_handle* handle, char * mem);
 
 /*
 * Set sms cpms.
@@ -1130,7 +1146,7 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_set(char * mem, char* response);
+mbtk_ril_err_enum mbtk_sms_cpms_set(mbtk_ril_handle* handle, char * mem, char* response);
 
 /*
 * Set sms cm.
@@ -1154,68 +1170,68 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgr_set(int index, char *resp);
+mbtk_ril_err_enum mbtk_sms_cmgr_set(mbtk_ril_handle* handle, int index, char *resp);
 
 /*
 * Get sim state.
 */
-mbtk_ril_err_enum mbtk_sim_state_get(mbtk_sim_state_enum *sim_state);
+mbtk_ril_err_enum mbtk_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_state_enum *sim_state);
 
 /*
 * Get sim card type.
 */
-mbtk_ril_err_enum mbtk_sim_type_get(mbtk_sim_card_type_enum *sim_card_type);
+mbtk_ril_err_enum mbtk_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_card_type_enum *sim_card_type);
 
 /*
 * Get plmn list
 */
-mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_plmn_info *plmn_list);
+mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_ril_handle* handle, mbtk_plmn_info *plmn_list);
 
 /*
 * call_start
 *
 */
-mbtk_ril_err_enum mbtk_call_start(char* phone_number);
+mbtk_ril_err_enum mbtk_call_start(mbtk_ril_handle* handle, char* phone_number);
 
 /*
 * Answer the phone call.
 *
 */
-mbtk_ril_err_enum mbtk_call_answer();
+mbtk_ril_err_enum mbtk_call_answer(mbtk_ril_handle* handle);
 
 /*
 * Hang up all call.
 *
 */
-mbtk_ril_err_enum mbtk_call_hang();
+mbtk_ril_err_enum mbtk_call_hang(mbtk_ril_handle* handle);
 
 /*
 * Hang up a call.
 *
 */
-mbtk_ril_err_enum mbtk_a_call_hang(int phone_id);
+mbtk_ril_err_enum mbtk_a_call_hang(mbtk_ril_handle* handle, int phone_id);
 
 /*
 * Hang up waiting or background call.
 *
 */
-mbtk_ril_err_enum mbtk_waiting_or_background_call_hang();
+mbtk_ril_err_enum mbtk_waiting_or_background_call_hang(mbtk_ril_handle* handle);
 
 /*
 * Hang up foreground resume background call.
 *
 */
-mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang();
+mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang(mbtk_ril_handle* handle);
 
 /*
 * Get current call phone number.
 */
-mbtk_ril_err_enum mbtk_call_reg_get(mbtk_call_info_t *reg);
+mbtk_ril_err_enum mbtk_call_reg_get(mbtk_ril_handle* handle, mbtk_call_info_t *reg);
 
 /*
 * Return mute state.
 */
-mbtk_ril_err_enum mbtk_mute_state_get(int *mute_state);
+mbtk_ril_err_enum mbtk_mute_state_get(mbtk_ril_handle* handle, int *mute_state);
 
 /*
 * Set mute state.
@@ -1226,167 +1242,167 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_mute_state_set(int mute_state);
+mbtk_ril_err_enum mbtk_mute_state_set(mbtk_ril_handle* handle, int mute_state);
 
 /*
 * Set DTMF character.
 *
 */
-mbtk_ril_err_enum mbtk_dtmf_send(mbtk_call_dtmf_info_t *dtmf_character);
+mbtk_ril_err_enum mbtk_dtmf_send(mbtk_ril_handle* handle, mbtk_call_dtmf_info_t *dtmf_character);
 
 /*
 * Set msd item.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_item_set(const mbtk_ecall_msd_cfg_info_t *msd_cfg);
+mbtk_ril_err_enum mbtk_ecall_msd_item_set(mbtk_ril_handle* handle, const mbtk_ecall_msd_cfg_info_t *msd_cfg);
 
 /*
 * Generate msd after msd item set.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_gen();
+mbtk_ril_err_enum mbtk_ecall_msd_gen(mbtk_ril_handle* handle);
 
 /*
 * Set ecall msd.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_set(const void* msd);
+mbtk_ril_err_enum mbtk_ecall_msd_set(mbtk_ril_handle* handle, const void* msd);
 
 /*
 * Get ecall msd.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_get(void* msd);
+mbtk_ril_err_enum mbtk_ecall_msd_get(mbtk_ril_handle* handle, void* msd);
 
 
 /*
 * Set ecall msd item.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_push();
+mbtk_ril_err_enum mbtk_ecall_push(mbtk_ril_handle* handle);
 
 /*
 * Set ecall only configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_only_set(const mbtk_ecall_only_info_t* info);
+mbtk_ril_err_enum mbtk_ecall_only_set(mbtk_ril_handle* handle, const mbtk_ecall_only_info_t* info);
 
 /*
 * Get ecall only configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_only_get(mbtk_ecall_only_info_t* info);
+mbtk_ril_err_enum mbtk_ecall_only_get(mbtk_ril_handle* handle, mbtk_ecall_only_info_t* info);
 
 /*
 * Set ecall network reg.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_reg_set(int reg);
+mbtk_ril_err_enum mbtk_ecall_reg_set(mbtk_ril_handle* handle, int reg);
 
 /*
 * Start ecall dial start.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dial_start(mbtk_ecall_dial_type_enum type);
+mbtk_ril_err_enum mbtk_ecall_dial_start(mbtk_ril_handle* handle, mbtk_ecall_dial_type_enum type);
 
 /*
 * Get ecall dial state.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dial_state_get(mbtk_ecall_dial_type_enum* type);
+mbtk_ril_err_enum mbtk_ecall_dial_state_get(mbtk_ril_handle* handle, mbtk_ecall_dial_type_enum* type);
 
 /*
 * Set ecall mode.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mode_set(mbtk_ecall_mode_type_enum mode);
+mbtk_ril_err_enum mbtk_ecall_mode_set(mbtk_ril_handle* handle, mbtk_ecall_mode_type_enum mode);
 
 /*
 * Get ecall mode.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mode_get(mbtk_ecall_mode_type_enum *mode);
+mbtk_ril_err_enum mbtk_ecall_mode_get(mbtk_ril_handle* handle, mbtk_ecall_mode_type_enum *mode);
 
 /*
 * Set ecall configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg);
+mbtk_ril_err_enum mbtk_ecall_cfg_set(mbtk_ril_handle* handle, const mbtk_ecall_cfg_info_t *cfg);
 
 /*
 * Get ecall configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_cfg_get(mbtk_ecall_cfg_info_t* cfg);
+mbtk_ril_err_enum mbtk_ecall_cfg_get(mbtk_ril_handle* handle, mbtk_ecall_cfg_info_t* cfg);
 
 /*
 * Set ecall sms number.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_sms_number_set(const void *number);
+mbtk_ril_err_enum mbtk_ecall_sms_number_set(mbtk_ril_handle* handle, const void *number);
 
 /*
 * Get ecall sms number.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_sms_number_get(void *number);
+mbtk_ril_err_enum mbtk_ecall_sms_number_get(mbtk_ril_handle* handle, void *number);
 
 /*
 * Set ecall mute speaker.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mute_spk_set(int mute);
+mbtk_ril_err_enum mbtk_ecall_mute_spk_set(mbtk_ril_handle* handle, int mute);
 
 /*
 * Set ecall dsp gain.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dsp_gain_set(const mbtk_ecall_gain_info_t *gain_info);
+mbtk_ril_err_enum mbtk_ecall_dsp_gain_set(mbtk_ril_handle* handle, const mbtk_ecall_gain_info_t *gain_info);
 
 /*
 * Set ril server ready callback function.
 */
-int mbtk_ril_ser_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ril_ser_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set net reg state change callback function.
 */
-int mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set call state change callback function.
 */
-int mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set sms state change callback function.
 */
-int mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set radio state change callback function.
 */
-int mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set sim state change callback function.
 */
-int mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set pdp state change callback function.
 */
-int mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set signal state change callback function.
 */
-int mbtk_signal_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_signal_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 /*
 * Set ecall state change callback function.
 */
-int mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb);
+mbtk_ril_err_enum mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb);
 
 
 
diff --git a/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h b/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
index b8b21b5..678a316 100755
--- a/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
+++ b/mbtk/libmbtk_lib_v2/ril/mbtk_ril.h
@@ -19,8 +19,8 @@
 
 // Tag(4) + Packet_Length(2)
 #define RIL_SOCK_PACK_EXTRA_LEN 6
-// RIL_SOCK_PACK_EXTRA_LEN + Index(2) + Type(2) + Id(2) + Error(2) + data_len(2)
-#define RIL_SOCK_PACK_LEN_MIN (RIL_SOCK_PACK_EXTRA_LEN + 10)
+// 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)
 
 #define RIL_MSG_INDEX_AUTO      (-1)         // automatically , refor to :  ril_index
 #define RIL_MSG_INDEX_INVALID   (0)       // Invalid msg index.
@@ -231,6 +231,7 @@
     uint32 tag;     // Refor to : RIL_SOCK_PACKET_TAG
     uint16 msg_len;
 
+    uint8 at_port;  // ATPortType_enum
     uint16 msg_index;   // Message index(Start from 1)
             // 0 : For unknown msg id
     uint16 msg_type;    // Refor to : ril_msg_type_enum
@@ -396,7 +397,7 @@
 
 void ril_msg_pack_free(ril_msg_pack_info_t* pack);
 
-ril_msg_pack_info_t* ril_msg_pack_creat(int msg_type, int msg_id, int msg_index, const void *data, int data_len);
+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);
 
 int ril_pack_send(int fd, ril_msg_pack_info_t *pack);
 
diff --git a/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c b/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
index 663bb54..ae35fd4 100755
--- a/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib_v2/ril/mbtk_ril_api.c
@@ -18,8 +18,15 @@
 #include "mbtk_str.h"
 
 typedef struct {
+    ATPortType_enum port;
+    bool enable;
+} ril_at_port_info_t;
+
+typedef struct {
     int cli_fd;
     bool ril_ready;
+
+    ril_at_port_info_t ports[ATPORTTYPE_NUM];
     int exit_fd[2];
     mbtk_ril_callback_func cb[IND_REGISTER_MAX];
     pthread_t read_thread_id;
@@ -348,13 +355,14 @@
 * Return recv data length.
 * -1 : fail.
 */
-static mbtk_ril_err_enum ril_req_process(ril_msg_id_enum  id,
+static mbtk_ril_err_enum ril_req_process(ATPortType_enum port,
+                             ril_msg_id_enum  id,
                              const void         *req,
                              int                req_len,
                              void               *rsp,
                              bool is_async)
 {
-    ril_msg_pack_info_t* pack = ril_msg_pack_creat(RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
+    ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
     if(pack == NULL)
     {
         return MBTK_RIL_ERR_MEMORY;
@@ -429,18 +437,39 @@
     MBTK_SOURCE_INFO_PRINT("mbtk_ril_lib");
 }
 
-mbtk_ril_err_enum mbtk_ril_init()
+static bool at_port_check(ATPortType_enum port)
 {
+    if(port < ATPORTTYPE_0 || port >= ATPORTTYPE_NUM) {
+        return FALSE;
+    }
+
+    return ril_cli.ports[port].port == port && ril_cli.ports[port].enable;
+}
+
+mbtk_ril_handle* mbtk_ril_open(ATPortType_enum port)
+{
+    if(port < ATPORTTYPE_0 || port >= ATPORTTYPE_NUM) {
+        LOGE("Port(%d) error.", port);
+        return NULL;
+    }
+
     if(ril_cli.ril_ready)
     {
-        return MBTK_RIL_ERR_INITED;
+        if(at_port_check(port)) {
+            LOGW("Port(%d) can not reopen.", port);
+            return NULL;
+        } else {
+            ril_cli.ports[port].port = port;
+            ril_cli.ports[port].enable = TRUE;
+            return &(ril_cli.ports[port]);
+        }
     }
 
     ril_cli.cli_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
     if(ril_cli.cli_fd < 0)
     {
         LOGE("socket() fail[%d].", errno);
-        return MBTK_RIL_ERR_UNKNOWN;
+        return NULL;
     }
 
     // Set O_NONBLOCK
@@ -518,7 +547,9 @@
 
     LOGD("RIL server ready...");
 
-    return MBTK_RIL_ERR_SUCCESS;
+    ril_cli.ports[port].port = port;
+    ril_cli.ports[port].enable = TRUE;
+    return &(ril_cli.ports[port]);
 error:
     if(ril_cli.cli_fd > 0)
     {
@@ -536,172 +567,220 @@
         ril_cli.exit_fd[1] = -1;
     }
 
-    return MBTK_RIL_ERR_UNKNOWN;
+    return NULL;
 }
 
-mbtk_ril_err_enum mbtk_ril_deinit()
+mbtk_ril_err_enum mbtk_ril_close(ATPortType_enum port)
 {
-    if(!ril_cli.ril_ready)
-    {
-        return MBTK_RIL_ERR_NOT_INIT;
+    if(!at_port_check(port)) {
+        return MBTK_RIL_ERR_PORT;
     }
 
-    if(ril_cli.exit_fd[1] > 0)
-    {
-        if(write(ril_cli.exit_fd[1], "EXIT", 4) != 4) {
-            return MBTK_RIL_ERR_UNKNOWN;
+    ril_cli.ports[port].enable = FALSE;
+    ril_cli.ports[port].port = ATPORTTYPE_NON;
+
+    // All port is close ???
+    int i = ATPORTTYPE_0;
+    for(; i < ATPORTTYPE_NUM; i++) {
+        if(ril_cli.ports[i].enable)
+            break;
+    }
+
+    if(i == ATPORTTYPE_NUM) { // All port is close.
+        if(!ril_cli.ril_ready)
+        {
+            return MBTK_RIL_ERR_NOT_INIT;
         }
+
+        if(ril_cli.exit_fd[1] > 0)
+        {
+            if(write(ril_cli.exit_fd[1], "EXIT", 4) != 4) {
+                return MBTK_RIL_ERR_UNKNOWN;
+            }
+        }
+
+        // Wait read_thread exit.
+        pthread_join(ril_cli.read_thread_id,NULL);
+
+        if(ril_cli.exit_fd[0] > 0)
+        {
+            close(ril_cli.exit_fd[0]);
+            ril_cli.exit_fd[0] = -1;
+        }
+
+        if(ril_cli.exit_fd[1] > 0)
+        {
+            close(ril_cli.exit_fd[1]);
+            ril_cli.exit_fd[1] = -1;
+        }
+
+        if(ril_cli.cli_fd > 0)
+        {
+            close(ril_cli.cli_fd);
+            ril_cli.cli_fd = -1;
+        }
+
+        pthread_mutex_destroy(&ril_cli.send_mutex);
+        if(ril_cli.msg_list) {
+            list_free(ril_cli.msg_list);
+        }
+        if(ril_cli.cli_thread_list) {
+            list_free(ril_cli.cli_thread_list);
+        }
+
+        ril_cli.ril_ready = FALSE;
+
+        return MBTK_RIL_ERR_SUCCESS;
+    } else {
+        return MBTK_RIL_ERR_PORT_NOT_CLOSE;
     }
-
-    // Wait read_thread exit.
-    pthread_join(ril_cli.read_thread_id,NULL);
-
-    if(ril_cli.exit_fd[0] > 0)
-    {
-        close(ril_cli.exit_fd[0]);
-        ril_cli.exit_fd[0] = -1;
-    }
-
-    if(ril_cli.exit_fd[1] > 0)
-    {
-        close(ril_cli.exit_fd[1]);
-        ril_cli.exit_fd[1] = -1;
-    }
-
-    if(ril_cli.cli_fd > 0)
-    {
-        close(ril_cli.cli_fd);
-        ril_cli.cli_fd = -1;
-    }
-
-    pthread_mutex_destroy(&ril_cli.send_mutex);
-    if(ril_cli.msg_list) {
-        list_free(ril_cli.msg_list);
-    }
-    if(ril_cli.cli_thread_list) {
-        list_free(ril_cli.cli_thread_list);
-    }
-
-    ril_cli.ril_ready = FALSE;
-
-    return MBTK_RIL_ERR_SUCCESS;
 }
 
 /*
 * Get platform version.
 */
-mbtk_ril_err_enum mbtk_version_get(void *version)
+mbtk_ril_err_enum mbtk_version_get(mbtk_ril_handle* handle, void *version)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(version == NULL)
+    if(version == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_VERSION, NULL, 0, version, FALSE);
+    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_DEV_VERSION, NULL, 0, version, FALSE);
 }
 
 /*
 * Get platform version.
 */
-mbtk_ril_err_enum mbtk_model_get(void *model)
+mbtk_ril_err_enum mbtk_model_get(mbtk_ril_handle* handle, void *model)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(model == NULL)
+    if(model == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_MODEL, NULL, 0, model, FALSE);
+    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_DEV_MODEL, NULL, 0, model, FALSE);
 }
 
 /*
 * Get platform IMEI.
 */
-mbtk_ril_err_enum mbtk_imei_get(void *imei)
+mbtk_ril_err_enum mbtk_imei_get(mbtk_ril_handle* handle, void *imei)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(imei == NULL)
+    if(imei == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_IMEI, NULL, 0, imei, FALSE);
+    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_DEV_IMEI, NULL, 0, imei, FALSE);
 }
 
 
 /*
 * Get platform SN.
 */
-mbtk_ril_err_enum mbtk_sn_get(void *sn)
+mbtk_ril_err_enum mbtk_sn_get(mbtk_ril_handle* handle, void *sn)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(sn == NULL)
+    if(sn == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_SN, NULL, 0, sn, FALSE);
+    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_DEV_SN, NULL, 0, sn, FALSE);
 }
 
 
 /*
 * Get platform MEID.
 */
-mbtk_ril_err_enum mbtk_meid_get(void *meid)
+mbtk_ril_err_enum mbtk_meid_get(mbtk_ril_handle* handle, void *meid)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(meid == NULL)
+    if(meid == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_MEID, NULL, 0, meid, FALSE);
+    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_DEV_MEID, NULL, 0, meid, FALSE);
 }
 
 
 /*
 * Return VoLTE state.
 */
-mbtk_ril_err_enum mbtk_volte_state_get(int *volte_state)
+mbtk_ril_err_enum mbtk_volte_state_get(mbtk_ril_handle* handle, int *volte_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(volte_state == NULL)
+    if(volte_state == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_VOLTE, NULL, 0, volte_state, FALSE);
+    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_DEV_VOLTE, NULL, 0, volte_state, FALSE);
 }
 
 /*
@@ -713,40 +792,50 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_volte_state_set(int volte_state)
+mbtk_ril_err_enum mbtk_volte_state_set(mbtk_ril_handle* handle, int volte_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(volte_state != 0 && volte_state != 1)
+    if((volte_state != 0 && volte_state != 1) || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DEV_VOLTE, &volte_state, 1, NULL, FALSE);
+    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_DEV_VOLTE, &volte_state, 1, NULL, FALSE);
 }
 
 /*
 * Return radio state.
 */
-mbtk_ril_err_enum mbtk_radio_state_get(mbtk_radio_state_enum *radio_state)
+mbtk_ril_err_enum mbtk_radio_state_get(mbtk_ril_handle* handle, mbtk_radio_state_enum *radio_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(radio_state == NULL)
+    if(radio_state == 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;
+    }
+
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, NULL, 0, &result, FALSE);
     *radio_state = (mbtk_radio_state_enum)result;
     return err;
 }
@@ -758,24 +847,29 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_radio_state_set(mbtk_radio_state_enum radio_state, bool reset_modem)
+mbtk_ril_err_enum mbtk_radio_state_set(mbtk_ril_handle* handle, mbtk_radio_state_enum radio_state, bool reset_modem)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(radio_state == MBTK_RADIO_STATE_UNKNOWN)
+    if(radio_state == MBTK_RADIO_STATE_UNKNOWN || 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;
+    }
+
     uint8 buff[2];
     buff[0] = (uint8)radio_state;
     buff[1] = reset_modem ? 1 : 0;
 
-    return ril_req_process(RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DEV_MODEM, buff, 2, NULL, FALSE);
 }
 
 /*
@@ -787,22 +881,27 @@
 * temp[OUT]:
 *   temperature in celsius.
 */
-mbtk_ril_err_enum mbtk_temp_get(mbtk_temp_type_enum type, int* temp)
+mbtk_ril_err_enum mbtk_temp_get(mbtk_ril_handle* handle, mbtk_temp_type_enum type, int* temp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(temp == NULL)
+    if(temp == 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;
+    }
+
     int16 result;
     uint8 temp_temp = (uint8)type;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_TEMP, &temp_temp, 1, &result, FALSE);
     *temp = (int16)result;
     return err;
 }
@@ -812,21 +911,26 @@
 * 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(char* time_str)
+mbtk_ril_err_enum mbtk_cell_time_get(mbtk_ril_handle* handle, char* time_str)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(time_str == NULL)
+    if(time_str == 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;
+    }
+
     char buff[RIL_SOCK_MSG_LEN_MAX] = {0};
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_DEV_CELL_TIME, NULL, 0, &buff, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == err)
     {
         memcpy(time_str,buff,strlen(buff));
@@ -880,21 +984,26 @@
 /*
 * Get sim state.
 */
-mbtk_ril_err_enum mbtk_sim_state_get(mbtk_sim_state_enum *sim_state)
+mbtk_ril_err_enum mbtk_sim_state_get(mbtk_ril_handle* handle, mbtk_sim_state_enum *sim_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(sim_state == NULL)
+    if(sim_state == 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;
+    }
+
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_STATE, NULL, 0, &result, FALSE);
     *sim_state = (mbtk_sim_state_enum)result;
     return err;
 }
@@ -902,21 +1011,26 @@
 /*
 * Get sim card type.
 */
-mbtk_ril_err_enum mbtk_sim_type_get(mbtk_sim_card_type_enum *sim_card_type)
+mbtk_ril_err_enum mbtk_sim_type_get(mbtk_ril_handle* handle, mbtk_sim_card_type_enum *sim_card_type)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(sim_card_type == NULL)
+    if(sim_card_type == 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;
+    }
+
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_TYPE, NULL, 0, &result, FALSE);
     *sim_card_type = (mbtk_sim_card_type_enum)result;
     return err;
 }
@@ -924,78 +1038,98 @@
 /*
 * Get platform IMSI.
 */
-mbtk_ril_err_enum mbtk_imsi_get(void *imsi)
+mbtk_ril_err_enum mbtk_imsi_get(mbtk_ril_handle* handle, void *imsi)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(imsi == NULL)
+    if(imsi == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_IMSI, NULL, 0, imsi, FALSE);
+    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_SIM_IMSI, NULL, 0, imsi, FALSE);
 }
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_iccid_get(void *iccid)
+mbtk_ril_err_enum mbtk_iccid_get(mbtk_ril_handle* handle, void *iccid)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(iccid == NULL)
+    if(iccid == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_ICCID, NULL, 0, iccid, FALSE);
+    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_SIM_ICCID, NULL, 0, iccid, FALSE);
 }
 
 /*
 * Get current phone number.
 */
-mbtk_ril_err_enum mbtk_phone_number_get(void *phone_number)
+mbtk_ril_err_enum mbtk_phone_number_get(mbtk_ril_handle* handle, void *phone_number)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(phone_number == NULL)
+    if(phone_number == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_PN, NULL, 0, phone_number, FALSE);
+    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_SIM_PN, NULL, 0, phone_number, FALSE);
 }
 
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_get(int *lock_state)
+mbtk_ril_err_enum mbtk_sim_lock_get(mbtk_ril_handle* handle, int *lock_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(lock_state == NULL)
+    if(lock_state == 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;
+    }
+
     uint8 result;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SIM_LOCK, NULL, 0, &result, FALSE);
     *lock_state = result;
     return err;
 }
@@ -1004,121 +1138,151 @@
 /*
 * Get platform ICCID.
 */
-mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_sim_lock_info_t *lock_info)
+mbtk_ril_err_enum mbtk_sim_lock_set(mbtk_ril_handle* handle, mbtk_sim_lock_info_t *lock_info)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(lock_info == NULL)
+    if(lock_info == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE);
+    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_SIM_LOCK, lock_info, sizeof(mbtk_sim_lock_info_t), NULL, FALSE);
 }
 
 /*
 * Get PIN’s number of remaining retry
 */
-mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_pin_puk_last_times_t *retry_times)
+mbtk_ril_err_enum mbtk_sim_lock_retry_times_get(mbtk_ril_handle* handle, mbtk_pin_puk_last_times_t *retry_times)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(retry_times == NULL)
+    if(retry_times == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE);
+    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_SIM_PINPUK_TIMES, NULL, 0, retry_times, FALSE);
 }
 
 /*
 * Get plmn list
 */
-mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_plmn_info *plmn_list)
+mbtk_ril_err_enum mbtk_plmn_list_get(mbtk_ril_handle* handle, mbtk_plmn_info *plmn_list)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(plmn_list == NULL)
+    if(plmn_list == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SIM_PLMN, NULL, 0, plmn_list, FALSE);
+    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_SIM_PLMN, NULL, 0, plmn_list, FALSE);
 }
 
 /*
 * Get available network.
 */
-mbtk_ril_err_enum mbtk_available_net_get(mbtk_net_info_array_t *net_array)
+mbtk_ril_err_enum mbtk_available_net_get(mbtk_ril_handle* handle, mbtk_net_info_array_t *net_array)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(net_array == NULL)
+    if(net_array == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_AVAILABLE, NULL, 0, net_array, FALSE);
+    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_NET_AVAILABLE, NULL, 0, net_array, FALSE);
 }
 
 /*
 * Set network select mode. (+COPS=...)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_set(const mbtk_net_info_t *net)
+mbtk_ril_err_enum mbtk_net_sel_mode_set(mbtk_ril_handle* handle, const mbtk_net_info_t *net)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(net == NULL)
+    if(net == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE);
+    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_NET_SEL_MODE, net, sizeof(mbtk_net_info_t), NULL, FALSE);
 }
 
 /*
 * Get network select mode. (+COPS?)
 */
-mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_net_info_t *net)
+mbtk_ril_err_enum mbtk_net_sel_mode_get(mbtk_ril_handle* handle, mbtk_net_info_t *net)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(net == NULL)
+    if(net == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_SEL_MODE, NULL, 0, net, FALSE);
+    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_NET_SEL_MODE, NULL, 0, net, FALSE);
 }
 
 /*
 * Get platform support bands.
 */
-mbtk_ril_err_enum mbtk_support_band_get(mbtk_band_info_t *band)
+mbtk_ril_err_enum mbtk_support_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band)
 {
     uint8 type = 0; // Get support bands.
     if(!ril_cli.ril_ready)
@@ -1126,19 +1290,24 @@
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(band == NULL)
+    if(band == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE);
+    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_NET_BAND, &type, sizeof(uint8), band, FALSE);
 }
 
 /*
 * Get platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_get(mbtk_band_info_t *band)
+mbtk_ril_err_enum mbtk_current_band_get(mbtk_ril_handle* handle, mbtk_band_info_t *band)
 {
     uint8 type = 1; // Get current bands.
     if(!ril_cli.ril_ready)
@@ -1146,51 +1315,66 @@
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(band == NULL)
+    if(band == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_BAND, &type, sizeof(uint8), band, FALSE);
+    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_NET_BAND, &type, sizeof(uint8), band, FALSE);
 }
 
 /*
 * Set platform current bands.
 */
-mbtk_ril_err_enum mbtk_current_band_set(const mbtk_band_info_t *band)
+mbtk_ril_err_enum mbtk_current_band_set(mbtk_ril_handle* handle, const mbtk_band_info_t *band)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(band == NULL)
+    if(band == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE);
+    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_NET_BAND, band, sizeof(mbtk_band_info_t), NULL, FALSE);
 }
 
 /*
 * Get current cell infomation.
 */
-mbtk_ril_err_enum mbtk_cell_get(mbtk_cell_info_array_t *cell_array)
+mbtk_ril_err_enum mbtk_cell_get(mbtk_ril_handle* handle, mbtk_cell_info_array_t *cell_array)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cell_array == NULL)
+    if(cell_array == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_CELL, NULL, 0, cell_array, FALSE);
+    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_NET_CELL, NULL, 0, cell_array, FALSE);
 }
 
 /*
@@ -1202,96 +1386,121 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_cell_set(char *info, char *response)
+mbtk_ril_err_enum mbtk_cell_set(mbtk_ril_handle* handle, char *info, char *response)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(info == NULL || response == NULL)
+    if(info == NULL || response == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_CELL, info, strlen(info), response, FALSE);
+    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_NET_CELL, info, strlen(info), response, FALSE);
 }
 
 /*
 * Get current network signal.
 */
-mbtk_ril_err_enum mbtk_net_signal_get(mbtk_signal_info_t *signal)
+mbtk_ril_err_enum mbtk_net_signal_get(mbtk_ril_handle* handle, mbtk_signal_info_t *signal)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(signal == NULL)
+    if(signal == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_SIGNAL, NULL, 0, signal, FALSE);
+    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_NET_SIGNAL, NULL, 0, signal, FALSE);
 }
 
 /*
 * Get current network register information.
 */
-mbtk_ril_err_enum mbtk_net_reg_get(mbtk_net_reg_info_t *reg)
+mbtk_ril_err_enum mbtk_net_reg_get(mbtk_ril_handle* handle, mbtk_net_reg_info_t *reg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(reg == NULL)
+    if(reg == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_NET_REG, NULL, 0, reg, FALSE);
+    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_NET_REG, NULL, 0, reg, FALSE);
 }
 
 /*
 * Get all APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_get(mbtk_apn_info_array_t *apns)
+mbtk_ril_err_enum mbtk_apn_get(mbtk_ril_handle* handle, mbtk_apn_info_array_t *apns)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(apns == NULL)
+    if(apns == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_DATA_CALL_APN, NULL, 0, apns, FALSE);
+    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_DATA_CALL_APN, NULL, 0, apns, FALSE);
 }
 
 
 /*
 * Set current APN informations.
 */
-mbtk_ril_err_enum mbtk_apn_set(const mbtk_apn_info_t *apn)
+mbtk_ril_err_enum mbtk_apn_set(mbtk_ril_handle* handle, const mbtk_apn_info_t *apn)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(apn == NULL)
+    if(apn == 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;
+    }
+
     if(str_empty(apn->apn)) { // Delete APN
         if(!ril_cid_check(apn->cid)) {
             return MBTK_RIL_ERR_CID;
@@ -1302,13 +1511,13 @@
         }
     }
 
-    return ril_req_process(RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_APN, apn, sizeof(mbtk_apn_info_t), NULL, FALSE);
 }
 
 /*
 * Start data call.
 */
-mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_cid_enum cid, mbtk_data_call_item_state_enum auto_boot_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)
 {
@@ -1317,10 +1526,20 @@
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
+    if(handle == NULL) {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
     if(!ril_cid_check(cid)) {
         return MBTK_RIL_ERR_CID;
     }
 
+    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;
+    }
+
     mbtk_data_call_info_t info;
     memset(&info, 0, sizeof(mbtk_data_call_info_t));
     info.type = MBTK_DATA_CALL_START;
@@ -1339,23 +1558,33 @@
         info.timeout = (uint16)10;
     }
 
-    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), rsp_info, FALSE);
 }
 
 /*
 * Stop data call.
 */
-mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_cid_enum cid, int timeout)
+mbtk_ril_err_enum mbtk_data_call_stop(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, int timeout)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
+    if(handle == NULL) {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
     if(!ril_cid_check(cid)) {
         return MBTK_RIL_ERR_CID;
     }
 
+    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;
+    }
+
     mbtk_data_call_info_t info;
     memset(&info, 0, sizeof(mbtk_data_call_info_t));
     info.type = MBTK_DATA_CALL_STOP;
@@ -1363,20 +1592,20 @@
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
     }
-    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), NULL, FALSE);
 }
 
 /*
 * Get data call state.
 */
-mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
+mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_handle* handle, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(ip == NULL)
+    if(ip == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
@@ -1386,32 +1615,42 @@
         return MBTK_RIL_ERR_CID;
     }
 
+    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;
+    }
+
     mbtk_data_call_info_t info;
     memset(&info, 0, sizeof(mbtk_data_call_info_t));
     info.type = MBTK_DATA_CALL_STATE;
     info.cid = cid;
 
-    return ril_req_process(RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_DATA_CALL_OPT, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
 }
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_get(int *sms_state)
+mbtk_ril_err_enum mbtk_sms_cmgf_get(mbtk_ril_handle* handle, int *sms_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(sms_state == NULL)
+    if(sms_state == 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;
+    }
+
     uint8 state;
-    mbtk_ril_err_enum err = ril_req_process(RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE);
+    mbtk_ril_err_enum err = ril_req_process(port_info->port, RIL_MSG_ID_SMS_CMGF, NULL, 0, &state, FALSE);
     *sms_state = state;
     return err;
 }
@@ -1425,14 +1664,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgf_set(int mode)
+mbtk_ril_err_enum mbtk_sms_cmgf_set(mbtk_ril_handle* handle, int mode)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE);
+    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_SMS_CMGF, &mode, sizeof(uint8), NULL, FALSE);
 }
 
 /*
@@ -1448,20 +1698,25 @@
 
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgs_set(char * cmgs, char *resp)
+mbtk_ril_err_enum mbtk_sms_cmgs_set(mbtk_ril_handle* handle, char * cmgs, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cmgs == NULL || resp == NULL)
+    if(cmgs == NULL || resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGS, cmgs, strlen(cmgs), resp, FALSE);
+    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_CMGS, cmgs, strlen(cmgs), resp, FALSE);
 }
 
 /*
@@ -1476,20 +1731,25 @@
 given<ctrl-Z/ESC>
 
 */
-mbtk_ril_err_enum mbtk_sms_cmgw_set(char * cmgw, char *resp)
+mbtk_ril_err_enum mbtk_sms_cmgw_set(mbtk_ril_handle* handle, char * cmgw, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cmgw == NULL || resp == NULL)
+    if(cmgw == NULL || resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGW, cmgw, strlen(cmgw), resp, FALSE);
+    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_CMGW, cmgw, strlen(cmgw), resp, FALSE);
 }
 
 /*
@@ -1499,20 +1759,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgd_set(char * cmdg)
+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)
+    if(cmdg == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGD, cmdg, strlen(cmdg), NULL, FALSE);
+    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);
 }
 
 /*
@@ -1522,20 +1787,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgd_get(char * cmdg)
+mbtk_ril_err_enum mbtk_sms_cmgd_get(mbtk_ril_handle* handle, char * cmdg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cmdg == NULL)
+    if(cmdg == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGD, NULL, 0, cmdg, FALSE);
+    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, NULL, 0, cmdg, FALSE);
 }
 
 
@@ -1546,39 +1816,49 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgl_set(char * cmgl, char *resp)
+mbtk_ril_err_enum mbtk_sms_cmgl_set(mbtk_ril_handle* handle, char * cmgl, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cmgl == NULL || resp == NULL)
+    if(cmgl == NULL || resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGL, cmgl, strlen(cmgl), resp, FALSE);
+    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_CMGL, cmgl, strlen(cmgl), resp, FALSE);
 }
 
 /*
 * Return sms csca.
 */
-mbtk_ril_err_enum mbtk_sms_csca_get(char *buf)
+mbtk_ril_err_enum mbtk_sms_csca_get(mbtk_ril_handle* handle, char *buf)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(buf == NULL)
+    if(buf == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CSCA, NULL, 0, buf, FALSE);
+    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_CSCA, NULL, 0, buf, FALSE);
 }
 
 /*
@@ -1588,20 +1868,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csca_set(char * csca)
+mbtk_ril_err_enum mbtk_sms_csca_set(mbtk_ril_handle* handle, char * csca)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(csca == NULL)
+    if(csca == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CSCA, csca, strlen(csca), NULL, FALSE);
+    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_CSCA, csca, strlen(csca), NULL, FALSE);
 }
 
 /*
@@ -1611,20 +1896,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_csmp_set(char * csmp)
+mbtk_ril_err_enum mbtk_sms_csmp_set(mbtk_ril_handle* handle, char * csmp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(csmp == NULL)
+    if(csmp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CSMP, csmp, strlen(csmp), NULL, FALSE);
+    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_CSMP, csmp, strlen(csmp), NULL, FALSE);
 }
 
 /*
@@ -1634,20 +1924,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cscb_set(char * cscb)
+mbtk_ril_err_enum mbtk_sms_cscb_set(mbtk_ril_handle* handle, char * cscb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cscb == NULL)
+    if(cscb == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CSCB, cscb, strlen(cscb), NULL, FALSE);
+    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_CSCB, cscb, strlen(cscb), NULL, FALSE);
 }
 
 /*
@@ -1659,14 +1954,25 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cnmi_set()
+mbtk_ril_err_enum mbtk_sms_cnmi_set(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CNMI, NULL, 0, NULL, FALSE);
+    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_SMS_CNMI, NULL, 0, NULL, FALSE);
 }
 
 /*
@@ -1680,39 +1986,49 @@
 if sending fails:
 +CMS ERROR: <err>
 */
-mbtk_ril_err_enum mbtk_sms_cmss_set(char * cmss, char *resp)
+mbtk_ril_err_enum mbtk_sms_cmss_set(mbtk_ril_handle* handle, char * cmss, char *resp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cmss == NULL || resp == NULL)
+    if(cmss == NULL || resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMSS, cmss, strlen(cmss), resp, FALSE);
+    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_CMSS, cmss, strlen(cmss), resp, FALSE);
 }
 
 /*
 * Return sms cmgf.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_get(char * mem)
+mbtk_ril_err_enum mbtk_sms_cpms_get(mbtk_ril_handle* handle, char * mem)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(mem == NULL)
+    if(mem == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CPMS, NULL, 0, mem, FALSE);
+    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_CPMS, NULL, 0, mem, FALSE);
 }
 
 
@@ -1723,20 +2039,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cpms_set(char * mem, char* resp)
+mbtk_ril_err_enum mbtk_sms_cpms_set(mbtk_ril_handle* handle, char * mem, char* resp)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(mem == NULL || resp == NULL)
+    if(mem == NULL || resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CPMS, mem, strlen(mem), resp, FALSE);
+    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_CPMS, mem, strlen(mem), resp, FALSE);
 }
 
 /*
@@ -1761,20 +2082,25 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_sms_cmgr_set(int index, char *resp)
+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)
+    if(resp == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_SMS_CMGR, &index, sizeof(uint8), resp, FALSE);
+    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);
 }
 
 
@@ -1968,128 +2294,198 @@
 * call_start
 *
 */
-mbtk_ril_err_enum mbtk_call_start(char* phone_number)
+mbtk_ril_err_enum mbtk_call_start(mbtk_ril_handle* handle, char* phone_number)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(phone_number == NULL)
+    if(phone_number == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_START, phone_number, strlen(phone_number), NULL, FALSE);
+    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_START, phone_number, strlen(phone_number), NULL, FALSE);
 }
 
 /*
 * Answer the phone call.
 *
 */
-mbtk_ril_err_enum mbtk_call_answer()
+mbtk_ril_err_enum mbtk_call_answer(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_ANSWER, NULL, 0, NULL, FALSE);
+    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_ANSWER, NULL, 0, NULL, FALSE);
 }
 
 /*
 * Hang up all call.
 *
 */
-mbtk_ril_err_enum mbtk_call_hang()
+mbtk_ril_err_enum mbtk_call_hang(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_HANGUP, NULL, 0, NULL, FALSE);
+    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, NULL, 0, NULL, FALSE);
 }
 
 /*
 * Hang up a call.
 *
 */
-mbtk_ril_err_enum mbtk_a_call_hang(int phone_id)
+mbtk_ril_err_enum mbtk_a_call_hang(mbtk_ril_handle* handle, int phone_id)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_HANGUP_A, &phone_id, sizeof(uint8), NULL, FALSE);
+    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_A, &phone_id, sizeof(uint8), NULL, FALSE);
 }
 
 /*
 * Hang up waiting or background call.
 *
 */
-mbtk_ril_err_enum mbtk_waiting_or_background_call_hang()
+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;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_HANGUP_B, NULL, 0, NULL, FALSE);
+    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);
 }
 
 /*
 * Hang up foreground resume background call.
 *
 */
-mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang()
+mbtk_ril_err_enum mbtk_foreground_resume_background_call_hang(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_HANGUP_C, NULL, 0, NULL, FALSE);
+    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_C, NULL, 0, NULL, FALSE);
 }
 
 /*
 * Get current call phone number.
 */
-mbtk_ril_err_enum mbtk_call_reg_get(mbtk_call_info_t *reg)
+mbtk_ril_err_enum mbtk_call_reg_get(mbtk_ril_handle* handle, mbtk_call_info_t *reg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(reg == NULL)
+    if(reg == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_WAITIN, NULL, 0, reg, FALSE);
+    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_WAITIN, NULL, 0, reg, FALSE);
 }
 
 /*
 * Return mute state.
 */
-mbtk_ril_err_enum mbtk_mute_state_get(int *mute_state)
+mbtk_ril_err_enum mbtk_mute_state_get(mbtk_ril_handle* handle, int *mute_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(mute_state == NULL)
+    if(mute_state == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_MUTE, NULL, 0, mute_state, FALSE);
+    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_MUTE, NULL, 0, mute_state, FALSE);
 }
 
 /*
@@ -2101,108 +2497,156 @@
 *
 * Restarting takes effect after execution.
 */
-mbtk_ril_err_enum mbtk_mute_state_set(int mute_state)
+mbtk_ril_err_enum mbtk_mute_state_set(mbtk_ril_handle* handle, int mute_state)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_MUTE, &mute_state, sizeof(uint8), NULL, FALSE);
+    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_MUTE, &mute_state, sizeof(uint8), NULL, FALSE);
 }
 
 /*
 * Set DTMF character.
 *
 */
-mbtk_ril_err_enum mbtk_dtmf_send(mbtk_call_dtmf_info_t *dtmf_character)
+mbtk_ril_err_enum mbtk_dtmf_send(mbtk_ril_handle* handle, mbtk_call_dtmf_info_t *dtmf_character)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(dtmf_character == NULL)
+    if(dtmf_character == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_CALL_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE);
+    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_DTMF, dtmf_character, sizeof(mbtk_call_dtmf_info_t), NULL, FALSE);
 }
 
 /*
 * Set msd item.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_item_set(const mbtk_ecall_msd_cfg_info_t *msd_cfg)
+mbtk_ril_err_enum mbtk_ecall_msd_item_set(mbtk_ril_handle* handle, const mbtk_ecall_msd_cfg_info_t *msd_cfg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(msd_cfg == NULL)
+    if(msd_cfg == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE);
+    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_ECALL_MSDCFG, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL, FALSE);
 }
 
 /*
 * Generate msd after msd item set.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_gen()
+mbtk_ril_err_enum mbtk_ecall_msd_gen(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MSDGEN, NULL, 0, NULL, FALSE);
+    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_ECALL_MSDGEN, NULL, 0, NULL, FALSE);
 }
 
 /*
 * Set ecall msd.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_set(const void* msd)
+mbtk_ril_err_enum mbtk_ecall_msd_set(mbtk_ril_handle* handle, const void* msd)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
+    if(handle == NULL)
+    {
+        LOGE("ARG error.");
+        return MBTK_RIL_ERR_PARAMETER;
+    }
+
     if(str_empty(msd))
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MSD, msd, strlen(msd), NULL, FALSE);
+    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_ECALL_MSD, msd, strlen(msd), NULL, FALSE);
 }
 
 /*
 * Get ecall msd.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_msd_get(void* msd)
+mbtk_ril_err_enum mbtk_ecall_msd_get(mbtk_ril_handle* handle, void* msd)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(msd == NULL)
+    if(msd == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MSD, NULL, 0, msd, FALSE);
+    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_ECALL_MSD, NULL, 0, msd, FALSE);
 }
 
 
@@ -2210,264 +2654,356 @@
 * Set ecall msd item.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_push()
+mbtk_ril_err_enum mbtk_ecall_push(mbtk_ril_handle* handle)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_PUSH, NULL, 0, NULL, FALSE);
+    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_ECALL_PUSH, NULL, 0, NULL, FALSE);
 }
 
 /*
 * Set ecall only configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_only_set(const mbtk_ecall_only_info_t* info)
+mbtk_ril_err_enum mbtk_ecall_only_set(mbtk_ril_handle* handle, const mbtk_ecall_only_info_t* info)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(info == NULL)
+    if(info == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE);
+    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_ECALL_ONLY, info, sizeof(mbtk_ecall_only_info_t), NULL, FALSE);
 }
 
 /*
 * Get ecall only configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_only_get(mbtk_ecall_only_info_t* info)
+mbtk_ril_err_enum mbtk_ecall_only_get(mbtk_ril_handle* handle, mbtk_ecall_only_info_t* info)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(info == NULL)
+    if(info == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_ONLY, NULL, 0, info, FALSE);
+    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_ECALL_ONLY, NULL, 0, info, FALSE);
 }
 
 /*
 * Set ecall network reg.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_reg_set(int reg)
+mbtk_ril_err_enum mbtk_ecall_reg_set(mbtk_ril_handle* handle, int reg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(reg != 0 && reg != 1)
+    if((reg != 0 && reg != 1) || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
-    return ril_req_process(RIL_MSG_ID_ECALL_REG, &reg, 1, NULL, FALSE);
+
+    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_ECALL_REG, &reg, 1, NULL, FALSE);
 }
 
 /*
 * Start ecall dial start.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dial_start(mbtk_ecall_dial_type_enum type)
+mbtk_ril_err_enum mbtk_ecall_dial_start(mbtk_ril_handle* handle, mbtk_ecall_dial_type_enum type)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_DIAL, &type, 1, NULL, FALSE);
+    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_ECALL_DIAL, &type, 1, NULL, FALSE);
 }
 
 /*
 * Get ecall dial state.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dial_state_get(mbtk_ecall_dial_type_enum* type)
+mbtk_ril_err_enum mbtk_ecall_dial_state_get(mbtk_ril_handle* handle, mbtk_ecall_dial_type_enum* type)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(type == NULL)
+    if(type == 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;
+    }
+
     memset(type, 0, sizeof(mbtk_ecall_dial_type_enum));
 
-    return ril_req_process(RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_DIAL, NULL, 0, type, FALSE);
 }
 
 /*
 * Set ecall mode.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mode_set(mbtk_ecall_mode_type_enum mode)
+mbtk_ril_err_enum mbtk_ecall_mode_set(mbtk_ril_handle* handle, mbtk_ecall_mode_type_enum mode)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MODE, &mode, 1, NULL, FALSE);
+    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_ECALL_MODE, &mode, 1, NULL, FALSE);
 }
 
 /*
 * Get ecall mode.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mode_get(mbtk_ecall_mode_type_enum *mode)
+mbtk_ril_err_enum mbtk_ecall_mode_get(mbtk_ril_handle* handle, mbtk_ecall_mode_type_enum *mode)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(mode == NULL)
+    if(mode == 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;
+    }
+
     memset(mode, 0, sizeof(mbtk_ecall_mode_type_enum));
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_MODE, NULL, 0, mode, FALSE);
 }
 
 /*
 * Set ecall configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg)
+mbtk_ril_err_enum mbtk_ecall_cfg_set(mbtk_ril_handle* handle, const mbtk_ecall_cfg_info_t *cfg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cfg == NULL || cfg->type == 0)
+    if(cfg == NULL || cfg->type == 0 || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE);
+    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_ECALL_CFG, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL, FALSE);
 }
 
 /*
 * Get ecall configs.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_cfg_get(mbtk_ecall_cfg_info_t* cfg)
+mbtk_ril_err_enum mbtk_ecall_cfg_get(mbtk_ril_handle* handle, mbtk_ecall_cfg_info_t* cfg)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(cfg == NULL || cfg->type == 0)
+    if(cfg == NULL || cfg->type == 0 || 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;
+    }
+
     uint32 type = cfg->type;
 
-    return ril_req_process(RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE);
+    return ril_req_process(port_info->port, RIL_MSG_ID_ECALL_CFG, &type, sizeof(uint32), cfg, FALSE);
 }
 
 /*
 * Set ecall sms number.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_sms_number_set(const void *number)
+mbtk_ril_err_enum mbtk_ecall_sms_number_set(mbtk_ril_handle* handle, const void *number)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(str_empty(number))
+    if(str_empty(number) || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE);
+    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_ECALL_SMS_NUM, number, strlen(number), NULL, FALSE);
 }
 
 /*
 * Get ecall sms number.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_sms_number_get(void *number)
+mbtk_ril_err_enum mbtk_ecall_sms_number_get(mbtk_ril_handle* handle, void *number)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(number == NULL)
+    if(number == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_SMS_NUM, NULL, 0, number, FALSE);
+    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_ECALL_SMS_NUM, NULL, 0, number, FALSE);
 }
 
 /*
 * Set ecall mute speaker.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_mute_spk_set(int mute)
+mbtk_ril_err_enum mbtk_ecall_mute_spk_set(mbtk_ril_handle* handle, int mute)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(mute != 0 && mute != 1)
+    if((mute != 0 && mute != 1) || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_MUTESPK, &mute, 1, NULL, FALSE);
+    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_ECALL_MUTESPK, &mute, 1, NULL, FALSE);
 }
 
 /*
 * Set ecall dsp gain.
 *
 */
-mbtk_ril_err_enum mbtk_ecall_dsp_gain_set(const mbtk_ecall_gain_info_t *gain_info)
+mbtk_ril_err_enum mbtk_ecall_dsp_gain_set(mbtk_ril_handle* handle, const mbtk_ecall_gain_info_t *gain_info)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    if(gain_info == NULL)
+    if(gain_info == NULL || handle == NULL)
     {
         LOGE("ARG error.");
         return MBTK_RIL_ERR_PARAMETER;
     }
 
-    return ril_req_process(RIL_MSG_ID_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE);
+    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_ECALL_DSP_GAIN, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL, FALSE);
 }
 
 #if 0
@@ -2520,14 +3056,18 @@
 /*
 * Set ril server state change callback function.
 */
-int mbtk_ril_ser_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_ril_ser_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SER_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SER_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2538,14 +3078,18 @@
 /*
 * Set net reg state change callback function.
 */
-int mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_net_reg_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_NET_REG_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2556,14 +3100,18 @@
 /*
 * Set call state change callback function.
 */
-int mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_call_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_CALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_CALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2574,14 +3122,18 @@
 /*
 * Set sms state change callback function.
 */
-int mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_sms_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SMS_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SMS_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2592,14 +3144,18 @@
 /*
 * Set radio state change callback function.
 */
-int mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_radio_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_RADIO_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2610,14 +3166,18 @@
 /*
 * Set sim state change callback function.
 */
-int mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_sim_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_SIM_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SIM_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2628,14 +3188,18 @@
 /*
 * Set pdp state change callback function.
 */
-int mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_pdp_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_PDP_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_PDP_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2646,14 +3210,18 @@
 /*
 * Set signal state change callback function.
 */
-int mbtk_signal_state_change_cb_reg(mbtk_ril_callback_func cb)
+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;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    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);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_SIGNAL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
@@ -2661,14 +3229,18 @@
     return ret;
 }
 
-int mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb)
+mbtk_ril_err_enum mbtk_ecall_state_change_cb_reg(mbtk_ril_callback_func cb)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
-    int ret = ril_req_process(RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
+    if(!at_port_check(ATPORTTYPE_0)) {
+        return MBTK_RIL_ERR_PORT;
+    }
+
+    int ret = ril_req_process(ATPORTTYPE_0, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, NULL, 0, NULL, FALSE);
     if(MBTK_RIL_ERR_SUCCESS == ret)
     {
         ril_cli.cb[RIL_MSG_ID_IND_ECALL_STATE_CHANGE - RIL_MSG_ID_IND_BEGIN - 1] = cb;
diff --git a/mbtk/libmbtk_lib_v2/ril/ril_utils.c b/mbtk/libmbtk_lib_v2/ril/ril_utils.c
index 236c06f..6928a1d 100755
--- a/mbtk/libmbtk_lib_v2/ril/ril_utils.c
+++ b/mbtk/libmbtk_lib_v2/ril/ril_utils.c
@@ -398,7 +398,7 @@
     }
 }
 
-ril_msg_pack_info_t* ril_msg_pack_creat(int msg_type, int msg_id, int msg_index, const void *data, int data_len)
+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 *pack = (ril_msg_pack_info_t *)malloc(sizeof(ril_msg_pack_info_t));
     if(!pack)
@@ -408,7 +408,7 @@
     }
 
     pack->tag = RIL_SOCK_PACKET_TAG;
-
+    pack->at_port = (uint8)port;
     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 b97cb27..43efd0e 100755
--- a/mbtk/mbtk_rild_v2/inc/atchannel.h
+++ b/mbtk/mbtk_rild_v2/inc/atchannel.h
@@ -22,6 +22,7 @@
 extern "C" {
 #endif
 #include "mbtk_type.h"
+#include "mbtk_ril_api.h"
 
 /* define AT_DEBUG to send AT traffic to /tmp/radio-at.log" */
 #define AT_DEBUG  0
@@ -44,7 +45,6 @@
                                           response */
 #define AT_ERROR_TIMEOUT_CLOSE    (-7)
 
-
 typedef enum
 {
     NO_RESULT,   /* no intermediate response expected */
@@ -87,8 +87,8 @@
  */
 typedef void (*ATUnsolHandler)(const char *s, const char *sms_pdu);
 
-int at_open(int at_fd, int uart_fd, ATUnsolHandler h);
-void at_close();
+int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h);
+void at_close(ATPortType_enum port);
 
 /* This callback is invoked on the command thread.
    You should reset or handshake here to avoid getting out of sync */
@@ -101,26 +101,26 @@
    channel is already closed */
 void at_set_on_reader_closed(void (*onClose)(void));
 
-int at_send_command_singleline (const char *command,
+int at_send_command_singleline (ATPortType_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse);
-int at_send_command_singleline_with_timeout (const char *command,
+int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec);
 
-int at_send_command_numeric (const char *command,
+int at_send_command_numeric (ATPortType_enum port, const char *command,
                              ATResponse **pp_outResponse);
 
-int at_send_command_multiline (const char *command,
+int at_send_command_multiline (ATPortType_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse);
 
 
-int at_handshake();
+int at_handshake(ATPortType_enum port);
 
-int at_send_command (const char *command, ATResponse **pp_outResponse);
+int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse);
 
-int at_send_command_sms (const char *command, const char *pdu,
+int at_send_command_sms (ATPortType_enum port, const char *command, const char *pdu,
                          const char *responsePrefix,
                          ATResponse **pp_outResponse);
 
@@ -136,8 +136,8 @@
 
 AT_CME_Error at_get_cme_error(const ATResponse *p_response);
 
-mbtk_ril_at_state_enum at_state_get();
-void at_state_set(mbtk_ril_at_state_enum state);
+mbtk_ril_at_state_enum at_state_get(ATPortType_enum port);
+void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state);
 bool at_rsp_check(ATResponse *p_response);
 
 #ifdef __cplusplus
diff --git a/mbtk/mbtk_rild_v2/inc/ril_info.h b/mbtk/mbtk_rild_v2/inc/ril_info.h
index c07e3f0..71e6bd7 100755
--- a/mbtk/mbtk_rild_v2/inc/ril_info.h
+++ b/mbtk/mbtk_rild_v2/inc/ril_info.h
@@ -35,6 +35,7 @@
 typedef struct
 {
     int fd;
+    ATPortType_enum port;
 
     uint32 ind_num;
     uint16 ind_register[IND_REGISTER_MAX];
@@ -52,12 +53,12 @@
     mbtk_sim_card_type_enum sim_type;
     int sock_listen_fd;
     int epoll_fd;
-    bool at_process;
+    bool at_process[ATPORTTYPE_NUM];
 
     list_node_t *sock_client_list;      // Refor to : sock_cli_info_t
-    mbtk_queue_node_t msg_queue;        // Refor to : ril_msg_queue_info_t
-    pthread_cond_t msg_cond;
-    pthread_mutex_t msg_mutex;
+    mbtk_queue_node_t msg_queue[ATPORTTYPE_NUM];        // Refor to : ril_msg_queue_info_t
+    pthread_cond_t msg_cond[ATPORTTYPE_NUM];
+    pthread_mutex_t msg_mutex[ATPORTTYPE_NUM];
 } ril_info_t;
 
 typedef struct {
@@ -119,12 +120,12 @@
 extern ril_info_t ril_info;
 
 
-mbtk_radio_state_enum ril_radio_state_get();
-mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset);
+mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port);
+mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset);
 
-mbtk_sim_state_enum ril_sim_state_get();
+mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port);
 
-void apn_auto_conf_from_prop();
+void apn_auto_conf_from_prop(ATPortType_enum port);
 
 bool is_ipv4(const char *ip);
 
diff --git a/mbtk/mbtk_rild_v2/src/atchannel.c b/mbtk/mbtk_rild_v2/src/atchannel.c
index fe96df1..8a19159 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -38,20 +38,20 @@
 #define HANDSHAKE_TIMEOUT_MSEC 500
 #define AT_BUFF_MAX 1024
 
-static pthread_t s_tid_reader;
-static int s_at_fd = -1;    /* fd of the AT channel */
+static pthread_t s_tid_reader[ATPORTTYPE_NUM];
+static int s_at_fd[ATPORTTYPE_NUM] = {-1};    /* fd of the AT channel */
 static int s_uart_fd = -1;    /* fd of the UART channel */
 
 static ATUnsolHandler s_unsolHandler;
 
 /* for input buffering */
 
-static char s_ATBuffer[MAX_AT_RESPONSE+1];
-static char *s_ATBufferCur = s_ATBuffer;
+static char s_ATBuffer[ATPORTTYPE_NUM][MAX_AT_RESPONSE+1];
+static char *s_ATBufferCur[ATPORTTYPE_NUM] = {s_ATBuffer[ATPORTTYPE_0], s_ATBuffer[ATPORTTYPE_1], s_ATBuffer[ATPORTTYPE_2]};
 static char s_UartBuffer[MAX_AT_RESPONSE+1];
 static char *s_UartBufferCur = s_UartBuffer;
 
-static mbtk_ril_at_state_enum at_state = RIL_AT_STATE_CLOSED;
+static mbtk_ril_at_state_enum at_state[ATPORTTYPE_NUM] = {RIL_AT_STATE_CLOSED};
 
 #if AT_DEBUG
 void  AT_DUMP(const char*  prefix, const char*  buff, int  len)
@@ -72,22 +72,22 @@
  */
 
 // "Wait" when AT process...
-static pthread_mutex_t s_commandmutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_commandcond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t s_commandmutex[ATPORTTYPE_NUM] = {PTHREAD_MUTEX_INITIALIZER};
+static pthread_cond_t s_commandcond[ATPORTTYPE_NUM] = {PTHREAD_COND_INITIALIZER};
 
-static ATCommandType s_type;
-static const char *s_responsePrefix = NULL;
-static const char *s_smsPDU = NULL;
-static ATResponse *sp_response = NULL;
-static char s_curr_at[AT_BUFF_MAX];
+static ATCommandType s_type[ATPORTTYPE_NUM];
+static const char *s_responsePrefix[ATPORTTYPE_NUM] = {NULL};
+static const char *s_smsPDU[ATPORTTYPE_NUM] = {NULL};
+static ATResponse *sp_response[ATPORTTYPE_NUM] = {NULL};
+static char s_curr_at[ATPORTTYPE_NUM][AT_BUFF_MAX];
 
 static void (*s_onTimeout)(void) = NULL;
 static void (*s_onReaderClosed)(void) = NULL;
 static int s_readerClosed;
 
-static void onReaderClosed();
-static int writeCtrlZ (const char *s);
-static int writeline (const char *s);
+static void onReaderClosed(ATPortType_enum port);
+static int writeCtrlZ (ATPortType_enum port, const char *s);
+static int writeline (ATPortType_enum port, const char *s);
 
 typedef struct
 {
@@ -137,7 +137,7 @@
 
 
 /** add an intermediate response to sp_response*/
-static void addIntermediate(const char *line)
+static void addIntermediate(ATPortType_enum port, const char *line)
 {
     ATLine *p_new;
 
@@ -151,8 +151,8 @@
     /* note: this adds to the head of the list, so the list
        will be in reverse order of lines received. the order is flipped
        again before passing on to the command issuer */
-    p_new->p_next = sp_response->p_intermediates;
-    sp_response->p_intermediates = p_new;
+    p_new->p_next = sp_response[port]->p_intermediates;
+    sp_response[port]->p_intermediates = p_new;
 }
 
 
@@ -170,7 +170,7 @@
     "NO ANSWER",
     "NO DIALTONE",
 };
-static int isFinalResponseError(const char *line)
+static int isFinalResponseError(ATPortType_enum port, const char *line)
 {
     size_t i;
 
@@ -182,7 +182,7 @@
         }
     }
 
-    if(!strncasecmp(s_curr_at, "ATD", 3) && strStartsWith(line, "NO CARRIER"))
+    if(!strncasecmp(s_curr_at[port], "ATD", 3) && strStartsWith(line, "NO CARRIER"))
     {
         return 1;
     }
@@ -220,9 +220,9 @@
  * See 27.007 annex B
  * WARNING: NO CARRIER and others are sometimes unsolicited
  */
-static int isFinalResponse(const char *line)
+static int isFinalResponse(ATPortType_enum port, const char *line)
 {
-    return isFinalResponseSuccess(line) || isFinalResponseError(line);
+    return isFinalResponseSuccess(line) || isFinalResponseError(port, line);
 }
 
 /**
@@ -252,12 +252,12 @@
 
 
 /** assumes s_commandmutex is held */
-static void handleFinalResponse(const char *line)
+static void handleFinalResponse(ATPortType_enum port, const char *line)
 {
-    sp_response->finalResponse = strdup(line);
+    sp_response[port]->finalResponse = strdup(line);
 
     //LOGD("AT complete (pthread_cond_signal): %s",line);
-    pthread_cond_signal(&s_commandcond);
+    pthread_cond_signal(&s_commandcond[port]);
 }
 
 static void handleUnsolicited(const char *line)
@@ -268,43 +268,43 @@
     }
 }
 
-static void processLine(const char *line)
+static void processLine(ATPortType_enum port, const char *line)
 {
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 //    LOGD("LINE : %s", line);
-    if (sp_response == NULL)
+    if (sp_response[port] == NULL)
     {
         /* no command pending */
         handleUnsolicited(line);
     }
     else if (isFinalResponseSuccess(line))
     {
-        sp_response->success = 1;
-        handleFinalResponse(line);
+        sp_response[port]->success = 1;
+        handleFinalResponse(port, line);
     }
-    else if (isFinalResponseError(line))
+    else if (isFinalResponseError(port, line))
     {
-        sp_response->success = 0;
-        handleFinalResponse(line);
+        sp_response[port]->success = 0;
+        handleFinalResponse(port, line);
     }
-    else if (s_smsPDU != NULL && 0 == strcmp(line, "> "))
+    else if (s_smsPDU[port] != NULL && 0 == strcmp(line, "> "))
     {
         // See eg. TS 27.005 4.3
         // Commands like AT+CMGS have a "> " prompt
-        writeCtrlZ(s_smsPDU);
-        s_smsPDU = NULL;
+        writeCtrlZ(port, s_smsPDU[port]);
+        s_smsPDU[port] = NULL;
     }
-    else switch (s_type)
+    else switch (s_type[port])
         {
             case NO_RESULT:
                 handleUnsolicited(line);
                 break;
             case NUMERIC:
-                if (sp_response->p_intermediates == NULL
+                if (sp_response[port]->p_intermediates == NULL
                     && isdigit(line[0])
                    )
                 {
-                    addIntermediate(line);
+                    addIntermediate(port, line);
                 }
                 else
                 {
@@ -314,8 +314,8 @@
                 }
                 break;
             case SINGLELINE:
-                if (sp_response->p_intermediates == NULL
-                    && strStartsWith (line, s_responsePrefix)
+                if (sp_response[port]->p_intermediates == NULL
+                    && strStartsWith (line, s_responsePrefix[port])
                    )
                 {
                     if(*line == '"')
@@ -331,12 +331,12 @@
                                 ptr--;
                             }
                         }
-                        addIntermediate(line_temp);
+                        addIntermediate(port, line_temp);
                         free(line_temp);
                     }
                     else
                     {
-                        addIntermediate(line);
+                        addIntermediate(port, line);
                     }
                 }
                 else
@@ -346,9 +346,9 @@
                 }
                 break;
             case MULTILINE:
-                if (strStartsWith (line, s_responsePrefix))
+                if (strStartsWith (line, s_responsePrefix[port]))
                 {
-                    addIntermediate(line);
+                    addIntermediate(port, line);
                 }
                 else
                 {
@@ -357,12 +357,12 @@
                 break;
 
             default: /* this should never be reached */
-                LOGE("Unsupported AT command type %d\n", s_type);
+                LOGE("Unsupported AT command type %d\n", s_type[port]);
                 handleUnsolicited(line);
                 break;
         }
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 }
 
 
@@ -397,7 +397,7 @@
  * have buffered stdio.
  */
 
-static const char *readline()
+static const char *readline(ATPortType_enum port)
 {
     ssize_t count;
 
@@ -409,33 +409,33 @@
      * mean "buffer consumed completely". If it points to a character, than
      * the buffer continues until a \0
      */
-    if (*s_ATBufferCur == '\0')
+    if (*s_ATBufferCur[port] == '\0')
     {
         /* empty buffer */
-        s_ATBufferCur = s_ATBuffer;
-        *s_ATBufferCur = '\0';
-        p_read = s_ATBuffer;
+        s_ATBufferCur[port] = s_ATBuffer[port];
+        *s_ATBufferCur[port] = '\0';
+        p_read = s_ATBuffer[port];
     }
     else       /* *s_ATBufferCur != '\0' */
     {
         /* there's data in the buffer from the last read */
 
         // skip over leading newlines
-        while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n')
-            s_ATBufferCur++;
+        while (*s_ATBufferCur[port] == '\r' || *s_ATBufferCur[port] == '\n')
+            s_ATBufferCur[port]++;
 
-        p_eol = findNextEOL(s_ATBufferCur);
+        p_eol = findNextEOL(s_ATBufferCur[port]);
 
         if (p_eol == NULL)
         {
             /* a partial line. move it up and prepare to read more */
             size_t len;
 
-            len = strlen(s_ATBufferCur);
+            len = strlen(s_ATBufferCur[port]);
 
-            memmove(s_ATBuffer, s_ATBufferCur, len + 1);
-            p_read = s_ATBuffer + len;
-            s_ATBufferCur = s_ATBuffer;
+            memmove(s_ATBuffer[port], s_ATBufferCur[port], len + 1);
+            p_read = s_ATBuffer[port] + len;
+            s_ATBufferCur[port] = s_ATBuffer[port];
         }
         /* Otherwise, (p_eol !- NULL) there is a complete line  */
         /* that will be returned the while () loop below        */
@@ -443,19 +443,19 @@
 
     while (p_eol == NULL)
     {
-        if (0 == MAX_AT_RESPONSE - (p_read - s_ATBuffer))
+        if (0 == MAX_AT_RESPONSE - (p_read - s_ATBuffer[port]))
         {
             LOGE("ERROR: Input line exceeded buffer\n");
             /* ditch buffer and start over again */
-            s_ATBufferCur = s_ATBuffer;
-            *s_ATBufferCur = '\0';
-            p_read = s_ATBuffer;
+            s_ATBufferCur[port] = s_ATBuffer[port];
+            *s_ATBufferCur[port] = '\0';
+            p_read = s_ATBuffer[port];
         }
 
         do
         {
-            count = read(s_at_fd, p_read,
-                         MAX_AT_RESPONSE - (p_read - s_ATBuffer));
+            count = read(s_at_fd[port], p_read,
+                         MAX_AT_RESPONSE - (p_read - s_ATBuffer[port]));
             usleep(10000);
         }
         while (count < 0 && errno == EINTR);
@@ -467,10 +467,10 @@
             p_read[count] = '\0';
 
             // skip over leading newlines
-            while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n')
-                s_ATBufferCur++;
+            while (*s_ATBufferCur[port] == '\r' || *s_ATBufferCur[port] == '\n')
+                s_ATBufferCur[port]++;
 
-            p_eol = findNextEOL(s_ATBufferCur);
+            p_eol = findNextEOL(s_ATBufferCur[port]);
             p_read += count;
         }
         else if (count <= 0)
@@ -490,9 +490,9 @@
 
     /* a full line in the buffer. Place a \0 over the \r and return */
 
-    ret = s_ATBufferCur;
+    ret = s_ATBufferCur[port];
     *p_eol = '\0';
-    s_ATBufferCur = p_eol + 1; /* this will always be <= p_read,    */
+    s_ATBufferCur[port] = p_eol + 1; /* this will always be <= p_read,    */
     /* and there will be a \0 at *p_read */
 
     LOGD("AT< %s", ret);
@@ -603,19 +603,19 @@
 
 
 
-static void onReaderClosed()
+static void onReaderClosed(ATPortType_enum port)
 {
     LOGD("onReaderClosed()");
     if (s_onReaderClosed != NULL && s_readerClosed == 0)
     {
 
-        pthread_mutex_lock(&s_commandmutex);
+        pthread_mutex_lock(&s_commandmutex[port]);
 
         s_readerClosed = 1;
 
-        pthread_cond_signal(&s_commandcond);
+        pthread_cond_signal(&s_commandcond[port]);
 
-        pthread_mutex_unlock(&s_commandmutex);
+        pthread_mutex_unlock(&s_commandmutex[port]);
 
         s_onReaderClosed();
     }
@@ -632,11 +632,12 @@
 static void *readerLoop(void *arg)
 {
     UNUSED(arg);
+    ATPortType_enum *port = (ATPortType_enum*)arg;
     for (;;)
     {
         const char * line;
 
-        line = readline();
+        line = readline(*port);
 
         if (line == NULL)
         {
@@ -661,7 +662,7 @@
             // till next call to 'readline()' hence making a copy of line
             // before calling readline again.
             line1 = strdup(line);
-            line2 = readline();
+            line2 = readline(*port);
 
             if (line2 == NULL)
             {
@@ -677,11 +678,13 @@
         }
         else
         {
-            processLine(line);
+            processLine(*port, line);
         }
     }
 
-    onReaderClosed();
+    onReaderClosed(*port);
+
+    free(port);
 
     return NULL;
 }
@@ -689,6 +692,7 @@
 static void *readerUrcLoop(void *arg)
 {
     UNUSED(arg);
+    ATPortType_enum *port = (ATPortType_enum*)arg;
     for (;;)
     {
         const char *line;
@@ -703,7 +707,9 @@
         handleUnsolicited(line);
     }
 
-    onReaderClosed();
+    onReaderClosed(*port);
+
+    free(port);
 
     return NULL;
 }
@@ -716,13 +722,13 @@
  * This function exists because as of writing, android libc does not
  * have buffered stdio.
  */
-static int writeline (const char *s)
+static int writeline (ATPortType_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
     ssize_t written;
 
-    if (s_at_fd < 0 || s_readerClosed > 0)
+    if (s_at_fd[port] < 0 || s_readerClosed > 0)
     {
         return AT_ERROR_CHANNEL_CLOSED;
     }
@@ -731,15 +737,15 @@
 
     AT_DUMP( ">> ", s, strlen(s) );
 
-    memset(s_curr_at, 0x0, AT_BUFF_MAX);
-    memcpy(s_curr_at, s, strlen(s));
+    memset(s_curr_at[port], 0x0, AT_BUFF_MAX);
+    memcpy(s_curr_at[port], s, strlen(s));
 
     /* the main string */
     while (cur < len)
     {
         do
         {
-            written = write (s_at_fd, s + cur, len - cur);
+            written = write (s_at_fd[port], s + cur, len - cur);
         }
         while (written < 0 && errno == EINTR);
 
@@ -755,7 +761,7 @@
 
     do
     {
-        written = write (s_at_fd, "\r", 1);
+        written = write (s_at_fd[port], "\r", 1);
     }
     while ((written < 0 && errno == EINTR) || (written == 0));
 
@@ -767,13 +773,13 @@
     return 0;
 }
 
-static int writeCtrlZ (const char *s)
+static int writeCtrlZ (ATPortType_enum port, const char *s)
 {
     size_t cur = 0;
     size_t len = strlen(s);
     ssize_t written;
 
-    if (s_at_fd < 0 || s_readerClosed > 0)
+    if (s_at_fd[port] < 0 || s_readerClosed > 0)
     {
         return AT_ERROR_CHANNEL_CLOSED;
     }
@@ -787,7 +793,7 @@
     {
         do
         {
-            written = write (s_at_fd, s + cur, len - cur);
+            written = write (s_at_fd[port], s + cur, len - cur);
         }
         while (written < 0 && errno == EINTR);
 
@@ -803,7 +809,7 @@
 
     do
     {
-        written = write (s_at_fd, "\032", 1);
+        written = write (s_at_fd[port], "\032", 1);
     }
     while ((written < 0 && errno == EINTR) || (written == 0));
 
@@ -815,16 +821,16 @@
     return 0;
 }
 
-static void clearPendingCommand()
+static void clearPendingCommand(ATPortType_enum port)
 {
-    if (sp_response != NULL)
+    if (sp_response[port] != NULL)
     {
-        at_response_free(sp_response);
+        at_response_free(sp_response[port]);
     }
 
-    sp_response = NULL;
-    s_responsePrefix = NULL;
-    s_smsPDU = NULL;
+    sp_response[port] = NULL;
+    s_responsePrefix[port] = NULL;
+    s_smsPDU[port] = NULL;
 }
 
 
@@ -832,22 +838,27 @@
  * Starts AT handler on stream "fd'
  * returns 0 on success, -1 on error
  */
-int at_open(int at_fd, int uart_fd, ATUnsolHandler h)
+int at_open(ATPortType_enum port, int at_fd, int uart_fd, ATUnsolHandler h)
 {
     int ret;
     pthread_attr_t attr;
 
-    s_at_fd = at_fd;
+    s_at_fd[port] = at_fd;
     s_uart_fd = uart_fd;
     s_unsolHandler = h;
     s_readerClosed = 0;
-    s_responsePrefix = NULL;
-    s_smsPDU = NULL;
-    sp_response = NULL;
+    s_responsePrefix[port] = NULL;
+    s_smsPDU[port] = NULL;
+    sp_response[port] = NULL;
+
+    ATPortType_enum *at_port_ptr = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
+    ATPortType_enum *urc_port_ptr = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
+    *at_port_ptr = port;
+    *urc_port_ptr = port;
 
     pthread_attr_init (&attr);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    ret = pthread_create(&s_tid_reader, &attr, readerLoop, NULL);
+    ret = pthread_create(&s_tid_reader[port], &attr, readerLoop, at_port_ptr);
     if (ret < 0)
     {
         LOGE("AT thread create fail.");
@@ -855,7 +866,7 @@
     }
 
     pthread_t uart_tid_reader;
-    ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, NULL);
+    ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, urc_port_ptr);
     if (ret < 0)
     {
         LOGE("Uart thread create fail.");
@@ -866,27 +877,27 @@
 }
 
 /* FIXME is it ok to call this from the reader and the command thread? */
-void at_close()
+void at_close(ATPortType_enum port)
 {
     LOGD("at_close()");
-    if (s_at_fd >= 0)
+    if (s_at_fd[port] >= 0)
     {
-        close(s_at_fd);
+        close(s_at_fd[port]);
     }
     if (s_uart_fd >= 0)
     {
         close(s_uart_fd);
     }
-    s_at_fd = -1;
+    s_at_fd[port] = -1;
     s_uart_fd = -1;
 
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
     s_readerClosed = 1;
-    pthread_cond_signal(&s_commandcond);
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_cond_signal(&s_commandcond[port]);
+    pthread_mutex_unlock(&s_commandmutex[port]);
     /* the reader thread should eventually die */
 
-    at_state = RIL_AT_STATE_CLOSED;
+    at_state[port] = RIL_AT_STATE_CLOSED;
 }
 
 static ATResponse * at_response_new()
@@ -960,33 +971,33 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full_nolock (const char *command, ATCommandType type,
+static int at_send_command_full_nolock (ATPortType_enum port, const char *command, ATCommandType type,
                                         const char *responsePrefix, const char *smspdu,
                                         long long timeoutMsec, ATResponse **pp_outResponse)
 {
     int err = 0;
     bool tiemout_close = true;
     struct timespec ts;
-    if(at_state == RIL_AT_STATE_READY)
-        at_state = RIL_AT_STATE_BUSY;
+    if(at_state[port] == RIL_AT_STATE_READY)
+        at_state[port] = RIL_AT_STATE_BUSY;
 
-    if(sp_response != NULL)
+    if(sp_response[port] != NULL)
     {
         err = AT_ERROR_COMMAND_PENDING;
         goto error;
     }
 
-    err = writeline (command);
+    err = writeline (port, command);
 
     if (err < 0)
     {
         goto error;
     }
 
-    s_type = type;
-    s_responsePrefix = responsePrefix;
-    s_smsPDU = smspdu;
-    sp_response = at_response_new();
+    s_type[port] = type;
+    s_responsePrefix[port] = responsePrefix;
+    s_smsPDU[port] = smspdu;
+    sp_response[port] = at_response_new();
 
     if(timeoutMsec == 0)
     {
@@ -998,16 +1009,16 @@
         setTimespecRelative(&ts, timeoutMsec);
     }
 
-    while (sp_response->finalResponse == NULL && s_readerClosed == 0)
+    while (sp_response[port]->finalResponse == NULL && s_readerClosed == 0)
     {
         //LOGD("AT wait time:%lld",timeoutMsec);
         if (timeoutMsec != 0)
         {
-            err = pthread_cond_timedwait(&s_commandcond, &s_commandmutex, &ts);
+            err = pthread_cond_timedwait(&s_commandcond[port], &s_commandmutex[port], &ts);
         }
         else
         {
-            err = pthread_cond_wait(&s_commandcond, &s_commandmutex);
+            err = pthread_cond_wait(&s_commandcond[port], &s_commandmutex[port]);
         }
 
         //LOGD("AT continue:err - %d",err);
@@ -1027,16 +1038,16 @@
 
     if (pp_outResponse == NULL)
     {
-        at_response_free(sp_response);
+        at_response_free(sp_response[port]);
     }
     else
     {
         /* line reader stores intermediate responses in reverse order */
-        reverseIntermediates(sp_response);
-        *pp_outResponse = sp_response;
+        reverseIntermediates(sp_response[port]);
+        *pp_outResponse = sp_response[port];
     }
 
-    sp_response = NULL;
+    sp_response[port] = NULL;
 
     if(s_readerClosed > 0)
     {
@@ -1046,9 +1057,9 @@
 
     err = 0;
 error:
-    if(at_state == RIL_AT_STATE_BUSY)
-        at_state = RIL_AT_STATE_READY;
-    clearPendingCommand();
+    if(at_state[port] == RIL_AT_STATE_BUSY)
+        at_state[port] = RIL_AT_STATE_READY;
+    clearPendingCommand(port);
 
     return err;
 }
@@ -1058,13 +1069,13 @@
  *
  * timeoutMsec == 0 means infinite timeout
  */
-static int at_send_command_full (const char *command, ATCommandType type,
+static int at_send_command_full (ATPortType_enum port, const char *command, ATCommandType type,
                                  const char *responsePrefix, const char *smspdu,
                                  long long timeoutMsec, ATResponse **pp_outResponse)
 {
     int err;
 
-    if (0 != pthread_equal(s_tid_reader, pthread_self()))
+    if (0 != pthread_equal(s_tid_reader[port], pthread_self()))
     {
         /* cannot be called from reader thread */
         LOGE("cannot be called from reader thread.");
@@ -1072,18 +1083,18 @@
     }
 
     // Waitting for previous AT complete.
-    while(at_state == RIL_AT_STATE_BUSY)
+    while(at_state[port] == RIL_AT_STATE_BUSY)
     {
         usleep(10000);
     }
 
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 
-    err = at_send_command_full_nolock(command, type,
+    err = at_send_command_full_nolock(port, command, type,
                                       responsePrefix, smspdu,
                                       timeoutMsec, pp_outResponse);
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 
     if (err == AT_ERROR_TIMEOUT_CLOSE && s_onTimeout != NULL)
     {
@@ -1103,20 +1114,20 @@
  * if non-NULL, the resulting ATResponse * must be eventually freed with
  * at_response_free
  */
-int at_send_command (const char *command, ATResponse **pp_outResponse)
+int at_send_command (ATPortType_enum port, const char *command, ATResponse **pp_outResponse)
 {
-    return at_send_command_full (command, NO_RESULT, NULL,
+    return at_send_command_full (port, command, NO_RESULT, NULL,
                                  NULL, 0, pp_outResponse);
 }
 
 
-int at_send_command_singleline (const char *command,
+int at_send_command_singleline (ATPortType_enum port, const char *command,
                                 const char *responsePrefix,
                                 ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 NULL, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1133,13 +1144,13 @@
     return err;
 }
 
-int at_send_command_singleline_with_timeout (const char *command,
+int at_send_command_singleline_with_timeout (ATPortType_enum port, const char *command,
         const char *responsePrefix,
         ATResponse **pp_outResponse,long long timeoutMsec)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 NULL, timeoutMsec, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1158,12 +1169,12 @@
 
 
 
-int at_send_command_numeric (const char *command,
+int at_send_command_numeric (ATPortType_enum port, const char *command,
                              ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, NUMERIC, NULL,
+    err = at_send_command_full (port, command, NUMERIC, NULL,
                                 NULL, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1181,14 +1192,14 @@
 }
 
 
-int at_send_command_sms (const char *command,
+int at_send_command_sms (ATPortType_enum port, const char *command,
                          const char *pdu,
                          const char *responsePrefix,
                          ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, SINGLELINE, responsePrefix,
+    err = at_send_command_full (port, command, SINGLELINE, responsePrefix,
                                 pdu, 0, pp_outResponse);
 
     if (err == 0 && pp_outResponse != NULL
@@ -1206,13 +1217,13 @@
 }
 
 
-int at_send_command_multiline (const char *command,
+int at_send_command_multiline (ATPortType_enum port, const char *command,
                                const char *responsePrefix,
                                ATResponse **pp_outResponse)
 {
     int err;
 
-    err = at_send_command_full (command, MULTILINE, responsePrefix,
+    err = at_send_command_full (port, command, MULTILINE, responsePrefix,
                                 NULL, 0, pp_outResponse);
 
     return err;
@@ -1242,17 +1253,17 @@
  * Periodically issue an AT command and wait for a response.
  * Used to ensure channel has start up and is active
  */
-int at_handshake()
+int at_handshake(ATPortType_enum port)
 {
 //    int i;
     int err = 0;
 
-    if (0 != pthread_equal(s_tid_reader, pthread_self()))
+    if (0 != pthread_equal(s_tid_reader[port], pthread_self()))
     {
         /* cannot be called from reader thread */
         return AT_ERROR_INVALID_THREAD;
     }
-    pthread_mutex_lock(&s_commandmutex);
+    pthread_mutex_lock(&s_commandmutex[port]);
 
 #if 0
     for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++)
@@ -1267,7 +1278,7 @@
         }
     }
 #else
-    err = at_send_command_full_nolock("ATE0Q0V1", NO_RESULT,
+    err = at_send_command_full_nolock(port, "ATE0Q0V1", NO_RESULT,
                                           NULL, NULL, 0, NULL);
 #endif
 
@@ -1278,7 +1289,7 @@
         sleepMsec(HANDSHAKE_TIMEOUT_MSEC);
     }
 
-    pthread_mutex_unlock(&s_commandmutex);
+    pthread_mutex_unlock(&s_commandmutex[port]);
 
 
     return err;
@@ -1324,14 +1335,14 @@
     return ret;
 }
 
-mbtk_ril_at_state_enum at_state_get()
+mbtk_ril_at_state_enum at_state_get(ATPortType_enum port)
 {
-    return at_state;
+    return at_state[port];
 }
 
-void at_state_set(mbtk_ril_at_state_enum state)
+void at_state_set(ATPortType_enum port, mbtk_ril_at_state_enum state)
 {
-    at_state = state;
+    at_state[port] = state;
 }
 
 bool at_rsp_check(ATResponse *p_response)
@@ -1342,8 +1353,8 @@
     return true;
 }
 
-void unused_func()
+void unused_func(ATPortType_enum port)
 {
-    isFinalResponse(NULL);
+    isFinalResponse(port, NULL);
 }
 
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 939585f..14284d7 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -70,7 +70,7 @@
 mbtk_ril_err_enum sms_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);

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

 

-void data_call_retry(mbtk_ril_net_reg_state_info_t *reg_state);

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

 

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

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

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

 {

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

-    at_close();

+    at_close(ATPORTTYPE_0);

 }

 

 /* Called on command or reader thread */

 static void onATReaderClosed()

 {

     LOGI("AT channel closed\n");

-    at_close();

+    at_close(ATPORTTYPE_0);

 }

 

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

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

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

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

     if(pack)
     {

         pack->err = (uint16)err;

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

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

 {

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

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

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

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

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

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

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

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

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

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

+    ril_info.radio_state = ril_radio_state_get(ATPORTTYPE_0);

     if (ril_info.radio_state != MBTK_RADIO_STATE_FULL_FUNC)

     {
-        ril_radio_state_set(MBTK_RADIO_STATE_FULL_FUNC, FALSE);

+        ril_radio_state_set(ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);

     }

 
     if(ril_info.radio_state == MBTK_RADIO_STATE_FULL_FUNC)

     {

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

     }
 
-    ril_info.sim_state = ril_sim_state_get();

+    ril_info.sim_state = ril_sim_state_get(ATPORTTYPE_0);

     if(ril_info.sim_state == MBTK_SIM_STATE_READY)

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

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

 

         // Set APN from prop.

-        apn_auto_conf_from_prop();

+        apn_auto_conf_from_prop(ATPORTTYPE_0);

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

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

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

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

-        return -1;
-    }
+{

+    if(cli_info) {

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

+        {

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

+            return -1;

+        }

+    } else {

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

+        {

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

+            return -1;

+        }

+    }

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

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

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

-    pthread_cond_signal(&ril_info.msg_cond);

-    pthread_mutex_unlock(&ril_info.msg_mutex);

+    item->pack = pack;

+

+    if(cli_info) {

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

+

+        // If thread is waitting,continue it.

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

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

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

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

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

+

+        // If thread is waitting,continue it.

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

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

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

+    }

 
     return 0;
 }

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

             }

 

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

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

 

             ril_msg_pack_free(pack);

         } else {

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

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

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

             {

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

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

         {

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

-            data_call_retry(reg_state);

+            data_call_retry(ATPORTTYPE_0, reg_state);

             break;

         }

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

                                 info->fd = client_fd;

+

+                                // Default AT port.

+                                info->port = ATPORTTYPE_0;

+

                                 list_add(ril_info.sock_client_list, info);

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

 

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

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

-
+

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

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

                         }
                         else
                         {
                             ril_msg_pack_info_t** pack_ptr = pack;

                             while(*pack_ptr)
-                            {
+                            {

+                                // Update AT port in the first.

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

+

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

 static void* ril_process_thread(void* arg)

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

+    ATPortType_enum *port = (ATPortType_enum*)arg;

     ril_msg_queue_info_t* item = NULL;

 
-    pthread_mutex_lock(&ril_info.msg_mutex);

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

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

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

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

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

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

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

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

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

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

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

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

-                ril_info.at_process = true;

+                ril_info.at_process[*port] = true;

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

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

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

                 }
-                ril_info.at_process = false;

+                ril_info.at_process[*port] = false;

                 ril_msg_pack_free(pack);

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

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

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

+

+    free(port);

+

     return NULL;
 }

 

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

 

-    mbtk_queue_init(&ril_info.msg_queue);

-    pthread_mutex_init(&ril_info.msg_mutex, NULL);

-    pthread_cond_init(&ril_info.msg_cond, NULL);

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

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

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

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

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

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

+

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

+    *port_0 = ATPORTTYPE_0;

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

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

         goto error;
-    }
+    }

+

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

+    *port_1 = ATPORTTYPE_1;

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

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

+        goto error;
+    }

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

     }

 

-    at_set_on_reader_closed(onATReaderClosed);

-    at_set_on_timeout(onATTimeout);

-

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

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

+    if(at_sock_1 < 0)

     {

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

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

         return -1;

     }

 

-    if(at_handshake())

+    at_set_on_reader_closed(onATReaderClosed);

+    at_set_on_timeout(onATTimeout);

+

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

+    {

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

+        return -1;

+    }

+

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

+    {

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

+        return -1;

+    }

+

+    if(at_handshake(ATPORTTYPE_0))

     {

         LOGE("AT handshake fail.");

         return -1;

diff --git a/mbtk/mbtk_rild_v2/src/ril_call.c b/mbtk/mbtk_rild_v2/src/ril_call.c
index 3891143..e35775a 100755
--- a/mbtk/mbtk_rild_v2/src/ril_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_call.c
@@ -17,21 +17,21 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 ATDXXXXXXX;
 OK
 
 */
-static int req_call_start(char *phont_number, int *cme_err)
+static int req_call_start(ATPortType_enum port, char *phont_number, int *cme_err)
 {
     ATResponse *response = NULL;
 //    int tmp_int;
 //    char *tmp_str = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "ATD%s;", phont_number);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -48,10 +48,10 @@
 OK
 
 */
-static int req_answer_call(int *cme_err)
+static int req_answer_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=2", &response);
+    int err = at_send_command(port, "AT+CHLD=2", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -67,10 +67,10 @@
 OK
 
 */
-static int req_hangup_call(int *cme_err)
+static int req_hangup_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("ATH", &response);
+    int err = at_send_command(port, "ATH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -86,12 +86,12 @@
 OK
 
 */
-static int req_hangup_a_call(int phone_id, int *cme_err)
+static int req_hangup_a_call(ATPortType_enum port, int phone_id, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CHLD=1%d", phone_id);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -107,10 +107,10 @@
 OK
 
 */
-static int req_hangup_waiting_or_background_call(int *cme_err)
+static int req_hangup_waiting_or_background_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=0", &response);
+    int err = at_send_command(port, "AT+CHLD=0", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -126,10 +126,10 @@
 OK
 
 */
-static int req_hangup_foreground_resume_background_call(int *cme_err)
+static int req_hangup_foreground_resume_background_call(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT+CHLD=1", &response);
+    int err = at_send_command(port, "AT+CHLD=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -145,13 +145,13 @@
 OK
 
 */
-static int req_waitin_call(mbtk_call_info_t *reg, int *cme_err)
+static int req_waitin_call(ATPortType_enum port, mbtk_call_info_t *reg, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_str = NULL;
 
-    int err = at_send_command_multiline("AT+CLCC", "+CLCC:", &response);
+    int err = at_send_command_multiline(port, "AT+CLCC", "+CLCC:", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -224,11 +224,11 @@
 
 OK
 */
-static int req_mute_get(int *state, int *cme_err)
+static int req_mute_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+CMUT?", "+CMUT:", &response);
+    int err = at_send_command_singleline(port, "AT+CMUT?", "+CMUT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -258,13 +258,13 @@
 OK
 
 */
-static int req_mute_set(int state, int *cme_err)
+static int req_mute_set(ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+CMUT=%d", state);
     LOG("Set the mute command is = %s.\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -280,13 +280,13 @@
 OK
 
 */
-static int req_dtmf_set(mbtk_call_dtmf_info_t *state, int *cme_err)
+static int req_dtmf_set(ATPortType_enum port, mbtk_call_dtmf_info_t *state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT+VTS=%c,%d", state->character, state->duration);
     LOG("Set the DTMF command is = %s.\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -315,7 +315,7 @@
             else     // Set
             {
                 char *pn = (char*)(pack->data);
-                if(req_call_start(pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_call_start(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -326,7 +326,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -335,7 +335,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-               if(req_answer_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+               if(req_answer_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -346,7 +346,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -360,7 +360,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -371,7 +371,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -391,7 +391,7 @@
             else
             {
                 uint8 phone_id = *(pack->data);
-                if(req_hangup_a_call(phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_a_call(cli_info->port, phone_id, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -402,7 +402,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -411,7 +411,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_waiting_or_background_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_waiting_or_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -422,7 +422,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -436,7 +436,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_hangup_foreground_resume_background_call(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_hangup_foreground_resume_background_call(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -447,7 +447,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else
@@ -463,7 +463,7 @@
             {
                 mbtk_call_info_t reg;
                 memset(&reg, 0, sizeof(mbtk_call_info_t));
-                if(req_waitin_call(&reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_waitin_call(cli_info->port, &reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -474,7 +474,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &reg, sizeof(mbtk_call_info_t));
                 }
             }
             else     // Set
@@ -489,7 +489,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_mute_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -500,7 +500,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set mute state.
@@ -513,7 +513,7 @@
                     break;
                 }
 
-                if(req_mute_set(on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_mute_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -524,7 +524,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -539,7 +539,7 @@
             else     // Set
             {
                 mbtk_call_dtmf_info_t *reg = (mbtk_call_dtmf_info_t *)pack->data;
-                if(req_dtmf_set(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_dtmf_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -550,7 +550,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_data_call.c b/mbtk/mbtk_rild_v2/src/ril_data_call.c
index aef3ac9..210141b 100755
--- a/mbtk/mbtk_rild_v2/src/ril_data_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_data_call.c
@@ -24,12 +24,12 @@
 ril_cgact_wait_t cgact_wait;
 static ril_data_call_info_t info_list[MBTK_APN_CID_MAX];
 
-static int req_apn_get(bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
-static int req_apn_set(mbtk_apn_info_t *apn, int *cme_err);
+static int req_apn_get(ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
+static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err);
 static void apn_prop_get(mbtk_apn_info_array_t *apns);
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
-static int req_data_call_start(mbtk_ril_cid_enum cid, int *cme_err);
-static int req_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err);
+static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
 
 /*
 IPv4 : 10.255.74.26
@@ -269,7 +269,7 @@
 }
 
 
-void apn_auto_conf_from_prop()
+void apn_auto_conf_from_prop(ATPortType_enum port)
 {
     mbtk_apn_info_array_t apns;
     int i = 0;
@@ -289,7 +289,7 @@
             info_list[cid - 1].apn_info.as_dns, info_list[cid - 1].apn_info.apn);
 
         int cme_err = MBTK_RIL_ERR_CME_NON;
-        if(req_apn_set(&(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_set(port, &(apns.apns[i]), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGD("Set APN fail.");
         }
@@ -319,7 +319,7 @@
     return TRUE;
 }
 
-static int apn_check_and_cid_reset(mbtk_apn_info_t *apn)
+static int apn_check_and_cid_reset(ATPortType_enum port, mbtk_apn_info_t *apn)
 {
     // Delete apn
     if(str_empty(apn->apn)) {
@@ -333,7 +333,7 @@
         mbtk_apn_info_array_t apns;
         int cme_err = MBTK_RIL_ERR_CME_NON;
         memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-        if(req_apn_get(FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             return 0;
@@ -360,7 +360,7 @@
             start_cid = MBTK_APN_CID_MIN;
         }
         memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-        if(req_apn_get(TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(port, TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             if(apn->cid == MBTK_RIL_CID_NUL) {
@@ -764,7 +764,7 @@
     }
 }
 
-void data_call_retry(mbtk_ril_net_reg_state_info_t *reg_state)
+void data_call_retry(ATPortType_enum port, mbtk_ril_net_reg_state_info_t *reg_state)
 {
     LOGV("NET_REG_STATE_CHANGE : type - %d, tech - %d, reg_state - %d", reg_state->type, reg_state->tech, reg_state->reg_state);
     // Only for 2g/3g/4g data domain.
@@ -790,7 +790,7 @@
 
                         // PDP active
                         int cme_err = MBTK_RIL_ERR_CME_NON;
-                        if(req_data_call_start(cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_start(port, cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             LOGE("Restart data call fail.");
                             return;
@@ -806,7 +806,7 @@
                             // Get Ip informations.
                             memset(&ip_info, 0, sizeof(ip_info));
                             cme_err = MBTK_RIL_ERR_CME_NON;
-                            if(req_data_call_state_get(cid, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_state_get(port, cid, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                             {
                                 LOGE("Get net informations fail.");
                                 return;
@@ -842,10 +842,10 @@
 OK
 
 */
-static int req_apn_get(bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err)
+static int req_apn_get(ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:", &response);
+    int err = at_send_command_multiline(port, "AT+CGDCONT?", "+CGDCONT:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -950,7 +950,7 @@
 OK
 
 */
-static int req_apn_set(mbtk_apn_info_t *apn, int *cme_err)
+static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -960,7 +960,7 @@
     // Delete apn
     if(str_empty(apn->apn)) {
         sprintf(cmd, "AT+CGDCONT=%d", apn->cid);
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -991,7 +991,7 @@
             index += sprintf(cmd + index,"\"%s\"", apn->apn);
         }
 
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -1014,7 +1014,7 @@
                 goto exit;
 
             sprintf(cmd, "AT*AUTHREQ=%d,%d,%s,%s",apn->cid,cmd_auth,apn->user,apn->pass);
-            err = at_send_command(cmd, &response);
+            err = at_send_command(port, cmd, &response);
             if (err < 0 || response->success == 0){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -1039,7 +1039,7 @@
 OK
 
 */
-static int req_data_call_start(mbtk_ril_cid_enum cid, int *cme_err)
+static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1050,7 +1050,7 @@
     cgact_wait.act = true;
 
     sprintf(cmd, "AT+CGACT=1,%d", cid);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1068,7 +1068,7 @@
 OK
 
 */
-static int req_data_call_stop(mbtk_ril_cid_enum cid, int timeout, int *cme_err)
+static int req_data_call_stop(ATPortType_enum port, mbtk_ril_cid_enum cid, int timeout, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
@@ -1080,7 +1080,7 @@
     cgact_wait.act = false;
 
     sprintf(cmd, "AT+CGACT=0,%d", cid);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -1101,7 +1101,7 @@
 OK
 
 */
-static int req_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
+static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -1109,7 +1109,7 @@
 
     sprintf(cmd, "AT+CGCONTRDP=%d", cid);
 
-    err = at_send_command_multiline(cmd, "+CGCONTRDP:", &response);
+    err = at_send_command_multiline(port, cmd, "+CGCONTRDP:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1274,7 +1274,7 @@
             {
                 mbtk_apn_info_array_t apns;
                 memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-                if(req_apn_get(FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_apn_get(cli_info->port, FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1286,17 +1286,17 @@
                 else
                 {
                     LOGD("size - %d", sizeof(mbtk_apn_info_array_t));
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &apns, sizeof(mbtk_apn_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &apns, sizeof(mbtk_apn_info_array_t));
                 }
             }
             else     // Set
             {
                 mbtk_apn_info_t *apn = (mbtk_apn_info_t*)pack->data;
-                if(apn_check_and_cid_reset(apn)) {
+                if(apn_check_and_cid_reset(cli_info->port, apn)) {
                     err = MBTK_RIL_ERR_CID;
                 } else {
                     if(apn_conf_support(apn->cid)) {
-                        if(req_apn_set(apn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_apn_set(cli_info->port, apn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1311,7 +1311,7 @@
                                 LOGE("Save APN fail.");
                             }
 
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                         }
                     } else {
                         err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -1352,7 +1352,7 @@
                             int index = 0;
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_CONNECTING;
 data_call_retry:
-                            if(req_data_call_start(call_info->cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                            if(req_data_call_start(cli_info->port, call_info->cid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                             {
                                 if(call_info->retry_interval[index] > 0) {
                                     LOGD("Start data call fail, will retry in %d s.", call_info->retry_interval[index]);
@@ -1378,7 +1378,7 @@
 
                                 // Get Ip informations.
                                 cme_err = MBTK_RIL_ERR_CME_NON;
-                                if(req_data_call_state_get(call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                                if(req_data_call_state_get(cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                                 {
                                     LOGD("Get net informations fail.");
                                     err = MBTK_RIL_ERR_NET_CONF;
@@ -1393,13 +1393,13 @@
 
                                     info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_CONNECTED;
 
-                                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
                                 }
                             }
                         }
                     } else if(call_info->type == MBTK_DATA_CALL_STOP) {
                         info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTING;
-                        if(req_data_call_stop(call_info->cid, call_info->timeout, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_stop(cli_info->port, call_info->cid, call_info->timeout, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1423,12 +1423,12 @@
                             }
 
                             info_list[call_info->cid - 1].act_state = RIL_ACT_STATE_DISCONNECTED;
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                         }
                     } else {
                         mbtk_ip_info_t ip_info;
                         memset(&ip_info, 0, sizeof(ip_info));
-                        if(req_data_call_state_get(call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_data_call_state_get(cli_info->port, call_info->cid ,&ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1439,7 +1439,7 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
                         }
                     }
                 }
diff --git a/mbtk/mbtk_rild_v2/src/ril_dev.c b/mbtk/mbtk_rild_v2/src/ril_dev.c
index 4d267de..d2d8c9f 100755
--- a/mbtk/mbtk_rild_v2/src/ril_dev.c
+++ b/mbtk/mbtk_rild_v2/src/ril_dev.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+CGSN
@@ -25,10 +25,10 @@
 
 OK
 */
-static int req_imei_get(void *data, int *cme_err)
+static int req_imei_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric("AT+CGSN", &response);
+    int err = at_send_command_numeric(port, "AT+CGSN", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates) {
         *cme_err = at_get_cme_error(response);
@@ -48,11 +48,11 @@
 OK
 
 */
-static int req_sn_get(void *data, int *cme_err)
+static int req_sn_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+MRD_SN=R", "+MRD_SN:", &response);
+    int err = at_send_command_singleline(port, "AT+MRD_SN=R", "+MRD_SN:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -102,10 +102,10 @@
 OK
 
 */
-static int req_version_get(void *data, int *cme_err)
+static int req_version_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("ATI", "", &response);
+    int err = at_send_command_multiline(port, "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -146,10 +146,10 @@
 OK
 
 */
-static int req_model_get(void *data, int *cme_err)
+static int req_model_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_multiline("ATI", "", &response);
+    int err = at_send_command_multiline(port, "ATI", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -187,7 +187,7 @@
 
 OK
 */
-static int req_volte_set(int state, int *cme_err)
+static int req_volte_set(ATPortType_enum port, int state, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[30] = {0};
@@ -199,7 +199,7 @@
     {
         strcpy(cmd, "AT+ACONFIG=\"IMSD=0\"");
     }
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -218,11 +218,11 @@
 
 OK
 */
-static int req_volte_get(int *state, int *cme_err)
+static int req_volte_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+ACONFIG?", "", &response);
+    int err = at_send_command_singleline(port, "AT+ACONFIG?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -264,15 +264,15 @@
 OK
 
 */
-static int req_temp_get(mbtk_temp_type_enum type, int16 *temp, int *cme_err)
+static int req_temp_get(ATPortType_enum port, mbtk_temp_type_enum type, int16 *temp, int *cme_err)
 {
     ATResponse *response = NULL;
     int err = -1;
     int tmp_int;
     if(type == MBTK_TEMP_TYPE_SOC) { // Soc
-        err = at_send_command_singleline("AT*SOCTEMP", "*SOCTEMP:", &response);
+        err = at_send_command_singleline(port, "AT*SOCTEMP", "*SOCTEMP:", &response);
     } else { // RF
-        err = at_send_command_singleline("AT*RFTEMP", "*RFTEMP:", &response);
+        err = at_send_command_singleline(port, "AT*RFTEMP", "*RFTEMP:", &response);
     }
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -316,11 +316,11 @@
 OK
 
 */
-static int req_cell_time_get(char *data, int *cme_err)
+static int req_cell_time_get(ATPortType_enum port, char *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CCLK?", "+CCLK:", &response);
+    int err = at_send_command_singleline(port, "AT+CCLK?", "+CCLK:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -354,14 +354,14 @@
 6: turn off full secondary receive.
 -1: fail
 */
-mbtk_radio_state_enum ril_radio_state_get()
+mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
     char *line;
     int ret;
 
-    err = at_send_command_singleline("AT+CFUN?", "+CFUN:", &p_response);
+    err = at_send_command_singleline(port, "AT+CFUN?", "+CFUN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -387,7 +387,7 @@
     return MBTK_RADIO_STATE_UNKNOWN;
 }
 
-mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset)
+mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset)
 {
     int err;
     ATResponse *p_response = NULL;
@@ -407,13 +407,13 @@
     } else {
         snprintf(cmd, sizeof(cmd), "AT+CFUN=%d", state);
     }
-    err = at_send_command(cmd, &p_response);
+    err = at_send_command(port, cmd, &p_response);
     if (err || !p_response->success) {
         goto done;
     }
 
     if(state == MBTK_RADIO_STATE_FULL_FUNC) { // +CFUN=1
-        if(ril_radio_state_get() == MBTK_RADIO_STATE_FULL_FUNC) { // success
+        if(ril_radio_state_get(port) == MBTK_RADIO_STATE_FULL_FUNC) { // success
             ril_info.radio_state = MBTK_RADIO_STATE_FULL_FUNC;
             ret = MBTK_RIL_ERR_SUCCESS;
             LOGD("Radio open success.");
@@ -446,7 +446,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get IMEI
             {
                 char imei[20] = {0};
-                if(req_imei_get(imei, &cme_err) || strlen(imei) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imei_get(cli_info->port, imei, &cme_err) || strlen(imei) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -457,7 +457,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imei, strlen(imei));
                 }
             }
             else     // Set IMEI(Unsupport).
@@ -472,7 +472,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char sn[20] = {0};
-                if(req_sn_get(sn, &cme_err) || strlen(sn) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sn_get(cli_info->port, sn, &cme_err) || strlen(sn) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -483,7 +483,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, sn, strlen(sn));
                 }
             }
             else     // Set
@@ -512,7 +512,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char version[50] = {0};
-                if(req_version_get(version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_version_get(cli_info->port, version, &cme_err) || strlen(version) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -523,7 +523,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, version, strlen(version));
                 }
             }
             else     // Set
@@ -538,7 +538,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char model[50] = {0};
-                if(req_model_get(model, &cme_err) || strlen(model) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_model_get(cli_info->port, model, &cme_err) || strlen(model) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -549,7 +549,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, model, strlen(model));
                 }
             }
             else     // Set
@@ -564,7 +564,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_volte_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -575,7 +575,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -589,7 +589,7 @@
                 }
 
                 uint8 on = *(pack->data);
-                if(req_volte_set(on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_volte_set(cli_info->port, on, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -600,7 +600,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
 
                     // Restart is required to take effect.
                     // LOG("Will reboot system...");
@@ -613,7 +613,7 @@
             if(pack->data && pack->data_len == sizeof(uint8)) {
                 int16 temp;
                 mbtk_temp_type_enum type = (mbtk_temp_type_enum)(*(pack->data));
-                if(req_temp_get(type, &temp, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_temp_get(cli_info->port, type, &temp, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -624,7 +624,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &temp, sizeof(int16));
                 }
             } else {
                 err = MBTK_RIL_ERR_UNSUPPORTED;
@@ -637,7 +637,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get Time
             {
                 char time[100] = {0};
-                if(req_cell_time_get(time, &cme_err) || strlen(time) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_time_get(cli_info->port, time, &cme_err) || strlen(time) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -648,7 +648,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, time, strlen(time));
                 }
             }
             else     // Set Time
@@ -662,7 +662,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_radio_state_enum radio_state = ril_radio_state_get();
+                mbtk_radio_state_enum radio_state = ril_radio_state_get(cli_info->port);
                 if(radio_state == MBTK_RADIO_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -670,7 +670,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &radio_state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -679,9 +679,9 @@
                 if(pack->data && pack->data_len == 2) {
                     mbtk_radio_state_enum radio_state = (mbtk_radio_state_enum)(*(pack->data));
                     bool reset = *(pack->data + 1);
-                    err = ril_radio_state_set(radio_state, reset);
+                    err = ril_radio_state_set(cli_info->port, radio_state, reset);
                     if(MBTK_RIL_ERR_SUCCESS == err) {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 } else {
                     err = MBTK_RIL_ERR_FORMAT;
diff --git a/mbtk/mbtk_rild_v2/src/ril_ecall.c b/mbtk/mbtk_rild_v2/src/ril_ecall.c
index 3c61159..60b64c5 100755
--- a/mbtk/mbtk_rild_v2/src/ril_ecall.c
+++ b/mbtk/mbtk_rild_v2/src/ril_ecall.c
@@ -19,9 +19,9 @@
 
 static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
-static int cfg_ecalldata_get(mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
+static int cfg_ecalldata_get(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 *value, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
@@ -30,7 +30,7 @@
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type);
-    err = at_send_command_singleline(cmd, "*ECALLDATA:", &response);
+    err = at_send_command_singleline(port, cmd, "*ECALLDATA:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -70,14 +70,14 @@
     return err;
 }
 
-static int cfg_ecalldata_set(mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
+static int cfg_ecalldata_set(ATPortType_enum port, mbtk_ecall_cfg_item_enum type, uint32 value, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d,%d", type, value / 20);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -89,14 +89,14 @@
     return err;
 }
 
-static int cfg_ecalltimer_set(const char* type, uint32 value, int *cme_err)
+static int cfg_ecalltimer_set(ATPortType_enum port, const char* type, uint32 value, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     int err = 0;
 
     snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=%s,%d", type, value);
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -108,12 +108,12 @@
     return err;
 }
 
-static int req_ecall_msdcfg(mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_msdcfg(ATPortType_enum port, mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLMSDCFG=%d,\"%s\",0", cfg_info->item_type, cfg_info->data);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -124,10 +124,10 @@
     return err;
 }
 
-static int req_ecall_msdgen(int *cme_err)
+static int req_ecall_msdgen(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT*ECALLMSDGEN", &response);
+    int err = at_send_command(port, "AT*ECALLMSDGEN", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -138,12 +138,12 @@
     return err;
 }
 
-static int req_ecall_msd_set(const uint8 *msd, int *cme_err)
+static int req_ecall_msd_set(ATPortType_enum port, const uint8 *msd, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLMSD=\"%s\"", msd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -154,11 +154,11 @@
     return err;
 }
 
-static int req_ecall_msd_get(uint8 *msd, int *cme_err)
+static int req_ecall_msd_get(ATPortType_enum port, uint8 *msd, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLMSD?", "*ECALLMSD:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLMSD?", "*ECALLMSD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -188,10 +188,10 @@
     return err;
 }
 
-static int req_ecall_push(int *cme_err)
+static int req_ecall_push(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command("AT*ECALLPUSH", &response);
+    int err = at_send_command(port, "AT*ECALLPUSH", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -209,12 +209,12 @@
 OK
 
 */
-static int req_ecall_only_get(mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_get(ATPortType_enum port, mbtk_ecall_only_info_t *only_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT*ECALLONLY?", "*ECALLONLY:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLONLY?", "*ECALLONLY:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -275,12 +275,12 @@
 OK
 
 */
-static int req_ecall_only_set(const mbtk_ecall_only_info_t *only_info, int *cme_err)
+static int req_ecall_only_set(ATPortType_enum port, const mbtk_ecall_only_info_t *only_info, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT*ECALLONLY=%d,%s,%s", only_info->active,only_info->test_num,only_info->reconfig_num);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -295,12 +295,12 @@
 AT*ECALLREG=0/1
 
 */
-static int req_ecall_reg_set(uint8 reg, int *cme_err)
+static int req_ecall_reg_set(ATPortType_enum port, uint8 reg, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[30] = {0};
     sprintf(cmd, "AT*ECALLREG=%d", reg);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -318,11 +318,11 @@
 OK
 
 */
-static int req_ecall_dial_state_get(mbtk_ecall_dial_type_enum *type, int *cme_err)
+static int req_ecall_dial_state_get(ATPortType_enum port, mbtk_ecall_dial_type_enum *type, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+CECALL?", "+CECALL:", &response);
+    int err = at_send_command_singleline(port, "AT+CECALL?", "+CECALL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -353,12 +353,12 @@
 AT+CECALL=<ecalltype>
 OK
 */
-static int req_ecall_dial_start(mbtk_ecall_dial_type_enum type, int *cme_err)
+static int req_ecall_dial_start(ATPortType_enum port, mbtk_ecall_dial_type_enum type, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
     sprintf(cmd, "AT+CECALL=%d", type);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -377,11 +377,11 @@
 OK
 
 */
-static int req_ecall_mode_get(mbtk_ecall_mode_type_enum *mode, int *cme_err)
+static int req_ecall_mode_get(ATPortType_enum port, mbtk_ecall_mode_type_enum *mode, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLMODE?", "*ECALLMODE:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLMODE?", "*ECALLMODE:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -424,7 +424,7 @@
 OK
 
 */
-static int req_ecall_mode_set(mbtk_ecall_mode_type_enum mode, int *cme_err)
+static int req_ecall_mode_set(ATPortType_enum port, mbtk_ecall_mode_type_enum mode, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[1024] = {0};
@@ -433,7 +433,7 @@
     } else {
         sprintf(cmd, "AT*ECALLMODE=\"ERA\"");
     }
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -458,7 +458,7 @@
 OK
 
 */
-static int req_ecall_cfg_get(uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
+static int req_ecall_cfg_get(ATPortType_enum port, uint32 type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
@@ -468,7 +468,7 @@
     cfg->type = type;
 
     if(type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T3, &(cfg->data[MBTK_ECALL_CFG_ITEM_T3]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -477,7 +477,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T5, &(cfg->data[MBTK_ECALL_CFG_ITEM_T5]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -486,7 +486,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T6, &(cfg->data[MBTK_ECALL_CFG_ITEM_T6]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -495,7 +495,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_T7, &(cfg->data[MBTK_ECALL_CFG_ITEM_T7]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -504,7 +504,7 @@
     }
 
     if(type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_get(MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
+        if(cfg_ecalldata_get(port, MBTK_ECALL_CFG_ITEM_TH, &(cfg->data[MBTK_ECALL_CFG_ITEM_TH]), cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -515,7 +515,7 @@
     if(type & (MBTK_ECALL_CFG_TIMER_CALLBACK | MBTK_ECALL_CFG_TIMER_CLEARDOWN | MBTK_ECALL_CFG_TIMER_DEREG
                 | MBTK_ECALL_CFG_TIMER_DIAL | MBTK_ECALL_CFG_TIMER_REDIAL | MBTK_ECALL_CFG_TIMER_SMS
                 | MBTK_ECALL_CFG_REDIALCNT | MBTK_ECALL_CFG_SMSPROCESS | MBTK_ECALL_CFG_SMSMSDCNT)) {
-        err = at_send_command_singleline("AT*ECALLTIMER?", "*ECALLTIMER:", &response);
+        err = at_send_command_singleline(port, "AT*ECALLTIMER?", "*ECALLTIMER:", &response);
         if (err < 0 || response->success == 0 || !response->p_intermediates){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -632,7 +632,7 @@
 AT*ECALLTIMER=dereg,300
 OK
 */
-static int req_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
+static int req_ecall_cfg_set(ATPortType_enum port, const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
 {
     int err = 0;
     if(ecall_mode == MBTK_ECALL_MODE_TYPE_EU) {
@@ -647,7 +647,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T3) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T3, cfg_info->data[MBTK_ECALL_CFG_ITEM_T3], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -655,7 +655,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T5) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T5, cfg_info->data[MBTK_ECALL_CFG_ITEM_T5], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -663,7 +663,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T6) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T6, cfg_info->data[MBTK_ECALL_CFG_ITEM_T6], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -671,7 +671,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_T7) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_T7, cfg_info->data[MBTK_ECALL_CFG_ITEM_T7], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -679,7 +679,7 @@
     }
 
     if(cfg_info->type & MBTK_ECALL_CFG_TH) {
-        if(cfg_ecalldata_set(MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
+        if(cfg_ecalldata_set(port, MBTK_ECALL_CFG_ITEM_TH, cfg_info->data[MBTK_ECALL_CFG_ITEM_TH], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON)
         {
             goto exit;
@@ -688,63 +688,63 @@
 
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CALLBACK)
     {
-        if(cfg_ecalltimer_set("callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "callback", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_TIMER_CLEARDOWN)
     {
-        if(cfg_ecalltimer_set("cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "cleardown", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DEREG)
     {
-        if(cfg_ecalltimer_set("dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "dereg", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DEREG] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_DIAL)
     {
-        if(cfg_ecalltimer_set("dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "dial", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_REDIAL)
     {
-        if(cfg_ecalltimer_set("redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "redialtmr", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_REDIAL] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_TIMER_SMS)
     {
-        if(cfg_ecalltimer_set("sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
+        if(cfg_ecalltimer_set(port, "sms", cfg_info->data[MBTK_ECALL_CFG_ITEM_TIMER_SMS] / 1000, cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_REDIALCNT)
     {
-        if(cfg_ecalltimer_set("redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
+        if(cfg_ecalltimer_set(port, "redialcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_REDIALCNT], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSPROCESS)
     {
-        if(cfg_ecalltimer_set("smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
+        if(cfg_ecalltimer_set(port, "smsprocess", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSPROCESS], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
     }
     if(cfg_info->type & MBTK_ECALL_CFG_ITEM_SMSMSDCNT)
     {
-        if(cfg_ecalltimer_set("smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
+        if(cfg_ecalltimer_set(port, "smsmsdcnt", cfg_info->data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT], cme_err)
             || *cme_err != MBTK_RIL_ERR_CME_NON) {
             goto exit;
         }
@@ -759,12 +759,12 @@
 OK
 
 */
-static int req_ecall_spkmute_set(int mute, int *cme_err)
+static int req_ecall_spkmute_set(ATPortType_enum port, int mute, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*ECALLMUTESPK=%d", mute);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -783,11 +783,11 @@
 OK
 
 */
-static int req_ecall_sms_num_get(uint8 *number, int *cme_err)
+static int req_ecall_sms_num_get(ATPortType_enum port, uint8 *number, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
+    int err = at_send_command_singleline(port, "AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -822,12 +822,12 @@
 OK
 
 */
-static int req_ecall_sms_num_set(const uint8 *number, int *cme_err)
+static int req_ecall_sms_num_set(ATPortType_enum port, const uint8 *number, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*ECALLSMSNUM=%s", number);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -843,12 +843,12 @@
 OK
 
 */
-static int req_ecall_gain_set(mbtk_ecall_gain_info_t *gain, int *cme_err)
+static int req_ecall_gain_set(ATPortType_enum port, mbtk_ecall_gain_info_t *gain, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
     sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -877,7 +877,7 @@
             else     // Set
             {
                 mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
-                if(req_ecall_msdcfg(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdcfg(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -888,7 +888,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -897,7 +897,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msdgen(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msdgen(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -908,7 +908,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -923,7 +923,7 @@
             memset(msd, 0, sizeof(msd));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_msd_get(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_get(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -934,13 +934,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, msd, strlen((char*)msd));
                 }
             }
             else     // Set
             {
                 memcpy(msd, pack->data, pack->data_len);
-                if(req_ecall_msd_set(msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_msd_set(cli_info->port, msd, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -951,7 +951,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -960,7 +960,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_push(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_push(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -971,7 +971,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             else     // Set
@@ -986,7 +986,7 @@
             {
                 mbtk_ecall_only_info_t only_info;
                 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
-                if(req_ecall_only_get(&only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_get(cli_info->port, &only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -997,13 +997,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &only_info, sizeof(mbtk_ecall_only_info_t));
                 }
             }
             else     // Set
             {
                 mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data);
-                if(req_ecall_only_set(only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_only_set(cli_info->port, only_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1014,7 +1014,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1028,7 +1028,7 @@
             else
             {
                 uint8 reg = pack->data[0];
-                if(req_ecall_reg_set(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_reg_set(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1039,7 +1039,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1049,7 +1049,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_dial_type_enum type;
-                if(req_ecall_dial_state_get(&type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_state_get(cli_info->port, &type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1060,13 +1060,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &type, sizeof(uint8));
                 }
             }
             else
             {
                 mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0];
-                if(req_ecall_dial_start(type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_dial_start(cli_info->port, type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1077,7 +1077,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1087,7 +1087,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_ecall_mode_type_enum mode;
-                if(req_ecall_mode_get(&mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_get(cli_info->port, &mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1098,13 +1098,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &mode, sizeof(uint8));
                 }
             }
             else
             {
                 mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0];
-                if(req_ecall_mode_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_mode_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1115,7 +1115,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1130,7 +1130,7 @@
             {
                 if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set
                     mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data;
-                    if(req_ecall_cfg_set(cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_set(cli_info->port, cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1141,13 +1141,13 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 } else { // Get
                     mbtk_ecall_cfg_info_t cfg_info;
                     memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t));
                     uint32 *type = (uint32*)(pack->data);
-                    if(req_ecall_cfg_get(*type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_ecall_cfg_get(cli_info->port, *type, &cfg_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1158,7 +1158,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
                     }
                 }
             }
@@ -1170,7 +1170,7 @@
             memset(number, 0, sizeof(number));
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                if(req_ecall_sms_num_get(number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_get(cli_info->port, number, &cme_err) || strlen((char*)number) == 0 || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1181,13 +1181,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, number, strlen((char*)number));
                 }
             }
             else     // Set
             {
                 memcpy(number, pack->data, pack->data_len);
-                if(req_ecall_sms_num_set(number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_sms_num_set(cli_info->port, number, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1198,7 +1198,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1219,7 +1219,7 @@
                     break;
                 }
 
-                if(req_ecall_spkmute_set(mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_spkmute_set(cli_info->port, mute, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1230,7 +1230,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1244,7 +1244,7 @@
             else     // Set
             {
                 mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
-                if(req_ecall_gain_set(gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_ecall_gain_set(cli_info->port, gain_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1255,7 +1255,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index 8aacb7c..837f1cc 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -23,7 +23,7 @@
 mbtk_cell_pack_info_t cell_info;
 
 extern ril_band_info_t band_info;
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+COPS=?
@@ -32,10 +32,10 @@
 
 OK
 */
-static int req_available_net_get(mbtk_net_info_array_t* nets, int *cme_err)
+static int req_available_net_get(ATPortType_enum port, mbtk_net_info_array_t* nets, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_singleline("AT+COPS=?", "+COPS:", &response);
+    int err = at_send_command_singleline(port, "AT+COPS=?", "+COPS:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
@@ -130,14 +130,14 @@
 OK
 
 */
-static int req_net_sel_mode_get(mbtk_net_info_t *net, int *cme_err)
+static int req_net_sel_mode_get(ATPortType_enum port, mbtk_net_info_t *net, int *cme_err)
 {
     //LOG("req_net_sel_mode_get() 0");
     //sleep(1);
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
+    int err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
     //LOG("req_net_sel_mode_get() 00");
     //sleep(1);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -216,7 +216,7 @@
 OK
 
 */
-static int req_net_sel_mode_set(mbtk_net_info_t* net, int *cme_err)
+static int req_net_sel_mode_set(ATPortType_enum port, mbtk_net_info_t* net, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[50] = {0};
@@ -233,7 +233,7 @@
         }
      }
 
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         if(cme_err) {
@@ -252,7 +252,7 @@
 OK
 
 */
-static int req_band_set(mbtk_band_info_t* band, int *cme_err)
+static int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
@@ -305,7 +305,7 @@
 
         if(band->net_pref == 0xFF) { // No change net_pref.
             int tmp_int;
-            err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
+            err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
             if (err < 0 || response->success == 0 || !response->p_intermediates){
                 if(cme_err) {
                     *cme_err = at_get_cme_error(response);
@@ -336,7 +336,7 @@
             sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band);
         }
     }
-    err = at_send_command(cmd, &response);
+    err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0){
         if(cme_err) {
@@ -417,13 +417,13 @@
     65536 ?C FDDLTE _BAND_17
     524288 ?C FDDLTE _BAND_20
 */
-static int req_band_get(mbtk_band_info_t *band, int *cme_err)
+static int req_band_get(ATPortType_enum port, mbtk_band_info_t *band, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
 
     log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t));
-    int err = at_send_command_singleline("AT*BAND?", "*BAND:", &response);
+    int err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -533,13 +533,13 @@
 OK
 
 */
-static int req_net_signal_get(mbtk_signal_info_t *signal, int *cme_err)
+static int req_net_signal_get(ATPortType_enum port, mbtk_signal_info_t *signal, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_ptr = NULL;
     // AT+EEMOPT=1 in the first.
-    int err = at_send_command_singleline("AT+CSQ", "+CSQ:", &response);
+    int err = at_send_command_singleline(port, "AT+CSQ", "+CSQ:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -561,7 +561,7 @@
     signal->rssi = (uint8)tmp_int;
     at_response_free(response);
 
-    err = at_send_command_singleline("AT+CESQ", "+CESQ:", &response);
+    err = at_send_command_singleline(port, "AT+CESQ", "+CESQ:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -618,7 +618,7 @@
     signal->rsrp = (uint8)tmp_int;
 
     at_response_free(response);
-    err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
+    err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err != NULL)
             *cme_err = at_get_cme_error(response);
@@ -693,12 +693,12 @@
 
 
 */
-static int req_net_reg_get(mbtk_net_reg_info_t *reg, int *cme_err)
+static int req_net_reg_get(ATPortType_enum port, mbtk_net_reg_info_t *reg, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     char *tmp_str = NULL;
-    int err = at_send_command("AT+CREG=3", &response);
+    int err = at_send_command(port, "AT+CREG=3", &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -707,7 +707,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CREG?", "+CREG:", &response);
+    err = at_send_command_multiline(port, "AT+CREG?", "+CREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -757,7 +757,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CEREG?", "+CEREG:", &response);
+    err = at_send_command_multiline(port, "AT+CEREG?", "+CEREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -807,7 +807,7 @@
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CIREG?", "+CIREG:", &response);
+    err = at_send_command_multiline(port, "AT+CIREG?", "+CIREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         reg->ims_state = (uint8)0;
         err = 0;
@@ -1039,13 +1039,13 @@
 OK
 
 */
-static int req_cell_info_get(int *cme_err)
+static int req_cell_info_get(ATPortType_enum port, int *cme_err)
 {
     ATResponse *response = NULL;
     int tmp_int;
     int buff_size = 0;
     // AT+EEMOPT=1 in the first.
-    int err = at_send_command("AT+EEMOPT=1", &response);
+    int err = at_send_command(port, "AT+EEMOPT=1", &response);
     if (err < 0 || response->success == 0){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1056,7 +1056,7 @@
     cell_info.running = true;
     cell_info.cell_list.num = 0;
 
-    err = at_send_command_singleline("AT+EEMGINFO?", "+EEMGINFO:", &response);
+    err = at_send_command_singleline(port, "AT+EEMGINFO?", "+EEMGINFO:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
         goto exit;
@@ -1147,7 +1147,7 @@
     return buff_size;
 }
 
-static int req_cell_info_set(const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cell_info_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[500] = {0};
@@ -1160,7 +1160,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -1202,7 +1202,7 @@
             {
                 mbtk_net_info_array_t net_array;
                 memset(&net_array, 0, sizeof(mbtk_net_info_array_t));
-                if(req_available_net_get(&net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_available_net_get(cli_info->port, &net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1213,7 +1213,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
                 }
             }
             else     // Set
@@ -1229,7 +1229,7 @@
             {
                 mbtk_net_info_t info;
                 memset(&info, 0, sizeof(mbtk_net_info_t));
-                if(req_net_sel_mode_get(&info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1240,13 +1240,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_net_info_t));
                 }
             }
             else     // Set
             {
                 mbtk_net_info_t *info = (mbtk_net_info_t*)pack->data;
-                if(req_net_sel_mode_set(info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_sel_mode_set(cli_info->port, info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1257,7 +1257,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1275,7 +1275,7 @@
                     if(*(pack->data)) { // Get current bands.
                         mbtk_band_info_t band;
                         memset(&band, 0x0, sizeof(mbtk_band_info_t));
-                        if(req_band_get(&band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                        if(req_band_get(cli_info->port, &band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                         {
                             if(cme_err != MBTK_RIL_ERR_CME_NON) {
                                 err = MBTK_RIL_ERR_CME + cme_err;
@@ -1286,10 +1286,10 @@
                         }
                         else
                         {
-                            ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
+                            ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
                         }
                     } else { // Get support bands.
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
                     }
                 } else { // Set current bands.
                     mbtk_band_info_t* band = (mbtk_band_info_t*)pack->data;
@@ -1300,7 +1300,7 @@
                         break;
                     }
 
-                    if(req_band_set(band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                    if(req_band_set(cli_info->port, band, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                     {
                         if(cme_err != MBTK_RIL_ERR_CME_NON) {
                             err = MBTK_RIL_ERR_CME + cme_err;
@@ -1311,7 +1311,7 @@
                     }
                     else
                     {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                        ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                     }
                 }
             }
@@ -1323,7 +1323,7 @@
             {
                 mbtk_signal_info_t signal;
                 memset(&signal, 0, sizeof(mbtk_signal_info_t));
-                if(req_net_signal_get(&signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_signal_get(cli_info->port, &signal, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1334,7 +1334,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &signal, sizeof(mbtk_signal_info_t));
                 }
             }
             else     // Set
@@ -1350,7 +1350,7 @@
             {
                 mbtk_net_reg_info_t net_reg;
                 memset(&net_reg, 0, sizeof(mbtk_net_reg_info_t));
-                if(req_net_reg_get(&net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_net_reg_get(cli_info->port, &net_reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1361,7 +1361,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &net_reg, sizeof(mbtk_net_reg_info_t));
                 }
             }
             else     // Set
@@ -1375,7 +1375,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)   // Get net cell.
             {
-                if(req_cell_info_get(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_get(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1387,7 +1387,7 @@
                 else
                 {
                     LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
                 }
             }
             else     // Lock cell
@@ -1395,7 +1395,7 @@
                 char *mem = (char*)(pack->data);
                 int len = pack->data_len;
                 char reg[100] = {0};
-                if(req_cell_info_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cell_info_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1405,7 +1405,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
diff --git a/mbtk/mbtk_rild_v2/src/ril_pb.c b/mbtk/mbtk_rild_v2/src/ril_pb.c
index 522f578..1d93cc9 100755
--- a/mbtk/mbtk_rild_v2/src/ril_pb.c
+++ b/mbtk/mbtk_rild_v2/src/ril_pb.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 //void net_list_free(void *data);
 // Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
diff --git a/mbtk/mbtk_rild_v2/src/ril_sim.c b/mbtk/mbtk_rild_v2/src/ril_sim.c
index 78ef0f0..fc9221e 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sim.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sim.c
@@ -17,10 +17,10 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /** Returns SIM_NOT_READY on error */
-mbtk_sim_state_enum ril_sim_state_get()
+mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port)
 {
     ATResponse *p_response = NULL;
     int err;
@@ -28,7 +28,7 @@
     char *cpinLine;
     char *cpinResult;
 
-    err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response);
+    err = at_send_command_singleline(port, "AT+CPIN?", "+CPIN:", &p_response);
 
     if (err < 0 || p_response->success == 0 || !p_response->p_intermediates)
     {
@@ -154,11 +154,11 @@
 
 OK
 */
-static int req_sim_type_get(uint8 *type, int *cme_err)
+static int req_sim_type_get(ATPortType_enum port, uint8 *type, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT*EUICC?", "*EUICC:", &response);
+    int err = at_send_command_singleline(port, "AT*EUICC?", "*EUICC:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -191,11 +191,11 @@
 
 OK
 */
-static int req_iccid_get(void *data, int *cme_err)
+static int req_iccid_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+ICCID", "+ICCID:", &response);
+    int err = at_send_command_singleline(port, "AT+ICCID", "+ICCID:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -228,11 +228,11 @@
 OK
 
 */
-static int req_phone_number_get(void *data, int *cme_err)
+static int req_phone_number_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
     char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CNUM?", "+CNUM:", &response);
+    int err = at_send_command_singleline(port, "AT+CNUM?", "+CNUM:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -278,10 +278,10 @@
 OK
 
 */
-static int req_imsi_get(void *data, int *cme_err)
+static int req_imsi_get(ATPortType_enum port, void *data, int *cme_err)
 {
     ATResponse *response = NULL;
-    int err = at_send_command_numeric("AT+CIMI", &response);
+    int err = at_send_command_numeric(port, "AT+CIMI", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -294,12 +294,12 @@
     return err;
 }
 
-static int req_sim_lock_state_get(int *state, int *cme_err)
+static int req_sim_lock_state_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char cmd[64]={0};
 
-    int err = at_send_command_singleline("AT+CLCK=SC,2", "+CLCK:", &response);
+    int err = at_send_command_singleline(port, "AT+CLCK=SC,2", "+CLCK:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -343,12 +343,12 @@
 
 *
 */
-static int req_sim_lock_switch(bool enable, uint8* pin, int *cme_err)
+static int req_sim_lock_switch(ATPortType_enum port, bool enable, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     snprintf(cmd, sizeof(cmd), "AT+CLCK=SC,%d,%s", enable ? 1 : 0, pin);
-    int err = at_send_command_singleline(cmd, "+CLCK:", &response);
+    int err = at_send_command_singleline(port, cmd, "+CLCK:", &response);
     if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates){
         if(response) {
             *cme_err = at_get_cme_error(response);
@@ -393,22 +393,22 @@
     return err;
 }
 
-static int req_sim_pin_change(uint8* old_pin, uint8 *new_pin, int *cme_err)
+static int req_sim_pin_change(ATPortType_enum port, uint8* old_pin, uint8 *new_pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[128]={0};
     int err = 0;
     int state;
-    if(req_sim_lock_state_get(&state, cme_err) || *cme_err != MBTK_RIL_ERR_CME_NON)
+    if(req_sim_lock_state_get(port, &state, cme_err) || *cme_err != MBTK_RIL_ERR_CME_NON)
     {
         return -1;
     }
 
     if(state == 0) { // Sim lock not open.
-        return req_sim_lock_switch(TRUE, new_pin, cme_err);
+        return req_sim_lock_switch(port, TRUE, new_pin, cme_err);
     } else {// Change password.
         snprintf(cmd, sizeof(cmd), "AT+CPWD=SC,%s,%s", old_pin, new_pin);
-        err = at_send_command(cmd, &response);
+        err = at_send_command(port, cmd, &response);
         if (err < 0 || response->success == 0){
             if(cme_err) {
                 *cme_err = at_get_cme_error(response);
@@ -422,12 +422,12 @@
     return err;
 }
 
-static int req_sim_pin_verify(uint8* pin, int *cme_err)
+static int req_sim_pin_verify(ATPortType_enum port, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     sprintf(cmd, "AT+CPIN=%s", pin);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -440,12 +440,12 @@
     return err;
 }
 
-static int req_sim_puk_verify(uint8* puk, uint8* pin, int *cme_err)
+static int req_sim_puk_verify(ATPortType_enum port, uint8* puk, uint8* pin, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[64]={0};
     sprintf(cmd, "AT+CPIN=%s,%s", puk, pin);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
     if (err < 0 || response->success == 0){
         if(cme_err) {
             *cme_err = at_get_cme_error(response);
@@ -458,29 +458,29 @@
     return err;
 }
 
-static int req_sim_lock_set(mbtk_sim_lock_info_t *lock_info, int *cme_err)
+static int req_sim_lock_set(ATPortType_enum port, mbtk_sim_lock_info_t *lock_info, int *cme_err)
 {
     switch(lock_info->type)
     {
         case MBTK_SIM_LOCK_TYPE_DISABLE:
         {
-            return req_sim_lock_switch(FALSE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(port, FALSE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_ENABLE:
         {
-            return req_sim_lock_switch(TRUE, lock_info->pin1, cme_err);
+            return req_sim_lock_switch(port, TRUE, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_CHANGE:
         {
-            return req_sim_pin_change(lock_info->pin1, lock_info->pin2, cme_err);
+            return req_sim_pin_change(port, lock_info->pin1, lock_info->pin2, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PIN:
         {
-            return req_sim_pin_verify(lock_info->pin1, cme_err);
+            return req_sim_pin_verify(port, lock_info->pin1, cme_err);
         }
         case MBTK_SIM_LOCK_TYPE_VERIFY_PUK:
         {
-            return req_sim_puk_verify(lock_info->puk, lock_info->pin1, cme_err);
+            return req_sim_puk_verify(port, lock_info->puk, lock_info->pin1, cme_err);
         }
         default:
         {
@@ -498,12 +498,12 @@
 
 OK
 */
-static int req_pin_puk_last_times_get(mbtk_pin_puk_last_times_t *times, int *cme_err)
+static int req_pin_puk_last_times_get(ATPortType_enum port, mbtk_pin_puk_last_times_t *times, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
     int tmp_int;
-    int err = at_send_command_singleline("AT+EPIN?", "+EPIN:", &response);
+    int err = at_send_command_singleline(port, "AT+EPIN?", "+EPIN:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -558,11 +558,11 @@
 
 OK
 */
-static int req_plmn_get(mbtk_plmn_info *info, int *cme_err)
+static int req_plmn_get(ATPortType_enum port, mbtk_plmn_info *info, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_multiline("AT+CPOL?", "+CPOL:", &response);
+    int err = at_send_command_multiline(port, "AT+CPOL?", "+CPOL:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -627,7 +627,7 @@
         {
             if(pack->data_len == 0 || pack->data == NULL)
             {
-                mbtk_sim_state_enum state = ril_sim_state_get();
+                mbtk_sim_state_enum state = ril_sim_state_get(cli_info->port);
                 if(state == MBTK_SIM_STATE_UNKNOWN)
                 {
                     err = MBTK_RIL_ERR_UNKNOWN;
@@ -635,7 +635,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set
@@ -650,7 +650,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 uint8 sim_card_type;
-                if(req_sim_type_get(&sim_card_type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_type_get(cli_info->port, &sim_card_type, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -661,7 +661,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &sim_card_type, sizeof(uint8));
                 }
             }
             else     // Set
@@ -676,7 +676,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char imsi[20] = {0};
-                if(req_imsi_get(imsi, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_imsi_get(cli_info->port, imsi, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -687,7 +687,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, imsi, strlen(imsi));
                 }
             }
             else     // Set
@@ -702,7 +702,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char pn[50] = {0};
-                if(req_phone_number_get(pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_phone_number_get(cli_info->port, pn, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -713,7 +713,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, pn, strlen(pn));
                 }
             }
             else     // Set
@@ -728,7 +728,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 char iccid[50] = {0};
-                if(req_iccid_get(iccid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_iccid_get(cli_info->port, iccid, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -739,7 +739,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, iccid, strlen(iccid));
                 }
             }
             else     // Set
@@ -754,7 +754,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 int state;
-                if(req_sim_lock_state_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_state_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -765,13 +765,13 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set
             {
                 mbtk_sim_lock_info_t *lock_info = (mbtk_sim_lock_info_t*)pack->data;
-                if(req_sim_lock_set(lock_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_sim_lock_set(cli_info->port, lock_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -782,7 +782,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -792,7 +792,7 @@
             if(pack->data_len == 0 || pack->data == NULL)
             {
                 mbtk_pin_puk_last_times_t last_times;
-                if(req_pin_puk_last_times_get(&last_times, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_pin_puk_last_times_get(cli_info->port, &last_times, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -803,7 +803,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &last_times, sizeof(mbtk_pin_puk_last_times_t));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &last_times, sizeof(mbtk_pin_puk_last_times_t));
                 }
             }
             else     // Set
@@ -819,7 +819,7 @@
             {
                 mbtk_plmn_info info;
                 memset(&info, 0, sizeof(mbtk_plmn_info));
-                if(req_plmn_get(&info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_plmn_get(cli_info->port, &info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -830,7 +830,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &info, sizeof(mbtk_plmn_info));
                 }
             }
             else     // Set
diff --git a/mbtk/mbtk_rild_v2/src/ril_sms.c b/mbtk/mbtk_rild_v2/src/ril_sms.c
index c2c87d6..bb64f34 100755
--- a/mbtk/mbtk_rild_v2/src/ril_sms.c
+++ b/mbtk/mbtk_rild_v2/src/ril_sms.c
@@ -17,7 +17,7 @@
 #include "mbtk_utils.h"
 #include "ril_info.h"
 
-void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
+void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
 
 /*
 AT+CMGF?
@@ -26,11 +26,11 @@
 OK
 
 */
-static int req_cmgf_get(int *state, int *cme_err)
+static int req_cmgf_get(ATPortType_enum port, int *state, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CMGF?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CMGF?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -61,7 +61,7 @@
 
 OK
 */
-static int req_cmgf_set(int state, int *cme_err)
+static int req_cmgf_set(ATPortType_enum port, int state, int *cme_err)
 {
     LOGD("req_cmgf_set()-------------start");
     LOGD("state:%d",state);
@@ -77,7 +77,7 @@
     }
 
     LOGD("req_cmgf_set()----cmd:%s", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
         *cme_err = at_get_cme_error(response);
@@ -91,7 +91,7 @@
 }
 
 /*set AT+CNMI=1,2*/
-static int req_cnmi_set(int *cme_err)
+static int req_cnmi_set(ATPortType_enum port, int *cme_err)
 {
     printf("req_cnmi_set()-------------start3\n");
     ATResponse *response = NULL;
@@ -100,7 +100,7 @@
 	strcpy(cmd, "AT+CNMI=1,2");
 
     printf("req_cnmi_set()----cmd:%s\n", cmd);
-    int err = at_send_command(cmd, &response);
+    int err = at_send_command(port, cmd, &response);
 
     if (err < 0 || response->success == 0) {
 		printf("err:%d, response->success:%d \n", err, response->success);
@@ -123,12 +123,12 @@
 OK
 
 */
-static int req_cpms_get(char *reg, int *cme_err)
+static int req_cpms_get(ATPortType_enum port, char *reg, int *cme_err)
 {
 	printf("req_cpms_get------------start(3)\n");
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CPMS?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CPMS?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -170,7 +170,7 @@
 OK
 
 */
-static int req_cpms_set(const char *mem, char *reg, int len, int *cme_err)
+static int req_cpms_set(ATPortType_enum port, const char *mem, char *reg, int len, int *cme_err)
 {
     printf("req_cpms_set(2)----------------start\n");
     printf("mem:%s\n", mem);
@@ -192,7 +192,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(cmd, "+CPMS:", &response);
+        err = at_send_command_multiline(port, cmd, "+CPMS:", &response);
         if (err < 0 || response->success == 0){
             *cme_err = at_get_cme_error(response);
             goto exit;
@@ -224,7 +224,7 @@
 
 
 */
-static int req_cmgs_set(char *cmgs, char *reg, int len, int *cme_err)
+static int req_cmgs_set(ATPortType_enum port, char *cmgs, char *reg, int len, int *cme_err)
 {
     LOGD("req_cmgs_set()----------------start");
     LOGD("cmgs:%s", cmgs);
@@ -262,7 +262,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(cmd, data, "+CMGS: ", &response);
+		int err = at_send_command_sms(port, cmd, data, "+CMGS: ", &response);
 		LOGD("err:%d, response:%d", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -281,7 +281,7 @@
     return err;
 }
 
-static int req_cmgw_set(char *cmgw,int len, int *cme_err)
+static int req_cmgw_set(ATPortType_enum port, char *cmgw,int len, int *cme_err)
 {
     printf("req_cmgw_set()----------------start\n");
     printf("cmgw:%s\n", cmgw);
@@ -307,7 +307,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command_sms(cmd, data, "+CMGW: ", &response);
+		int err = at_send_command_sms(port, cmd, data, "+CMGW: ", &response);
 		printf("err:%d, response:%d\n", err, response->success);
 
 		if (err < 0 || response->success == 0) {
@@ -330,7 +330,7 @@
 
 +MMSG: 1, 0
 */
-static int req_cmgd_set(char *cmgd, int len, int *cme_err)
+static int req_cmgd_set(ATPortType_enum port, char *cmgd, int len, int *cme_err)
 {
     printf("0req_cmgd_set()--------------start\n");
     printf("cmgd:%s\n", cmgd);
@@ -347,7 +347,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -372,11 +372,11 @@
 OK
 
 */
-static int req_cmgd_get(char *reg, int *cme_err)
+static int req_cmgd_get(ATPortType_enum port, char *reg, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CMGD=?", "+CMGD:", &response);
+    int err = at_send_command_singleline(port, "AT+CMGD=?", "+CMGD:", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -420,7 +420,7 @@
 
 */
 
-static int req_cmgl_set(const char *cmgl, char *reg, int len, int *cme_err)
+static int req_cmgl_set(ATPortType_enum port, const char *cmgl, char *reg, int len, int *cme_err)
 {
     printf("req_cmgl_set(2)-----------------start\n");
     printf("cmgl:%s\n", cmgl);
@@ -463,7 +463,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
             printf("at_send_command_multiline() is err-----------------\n");
@@ -534,11 +534,11 @@
 +CSCA: "+8613800280500",145
 OK
 */
-static int req_csca_get(char *req, int *cme_err)
+static int req_csca_get(ATPortType_enum port, char *req, int *cme_err)
 {
     ATResponse *response = NULL;
 //    char *tmp_ptr = NULL;
-    int err = at_send_command_singleline("AT+CSCA?", "", &response);
+    int err = at_send_command_singleline(port, "AT+CSCA?", "", &response);
 
     if (err < 0 || response->success == 0 || !response->p_intermediates){
         *cme_err = at_get_cme_error(response);
@@ -565,7 +565,7 @@
     return err;
 }
 
-static int req_csca_set(char *csca, int len, int *cme_err)
+static int req_csca_set(ATPortType_enum port, char *csca, int len, int *cme_err)
 {
     printf("req_csca_set()--------------start\n");
     printf("csca:%s\n", csca);
@@ -582,7 +582,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -598,7 +598,7 @@
     return err;
 }
 
-static int req_csmp_set(char *csmp, int len, int *cme_err)
+static int req_csmp_set(ATPortType_enum port, char *csmp, int len, int *cme_err)
 {
     printf("req_csmp_set()-------------------start\n");
     printf("csmp:%s\n", csmp);
@@ -615,7 +615,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -631,7 +631,7 @@
     return err;
 }
 
-static int req_cscb_set(char *cscb,int len, int *cme_err)
+static int req_cscb_set(ATPortType_enum port, char *cscb,int len, int *cme_err)
 {
     printf("req_cscb_set()----------------start\n");
     printf("cscb:%s\n", cscb);
@@ -648,7 +648,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-		int err = at_send_command(cmd, &response);
+		int err = at_send_command(port, cmd, &response);
 	    if (err < 0 || response->success == 0) {
 	        *cme_err = at_get_cme_error(response);
 	        goto exit;
@@ -669,7 +669,7 @@
 +CMSS: 81
 OK
 */
-static int req_cmss_set(const char *cmss, char *reg, int len, int *cme_err)
+static int req_cmss_set(ATPortType_enum port, const char *cmss, char *reg, int len, int *cme_err)
 {
     printf("req_cmss_set()----------------start\n");
     printf("cmss:%s\n", cmss);
@@ -692,7 +692,7 @@
 
 	if(strlen(cmd) > 8)
 	{
-        err = at_send_command_multiline(cmd, "+CMSS:", &response);
+        err = at_send_command_multiline(port, cmd, "+CMSS:", &response);
 		if (err < 0 || response->success == 0){
 			*cme_err = at_get_cme_error(response);
 			goto exit;
@@ -737,7 +737,7 @@
 
 OK
 */
-static int req_cmgr_set(int index, char *reg, int *cme_err)
+static int req_cmgr_set(ATPortType_enum port, int index, char *reg, int *cme_err)
 {
     printf("0req_cmgr_set()-------------------start\n");
     printf("index:%d\n", index);
@@ -750,7 +750,7 @@
 
 	if(strlen(cmd) > 0)
 	{
-        err = at_send_command_multiline(cmd, "", &response);
+        err = at_send_command_multiline(port, cmd, "", &response);
 		if (err < 0 || response->success == 0 || !response->p_intermediates){
 			*cme_err = at_get_cme_error(response);
             printf("at_send_command_multiline() is err-----------------\n");
@@ -802,7 +802,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 int state;
-                if(req_cmgf_get(&state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_get(cli_info->port, &state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -813,7 +813,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &state, sizeof(uint8));
                 }
             }
             else     // Set VoLTE state.
@@ -826,7 +826,7 @@
                     break;
                 }
 
-                if(req_cmgf_set(mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgf_set(cli_info->port, mode, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -837,7 +837,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -847,7 +847,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // SET at+cnmi=1,2.
             {
 //                int state;
-                if(req_cnmi_set(&cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cnmi_set(cli_info->port, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -858,7 +858,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
 			break;
@@ -868,7 +868,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[100] = {0};
-                if(req_cpms_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -879,7 +879,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -889,7 +889,7 @@
                 char reg[100] = {0};
                 LOGD("mem:%s, len:%d", pack->data, pack->data_len);
 
-                if(req_cpms_set(mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cpms_set(cli_info->port, mem, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -901,7 +901,7 @@
                 else
                 {
                     LOGD("cpms_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -919,7 +919,7 @@
 				char reg[50] ={0};
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgs, len);
 
-                if(req_cmgs_set(cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgs_set(cli_info->port, cmgs,reg,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -930,7 +930,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -948,7 +948,7 @@
                 char reg[128] = {0};
                 LOGD("mbtk_sms,cmgs:%s, len:%d", cmss, len);
 
-                if(req_cmss_set(cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmss_set(cli_info->port, cmss,reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -960,7 +960,7 @@
                 else
                 {
                     LOGD("req_cmss_set success, reg:%s", reg);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -982,7 +982,7 @@
                     break;
                 }
 
-                if(req_cmgr_set(index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgr_set(cli_info->port, index, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -993,7 +993,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             break;
@@ -1010,7 +1010,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgw:%s,len:%d", cmgw, len);
 
-                if(req_cmgw_set(cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgw_set(cli_info->port, cmgw, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1021,7 +1021,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1031,7 +1031,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char reg[1024] = {0};
-                if(req_cmgd_get(reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_get(cli_info->port, reg, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1042,7 +1042,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
                 }
             }
             else     // Set VoLTE state.
@@ -1051,7 +1051,7 @@
 				int len = pack->data_len;
                 LOGD("mbtk_sms,cmgs:%s,len:%d", cmgd, len);
 
-                if(req_cmgd_set(cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgd_set(cli_info->port, cmgd,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1062,7 +1062,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
 
             }
@@ -1081,7 +1081,7 @@
                 char reg[5*1024] = {0};
                 char reg1[1024+1] = {0};
 
-                if(req_cmgl_set(cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cmgl_set(cli_info->port, cmgl, reg, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1093,7 +1093,7 @@
                 else
                 {
                     memcpy(reg1, reg, 1024);
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, reg1, strlen(reg1));
                 }
             }
             break;
@@ -1103,7 +1103,7 @@
             if(pack->data_len == 0 || pack->data == NULL)   // Get VoLTE state.
             {
                 char csca[50]={0};
-                if(req_csca_get(csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_get(cli_info->port, csca, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1114,7 +1114,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, csca, strlen(csca));
                 }
                 err = MBTK_RIL_ERR_UNSUPPORTED;
             }
@@ -1123,7 +1123,7 @@
 				char *csca = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csca_set(csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csca_set(cli_info->port, csca, len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1134,7 +1134,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1150,7 +1150,7 @@
 				char *csmp = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_csmp_set(csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_csmp_set(cli_info->port, csmp,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1161,7 +1161,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
@@ -1177,7 +1177,7 @@
 				char *cscb = (char*)pack->data;
 				int len = pack->data_len;
 
-                if(req_cscb_set(cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_cscb_set(cli_info->port, cscb,len, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
                 {
                     if(cme_err != MBTK_RIL_ERR_CME_NON) {
                         err = MBTK_RIL_ERR_CME + cme_err;
@@ -1188,7 +1188,7 @@
                 }
                 else
                 {
-                    ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+                    ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
                 }
             }
             break;
diff --git a/mbtk/mbtk_sdk_ready_v2/src/main.c b/mbtk/mbtk_sdk_ready_v2/src/main.c
index c69729b..f0eef7d 100755
--- a/mbtk/mbtk_sdk_ready_v2/src/main.c
+++ b/mbtk/mbtk_sdk_ready_v2/src/main.c
@@ -25,7 +25,8 @@
 }mbtk_ready_status_type;
 
 static mbtk_ready_status_type mbtk_ready_status = MBTK_READY_INIT;
-static bool ril_inited = FALSE;
+static mbtk_ril_handle* ril_handle = NULL;
+
 #if 1
 static mbtk_ready_status_type modem_check(void)
 {
@@ -33,15 +34,14 @@
 //    int cme_err = 0;
 
     mbtk_ril_err_enum ret;
-    if(!ril_inited) {
-        ret = mbtk_ril_init();
-        if(ret != MBTK_RIL_ERR_SUCCESS) {
+    if(ril_handle == NULL) {
+        ril_handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
+        if(ril_handle == NULL) {
             return MBTK_READY_RIL_FAIL;
         }
-        ril_inited = TRUE;
     }
 
-    ret = mbtk_imei_get(imei);
+    ret = mbtk_imei_get(ril_handle, imei);
     //LOGE("[SDK_READY] imei = [%s], cme_err = [%d]", imei, cme_err);
     if(ret != MBTK_RIL_ERR_SUCCESS || strlen(imei) == 0)
     {
diff --git a/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c b/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v2.c
index 9ec898d..dbdce3e 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_deinit();
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
         {
             LOGI("Exit by SIGQUIT.\n");
 //            thread_exit_with_wait();
-            mbtk_ril_deinit();
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGTERM:// 默认kill   (同 SIGKILL ,但 SIGKILL 不可捕获)
         {
             LOGI("Exit by SIGTERM.\n");
 //            thread_exit_with_wait();
-            mbtk_ril_deinit();
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
@@ -176,8 +176,9 @@
     //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
     //test2(1, "2400:3200::1");
 
-    if(mbtk_ril_init() != MBTK_RIL_ERR_SUCCESS)
-    {
+    mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
+    if(handle_1 == NULL) {
+        printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
         return -1;
     }
 
@@ -205,7 +206,7 @@
                 int count = sscanf(cmd, "msdcfg %d %s", &item, cfg.data);
                 if(count == 2 && strlen((char*)cfg.data) > 0) {
                     cfg.item_type = (mbtk_ecall_msd_item_enum)item;
-                    err = mbtk_ecall_msd_item_set(&cfg);
+                    err = mbtk_ecall_msd_item_set(handle_1, &cfg);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -214,14 +215,14 @@
                 }
             }
             else if(!strncasecmp(cmd, "msdgen", 6)){
-                err = mbtk_ecall_msd_gen();
+                err = mbtk_ecall_msd_gen(handle_1);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
                     printf("MSD gen success\n");
                 }
             } else if(!strncasecmp(cmd, "msdpush", 7)){
-                err = mbtk_ecall_push();
+                err = mbtk_ecall_push(handle_1);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -230,7 +231,7 @@
             } else if(!strncasecmp(cmd, "msd", 3)){ // msd <MSD>
                 uint8 msd[500] = {0};
                 if(!strcasecmp(cmd, "msd")) { // Get
-                    err = mbtk_ecall_msd_get(msd);
+                    err = mbtk_ecall_msd_get(handle_1, msd);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -239,7 +240,7 @@
                 } else { // Set
                     int count = sscanf(cmd, "msd %s", msd);
                     if(count == 1 && strlen((char*)msd) > 0) { // set
-                        err = mbtk_ecall_msd_set(msd);
+                        err = mbtk_ecall_msd_set(handle_1, msd);
                         if(err != MBTK_RIL_ERR_SUCCESS) {
                             printf("Error : %d\n", err);
                         } else {
@@ -251,7 +252,7 @@
                 mbtk_ecall_only_info_t only_info;
                 if(strcasecmp(cmd, "only") == 0) { // Get
                     memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
-                    err = mbtk_ecall_only_get(&only_info);
+                    err = mbtk_ecall_only_get(handle_1, &only_info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -263,7 +264,7 @@
                     int count = sscanf(cmd, "only %d %s %s", &tmp_int, only_info.test_num, only_info.reconfig_num);
                     if(count > 0 && tmp_int >= 0) { // set
                         only_info.active = (mbtk_ecall_only_type_enum)tmp_int;
-                        err = mbtk_ecall_only_set(&only_info);
+                        err = mbtk_ecall_only_set(handle_1, &only_info);
                         if(err != MBTK_RIL_ERR_SUCCESS) {
                             printf("Error : %d\n", err);
                         } else {
@@ -274,7 +275,7 @@
             } else if(!strncasecmp(cmd, "dial", 4)){ // dial <0-5>
                 mbtk_ecall_dial_type_enum type;
                 if(!strcasecmp(cmd, "dial")) { // Get
-                    err = mbtk_ecall_dial_state_get(&type);
+                    err = mbtk_ecall_dial_state_get(handle_1, &type);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -284,7 +285,7 @@
                     int reset;
                     int count = sscanf(cmd, "dial %d", &reset);
                     if(count == 1) {
-                        err = mbtk_ecall_dial_start((mbtk_ecall_dial_type_enum)reset);
+                        err = mbtk_ecall_dial_start(handle_1, (mbtk_ecall_dial_type_enum)reset);
                         if(err != MBTK_RIL_ERR_SUCCESS) {
                             printf("Error : %d\n", err);
                         } else {
@@ -294,14 +295,14 @@
                 }
             } else if(!strncasecmp(cmd, "reg", 3)){ // reg <0/1>
                 if(!strcasecmp(cmd, "reg 0")) {
-                    err = mbtk_ecall_reg_set(0);
+                    err = mbtk_ecall_reg_set(handle_1, 0);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Set net reg 0\n");
                     }
                 } else if(!strcasecmp(cmd, "reg 1")) {
-                    err = mbtk_ecall_reg_set(1);
+                    err = mbtk_ecall_reg_set(handle_1, 1);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -311,21 +312,21 @@
             } else if(!strncasecmp(cmd, "mode", 4)){ // mode EU/ERA
                 if(!strcasecmp(cmd, "mode")) {
                     mbtk_ecall_mode_type_enum mode;
-                    err = mbtk_ecall_mode_get(&mode);
+                    err = mbtk_ecall_mode_get(handle_1, &mode);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Ecall mode[%d] : %s\n", mode, mode == MBTK_ECALL_MODE_TYPE_EU ? "EU" : "ERA");
                     }
                 } else if(!strcasecmp(cmd, "mode EU")) {
-                    err = mbtk_ecall_mode_set(MBTK_ECALL_MODE_TYPE_EU);
+                    err = mbtk_ecall_mode_set(handle_1, MBTK_ECALL_MODE_TYPE_EU);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Set mode EU\n");
                     }
                 } else if(!strcasecmp(cmd, "mode ERA")) {
-                    err = mbtk_ecall_mode_set(MBTK_ECALL_MODE_TYPE_ERA);
+                    err = mbtk_ecall_mode_set(handle_1, MBTK_ECALL_MODE_TYPE_ERA);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -369,7 +370,7 @@
                         cfg.type |= MBTK_ECALL_CFG_SMSPROCESS;
                     if(tmp[MBTK_ECALL_CFG_ITEM_SMSMSDCNT])
                         cfg.type |= MBTK_ECALL_CFG_SMSMSDCNT;
-                    err = mbtk_ecall_cfg_get(&cfg);
+                    err = mbtk_ecall_cfg_get(handle_1, &cfg);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -446,7 +447,7 @@
                         cfg.type |= MBTK_ECALL_CFG_SMSMSDCNT;
                         cfg.data[MBTK_ECALL_CFG_ITEM_SMSMSDCNT] = tmp[MBTK_ECALL_CFG_ITEM_SMSMSDCNT];
                     }
-                    err = mbtk_ecall_cfg_set(&cfg);
+                    err = mbtk_ecall_cfg_set(handle_1, &cfg);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -456,7 +457,7 @@
             } else if(!strncasecmp(cmd, "sms_num", 7)){ // sms_num <number>
                 uint8 number[RIL_MAX_NUMBER_LEN] = {0};
                 if(!strcasecmp(cmd, "sms_num")) { // Get
-                    err = mbtk_ecall_sms_number_get(number);
+                    err = mbtk_ecall_sms_number_get(handle_1, number);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -465,7 +466,7 @@
                 } else { // Set
                     int count = sscanf(cmd, "sms_num %s", number);
                     if(count == 1 && strlen((char*)number) > 0) {
-                        err = mbtk_ecall_sms_number_set(number);
+                        err = mbtk_ecall_sms_number_set(handle_1, number);
                         if(err != MBTK_RIL_ERR_SUCCESS) {
                             printf("Error : %d\n", err);
                         } else {
@@ -475,14 +476,14 @@
                 }
             } else if(!strncasecmp(cmd, "mute_spk", 8)){ // mute_spk <0/1>
                 if(!strcasecmp(cmd, "mute_spk 0")) {
-                    err = mbtk_ecall_mute_spk_set(0);
+                    err = mbtk_ecall_mute_spk_set(handle_1, 0);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Set mute spk to 0\n");
                     }
                 } else if(!strcasecmp(cmd, "mute_spk 1")) {
-                    err = mbtk_ecall_mute_spk_set(1);
+                    err = mbtk_ecall_mute_spk_set(handle_1, 1);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -497,7 +498,7 @@
                     memset(&gain, 0, sizeof(gain));
                     gain.mode = (mbtk_ecall_gain_mode_enum)tmp1;
                     gain.gain = (int8)tmp2;
-                    err = mbtk_ecall_dsp_gain_set(&gain);
+                    err = mbtk_ecall_dsp_gain_set(handle_1, &gain);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -508,7 +509,7 @@
             else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
                 help();
             } else if(!strcasecmp(cmd, "q")) {
-                mbtk_ril_deinit();
+                mbtk_ril_close(ATPORTTYPE_1);
                 break;
             } else {
                 printf("\n");
@@ -519,7 +520,7 @@
 //    thread_exit_with_wait();
 
 //exit:
-    mbtk_ril_deinit();
+    mbtk_ril_close(ATPORTTYPE_1);
 
     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 1992bef..1f4ac7a 100755
--- a/mbtk/test/libmbtk_ril/mbtk_ril_test.c
+++ b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
@@ -193,7 +193,8 @@
 #if RIL_DEBUG_THREAD
             thread_exit_with_wait();
 #endif
-            mbtk_ril_deinit();
+            mbtk_ril_close(MBTK_AT_PORT_DEF);
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
@@ -202,7 +203,8 @@
 #if RIL_DEBUG_THREAD
             thread_exit_with_wait();
 #endif
-            mbtk_ril_deinit();
+            mbtk_ril_close(MBTK_AT_PORT_DEF);
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGTERM:// 默认kill   (同 SIGKILL ,但 SIGKILL 不可捕获)
@@ -211,7 +213,8 @@
 #if RIL_DEBUG_THREAD
             thread_exit_with_wait();
 #endif
-            mbtk_ril_deinit();
+            mbtk_ril_close(MBTK_AT_PORT_DEF);
+            mbtk_ril_close(ATPORTTYPE_1);
             exit(0);
         }
         case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
@@ -291,8 +294,15 @@
     //test2(1, "254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239");
     //test2(1, "2400:3200::1");
 
-    if(mbtk_ril_init() != MBTK_RIL_ERR_SUCCESS)
-    {
+    mbtk_ril_handle* handle_def = mbtk_ril_open(MBTK_AT_PORT_DEF);
+    if(handle_def == NULL) {
+        printf("mbtk_ril_open(MBTK_AT_PORT_DEF/ATPORTTYPE_0) fail.");
+        return -1;
+    }
+
+    mbtk_ril_handle* handle_1 = mbtk_ril_open(ATPORTTYPE_1);
+    if(handle_1 == NULL) {
+        printf("mbtk_ril_open(ATPORTTYPE_1) fail.");
         return -1;
     }
 
@@ -352,7 +362,7 @@
             if(!strncasecmp(cmd, "version", 7))
             {
                 char version[50] = {0};
-                err = mbtk_version_get(version);
+                err = mbtk_version_get(handle_def, version);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -361,7 +371,7 @@
             }
             else if(!strncasecmp(cmd, "imei", 4)){
                 char imei[50] = {0};
-                err = mbtk_imei_get(imei);
+                err = mbtk_imei_get(handle_def, imei);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -369,7 +379,7 @@
                 }
             } else if(!strncasecmp(cmd, "sn", 2)){
                 char sn[50] = {0};
-                err = mbtk_sn_get(sn);
+                err = mbtk_sn_get(handle_def, sn);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -377,7 +387,7 @@
                 }
             } else if(!strncasecmp(cmd, "meid", 4)){
                 char meid[50] = {0};
-                err = mbtk_meid_get(meid);
+                err = mbtk_meid_get(handle_def, meid);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -386,7 +396,7 @@
             } else if(!strncasecmp(cmd, "volte", 5)){ // "volte" or "volte 0" or "volte 1"
                 int volte;
                 if(!strcasecmp(cmd, "volte")) { // Get
-                    err = mbtk_volte_state_get(&volte);
+                    err = mbtk_volte_state_get(handle_def, &volte);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -398,7 +408,7 @@
                     } else { // Close VoLTE
                         volte = 0;
                     }
-                    err = mbtk_volte_state_set(volte);
+                    err = mbtk_volte_state_set(handle_def, volte);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -408,7 +418,7 @@
             } else if(!strncasecmp(cmd, "radio", 5)){ // "radio" or "radio 0" or "radio 1"
                 mbtk_radio_state_enum radio;
                 if(!strcasecmp(cmd, "radio")) { // Get
-                    err = mbtk_radio_state_get(&radio);
+                    err = mbtk_radio_state_get(handle_def, &radio);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -422,7 +432,7 @@
                             reset = 0;
                         }
 
-                        err = mbtk_radio_state_set(radio, reset);
+                        err = mbtk_radio_state_set(handle_def, radio, reset);
                         if(err != MBTK_RIL_ERR_SUCCESS) {
                             printf("Error : %d\n", err);
                         } else {
@@ -433,14 +443,14 @@
             } else if(!strncasecmp(cmd, "temp", 4)){
                 int temp;
                 if(!strcasecmp(cmd, "temp 0")) {
-                    err = mbtk_temp_get(MBTK_TEMP_TYPE_SOC, &temp);
+                    err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_SOC, &temp);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("SOC : %d\n", temp);
                     }
                 } else if(!strcasecmp(cmd, "temp 1")) {
-                    err = mbtk_temp_get(MBTK_TEMP_TYPE_RF, &temp);
+                    err = mbtk_temp_get(handle_def, MBTK_TEMP_TYPE_RF, &temp);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -449,7 +459,7 @@
                 }
             } else if(!strncasecmp(cmd, "cell_time", 9)){
                 char time[128] = {0};
-                err = mbtk_cell_time_get(time);
+                err = mbtk_cell_time_get(handle_def, time);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -457,7 +467,7 @@
                 }
             } else if(!strncasecmp(cmd, "sim_state", 9)){
                 mbtk_sim_state_enum sim;
-                err = mbtk_sim_state_get(&sim);
+                err = mbtk_sim_state_get(handle_def, &sim);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -465,7 +475,7 @@
                 }
             } else if(!strncasecmp(cmd, "sim_type", 8)){
                 mbtk_sim_card_type_enum type;
-                err = mbtk_sim_type_get(&type);
+                err = mbtk_sim_type_get(handle_def, &type);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -473,7 +483,7 @@
                 }
             } else if(!strncasecmp(cmd, "imsi", 4)){
                 char imsi[50] = {0};
-                err = mbtk_imsi_get(imsi);
+                err = mbtk_imsi_get(handle_def, imsi);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -481,7 +491,7 @@
                 }
             } else if(!strncasecmp(cmd, "iccid", 5)){
                 char iccid[50] = {0};
-                err = mbtk_iccid_get(iccid);
+                err = mbtk_iccid_get(handle_def, iccid);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -489,7 +499,7 @@
                 }
             } else if(!strncasecmp(cmd, "pn", 2)){
                 char phone_number[50] = {0};
-                err = mbtk_phone_number_get(phone_number);
+                err = mbtk_phone_number_get(handle_def, phone_number);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -507,7 +517,7 @@
             */
             else if(!strncasecmp(cmd, "pin_state", 9)){
                 int lock_state;
-                err = mbtk_sim_lock_get(&lock_state);
+                err = mbtk_sim_lock_get(handle_def, &lock_state);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -515,7 +525,7 @@
                 }
             } else if(!strncasecmp(cmd, "pin_times", 9)){
                 mbtk_pin_puk_last_times_t times;
-                err = mbtk_sim_lock_retry_times_get(&times);
+                err = mbtk_sim_lock_retry_times_get(handle_def, &times);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -526,7 +536,7 @@
                 info.type = MBTK_SIM_LOCK_TYPE_ENABLE;
                 int count = sscanf(cmd, "pin_open %s", info.pin1);
                 if(count == 1) {
-                    err = mbtk_sim_lock_set(&info);
+                    err = mbtk_sim_lock_set(handle_def, &info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -538,7 +548,7 @@
                 info.type = MBTK_SIM_LOCK_TYPE_DISABLE;
                 int count = sscanf(cmd, "pin_close %s", info.pin1);
                 if(count == 1) {
-                    err = mbtk_sim_lock_set(&info);
+                    err = mbtk_sim_lock_set(handle_def, &info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -550,7 +560,7 @@
                 info.type = MBTK_SIM_LOCK_TYPE_CHANGE;
                 int count = sscanf(cmd, "pin_change %s %s", info.pin1, info.pin2);
                 if(count == 2) {
-                    err = mbtk_sim_lock_set(&info);
+                    err = mbtk_sim_lock_set(handle_def, &info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -562,7 +572,7 @@
                 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PIN;
                 int count = sscanf(cmd, "pin_verify %s", info.pin1);
                 if(count == 1) {
-                    err = mbtk_sim_lock_set(&info);
+                    err = mbtk_sim_lock_set(handle_def, &info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -574,7 +584,7 @@
                 info.type = MBTK_SIM_LOCK_TYPE_VERIFY_PUK;
                 int count = sscanf(cmd, "puk_verify %s %s", info.puk, info.pin1);
                 if(count == 2) {
-                    err = mbtk_sim_lock_set(&info);
+                    err = mbtk_sim_lock_set(handle_def, &info);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -583,7 +593,7 @@
                 }
             } else if(!strncasecmp(cmd, "plmn", 4)){
                 mbtk_plmn_info info;
-                err = mbtk_plmn_list_get(&info);
+                err = mbtk_plmn_list_get(handle_def, &info);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -597,7 +607,7 @@
             }
             else if(!strncasecmp(cmd, "avail_net", 9)){
                 mbtk_net_info_array_t net_list;
-                err = mbtk_available_net_get(&net_list);
+                err = mbtk_available_net_get(handle_1, &net_list);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -614,7 +624,7 @@
                 mbtk_net_info_t net;
                 memset(&net, 0, sizeof(mbtk_net_info_t));
                 if(!strcasecmp(cmd, "sel_mode")) { // Get
-                    err = mbtk_net_sel_mode_get(&net);
+                    err = mbtk_net_sel_mode_get(handle_def, &net);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -642,7 +652,7 @@
                         ptr++;
                     net.plmn = (uint32)atoi(ptr);
 
-                    err = mbtk_net_sel_mode_set(&net);
+                    err = mbtk_net_sel_mode_set(handle_def, &net);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -653,14 +663,14 @@
                 mbtk_band_info_t band;
                 memset(&band, 0x0, sizeof(mbtk_band_info_t));
                 if(!strcasecmp(cmd, "band")) { // Get
-                    err = mbtk_current_band_get(&band);
+                    err = mbtk_current_band_get(handle_def, &band);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Band : %d, %d, %d, %d, %d, %d\n", band.net_pref, band.gsm_band, band.umts_band, band.tdlte_band, band.fddlte_band, band.lte_ext_band);
                     }
                 } else if(!strcasecmp(cmd, "band support")) { // Get
-                    err = mbtk_support_band_get(&band);
+                    err = mbtk_support_band_get(handle_def, &band);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -702,7 +712,7 @@
                         ptr++;
                     band.fddlte_band = (uint32)atoi(ptr);
 
-                    err = mbtk_current_band_set(&band);
+                    err = mbtk_current_band_set(handle_def, &band);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -711,7 +721,7 @@
                 }
             } else if(!strncasecmp(cmd, "signal", 6)){
                 mbtk_signal_info_t signal;
-                err = mbtk_net_signal_get(&signal);
+                err = mbtk_net_signal_get(handle_def, &signal);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -720,7 +730,7 @@
                 }
             } else if(!strncasecmp(cmd, "reg", 3)){
                 mbtk_net_reg_info_t reg;
-                err = mbtk_net_reg_get(&reg);
+                err = mbtk_net_reg_get(handle_def, &reg);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -735,7 +745,7 @@
                     apn.cid = (mbtk_ril_cid_enum)cid;
                     apn.auto_save = (uint8)auto_save;
                 }
-                err = mbtk_apn_set(&apn);
+                err = mbtk_apn_set(handle_def, &apn);
                 if(err != MBTK_RIL_ERR_SUCCESS) {
                     printf("Error : %d\n", err);
                 } else {
@@ -745,7 +755,7 @@
             } else if(!strncasecmp(cmd, "apn", 3)){
                 if(!strcasecmp(cmd, "apn")) { // Get apn
                     mbtk_apn_info_array_t apns;
-                    err = mbtk_apn_get(&apns);
+                    err = mbtk_apn_get(handle_def, &apns);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -806,7 +816,7 @@
                         ptr++;
                     memcpy(apn.apn, ptr, strlen(ptr));
 #endif
-                    err = mbtk_apn_set(&apn);
+                    err = mbtk_apn_set(handle_def, &apn);
                     if(err != MBTK_RIL_ERR_SUCCESS) {
                         printf("Error : %d\n", err);
                     } else {
@@ -829,18 +839,18 @@
                     if(type == MBTK_DATA_CALL_START) {
                         int retry_interval[] = {5, 10, 15};
                         if(count == 5) {
-                            err = mbtk_data_call_start((mbtk_ril_cid_enum)cid, (mbtk_data_call_item_state_enum)auto_boot_call,
+                            err = mbtk_data_call_start(handle_def, (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, retry_interval,
                                     3, 0, &ip);
                         } else {
-                            mbtk_data_call_start((mbtk_ril_cid_enum)cid, MBTK_DATA_CALL_ITEM_STATE_NON,
+                            err = mbtk_data_call_start(handle_def, (mbtk_ril_cid_enum)cid, MBTK_DATA_CALL_ITEM_STATE_NON,
                                 MBTK_DATA_CALL_ITEM_STATE_NON, MBTK_DATA_CALL_ITEM_STATE_NON, retry_interval,
                                     3, 0, &ip);
                         }
                     } else if(type == MBTK_DATA_CALL_STOP) {
-                        err = mbtk_data_call_stop((mbtk_ril_cid_enum)cid, 10);
+                        err = mbtk_data_call_stop(handle_def, (mbtk_ril_cid_enum)cid, 10);
                     } else {
-                        err = mbtk_data_call_state_get((mbtk_ril_cid_enum)cid, &ip);
+                        err = mbtk_data_call_state_get(handle_def, (mbtk_ril_cid_enum)cid, &ip);
                     }
                     if(err) {
                         printf("Error : %d\n", err);
@@ -935,7 +945,7 @@
 				if(ptr == NULL)
 				{
                     mbtk_cell_info_array_t cell;
-                    err = mbtk_cell_get(&cell);
+                    err = mbtk_cell_get(handle_def, &cell);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else if(cell.num > 0){
@@ -992,7 +1002,7 @@
 					printf("cell_mem: %s \n", mem);
 
 					memset(resp, 0, sizeof(resp));
-					err = mbtk_cell_set(mem, resp);
+					err = mbtk_cell_set(handle_def, mem, resp);
 					if(err) {
 						printf("Error : %d\n", err);
 					} else {
@@ -1010,14 +1020,14 @@
                 memset(phone_number,0,strlen(phone_number));
                 memcpy(phone_number,ptr,strlen(ptr));
                 printf("phone number is: %s\n",phone_number);
-                err = mbtk_call_start(phone_number);
+                err = mbtk_call_start(handle_def, phone_number);
                 if(err) {
                     printf("Error : %d\n", err);
                 } else {
                     printf("Call success.\n");
                 }
             } else if(!strncasecmp(cmd, "answer", 6)){
-                err = mbtk_call_answer();
+                err = mbtk_call_answer(handle_def);
                 if(err) {
                     printf("Error : %d\n", err);
                 } else {
@@ -1026,21 +1036,21 @@
             } else if(!strncasecmp(cmd, "hangup", 6)){
                 int phone_id = 1;
                 if(!strcasecmp(cmd, "hangup")) { // hang up all
-                    err = mbtk_call_hang();
+                    err = mbtk_call_hang(handle_def);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Call hang up all.\n");
                     }
                 } else if(!strcasecmp(cmd, "hangup 0")) {
-                    err = mbtk_waiting_or_background_call_hang();
+                    err = mbtk_waiting_or_background_call_hang(handle_def);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
                         printf("Call hang up waiting or background.\n");
                     }
                 } else if(!strcasecmp(cmd, "hangup 3")) {
-                    err = mbtk_foreground_resume_background_call_hang();
+                    err = mbtk_foreground_resume_background_call_hang(handle_def);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1054,7 +1064,7 @@
                     } else {
                         printf("Error : Invalid input\n");
                     }
-                    err = mbtk_a_call_hang(phone_id);
+                    err = mbtk_a_call_hang(handle_def, phone_id);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1063,7 +1073,7 @@
                 }
             } else if(!strncasecmp(cmd, "waitin", 6)){
                 mbtk_call_info_t reg;
-                err = mbtk_call_reg_get(&reg);
+                err = mbtk_call_reg_get(handle_def, &reg);
                 if(err) {
                     printf("Error : %d\n", err);
                 } else {
@@ -1077,7 +1087,7 @@
             } else if(!strncasecmp(cmd, "mute", 4)){ // "mute" or "mute 0" or "mute 1"
                 int mute;
                 if(!strcasecmp(cmd, "mute")) { // Get
-                    err = mbtk_mute_state_get(&mute);
+                    err = mbtk_mute_state_get(handle_def, &mute);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1089,7 +1099,7 @@
                     } else { // off mute
                         mute = 0;
                     }
-                    err = mbtk_mute_state_set(mute);
+                    err = mbtk_mute_state_set(handle_def, mute);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1114,7 +1124,7 @@
                     ptr++;
                 reg.duration = (uint32)atoi(ptr);
                 printf("DTMF character is: %c,%d\n",reg.character, reg.duration);
-                err = mbtk_dtmf_send(&reg);
+                err = mbtk_dtmf_send(handle_def, &reg);
                 if(err) {
                     printf("Error : %d\n", err);
                 } else {
@@ -1123,7 +1133,7 @@
             } else if(!strncasecmp(cmd, "cmgf", 4)){ // set mode 0: pud, 1:text
                 int mode;
                 if(!strcasecmp(cmd, "cmgf")) { // Get
-                    err = mbtk_sms_cmgf_get(&mode);
+                    err = mbtk_sms_cmgf_get(handle_def, &mode);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1137,7 +1147,7 @@
                     }
                     printf("mode:%d\n", mode);
                     sleep(2);
-                   err = mbtk_sms_cmgf_set(mode);
+                   err = mbtk_sms_cmgf_set(handle_def, mode);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1148,7 +1158,7 @@
 				char mem[100] = {0};
                 char resp[100] = {0};
                 if(!strcasecmp(cmd, "cpms")) { // Get
-                    err = mbtk_sms_cpms_get(mem);
+                    err = mbtk_sms_cpms_get(handle_def, mem);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1167,7 +1177,7 @@
                     printf("cpms 0\n");
 
                     memset(resp, 0, sizeof(resp));
-                    err = mbtk_sms_cpms_set(mem, resp);
+                    err = mbtk_sms_cpms_set(handle_def, mem, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1205,7 +1215,7 @@
 				    }
 
 					memset(resp, 0, sizeof(resp));
-                    err = mbtk_sms_cmgs_set(cmgs, resp);
+                    err = mbtk_sms_cmgs_set(handle_def, cmgs, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1230,7 +1240,7 @@
 				    }
 
 
-                    err = mbtk_sms_cmss_set(cmss, resp);
+                    err = mbtk_sms_cmss_set(handle_def, cmss, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1255,7 +1265,7 @@
                     printf("1index:%d\n", index);
 
                     memset(resp, 0, sizeof(resp));
-                    err = mbtk_sms_cmgr_set(index, resp);
+                    err = mbtk_sms_cmgr_set(handle_def, index, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1282,7 +1292,7 @@
 				    }
 
                     memset(resp, 0, sizeof(resp));
-                    err = mbtk_sms_cmgw_set(cmgw, resp);
+                    err = mbtk_sms_cmgw_set(handle_def, cmgw, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1307,7 +1317,7 @@
 				    }
 
 
-                    err = mbtk_sms_cmgd_set(cmgd);
+                    err = mbtk_sms_cmgd_set(handle_def, cmgd);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1334,7 +1344,7 @@
 				    }
 
 					memset(resp, 0, sizeof(resp));
-                    err = mbtk_sms_cmgl_set(cmgl, resp);
+                    err = mbtk_sms_cmgl_set(handle_def, cmgl, resp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1346,7 +1356,7 @@
                                                     //
                 char csca[128] = {0};
                 if(!strcasecmp(cmd, "csca")) { // Get
-                    err = mbtk_sms_csca_get(csca);
+                    err = mbtk_sms_csca_get(handle_def, csca);
                     if(err) {
                         printf("mbtk_sms_csca_get Error : %d\n", err);
                     } else {
@@ -1363,7 +1373,7 @@
 						printf("csca:%s\n", csca);
 				    }
 
-                    err = mbtk_sms_csca_set(csca);
+                    err = mbtk_sms_csca_set(handle_def, csca);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1387,7 +1397,7 @@
 						printf("csmp:%s\n", csmp);
 				    }
 
-                    err = mbtk_sms_csmp_set(csmp);
+                    err = mbtk_sms_csmp_set(handle_def, csmp);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1411,7 +1421,7 @@
 						printf("cscb:%s\n", cscb);
 				    }
 
-                    err = mbtk_sms_cscb_set(cscb);
+                    err = mbtk_sms_cscb_set(handle_def, cscb);
                     if(err) {
                         printf("Error : %d\n", err);
                     } else {
@@ -1499,7 +1509,8 @@
             else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
                 help();
             } else if(!strcasecmp(cmd, "q")) {
-                mbtk_ril_deinit();
+                mbtk_ril_close(MBTK_AT_PORT_DEF);
+                mbtk_ril_close(ATPORTTYPE_1);
                 break;
             } else {
                 printf("\n");
@@ -1511,7 +1522,9 @@
     thread_exit_with_wait();
 exit:
 #endif
-    mbtk_ril_deinit();
+    mbtk_ril_close(MBTK_AT_PORT_DEF);
+    mbtk_ril_close(ATPORTTYPE_1);
+
 
     LOG("Client exec complete.");