Add mbtk_source git commit info

Change-Id: I9867613657db269bba81d28c4b3712062ae41bdd
diff --git a/mbtk/Make.defines b/mbtk/Make.defines
index 83117fa..056fc5f 100755
--- a/mbtk/Make.defines
+++ b/mbtk/Make.defines
@@ -68,7 +68,12 @@
 	-DNDEBUG \

 	-UDEBUG \

 	-D_FORTIFY_SOURCE=2 \

-	-D_GNU_SOURCE

+	-D_GNU_SOURCE \

+	-DMBTK_BUILD_TIME=\""$(shell date +%Y/%m/%d\ %H:%M:%S)\"" \

+	-DMBTK_BUILD_GIT=\""$(shell git log | grep commit | head -1 | cut -d ' ' -f 2)\""

+

+#MBTK_BUILD_GIT="$(shell git log | grep commit | head -1 | cut -d ' ' -f 2)"

+#$(info MBTK_BUILD_GIT=$(MBTK_BUILD_GIT))

 

 #$(info TOPDIR=$(TOPDIR))

 # BUILD_PROJECT=$(shell cat $(ROOT)/../build_version | grep PROJECT | cut -d '=' -f 2)

@@ -162,6 +167,10 @@
 DEFINE += -DMBTK_DUMP_SUPPORT

 endif

 

+ifeq ($(MBTK_SOURCE_VERSION), 2)
+DEFINE += -DMBTK_SOURCE_VERSION_2

+endif

+

 LIB_DIR = \

 	-L$(OUT_DIR)/lib

 

diff --git a/mbtk/Makefile b/mbtk/Makefile
index d4b4e99..c7157cf 100755
--- a/mbtk/Makefile
+++ b/mbtk/Makefile
@@ -7,7 +7,8 @@
 
 # Build libmbtk_ril libql_lib and liblynq_lib.
 ifeq ($(MBTK_SOURCE_VERSION), 2)
-DIRS += libmbtk_ril_v2 libql_lib_v2 liblynq_lib_v2
+DIRS += libmbtk_ril_v2
+# libql_lib_v2 liblynq_lib_v2
 else
 DIRS += libmbtk_ril libql_lib liblynq_lib
 endif
diff --git a/mbtk/include/mbtk/mbtk_log.h b/mbtk/include/mbtk/mbtk_log.h
index f75cc06..f217adb 100755
--- a/mbtk/include/mbtk/mbtk_log.h
+++ b/mbtk/include/mbtk/mbtk_log.h
@@ -134,6 +134,28 @@
     } while(0)
 #endif
 
+#define MBTK_SOURCE_INFO_PRINT(name) \
+    do{ \
+        LOGD("%s : %s(%s)", name, MBTK_BUILD_GIT, MBTK_BUILD_TIME); \
+        printf("%s : %s(%s)\n", name, MBTK_BUILD_GIT, MBTK_BUILD_TIME); \
+    } while(0)
+
+
 void mbtk_debug_open(const char *log_file, bool thread_support);
 
+void ql_lib_info_print();
+void mbtk_tcpip_lib_info_print();
+void mbtk_net_lib_info_print();
+void mbtk_mqtt_lib_info_print();
+void mbtk_http_lib_info_print();
+void mbtk_gnss_lib_info_print();
+void mbtk_ftp_lib_info_print();
+void mbtk_fota_lib_info_print();
+void mbtk_factory_lib_info_print();
+void mbtk_coap_lib_info_print();
+void mbtk_audio_lib_info_print();
+void lynq_lib_info_print();
+void mbtk_ril_lib_info_print();
+void mbtk_lib_info_print();
+
 #endif /* MBTK_LOG_INCLUDE */
diff --git a/mbtk/liblynq_lib/src/lynq_log.c b/mbtk/liblynq_lib/src/lynq_log.c
index e096f8a..3dbb33b 100755
--- a/mbtk/liblynq_lib/src/lynq_log.c
+++ b/mbtk/liblynq_lib/src/lynq_log.c
@@ -307,7 +307,7 @@
         json_object_put(jsonobj);
         return -1;
     }
-    
+
     json_object_object_get_ex(datajson, "filter_list", &listjson);
     if (NULL == listjson) {
         printf("%s %d: object failure!\n", __FUNCTION__, __LINE__);
@@ -491,4 +491,9 @@
 
     close(clientFd);
     return 0;
+}
+
+void lynq_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("lynq_lib");
 }
\ No newline at end of file
diff --git a/mbtk/liblynq_lib_v2/src/lynq_log.c b/mbtk/liblynq_lib_v2/src/lynq_log.c
index e096f8a..3dbb33b 100755
--- a/mbtk/liblynq_lib_v2/src/lynq_log.c
+++ b/mbtk/liblynq_lib_v2/src/lynq_log.c
@@ -307,7 +307,7 @@
         json_object_put(jsonobj);
         return -1;
     }
-    
+
     json_object_object_get_ex(datajson, "filter_list", &listjson);
     if (NULL == listjson) {
         printf("%s %d: object failure!\n", __FUNCTION__, __LINE__);
@@ -491,4 +491,9 @@
 
     close(clientFd);
     return 0;
+}
+
+void lynq_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("lynq_lib");
 }
\ No newline at end of file
diff --git a/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c b/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
index a08338f..9f2336d 100755
--- a/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
+++ b/mbtk/libmbtk_audio/src/mbtk_pcm_stream.c
@@ -667,7 +667,7 @@
     int value = 1;
     struct mopen_audio_t *aud_hdl = NULL;
     int ret;
-    
+
     if(internal_hdl)
     {
         printf("Audio device inited\n");
@@ -740,7 +740,7 @@
     if (NULL == dev_hdl || NULL == internal_hdl)
         return -1;
 
- 
+
     LOGD("mbtk_audio_play_file_new()  dev_hdl:%p\n", dev_hdl);
 
     if(AUDIO_RUNNING == pcxt->state)
@@ -768,7 +768,7 @@
       //   printf("%s:read : %d bytes\n", __FUNCTION__, res);
         if(res == 0 || res < 0)
         {
-             LOGD("read:[%d]", res); 
+             LOGD("read:[%d]", res);
             break;
         }
 
@@ -860,7 +860,7 @@
 
         if(read_size > len)
         {
-         //    printf(">[%d]\n", read_size); 
+         //    printf(">[%d]\n", read_size);
             break;
         }
 
@@ -886,7 +886,7 @@
 
         if(read_size == len)
         {
-         //    printf("=[%d]", read_size); 
+         //    printf("=[%d]", read_size);
             break;
         }
 
@@ -897,14 +897,14 @@
             {
                 sprintf(cmd, "ubus call audio_if config_dspgain \"{\'type\':1, \'gain\':%d}\"", gain);
                 system(cmd);
-            
+
                 flay_flag = FALSE;
                 usleep(80000);
             }
         }
 
     }
-    
+
     if(pcxt->state != AUDIO_STOP)
     {
         mbtk_audio_set_status_new(dev_hdl, AUDIO_OPEN);
@@ -942,4 +942,8 @@
     return 0;
 }
 
+void mbtk_audio_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_audio_lib");
+}
 
diff --git a/mbtk/libmbtk_coap/mbtk_coap.c b/mbtk/libmbtk_coap/mbtk_coap.c
index 186255e..226fd5c 100755
--- a/mbtk/libmbtk_coap/mbtk_coap.c
+++ b/mbtk/libmbtk_coap/mbtk_coap.c
@@ -196,7 +196,7 @@
 			pud_lenth,

 			type,

 			code,

-			mesageId);	

+			mesageId);

 

 

     int i = 0;

@@ -214,14 +214,14 @@
     LOGE("len:%d, i :%d\n",len,i);

 	if(Payload[len-i -1] == '\0' )

 	{

-		LOGE("==\0-------------------\n");		

+		LOGE("==\0-------------------\n");

 	//	coap_log(-1,(char*)Payload,len - i-1);

 	}else{

 		LOGE("!=\0--------------------\n");

 		Payload[0]='\0';

 	}

 

-    buffer_len = strlen(dest) + strlen(Payload); 

+    buffer_len = strlen(dest) + strlen(Payload);

     strcat(dest,Payload);

 	LOGE("2---------buffer_len:%d,coap_recv_buffer_dest:%s,Payload:%s\n",buffer_len,dest,Payload);

     return buffer_len;

@@ -335,7 +335,7 @@
 			memcpy(ptr,"5.05",4);

 		break;

 		default:

-			sprintf(ptr, "UndefCod%u",(unsigned)(coapGetRecvCode()));			

+			sprintf(ptr, "UndefCod%u",(unsigned)(coapGetRecvCode()));

 	}

 }

 

@@ -366,7 +366,7 @@
 	mbtk_ecoap_package_s *coap_next = NULL;

 	mbtk_ecoap_option_s * option_ptr = NULL;

 	mbtk_ecoap_option_s * option_ptr_next = NULL;

-	

+

     while(coap != NULL)

     {

 		coap_next = coap->next;

@@ -383,9 +383,9 @@
 				option_ptr = NULL;

 				option_ptr = option_ptr_next;

 			}

-			

+

 		}

-		

+

 		free(coap);

 		coap = NULL;

 		coap = coap_next;

@@ -533,7 +533,7 @@
     }

     else     // Not first item.

     {

-        while(coap->next != NULL)  

+        while(coap->next != NULL)

         {

             if(message_id == coap->next->message_id)   // delete

             {

@@ -777,7 +777,7 @@
     mbtk_sock_info *sock_info = NULL;

     int rc = 0;

     int errno;

-	

+

     sock_info = (mbtk_sock_info *)malloc(sizeof(mbtk_sock_info));

     if(sock_info == NULL)

     {

@@ -789,7 +789,7 @@
     sock_info->is_support_ssl = is_support_ssl;

     sock_info->ingnore_cert = ingnore_cert;

 	sock_info->type = MBTK_SOCK_UDP;

-	

+

     printf("host %s\nport %d\nis_support_ssl %d\ningnore_cert %d\n",sock_info->address,sock_info->port,sock_info->is_support_ssl,sock_info->ingnore_cert);

 

 	if(!coap_sock_inited)

@@ -918,7 +918,7 @@
 			pud_lenth,

 			type,

 			code,

-			mesageId);	

+			mesageId);

 

 	return 0;

 }

@@ -959,7 +959,7 @@
         int buffer_len = ecoap_recv_buffer(buff_data, data, data_len);

 		printf("recv buff_len:%d\n",buffer_len);

         printf("buf:\n%s\r\n",buff_data);

-		

+

         LOGE("type:%X\n",type);

         if(type == COAP_CONFIRMABLE) // Should ACK

         {

@@ -1075,7 +1075,7 @@
 (

     char *ip_addr,

     int port,

-    bool is_support_ssl, 

+    bool is_support_ssl,

     bool ingnore_cert

 )

 {

@@ -1088,7 +1088,7 @@
 	}

 

 	ret = mbtk_ecoap_handle_sock_init(ip_addr, port, is_support_ssl, ingnore_cert);

-	

+

     return ret;

 }

 

@@ -1099,7 +1099,7 @@
 {

     int result = 0;

 	int rx_mod = mode;

-	

+

     return result;

 }

 

@@ -1120,7 +1120,7 @@
 {

     int result = 0;

 	int get_len = len;

-	

+

     return result;

 

 }

@@ -1143,7 +1143,7 @@
 {

     int result = 0;

 	mbth_ecoap_package_ver.type = type;

-	

+

     return result;

 

 }

@@ -1172,12 +1172,12 @@
 {

     int result = 0;

 	uint16 token_length = len;

-	char * token = token_buf;	

+	char * token = token_buf;

 	if(strlen(token) != token_length)

 	{

 		return -1;

 	}

-	

+

 	mbth_ecoap_package_ver.token_len = token_length;

 	memcpy(mbth_ecoap_package_ver.token, token, strlen(token));

 

@@ -1190,7 +1190,7 @@
 )

 {

     int result = 0;

-	 mbth_ecoap_package_ver.message_id = msg_id;        

+	 mbth_ecoap_package_ver.message_id = msg_id;

 

 	return result;

 }

@@ -1289,7 +1289,7 @@
                 coap->token_len = mbth_ecoap_package_ver.token_len;

                 memcpy(coap->token, mbth_ecoap_package_ver.token, strlen((char *)mbth_ecoap_package_ver.token));

             }

-            

+

             if(data_len > 0)

             {

                 coap->payload_len = data_len;

@@ -1344,13 +1344,13 @@
 	{

 		return -1;

 	}

-	

+

 	 if(mbtk_ecoap_state <= MBTK_ECOAP_STATE_CLOSING )

 	{

 		mbtk_ecoap_show_error(MBTK_ECOAP_ERR_NO_OPEN);

 		return -1;

 	}

-			

+

 	LOGE("del---------del_id:%d\n",del_id);

 

     return result;

@@ -1378,4 +1378,8 @@
     return result;

 }

 

+void mbtk_coap_lib_info_print()

+{

+    MBTK_SOURCE_INFO_PRINT("mbtk_coap_lib");

+}

 

diff --git a/mbtk/libmbtk_factory/mbtk_basic_at_wrapper.c b/mbtk/libmbtk_factory/mbtk_basic_at_wrapper.c
index 3cd41cd..8a96d24 100755
--- a/mbtk/libmbtk_factory/mbtk_basic_at_wrapper.c
+++ b/mbtk/libmbtk_factory/mbtk_basic_at_wrapper.c
@@ -1,4 +1,5 @@
 #include "mbtk_adc.h"
+#include "mbtk_log.h"
 
 int mbtk_at_adc(int value)
 {
@@ -17,3 +18,9 @@
 
     return mbtk_adc_get((mbtk_adc_enum)value);
 }
+
+void mbtk_factory_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_factory_lib");
+}
+
diff --git a/mbtk/libmbtk_fota/mbtk_fota.c b/mbtk/libmbtk_fota/mbtk_fota.c
index 6e67569..68e2ba0 100755
--- a/mbtk/libmbtk_fota/mbtk_fota.c
+++ b/mbtk/libmbtk_fota/mbtk_fota.c
@@ -243,7 +243,7 @@
     {

         LOGE("/sys/power/wake_lock can not write.\n");

     }

-    

+

     blob_buf_init(&b, 0);

     blobmsg_add_string(&b, "url", url);

     blobmsg_add_string(&b, "username", "user name");

@@ -420,8 +420,8 @@
     return fota_dowload_flag;

 }

 

-

-

-

-

+void mbtk_fota_lib_info_print()

+{

+    MBTK_SOURCE_INFO_PRINT("mbtk_fota_lib");

+}

 

diff --git a/mbtk/libmbtk_ftp/mbtk_ftp.c b/mbtk/libmbtk_ftp/mbtk_ftp.c
index 2821087..f485ec7 100755
--- a/mbtk/libmbtk_ftp/mbtk_ftp.c
+++ b/mbtk/libmbtk_ftp/mbtk_ftp.c
@@ -3055,4 +3055,8 @@
     return FTP_ERR_SUCCESS;
 }
 
+void mbtk_ftp_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_ftp_lib");
+}
 
diff --git a/mbtk/libmbtk_gnss/mbtk_gnss.c b/mbtk/libmbtk_gnss/mbtk_gnss.c
index 3e22cf7..18e8bbf 100755
--- a/mbtk/libmbtk_gnss/mbtk_gnss.c
+++ b/mbtk/libmbtk_gnss/mbtk_gnss.c
@@ -244,7 +244,7 @@
         return -1;
     }
 
-    while (p <= q) 
+    while (p <= q)
     {
         tmp = memchr(p, ',', q-p);
         if (tmp == NULL)
@@ -262,7 +262,7 @@
                 count += 1;
             }
         }
-        
+
         if (tmp <= q)
         {
             tmp += 1;
@@ -313,9 +313,9 @@
     memcpy(tmp_char, time.head + 4, 2);
     tmp_time.tm_sec = atoi(tmp_char);
     tmp_time.tm_isdst = -1;
-    
+
 #if MBTK_GNSS_LOG_ENABLED
-    LOGD("data:%d-%d-%d %d:%d:%d", tmp_time.tm_year + 1900, 
+    LOGD("data:%d-%d-%d %d:%d:%d", tmp_time.tm_year + 1900,
                                     tmp_time.tm_mon,
                                     tmp_time.tm_mday,
                                     tmp_time.tm_hour,
@@ -377,7 +377,7 @@
     locl_info->latitude = str2float(tok.head, tok.end);
 
     tok = longitude;
-    if (tok.head + 6 > tok.end) 
+    if (tok.head + 6 > tok.end)
     {
         LOGD("longitude get fail");
         return -1;
@@ -475,7 +475,7 @@
                 return -1;
             }
             locl_info->flags |= GNSS_LOCATION_HAS_LAT_LONG;
-            
+
             ret = nmea_update_altitude(locl_info, tok_altitude);
             if(ret < 0)
             {
@@ -920,3 +920,8 @@
     }
 }
 
+void mbtk_gnss_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_gnss_lib");
+}
+
diff --git a/mbtk/libmbtk_http/mbtk_http.c b/mbtk/libmbtk_http/mbtk_http.c
index a50b8e5..f83ae35 100755
--- a/mbtk/libmbtk_http/mbtk_http.c
+++ b/mbtk/libmbtk_http/mbtk_http.c
@@ -713,14 +713,14 @@
             return -1;
         }
 
-        
+
         if(read_count + read_len >= session->rsp.content_length)   // Read data complete.
         {
             if(http_handles[session->handle_id].data_cb)
             {
                 http_handles[session->handle_id].data_cb(session->id,
                         MBTK_HTTP_DATA_CONTENT,read_buf,session->rsp.content_length - read_count);
-        
+
                 http_handles[session->handle_id].data_cb(session->id,
                         MBTK_HTTP_DATA_COMPLETE,NULL,0);
             }
@@ -1259,7 +1259,7 @@
 
         LOGI("HTTP request start.");
         LOGI("host:%s, port:%d, uri:%s",session->host,session->port,session->uri);
-        LOGI("is_ssl:%d,ingnore_cert:%d, version:%d, option:%d, content_len:%d",session->is_ssl, 
+        LOGI("is_ssl:%d,ingnore_cert:%d, version:%d, option:%d, content_len:%d",session->is_ssl,
             session->ingnore_cert, session->version,session->option,session->req.content_len);
 
         int sock_fd = mbtk_http_open(session->is_ssl,session->ingnore_cert,session->host,session->port);
@@ -1389,4 +1389,8 @@
     return http_handles[handle_id].session[session_id];
 }
 
+void mbtk_http_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_http_lib");
+}
 
diff --git a/mbtk/libmbtk_lib/src/mbtk_version.c b/mbtk/libmbtk_lib/src/mbtk_version.c
index 393c7c3..a144c93 100755
--- a/mbtk/libmbtk_lib/src/mbtk_version.c
+++ b/mbtk/libmbtk_lib/src/mbtk_version.c
@@ -14,6 +14,7 @@
 
 ******************************************************************************/
 #include "mbtk_version.h"
+#include "mbtk_log.h"
 
 #define STR_GET(str) (#str)
 
@@ -122,3 +123,8 @@
     }
 }
 
+void mbtk_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_lib");
+}
+
diff --git a/mbtk/libmbtk_mqtt/mbtk_mqtt.c b/mbtk/libmbtk_mqtt/mbtk_mqtt.c
index 3af31f2..3b78429 100755
--- a/mbtk/libmbtk_mqtt/mbtk_mqtt.c
+++ b/mbtk/libmbtk_mqtt/mbtk_mqtt.c
@@ -1,7 +1,7 @@
 /*************************************************************************
 	> File Name: main.c
 	> Author: LFJ
-	> Mail: 
+	> Mail:
 	> Created Time: 2018年09月05日 星期三 13时48分17秒
  ************************************************************************/
 
@@ -22,6 +22,7 @@
 
 #include "mbtk_type.h"
 #include "mbtk_http.h"
+#include "mbtk_log.h"
 
 /*
 static Cloud_MQTT_t *iot_mqtt;
@@ -327,16 +328,16 @@
     char content[300] = {0};
     uint8_t source_temp[65]={0};
     sprintf(content,"clientId%s.%sdeviceName%sproductKey%stimestamp%s",product_key, device_name, device_name, product_key,CORE_AUTH_TIMESTAMP);
-	
+
 //    sprintf(content,"clientId%sdeviceName%sproductKey%stimestamp%s",client_id, device_name, product_key,CORE_AUTH_TIMESTAMP);
     core_hmac_sha256((uint8_t *)content, strlen((const char *)content), (uint8_t *)device_secret, strlen(device_secret),
                       source_temp);
-		  
+
     core_hex2str(source_temp, 32, dest,0);
 }
 
-void iot_aliyun_mqtt_init(Cloud_MQTT_t *piot_mqtt,int host,int port ,char *device_name,char *product_key, 
-		char * DeviceSecret,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb) 
+void iot_aliyun_mqtt_init(Cloud_MQTT_t *piot_mqtt,int host,int port ,char *device_name,char *product_key,
+		char * DeviceSecret,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb)
 {
     mbtk_imqtt_auth_hostname(piot_mqtt->mqtt_host,product_key,host);
     mbtk_imqtt_auth_clientid(piot_mqtt->mqtt_client_id,product_key,device_name);
@@ -350,18 +351,18 @@
     printf("mqtt_host is %s\nmqtt_port is %d\nmqtt_client_id is %s\nmqtt_user is %s\nmqtt_pass is %s\n",piot_mqtt->mqtt_host,piot_mqtt->mqtt_port,piot_mqtt->mqtt_client_id,piot_mqtt->mqtt_user,piot_mqtt->mqtt_pass);
     memset(piot_mqtt->sub_topic, '\0', MQTT_TOPIC_SIZE);
     memset(piot_mqtt->pub_topic, '\0', MQTT_TOPIC_SIZE);
-    
+
     sprintf(piot_mqtt->sub_topic, "%s", sub_topic);	//将初始化好的订阅主题填到数组中
     printf("subscribe:%s\n", piot_mqtt->sub_topic);
 
     sprintf(piot_mqtt->pub_topic, "%s", pub_topic);	//将初始化好的发布主题填到数组中
     printf("pub:%s\n", piot_mqtt->pub_topic);
-    
+
     piot_mqtt->DataArrived_Cb = mqtt_data_rx_cb;		//设置接收到数据回调函数
     printf("iot_mqtt_init end\n");
 }
 
-void mbtk_aliyun_mqtt_one_type_one_secret_unregin_set_info_init(Cloud_MQTT_t *piot_mqtt,mbtk_mqtt_device_session_t *device,int keepAliveInterval,int version,pMessageArrived_Fun mqtt_data_rx_cb) 
+void mbtk_aliyun_mqtt_one_type_one_secret_unregin_set_info_init(Cloud_MQTT_t *piot_mqtt,mbtk_mqtt_device_session_t *device,int keepAliveInterval,int version,pMessageArrived_Fun mqtt_data_rx_cb)
 {
 
     mbtk_imqtt_auth_hostname(piot_mqtt->mqtt_host,device->product_key,device->host);
@@ -375,7 +376,7 @@
     printf("piot_mqtt->mqtt_version:%d\n", piot_mqtt->mqtt_version);
     memset(piot_mqtt->sub_topic, '\0', MQTT_TOPIC_SIZE);
     memset(piot_mqtt->pub_topic, '\0', MQTT_TOPIC_SIZE);
-    
+
     piot_mqtt->DataArrived_Cb = mqtt_data_rx_cb;		//设置接收到数据回调函数
     printf("iot_mqtt_init end\n");
 }
@@ -398,7 +399,7 @@
 
 
 void iot_aliyun_mqtt_one_type_one_secret_unregin_connect_init(Cloud_MQTT_t *piot_mqtt,mbtk_mqtt_device_session_t *device, char *clientId, char *deviceToken,
-         int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb) 
+         int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb)
 {
     mbtk_imqtt_auth_hostname(piot_mqtt->mqtt_host,device->product_key,device->host);
     mbtk_imqtt_auth_clientid_yixinyimi_unregin(piot_mqtt->mqtt_client_id, clientId);
@@ -412,20 +413,20 @@
     printf("mqtt_host is %s\nmqtt_port is %d\nmqtt_client_id is %s\nmqtt_user is %s\nmqtt_pass is %s\n",piot_mqtt->mqtt_host,piot_mqtt->mqtt_port,piot_mqtt->mqtt_client_id,piot_mqtt->mqtt_user,piot_mqtt->mqtt_pass);
     memset(piot_mqtt->sub_topic, '\0', MQTT_TOPIC_SIZE);
     memset(piot_mqtt->pub_topic, '\0', MQTT_TOPIC_SIZE);
-    
+
     sprintf(piot_mqtt->sub_topic, "%s", sub_topic);	//将初始化好的订阅主题填到数组中
     printf("subscribe:%s\n", piot_mqtt->sub_topic);
 
     sprintf(piot_mqtt->pub_topic, "%s", pub_topic);	//将初始化好的发布主题填到数组中
     printf("pub:%s\n", piot_mqtt->pub_topic);
-    
+
     piot_mqtt->DataArrived_Cb = mqtt_data_rx_cb;		//设置接收到数据回调函数
     printf("iot_mqtt_init end\n");
 }
 
 
-void mbtk_aliyun_mqtt_one_type_one_secret_regint_connect_init(Cloud_MQTT_t *piot_mqtt,int host,int port ,char *device_name,char *product_key, 
-		char * DeviceSecret,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb) 
+void mbtk_aliyun_mqtt_one_type_one_secret_regint_connect_init(Cloud_MQTT_t *piot_mqtt,int host,int port ,char *device_name,char *product_key,
+		char * DeviceSecret,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb)
 {
     mbtk_imqtt_auth_hostname(piot_mqtt->mqtt_host,product_key,host);
     mbtk_aliyun_imqtt_auth_clientid(piot_mqtt->mqtt_client_id,product_key,device_name);
@@ -439,19 +440,19 @@
     printf("mqtt_host is %s\nmqtt_port is %d\nmqtt_client_id is %s\nmqtt_user is %s\nmqtt_pass is %s\n",piot_mqtt->mqtt_host,piot_mqtt->mqtt_port,piot_mqtt->mqtt_client_id,piot_mqtt->mqtt_user,piot_mqtt->mqtt_pass);
     memset(piot_mqtt->sub_topic, '\0', MQTT_TOPIC_SIZE);
     memset(piot_mqtt->pub_topic, '\0', MQTT_TOPIC_SIZE);
-    
+
     sprintf(piot_mqtt->sub_topic, "%s", sub_topic);	//将初始化好的订阅主题填到数组中
     printf("subscribe:%s\n", piot_mqtt->sub_topic);
 
     sprintf(piot_mqtt->pub_topic, "%s", pub_topic);	//将初始化好的发布主题填到数组中
     printf("pub:%s\n", piot_mqtt->pub_topic);
-    
+
     piot_mqtt->DataArrived_Cb = mqtt_data_rx_cb;		//设置接收到数据回调函数
     printf("iot_mqtt_init end\n");
 }
 
 
-void iot_mqtt_init(Cloud_MQTT_t *piot_mqtt,char *host,int port ,char *clientid,char *user,char *pass,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb) 
+void iot_mqtt_init(Cloud_MQTT_t *piot_mqtt,char *host,int port ,char *clientid,char *user,char *pass,int keepAliveInterval,int version,char *sub_topic,char *pub_topic,pMessageArrived_Fun mqtt_data_rx_cb)
 {
 
     memcpy(piot_mqtt->mqtt_host,host,strlen(host));
@@ -462,24 +463,24 @@
     piot_mqtt->keepAliveInterval = keepAliveInterval;
     piot_mqtt->mqtt_version = version;
 
-    
+
     printf("mqtt_host is %s\nmqtt_port is %d\nmqtt_client_id is %s\nmqtt_user is %s\nmqtt_pass is %s\n",piot_mqtt->mqtt_host,piot_mqtt->mqtt_port,piot_mqtt->mqtt_client_id,piot_mqtt->mqtt_user,piot_mqtt->mqtt_pass);
     memset(piot_mqtt->sub_topic, '\0', MQTT_TOPIC_SIZE);
     memset(piot_mqtt->pub_topic, '\0', MQTT_TOPIC_SIZE);
-    
+
     sprintf(piot_mqtt->sub_topic, "%s", sub_topic);	//将初始化好的订阅主题填到数组中
     printf("subscribe:%s\n", piot_mqtt->sub_topic);
 
     sprintf(piot_mqtt->pub_topic, "%s", pub_topic);	//将初始化好的发布主题填到数组中
     printf("pub:%s\n", piot_mqtt->pub_topic);
-    
+
     piot_mqtt->DataArrived_Cb = mqtt_data_rx_cb;		//设置接收到数据回调函数
     printf("iot_mqtt_init end\n");
 }
 /*
 void MQTTMessageArrived_Cb(MessageData* md)
 {
-    MQTTMessage *message = md->message; 
+    MQTTMessage *message = md->message;
 
     Cloud_MQTT_t *piot_mqtt = get_mqtt_t();
 
@@ -667,3 +668,9 @@
     return ret;
 }
 
+void mbtk_mqtt_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_mqtt_lib");
+}
+
+
diff --git a/mbtk/libmbtk_net/mbtk_sock2.c b/mbtk/libmbtk_net/mbtk_sock2.c
index d75a854..ae5329e 100755
--- a/mbtk/libmbtk_net/mbtk_sock2.c
+++ b/mbtk/libmbtk_net/mbtk_sock2.c
@@ -1733,5 +1733,9 @@
     return len;
 }
 
+void mbtk_net_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_net_lib");
+}
 
 
diff --git a/mbtk/libmbtk_ril/mbtk_info_api.c b/mbtk/libmbtk_ril/mbtk_info_api.c
index 6dda440..7823f3d 100755
--- a/mbtk/libmbtk_ril/mbtk_info_api.c
+++ b/mbtk/libmbtk_ril/mbtk_info_api.c
@@ -428,7 +428,7 @@
             handle->data = NULL;
         }
         pthread_mutex_unlock(&handle->send_mutex);
-        
+
         return recv_len;
     } else {
         LOG("REQ %s fail : %s", id2str(id), err2str(handle->info_err));
@@ -438,7 +438,10 @@
     }
 }
 
-
+void mbtk_ril_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_ril_lib");
+}
 
 mbtk_info_handle_t* mbtk_info_handle_get()
 {
@@ -1225,7 +1228,7 @@
 
             i++;
         }
-    } 
+    }
     else if(len == 0)
     {
         LOGD("get data len : 0.");
@@ -1250,7 +1253,7 @@
         LOGE("ARG error.");
         return -1;
     }
-    
+
     uint8 data[SOCK_MSG_LEN_MAX];
     memset(data, 0, SOCK_MSG_LEN_MAX);
     // cid : 2 - 7
@@ -1387,12 +1390,12 @@
     }
 
     profile_idx++;
-    if(info_item_process(handle, MBTK_INFO_ID_NET_APN_DEL_REQ, &profile_idx, sizeof(profile_idx), NULL) >= 0) 
+    if(info_item_process(handle, MBTK_INFO_ID_NET_APN_DEL_REQ, &profile_idx, sizeof(profile_idx), NULL) >= 0)
     {
         LOG("profile_idx Number : %d", profile_idx);
         return 0;
-    } 
-    else 
+    }
+    else
     {
         return handle->info_err;
     }
diff --git a/mbtk/libmbtk_ril_v2/src/mbtk_ril_api.c b/mbtk/libmbtk_ril_v2/src/mbtk_ril_api.c
index d864a75..4668bd2 100755
--- a/mbtk/libmbtk_ril_v2/src/mbtk_ril_api.c
+++ b/mbtk/libmbtk_ril_v2/src/mbtk_ril_api.c
@@ -31,6 +31,14 @@
 static ril_cli_info_t ril_cli;
 static int pthread_id_index = 1;
 
+static bool ril_cid_check(mbtk_ril_cid_enum cid)
+{
+    if(cid < MBTK_APN_CID_MIN || cid > MBTK_APN_CID_MAX)
+        return FALSE;
+
+    return TRUE;
+}
+
 static ril_cli_thread_info_t* thread_find_by_pid(pthread_t pid)
 {
     ril_cli_thread_info_t* cli_thread = NULL;
@@ -399,6 +407,11 @@
     }
 }
 
+void mbtk_ril_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_ril_lib");
+}
+
 mbtk_ril_err_enum mbtk_ril_init()
 {
     if(ril_cli.ril_ready)
@@ -1262,6 +1275,16 @@
         return MBTK_RIL_ERR_PARAMETER;
     }
 
+    if(str_empty(apn->apn)) { // Delete APN
+        if(!ril_cid_check(apn->cid)) {
+            return MBTK_RIL_ERR_CID;
+        }
+    } else { // Set APN
+        if(apn->cid != MBTK_RIL_CID_NUL && !ril_cid_check(apn->cid)) {
+            return MBTK_RIL_ERR_CID;
+        }
+    }
+
     return ril_req_process(RIL_MSG_ID_NET_APN, apn, sizeof(mbtk_apn_info_t), NULL, FALSE);
 }
 
@@ -1269,18 +1292,24 @@
 * Start data call.
 */
 mbtk_ril_err_enum mbtk_data_call_start(mbtk_ril_cid_enum cid, bool auto_boot_call,
-            bool def_route, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info)
+            bool def_route, bool as_dns, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info)
 {
     if(!ril_cli.ril_ready)
     {
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
+    if(!ril_cid_check(cid)) {
+        return MBTK_RIL_ERR_CID;
+    }
+
     mbtk_data_call_info_t info;
     memset(&info, 0, sizeof(mbtk_data_call_info_t));
     info.type = MBTK_DATA_CALL_START;
+    info.cid = cid;
     info.auto_boot_call = (uint8)auto_boot_call;
     info.def_route = (uint8)def_route;
+    info.as_dns = (uint8)as_dns;
     info.retry_interval = (uint16)retry_interval;
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
@@ -1299,9 +1328,14 @@
         return MBTK_RIL_ERR_NOT_INIT;
     }
 
+    if(!ril_cid_check(cid)) {
+        return MBTK_RIL_ERR_CID;
+    }
+
     mbtk_data_call_info_t info;
     memset(&info, 0, sizeof(mbtk_data_call_info_t));
     info.type = MBTK_DATA_CALL_STOP;
+    info.cid = cid;
     if(timeout > 0) {
         info.timeout = (uint16)timeout;
     }
@@ -1311,7 +1345,7 @@
 /*
 * Get data call state.
 */
-mbtk_ril_err_enum mbtk_data_call_state_get(int cid, mbtk_ip_info_t *ip)
+mbtk_ril_err_enum mbtk_data_call_state_get(mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip)
 {
     if(!ril_cli.ril_ready)
     {
@@ -1324,9 +1358,14 @@
         return MBTK_RIL_ERR_PARAMETER;
     }
 
+    if(!ril_cid_check(cid)) {
+        return MBTK_RIL_ERR_CID;
+    }
+
     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_NET_DATA_CALL, &info, sizeof(mbtk_data_call_info_t), ip, FALSE);
 }
diff --git a/mbtk/libmbtk_tcpip/mbtk_tcpip_at.c b/mbtk/libmbtk_tcpip/mbtk_tcpip_at.c
index 8490ede..fadb1a6 100755
--- a/mbtk/libmbtk_tcpip/mbtk_tcpip_at.c
+++ b/mbtk/libmbtk_tcpip/mbtk_tcpip_at.c
@@ -658,3 +658,8 @@
     tcpip_link[link_id].tcpip_info.cli_info.read_cb = read_cb;
 }
 
+void mbtk_tcpip_lib_info_print()
+{
+    MBTK_SOURCE_INFO_PRINT("mbtk_tcpip_lib");
+}
+
diff --git a/mbtk/libql_lib/src/ql_common.c b/mbtk/libql_lib/src/ql_common.c
index 70d0ad3..eee9fa2 100755
--- a/mbtk/libql_lib/src/ql_common.c
+++ b/mbtk/libql_lib/src/ql_common.c
@@ -1,5 +1,6 @@
 #include <stdlib.h>

 #include "ql/ql_common.h"

+#include "mbtk_log.h"

 

 void Ql_Powerdown(int mode)

 {

@@ -19,3 +20,9 @@
 

 }

 

+void ql_lib_info_print()

+{

+    MBTK_SOURCE_INFO_PRINT("ql_lib");

+}

+

+

diff --git a/mbtk/libql_lib_v2/src/ql_common.c b/mbtk/libql_lib_v2/src/ql_common.c
index 70d0ad3..d269b82 100755
--- a/mbtk/libql_lib_v2/src/ql_common.c
+++ b/mbtk/libql_lib_v2/src/ql_common.c
@@ -1,5 +1,6 @@
 #include <stdlib.h>

 #include "ql/ql_common.h"

+#include "mbtk_log.h"

 

 void Ql_Powerdown(int mode)

 {

@@ -19,3 +20,8 @@
 

 }

 

+void ql_lib_info_print()

+{

+    MBTK_SOURCE_INFO_PRINT("ql_lib");

+}

+

diff --git a/mbtk/mbtk_adbd/src/main.c b/mbtk/mbtk_adbd/src/main.c
index 1907bd4..036ba24 100755
--- a/mbtk/mbtk_adbd/src/main.c
+++ b/mbtk/mbtk_adbd/src/main.c
@@ -384,6 +384,8 @@
     char port_config[32] = {0};
     mbtk_log_init("radio", "MBTK_ADBD");
 
+    MBTK_SOURCE_INFO_PRINT("mbtk_adbd");
+
 #ifdef MBTK_DUMP_SUPPORT
     mbtk_debug_open(NULL, TRUE);
 #endif
diff --git a/mbtk/mbtk_gnssd/gnss_main.c b/mbtk/mbtk_gnssd/gnss_main.c
index e319a45..c0eae05 100755
--- a/mbtk/mbtk_gnssd/gnss_main.c
+++ b/mbtk/mbtk_gnssd/gnss_main.c
@@ -38,7 +38,7 @@
 #define GNSS_FILE_LOG_MAX       104857600    // 100MB
 #endif
 
-gnss_info_t gnss_info; 
+gnss_info_t gnss_info;
 
 #ifdef MBTK_GNSS_UBUS_ENABLE
 struct ubus_context *gnss_ubus_init(void);
@@ -388,7 +388,7 @@
         return -1;
     }
 
-    while (p <= q) 
+    while (p <= q)
     {
         tmp = memchr(p, ',', q-p);
         if (tmp == NULL)
@@ -406,7 +406,7 @@
                 count += 1;
             }
         }
-        
+
         if (tmp <= q)
         {
             tmp += 1;
@@ -512,9 +512,9 @@
     memcpy(tmp_char, time.head + 4, 2);
     tmp_time.tm_sec = atoi(tmp_char);
     tmp_time.tm_isdst = -1;
-    
 
-    LOGD("data:%d-%d-%d %d:%d:%d", tmp_time.tm_year + 1900, 
+
+    LOGD("data:%d-%d-%d %d:%d:%d", tmp_time.tm_year + 1900,
                                     tmp_time.tm_mon,
                                     tmp_time.tm_mday,
                                     tmp_time.tm_hour,
@@ -1140,7 +1140,7 @@
             }
             ind_info[index].cli_fd = fd;
             ind_info[index].ind_flag = (uint32)ind_type;
-        } else { // Change flag     
+        } else { // Change flag
             ind_info[index].cli_fd = fd;
             ind_info[index].ind_flag = (uint32)ind_type;
         }
@@ -1153,7 +1153,7 @@
 
         if(index == GNSS_CLI_IND_MAX) {
             return GNSS_ERR_ARG;
-        }    
+        }
         ind_info[index].cli_fd = 0;
         ind_info[index].ind_flag = 0;
     }
@@ -1210,6 +1210,8 @@
 {
     mbtk_log_init("radio", GNSS_TAG);
 
+    MBTK_SOURCE_INFO_PRINT("mbtk_gnssd");
+
 #ifdef MBTK_DUMP_SUPPORT
     mbtk_debug_open(NULL, TRUE);
 #endif
diff --git a/mbtk/mbtk_rild/src/main.c b/mbtk/mbtk_rild/src/main.c
index ffca006..2eac8a6 100755
--- a/mbtk/mbtk_rild/src/main.c
+++ b/mbtk/mbtk_rild/src/main.c
@@ -418,7 +418,7 @@
             } else {

                 LOGI("No process : %s", s);

             }

-			

+

 			urc_msg_distribute(true, INFO_URC_MSG_CGEV, data, sizeof(uint8) * 2);

         }

     }

@@ -439,7 +439,7 @@
         uint8 data[2];

         data[0] = (uint8)atoi(tmp_s); // Reg State.

 

-        if(strStartsWith(s, "+CGREG:")) 

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

         {

            data[1] = 0;  // GMS/WCDMA

            if(data[0] == 1)

@@ -450,9 +450,9 @@
            {

                net_led_gms_wcdma = FALSE;

            }

-    

-        } 

-        else 

+

+        }

+        else

         {

            data[1] = 1;  // LTE

            if(data[0] == 1)

@@ -464,7 +464,7 @@
                net_led_lte = FALSE;

            }

         }

-   

+

         if(FALSE == net_led_gms_wcdma && FALSE == net_led_lte)

         {

            mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);

@@ -1899,6 +1899,8 @@
 {

     mbtk_log_init("radio", "MBTK_RIL");

 

+    MBTK_SOURCE_INFO_PRINT("mbtk_rild");

+

 #ifdef MBTK_DUMP_SUPPORT

     mbtk_debug_open(NULL, TRUE);

 #endif

diff --git a/mbtk/mbtk_rild_v2/inc/ril_info.h b/mbtk/mbtk_rild_v2/inc/ril_info.h
index 896a73c..595d603 100755
--- a/mbtk/mbtk_rild_v2/inc/ril_info.h
+++ b/mbtk/mbtk_rild_v2/inc/ril_info.h
@@ -26,6 +26,7 @@
 
 #define MBTK_APN_PROP       "persist.mbtk.apn"
 #define MBTK_DEF_ROUTE_CID  "persist.mbtk.def_route_cid"
+#define MBTK_DEF_DNS_CID  "persist.mbtk.def_dns_cid"
 
 typedef struct
 {
@@ -104,11 +105,19 @@
 
 typedef struct {
     mbtk_ril_cid_enum cid_for_def_route;
+    mbtk_ril_cid_enum cid_for_dns;
 
     int num;
     mbtk_apn_info_t apns[MBTK_APN_CID_MAX];
 } ril_apn_info_array_t;
 
+typedef struct
+{
+    int cid;
+    bool act;
+    bool waitting;
+} ril_cgact_wait_t;
+
 extern ril_info_t ril_info;
 
 
@@ -121,4 +130,8 @@
 
 bool is_ipv4(const char *ip);
 
+int net_ifc_config(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
+
+int net_ifc_reconfig(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
+
 #endif /* _RIL_INFO_H */
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 24a74a3..7f68de3 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -52,6 +52,7 @@
 ril_band_info_t band_info;

 ril_info_t ril_info;

 extern mbtk_cell_pack_info_t cell_info;

+extern ril_cgact_wait_t cgact_wait;

 

 // int urc_msg_distribute(bool async_process, info_urc_msg_id_enum msg, void *data, int data_len);

 // int mbtk_signal_log(char *data);

@@ -282,7 +283,297 @@
     }
 }

 

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

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

+{

+    // "CONNECT"

+    if(strStartsWith(s, "CONNECT"))

+    {

+#if 1

+        if(cgact_wait.waitting && cgact_wait.act) {

+            cgact_wait.waitting = false;

+        }

+#endif

+    }

+    // +CGEV:

+    // +CGEV: NW DEACT <cid>,<cid>

+    // +CGEV: ME DEACT <cid>,<cid>

+    // +CGEV: NW PDN DEACT <cid>

+    // +CGEV: ME PDN DEACT <cid>

+    // +CGEV: NW DETACH

+    // +CGEV: ME DETACH

+    //

+    // +CGEV: NW ACT <cid>,<cid>

+    // +CGEV: ME ACT <cid>,<cid>

+    // +CGEV: EPS PDN ACT <cid>

+    // +CGEV: ME PDN ACT <cid>,<reason>,<cid>

+    // +CGEV: ME PDN ACT <cid>,<reason>

+    // +CGEV: NW PDN ACT <cid>

+    // +CGEV: EPS ACT <cid>

+    // +CGEV: NW MODIFY <cid>,<reason>

+    // +CGEV: NW REATTACH

+

+    /*

+    +CGEV: NW DETACH

+    +CGEV: ME DETACH

+    +CGEV: NW CLASS <class>

+    +CGEV: ME CLASS <class>

+    +CGEV: NW PDN ACT <cid>

+    +CGEV: ME PDN ACT <cid>[,<reason>[,<cid_other>]]

+    +CGEV: NW ACT <p_cid>, <cid>, <event_type>

+    +CGEV: ME ACT <p_cid>, <cid>, <event_type>

+    +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: NW PDN DEACT <cid>

+    +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: ME PDN DEACT <cid>

+    +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: NW DEACT <p_cid>, <cid>, <event_type>

+    +CGEV: NW DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: ME DEACT <p_cid>, <cid>, <event_type>

+    +CGEV: ME DEACT <PDP_type>, <PDP_addr>, [<cid>]

+    +CGEV: NW MODIFY <cid>, <change_reason>, <event_type>

+    +CGEV: ME MODIFY <cid>, <change_reason>, <event_type>

+    +CGEV: REJECT <PDP_type>, <PDP_addr>

+    +CGEV: NW REACT <PDP_type>, <PDP_addr>, [<cid>]

+    */

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

+    {

+#if 1

+        // "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>[,<reason>[,<cid_other>]]

+        // "+CGEV: NW MODIFY ")) { //  +CGEV: NW MODIFY <cid>, <change_reason>, <event_type>

+        // "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1

+        // "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>

+        // "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>

+        // "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>

+        // "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1

+        int cid = -1;

+        int reason = -1;

+        bool act = FALSE;

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

+            act = FALSE;

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

+            act = FALSE;

+        } else if(sscanf(s, "+CGEV: ME PDN ACT %d,%d", &cid, &reason) == 2

+                || sscanf(s, "+CGEV: ME PDN ACT %d", &cid) == 1) {

+            act = TRUE;

+        } else if (!strcmp(s, "+CGEV: ME DETACH")) {

+            if(cgact_wait.waitting) {

+                cid = cgact_wait.cid;

+            }

+            act = FALSE;

+        } else if (sscanf(s, "+CGEV: NW MODIFY %d,%d", &cid, &reason) == 2) {

+            act = TRUE;

+        } else if(sscanf(s, "+CGEV: EPS PDN ACT %d", &cid) == 1) {

+            act = TRUE;

+        } else {

+            LOGD(">>>>>>>>>No process +CGEV <<<<<<<<<");

+            return;

+        }

+

+        if(cgact_wait.act) {

+            if(cgact_wait.waitting && act && cgact_wait.cid == cid) {

+                cgact_wait.waitting = false;

+            }

+        } else {

+            if(cgact_wait.waitting && !act && cgact_wait.cid == cid) {

+                cgact_wait.waitting = false;

+            }

+        }

+

+        LOGD("+CGEV:cid - %d, act - %d, reason - %d", cid, act, reason);

+#else

+        if(at_process) {

+            if(cgact_wait.act) {

+                if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT 15,4

+                    if(cgact_wait.cid == atoi(s + 18)) {

+                        cgact_wait.waitting = false;

+                    }

+

+                    uint8 data_pdp;

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

+                    char* free_ptr = tmp_s;

+                    char *line = tmp_s;

+                    int tmp_int;

+                    if (at_tok_start(&line) < 0)

+                    {

+                        goto at_PDP_CREG_EXIT;

+                    }

+                    if (at_tok_nextint(&line, &tmp_int) < 0)

+                    {

+                        goto at_PDP_CREG_EXIT;

+                    }

+                    if (at_tok_nextint(&line, &tmp_int) < 0)

+                    {

+                        goto at_PDP_CREG_EXIT;

+                    }

+                    data_pdp = tmp_int;

+at_PDP_CREG_EXIT:

+                    free(free_ptr);

+

+                    //data_pdp = (uint8)atoi(s + 20);  //reason

+                    if(cgact_wait.cid >= 1 && cgact_wait.cid < 8)

+                    {

+                        if(data_pdp == 0)

+                        {

+                            data_pdp = 25;

+                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                            //data_pdp = cgact_wait.cid + 200;

+                        }

+                        else if(data_pdp == 1)

+                        {

+                            data_pdp = 26;

+                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                        }

+                        else if(data_pdp == 2)

+                        {

+                            data_pdp = 27;

+                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                        }

+                        else if(data_pdp == 3)

+                        {

+                            data_pdp = 27;

+                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                        }

+                        else

+                        {

+

+                        }

+                        if(cgact_wait.cid != 0)

+                        {

+                            data_pdp = cgact_wait.cid + 200;

+                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                        }

+                    }

+                } else if(strStartsWith(s, "+CGEV: NW MODIFY ")) { // +CGEV: NW MODIFY 1,4

+                    if(cgact_wait.cid == atoi(s + 17)) {

+                        cgact_wait.waitting = false;

+                    }

+                }

+            } else {

+                if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1

+                    if(cgact_wait.cid == atoi(s + 20)) {

+                        cgact_wait.waitting = false;

+                    }

+                    uint8 data_pdp;

+                    data_pdp = 0;       //

+                    urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    if(cgact_wait.cid != 0)

+                    {

+                        data_pdp = cgact_wait.cid + 100;

+                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    }

+                }

+            }

+        } else {

+            // apn_state_set

+

+            // +CGEV: NW PDN DEACT <cid>

+

+            // +CGEV: EPS PDN ACT 1

+            // +CGEV: ME PDN ACT 8,1

+

+            // +CGEV: ME PDN ACT 2,4

+            uint8 data[2] = {0xFF};

+            if(strStartsWith(s, "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>

+                //apn_state_set(atoi(s + 20), false);

+                data[0] = (uint8)0;

+                data[1] = (uint8)atoi(s + 20);

+

+                uint8 data_pdp;

+                data_pdp = 0;       //

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                data_pdp = data[1] + 100;

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+            } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>

+                //apn_state_set(atoi(s + 19), true);

+#if (defined(MBTK_AF_SUPPORT) || defined(MBTK_ALL_CID_SUPPORT))

+				//data[0] = (uint8)1;

+                //data[1] = (uint8)atoi(s + 19);

+#else

+                data[0] = (uint8)1;

+                data[1] = (uint8)atoi(s + 19);

+#endif

+            } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>

+                //apn_state_set(atoi(s + 19), true);

+                data[0] = (uint8)0;

+                data[1] = (uint8)atoi(s + 20);

+

+                uint8 data_pdp;

+                data_pdp = 0;       //

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                data_pdp = data[1] + 100;

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+            } else if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1

+                //apn_state_set(atoi(s + 18), true);

+                data[0] = (uint8)1;

+                data[1] = (uint8)atoi(s + 18);

+

+                uint8 data_pdp;

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

+                char* free_ptr = tmp_s;

+                char *line = tmp_s;

+                int tmp_int;

+                if (at_tok_start(&line) < 0)

+                {

+                    goto PDP_CREG_EXIT;

+                }

+                if (at_tok_nextint(&line, &tmp_int) < 0)

+                {

+                    goto PDP_CREG_EXIT;

+                }

+                if (at_tok_nextint(&line, &tmp_int) < 0)

+                {

+                    goto PDP_CREG_EXIT;

+                }

+                data_pdp = tmp_int;

+PDP_CREG_EXIT:

+                free(free_ptr);

+                //data_pdp = (uint8)atoi(s + 20);  //reason

+                if(data[1] >= 1 && data[1] < 8)

+                {

+                    if(data_pdp == 0)

+                    {

+                        data_pdp = 25;

+                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    }

+                    else if(data_pdp == 1)

+                    {

+                        data_pdp = 26;

+                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    }

+                    else if(data_pdp == 2)

+                    {

+                        data_pdp = 27;

+                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    }

+                    else if(data_pdp == 3)

+                    {

+                        data_pdp = 27;

+                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                    }

+                    else

+                    {

+

+                    }

+

+                    data_pdp = data[1] + 200;

+                    urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+					data[1] = 0;

+                }

+            } else {

+                LOGI("No process : %s", s);

+            }

+

+			urc_msg_distribute(true, INFO_URC_MSG_CGEV, data, sizeof(uint8) * 2);

+        }

+#endif

+    } else {

+        LOGW("Unknown PDP URC : %s", s);

+    }

+}

+

+

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

 {

     /*

     // <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,

@@ -925,6 +1216,15 @@
     if (strStartsWith(s, "MBTK_AT_READY")) // AT ready.

     {

 

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

+        urc_pdp_state_process(s, sms_pdu);

+    } else if(strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")

+        || strStartsWith(s, "+EEMLTEINTRA:") || strStartsWith(s, "+EEMLTEINTERRAT:")

+        || strStartsWith(s, "+EEMUMTSSVC:") || strStartsWith(s, "+EEMUMTSINTRA:")

+        || strStartsWith(s, "+EEMUMTSINTERRAT:") || strStartsWith(s, "+EEMGINFOBASIC:")

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

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

+        urc_cell_info_process(s, sms_pdu);

     }

 #if 0

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

@@ -946,119 +1246,7 @@
         }

         urc_msg_distribute(true, INFO_URC_MSG_RADIO_STATE, &state, sizeof(uint8));

     }

-    // "CONNECT"

-    else if(strStartsWith(s, "CONNECT"))

-    {

-        if(cgact_wait.waitting && cgact_wait.act) {

-            cgact_wait.waitting = false;

-        }

-

-        uint8 data_pdp;

-        data_pdp = 1;       //

-        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-    }

-    // +CGEV:

-    // +CGEV: NW DEACT <cid>,<cid>

-    // +CGEV: ME DEACT <cid>,<cid>

-    // +CGEV: NW PDN DEACT <cid>

-    // +CGEV: ME PDN DEACT <cid>

-    // +CGEV: NW DETACH

-    // +CGEV: ME DETACH

-    //

-    // +CGEV: NW ACT <cid>,<cid>

-    // +CGEV: ME ACT <cid>,<cid>

-    // +CGEV: EPS PDN ACT <cid>

-    // +CGEV: ME PDN ACT <cid>,<reason>,<cid>

-    // +CGEV: ME PDN ACT <cid>,<reason>

-    // +CGEV: NW PDN ACT <cid>

-    // +CGEV: EPS ACT <cid>

-    // +CGEV: NW MODIFY <cid>,<reason>

-    // +CGEV: NW REATTACH

-    else if(strStartsWith(s, "+CGEV:"))

-    {

-        if(at_process) {

-            if(cgact_wait.act) {

-                if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT 15,4

-                    if(cgact_wait.cid == atoi(s + 18)) {

-                        cgact_wait.waitting = false;

-                    }

-

-                    uint8 data_pdp;

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

-                    char* free_ptr = tmp_s;

-                    char *line = tmp_s;

-                    int tmp_int;

-                    if (at_tok_start(&line) < 0)

-                    {

-                        goto at_PDP_CREG_EXIT;

-                    }

-                    if (at_tok_nextint(&line, &tmp_int) < 0)

-                    {

-                        goto at_PDP_CREG_EXIT;

-                    }

-                    if (at_tok_nextint(&line, &tmp_int) < 0)

-                    {

-                        goto at_PDP_CREG_EXIT;

-                    }

-                    data_pdp = tmp_int;

-at_PDP_CREG_EXIT:

-                    free(free_ptr);

-

-                    //data_pdp = (uint8)atoi(s + 20);  //reason

-                    if(cgact_wait.cid >= 1 && cgact_wait.cid < 8)

-                    {

-                        if(data_pdp == 0)

-                        {

-                            data_pdp = 25;

-                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                            //data_pdp = cgact_wait.cid + 200;

-                        }

-                        else if(data_pdp == 1)

-                        {

-                            data_pdp = 26;

-                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                        }

-                        else if(data_pdp == 2)

-                        {

-                            data_pdp = 27;

-                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                        }

-                        else if(data_pdp == 3)

-                        {

-                            data_pdp = 27;

-                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                        }

-                        else

-                        {

-

-                        }

-                        if(cgact_wait.cid != 0)

-                        {

-                            data_pdp = cgact_wait.cid + 200;

-                            urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                        }

-                    }

-                } else if(strStartsWith(s, "+CGEV: NW MODIFY ")) { // +CGEV: NW MODIFY 1,4

-                    if(cgact_wait.cid == atoi(s + 17)) {

-                        cgact_wait.waitting = false;

-                    }

-                }

-            } else {

-                if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: ME PDN DEACT 1

-                    if(cgact_wait.cid == atoi(s + 20)) {

-                        cgact_wait.waitting = false;

-                    }

-                    uint8 data_pdp;

-                    data_pdp = 0;       //

-                    urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                    if(cgact_wait.cid != 0)

-                    {

-                        data_pdp = cgact_wait.cid + 100;

-                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                    }

-                }

-            }

-        } else {

+    else {

             // apn_state_set

 

             // +CGEV: NW PDN DEACT <cid>

@@ -1581,14 +1769,6 @@
 #endif

 

 #endif

-    else if(strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")

-        || strStartsWith(s, "+EEMLTEINTRA:") || strStartsWith(s, "+EEMLTEINTERRAT:")

-        || strStartsWith(s, "+EEMUMTSSVC:") || strStartsWith(s, "+EEMUMTSINTRA:")

-        || strStartsWith(s, "+EEMUMTSINTERRAT:") || strStartsWith(s, "+EEMGINFOBASIC:")

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

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

-        urc_cell_process(s, sms_pdu);

-    }

     else if(strStartsWith(s, "+ZGIPDNS:")) // +ZGIPDNS: 1,"IPV4V6","10.156.239.245","10.156.239.246","223.87.253.100","223.87.253.253","fe80:0000:0000:0000:0001:0001:9b8c:7c0c","fe80::1:1:9b8c:7c0d","2409:8062:2000:2::1","2409:8062:2000:2::2"

     {

 

@@ -2151,11 +2331,12 @@
     return -1;
 }

 

-

 int main(int argc, char *argv[])

 {

     mbtk_log_init("radio", "MBTK_RIL");

 

+    MBTK_SOURCE_INFO_PRINT("mbtk_rild");

+

 #ifdef MBTK_DUMP_SUPPORT

     mbtk_debug_open(NULL, TRUE);

 #endif

diff --git a/mbtk/mbtk_rild_v2/src/ril_data_call.c b/mbtk/mbtk_rild_v2/src/ril_data_call.c
index a0f3eeb..4fbeca5 100755
--- a/mbtk/mbtk_rild_v2/src/ril_data_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_data_call.c
@@ -38,4 +38,165 @@
     }
 }
 
+static void net_if_as_def_route(mbtk_ril_cid_enum cid)
+{
+    if(cid != MBTK_RIL_CID_NUL) {
+        char buf[100] = {0};
+
+        // Delete all default route in the first.
+
+
+        // Add default route.
+        memset(buf, 0, sizeof(buf));
+        sprintf(buf, "route add default dev ccinet%d", cid - 1);
+        system(buf);
+    }
+}
+
+static int net_if_as_dns(mbtk_ril_cid_enum cid, mbtk_ipv4_info_t *ipv4, mbtk_ipv6_info_t *ipv6)
+{
+    char buf[1024] = {0};
+    char dns[128] = {0};
+    int offset = 0;
+    int fd = -1;
+
+    memset(buf, 0x0, 1024);
+    memset(dns, 0x0, 128);
+    offset = sprintf(buf, "search lan\n");
+    if(ipv4->valid)
+    {
+        if(inet_ntop(AF_INET, &(ipv4->PrimaryDNS), dns, 32) == NULL) {
+            LOGE("PrimaryDNS error.");
+        } else {
+            LOGD("PrimaryDNS : %s", dns);
+        }
+        offset += sprintf(buf + offset, "nameserver %s\n", dns);
+        memset(dns, 0x0, 128);
+        if(inet_ntop(AF_INET, &(ipv4->SecondaryDNS), dns, 32) == NULL) {
+            LOGE("SecondaryDNS error.");
+        } else {
+            LOGD("SecondaryDNS : %s", dns);
+        }
+        offset += sprintf(buf + offset, "nameserver %s\n", dns);
+    }
+    if(ipv6->valid)
+    {
+        memset(dns, 0x0, 128);
+		if(ipv6_2_str(&(ipv6->PrimaryDNS), dns))
+        {
+			LOGE("PrimaryDNS error.");
+		} else {
+			LOGD("PrimaryDNS : %s", dns);
+		}
+        offset += sprintf(buf + offset, "nameserver %s\n", dns);
+        memset(dns, 0x0, 128);
+		if(ipv6_2_str(&(ipv6->SecondaryDNS), dns))
+        {
+			LOGE("SecondaryDNS error.");
+		} else {
+			LOGD("SecondaryDNS : %s", dns);
+		}
+        offset += sprintf(buf + offset, "nameserver %s\n", dns);
+    }
+
+    if(offset > 0)
+    {
+        fd = open("/tmp/resolv.conf", O_WRONLY | O_TRUNC);
+        if(fd < 0)
+        {
+            LOGE("/tmp/resolv.conf : open fail.");
+            return -1;
+        }
+
+        int ret = write(fd, buf, offset);
+        if(ret < 0)
+        {
+            LOGE("/tmp/resolv.conf : write fail.");
+            close(fd);
+            return -1;
+        }
+
+        close(fd);
+    }
+    return 0;
+}
+
+int net_ifc_config(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info)
+{
+    int ret = -1;
+    char dev[20] = {0};
+    sprintf(dev, "ccinet%d", cid - 1);
+    if(ip_info) { // Config IP.
+        // Config IPv4 address.
+        if(ip_info->ipv4.valid) {
+            char ip[20] = {0};
+            if(inet_ntop(AF_INET, &(ip_info->ipv4.IPAddr), ip, 20) == NULL) {
+                LOGE("inet_ntop ipv4 ip fail.");
+                goto exit;
+            }
+
+            if(mbtk_ifc_configure2(dev, ip, 0, NULL, "255.255.255.0")) {
+                LOGD("Config %s IPv4 %s fail.", dev, ip);
+                goto exit;
+            } else {
+                LOGD("Config %s IPv4 %s success.", dev, ip);
+            }
+        }
+
+        // Config IPv6 address.
+        if(ip_info->ipv6.valid) {
+            char ip[50] = {0};
+
+            if(inet_ntop(AF_INET6, &(ip_info->ipv6.IPV6Addr), ip, 50) == NULL) {
+                LOGE("inet_ntop ipv6 ip fail.");
+                goto exit;
+            }
+
+            if(mbtk_ipv6_config(dev, ip, 64)) {
+                LOGD("Config %s IPv6 %s fail.", dev, ip);
+                goto exit;
+            } else {
+                LOGD("Config %s IPv6 %s success.", dev, ip);
+            }
+        }
+
+        // mbtk_qser_route_config(cid, &ip_info->ipv4, &ip_info->ipv6);
+        if(def_route && (ip_info->ipv4.valid || ip_info->ipv6.valid)) {
+            net_if_as_def_route(cid);
+        }
+
+        if(as_dns) {
+            ret = net_if_as_dns(cid, &(ip_info->ipv4), &(ip_info->ipv6));
+        }
+    } else { // Del IP
+        if(mbtk_ifc_configure2(dev, NULL, 0, NULL, NULL)) {
+            LOGD("Config %s IPv4 0 fail.", dev);
+            goto exit;
+        } else {
+            LOGD("Config %s IPv4 0 success.", dev);
+        }
+#if 0
+        if(mbtk_ipv6_config(dev, NULL, 64)) {
+            LOGD("Config %s IPv6 0 fail.", dev);
+            goto exit;
+        } else {
+            LOGD("Config %s IPv6 0 success.", dev);
+        }
+#endif
+    }
+
+    ret = 0;
+exit:
+    return ret;
+}
+
+int net_ifc_reconfig(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info)
+{
+    int ret = net_ifc_config(cid, FALSE, FALSE, NULL);
+    if(ret) {
+        return ret;
+    }
+
+    return net_ifc_config(cid, def_route, as_dns, ip_info);
+}
 
diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index 6e0cd8c..3592850 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -21,10 +21,11 @@
 #include "mbtk_str.h"
 
 mbtk_cell_pack_info_t cell_info;
+ril_cgact_wait_t cgact_wait;
 
 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);
-static int req_apn_get(mbtk_apn_info_array_t *apns, int *cme_err);
+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 void apn_prop_get(ril_apn_info_array_t *apns);
 
@@ -66,7 +67,7 @@
     return TRUE;
 }
 
-static int apn_cid_reset(mbtk_apn_info_t *apn)
+static int apn_check_and_cid_reset(mbtk_apn_info_t *apn)
 {
     // Delete apn
     if(str_empty(apn->apn)) {
@@ -76,10 +77,11 @@
         if(!apn_conf_support(MBTK_RIL_CID_DEF) && apn->cid == MBTK_RIL_CID_DEF)
             return -1;
 
+        // The cid no use,so can not delete.
         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(&apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+        if(req_apn_get(FALSE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
         {
             LOGW("Get APN fail.");
             return 0;
@@ -94,27 +96,33 @@
             }
             return -1;
         }
-    } else {
-        if(apn->cid == MBTK_RIL_CID_NUL) {
-            int start_cid;
-            bool asr_auto_call_open = !apn_conf_support(MBTK_RIL_CID_DEF);
-            mbtk_apn_info_array_t apns;
-            int cme_err = MBTK_RIL_ERR_CME_NON;
-            if(asr_auto_call_open) {
-                start_cid = MBTK_RIL_CID_2;
-            } else {
-                start_cid = MBTK_APN_CID_MIN;
-            }
-            memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-            if(req_apn_get(&apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
-            {
-                LOGW("Get APN fail.");
+    } else { // Add or change APN.
+        int start_cid;
+        bool asr_auto_call_open = !apn_conf_support(MBTK_RIL_CID_DEF);
+        mbtk_apn_info_array_t apns;
+        int cme_err = MBTK_RIL_ERR_CME_NON;
+
+        if(asr_auto_call_open) {
+            start_cid = MBTK_RIL_CID_2;
+        } else {
+            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)
+        {
+            LOGW("Get APN fail.");
+            if(apn->cid == MBTK_RIL_CID_NUL) {
                 apn->cid = start_cid;
             }
-            else
-            {
+        }
+        else
+        {
+            int index = 0;
+            bool is_change = FALSE;  // Is add APN default.
+
+            if(apn->cid == MBTK_RIL_CID_NUL) { // Is add (auto set cid).
                 for(; start_cid <= MBTK_APN_CID_MAX; start_cid++) {
-                    int index = 0;
+                    index = 0;
                     while(index < apns.num) {
                         if(apns.apns[index].cid == start_cid)
                             break;
@@ -124,7 +132,8 @@
                     if(index == apns.num) { // Found not used cid : start_cid.
                         LOGD("Change CID : %d -> %d", apn->cid, start_cid);
                         apn->cid = start_cid;
-                        return 0;
+                        // return 0;
+                        break;
                     }
                 }
 
@@ -132,6 +141,28 @@
                     LOGE("APN full.");
                     return -1;
                 }
+                is_change = FALSE;
+            } else {
+                index = 0;
+                while(index < apns.num) {
+                    if(apns.apns[index].cid == apn->cid) {
+                        is_change = TRUE;
+                        break;
+                    }
+                    index++;
+                }
+            }
+
+            // Is add,the APN can't same.
+            if(!is_change) {
+                index = 0;
+                while(index < apns.num) {
+                    if(strcmp(apns.apns[index].apn,apn->apn) == 0) {
+                        LOGW("APN : %s exist.", apn->apn);
+                        return -1;
+                    }
+                    index++;
+                }
             }
         }
     }
@@ -149,11 +180,16 @@
     // If auto data call is open,the default route is CID 1.
     if(asr_auto_call_open) {
         apns->cid_for_def_route = MBTK_RIL_CID_DEF;
+        apns->cid_for_dns = MBTK_RIL_CID_DEF;
         cid = MBTK_RIL_CID_2;
     } else {
         if(property_get(MBTK_DEF_ROUTE_CID, prop_data, "") > 0 && !str_empty(prop_data)) {
             apns->cid_for_def_route = (mbtk_ril_cid_enum)atoi(prop_data);
         }
+        memset(prop_data, 0, sizeof(prop_data));
+        if(property_get(MBTK_DEF_DNS_CID, prop_data, "") > 0 && !str_empty(prop_data)) {
+            apns->cid_for_dns = (mbtk_ril_cid_enum)atoi(prop_data);
+        }
         cid = MBTK_APN_CID_MIN;
     }
     for(; cid <= MBTK_APN_CID_MAX; cid++) {
@@ -295,6 +331,11 @@
         prop_data[0] = '0' + apn->cid;
         ret = property_set(MBTK_DEF_ROUTE_CID, prop_data);
     }
+    if(apn->as_dns) {
+        memset(prop_data, 0, sizeof(prop_data));
+        prop_data[0] = '0' + apn->cid;
+        ret = property_set(MBTK_DEF_DNS_CID, prop_data);
+    }
     return ret;
 }
 
@@ -306,10 +347,28 @@
     } else {
         apn.auto_boot_call = data_info->auto_boot_call;
         apn.def_route = data_info->def_route;
+        apn.as_dns = data_info->as_dns;
         return apn_prop_set(&apn);
     }
 }
 
+static int wait_cgact_complete(int timeout)
+{
+    int count = timeout * 10; // timeout * 1000 / 100
+    int i = 0;
+
+    while(cgact_wait.waitting && i < count) {
+        i++;
+        usleep(100000); // 100ms
+    }
+
+    memset(&cgact_wait, 0, sizeof(ril_cgact_wait_t));
+    if(i == count) { // Timeout
+        return -1;
+    } else {
+        return 0;
+    }
+}
 
 /*
 AT+COPS=?
@@ -1484,7 +1543,7 @@
 OK
 
 */
-static int req_apn_get(mbtk_apn_info_array_t *apns, int *cme_err)
+static int req_apn_get(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);
@@ -1500,6 +1559,16 @@
     char *line = NULL;
     int tmp_int;
     char *tmp_str = NULL;
+    int cid_start;
+    if(apn_conf_support(MBTK_RIL_CID_DEF)) {
+        cid_start = MBTK_RIL_CID_DEF;
+    } else {
+        if(get_def_cid) {
+            cid_start = MBTK_RIL_CID_DEF;
+        } else {
+            cid_start = MBTK_RIL_CID_2;
+        }
+    }
     /*
     <apn_num[1]><cid[1]><ip_type[1]><apn_len[2]><apn><user_len[2]><user><pass_len[2]><pass><auth_len[2]><auth>...
                 <cid[1]><ip_type[1]><apn_len[2]><apn><user_len[2]><user><pass_len[2]><pass><auth_len[2]><auth>
@@ -1519,7 +1588,7 @@
             goto exit;
         }
         // Only get CID 1-7
-        if(tmp_int >= MBTK_APN_CID_MIN && tmp_int <= MBTK_APN_CID_MAX) {
+        if(tmp_int >= cid_start && tmp_int <= MBTK_APN_CID_MAX) {
             apns->apns[apns->num].cid = (mbtk_ril_cid_enum)tmp_int;
 
             err = at_tok_nextstr(&line, &tmp_str);// ip type
@@ -1655,12 +1724,16 @@
 OK
 
 */
-static int req_data_call_start(mbtk_ril_cid_enum cid, bool def_route,
-                int retry_interval, int timeout, mbtk_ip_info_t *ip_info, int *cme_err)
+static int req_data_call_start(mbtk_ril_cid_enum cid, bool def_route, bool as_dns,
+                int retry_interval, int timeout, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[400] = {0};
     int err = 0;
+    memset(&cgact_wait, 0, sizeof(ril_cgact_wait_t));
+    cgact_wait.waitting = true;
+    cgact_wait.cid = cid;
+    cgact_wait.act = true;
 
     sprintf(cmd, "AT+CGACT=1,%d", cid);
     err = at_send_command(cmd, &response);
@@ -1687,6 +1760,11 @@
     char cmd[400] = {0};
     int err = 0;
 
+    memset(&cgact_wait, 0, sizeof(ril_cgact_wait_t));
+    cgact_wait.waitting = true;
+    cgact_wait.cid = cid;
+    cgact_wait.act = false;
+
     sprintf(cmd, "AT+CGACT=0,%d", cid);
     err = at_send_command(cmd, &response);
     if (err < 0 || response->success == 0){
@@ -2089,7 +2167,7 @@
             {
                 mbtk_apn_info_array_t apns;
                 memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
-                if(req_apn_get(&apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(req_apn_get(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;
@@ -2107,7 +2185,7 @@
             else     // Set
             {
                 mbtk_apn_info_t *apn = (mbtk_apn_info_t*)pack->data;
-                if(apn_cid_reset(apn)) {
+                if(apn_check_and_cid_reset(apn)) {
                     err = MBTK_RIL_ERR_CID;
                 } else {
                     if(apn_conf_support(apn->cid)) {
@@ -2144,58 +2222,104 @@
             else     // Set
             {
                 mbtk_data_call_info_t *call_info = (mbtk_data_call_info_t*)pack->data;
-                if(call_info->type == MBTK_DATA_CALL_START) {
-                    mbtk_ip_info_t ip_info;
-                    memset(&ip_info, 0, sizeof(ip_info));
-                    if(apn_prop_reset(call_info)) {
-                        err = MBTK_RIL_ERR_REQ_UNKNOWN;
-                        LOG("apn_prop_reset() fail.");
-                    } else {
-                        if(req_data_call_start(call_info->cid, call_info->def_route,
-                                call_info->retry_interval, call_info->timeout, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+                if(!apn_conf_support(call_info->cid)) {
+                    err = MBTK_RIL_ERR_UNSUPPORTED;
+                    LOGD("Can not data call for CID : %d", call_info->cid);
+                } else {
+                    if(call_info->type == MBTK_DATA_CALL_START) {
+                        mbtk_ip_info_t ip_info;
+                        memset(&ip_info, 0, sizeof(ip_info));
+#if 0
+                        if(apn_prop_reset(call_info)) {
+                            err = MBTK_RIL_ERR_REQ_UNKNOWN;
+                            LOG("apn_prop_reset() fail.");
+                        } else
+#else
+                        if(apn_prop_reset(call_info)) {
+                            LOG("apn_prop_reset() fail.");
+                        }
+#endif
+                        {
+                            if(req_data_call_start(call_info->cid, call_info->def_route, call_info->as_dns,
+                                    call_info->retry_interval, 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;
+                                } else {
+                                    err = MBTK_RIL_ERR_UNKNOWN;
+                                }
+                                LOGD("Start data call fail.");
+                            }
+                            else
+                            {
+                                // Wait for "CONNECT" or "+CGEV:"
+                                if(wait_cgact_complete(call_info->timeout)) { // Timeout
+                                    err = MBTK_RIL_ERR_TIMEOUT;
+                                    break;
+                                }
+
+                                // 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)
+                                {
+                                    LOGD("Get net informations fail.");
+                                    err = MBTK_RIL_ERR_NET_CONF;
+                                }
+                                else
+                                {
+                                    // Config network informations.
+                                    if(net_ifc_reconfig(call_info->cid, call_info->def_route, call_info->as_dns, &ip_info)) {
+                                        err = MBTK_RIL_ERR_NET_CONF;
+                                        break;
+                                    }
+
+                                    ril_rsp_pack_send(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) {
+                        if(req_data_call_stop(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;
                             } else {
                                 err = MBTK_RIL_ERR_UNKNOWN;
                             }
-                            LOGD("Start data call fail.");
+                            LOGD("Stop data call fail.");
+                        }
+                        else
+                        {
+                            // Wait for "CONNECT" or "+CGEV:"
+                            if(wait_cgact_complete(call_info->timeout)) { // Timeout
+                                err = MBTK_RIL_ERR_TIMEOUT;
+                                break;
+                            }
+
+                            // Clean network config.
+                            if(net_ifc_config(call_info->cid, FALSE, FALSE, NULL)) {
+                                err = MBTK_RIL_ERR_NET_CONF;
+                                break;
+                            }
+
+                            ril_rsp_pack_send(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(cme_err != MBTK_RIL_ERR_CME_NON) {
+                                err = MBTK_RIL_ERR_CME + cme_err;
+                            } else {
+                                err = MBTK_RIL_ERR_UNKNOWN;
+                            }
+                            LOGD("Get data call state fail.");
                         }
                         else
                         {
                             ril_rsp_pack_send(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) {
-                    if(req_data_call_stop(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;
-                        } else {
-                            err = MBTK_RIL_ERR_UNKNOWN;
-                        }
-                        LOGD("Stop data call fail.");
-                    }
-                    else
-                    {
-                        ril_rsp_pack_send(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(cme_err != MBTK_RIL_ERR_CME_NON) {
-                            err = MBTK_RIL_ERR_CME + cme_err;
-                        } else {
-                            err = MBTK_RIL_ERR_UNKNOWN;
-                        }
-                        LOGD("Get data call state fail.");
-                    }
-                    else
-                    {
-                        ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &ip_info, sizeof(mbtk_ip_info_t));
-                    }
                 }
             }
             break;
@@ -2211,8 +2335,3 @@
     return err;
 }
 
-
-
-
-
-
diff --git a/mbtk/mbtk_sdk_ready/src/main.c b/mbtk/mbtk_sdk_ready/src/main.c
index 12a3c61..bcb696b 100755
--- a/mbtk/mbtk_sdk_ready/src/main.c
+++ b/mbtk/mbtk_sdk_ready/src/main.c
@@ -22,7 +22,7 @@
     MBTK_READY_SOCKET_FAIL,
     MBTK_READY_RIL_FAIL
 }mbtk_ready_status_type;
-    
+
 static mbtk_ready_status_type mbtk_ready_status = MBTK_READY_INIT;
 static mbtk_info_handle_t* mbtk_handle = NULL;
 #if 1
@@ -86,7 +86,7 @@
         {
             sleep_time = 30;
         }
-        
+
         sleep(sleep_time);
     }
     LOGE("[SDK_READY] sdk_ready_check_pthread exit.");
@@ -95,6 +95,10 @@
 
 int main(int argc, char *argv[])
 {
+    mbtk_log_init("radio", "MBTK_SDK_READY");
+
+    MBTK_SOURCE_INFO_PRINT("mbtk_sdk_ready");
+
     if(mbtk_ready_status != MBTK_READY_INIT)
     {
         LOGE("[SDK_READY] sdk has check.");
@@ -114,7 +118,7 @@
         LOGE("[SDK_READY] pthread_attr_setdetachstate() fail.");
         return MBTK_RESULT_FAIL;
     }
-    
+
     if(pthread_create(&sdk_ready_pid, &thread_attr, sdk_ready_check_pthread, NULL))
     {
         LOGE("[SDK_READY] pthread_create() fail.");
diff --git a/mbtk/mbtk_sdk_ready_v2/src/main.c b/mbtk/mbtk_sdk_ready_v2/src/main.c
index 9da6ab0..bed49c7 100755
--- a/mbtk/mbtk_sdk_ready_v2/src/main.c
+++ b/mbtk/mbtk_sdk_ready_v2/src/main.c
@@ -86,6 +86,10 @@
 
 int main(int argc, char *argv[])
 {
+    mbtk_log_init("radio", "MBTK_SDK_READY");
+
+    MBTK_SOURCE_INFO_PRINT("mbtk_sdk_ready");
+
     if(mbtk_ready_status != MBTK_READY_INIT)
     {
         LOGE("[SDK_READY] sdk has check.");
diff --git a/mbtk/mbtk_servicesd/main.c b/mbtk/mbtk_servicesd/main.c
index c832588..6afe654 100755
--- a/mbtk/mbtk_servicesd/main.c
+++ b/mbtk/mbtk_servicesd/main.c
@@ -83,6 +83,8 @@
 {
     mbtk_log_init("radio", "MBTK_SERVICES");
 
+    MBTK_SOURCE_INFO_PRINT("mbtk_services");
+
 #ifdef MBTK_DUMP_SUPPORT
     mbtk_debug_open(NULL, TRUE);
 #endif
diff --git a/mbtk/mbtk_servicesd_v2/src/main.c b/mbtk/mbtk_servicesd_v2/src/main.c
index c832588..6afe654 100755
--- a/mbtk/mbtk_servicesd_v2/src/main.c
+++ b/mbtk/mbtk_servicesd_v2/src/main.c
@@ -83,6 +83,8 @@
 {
     mbtk_log_init("radio", "MBTK_SERVICES");
 
+    MBTK_SOURCE_INFO_PRINT("mbtk_services");
+
 #ifdef MBTK_DUMP_SUPPORT
     mbtk_debug_open(NULL, TRUE);
 #endif
diff --git a/mbtk/mbtk_utils/Makefile b/mbtk/mbtk_utils/Makefile
index d58f815..ad5e6bb 100755
--- a/mbtk/mbtk_utils/Makefile
+++ b/mbtk/mbtk_utils/Makefile
@@ -5,7 +5,8 @@
 
 LIB_DIR +=
 
-LIBS += -lmbtk_lib
+LIBS += -lmbtk_lib -lmbtk_ril -lmbtk_net -lmbtk_audio -lmbtk_fota -lmbtk_gnss -lmbtk_factory -llynq_lib \
+		-lql_lib -lmbtk_coap -lmbtk_ftp -lmbtk_http -lmbtk_mqtt -lmbtk_tcpip
 
 CFLAGS +=
 
diff --git a/mbtk/mbtk_utils/mbtk_version.c b/mbtk/mbtk_utils/mbtk_version.c
index 93a3326..477fb96 100755
--- a/mbtk/mbtk_utils/mbtk_version.c
+++ b/mbtk/mbtk_utils/mbtk_version.c
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 
 #include "mbtk_version.h"
+#include "mbtk_log.h"
 
 int main(int argc, char *argv[])
 {
@@ -11,6 +12,22 @@
 
     printf("%s\n", buff);
 
+
+    mbtk_lib_info_print();
+    mbtk_ril_lib_info_print();
+    lynq_lib_info_print();
+    ql_lib_info_print();
+    mbtk_audio_lib_info_print();
+    mbtk_coap_lib_info_print();
+    mbtk_factory_lib_info_print();
+    mbtk_fota_lib_info_print();
+    mbtk_ftp_lib_info_print();
+    mbtk_gnss_lib_info_print();
+    mbtk_http_lib_info_print();
+    mbtk_mqtt_lib_info_print();
+    mbtk_net_lib_info_print();
+    mbtk_tcpip_lib_info_print();
+
     return 0;
 }
 
diff --git a/mbtk/test/libmbtk_ril/mbtk_ril_test.c b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
index 20178b3..30ad2a1 100755
--- a/mbtk/test/libmbtk_ril/mbtk_ril_test.c
+++ b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
@@ -64,9 +64,9 @@
     printf("power_sim <0,1>: Power off/on sim.\n");
     printf("time <0,1,2> YYYY-MM-DD HH:MM:SS : Set system time as CELL/NTP/User.\n");
     printf("apn : Get current apns.\n");
-    printf("apn <cid> <ip_type:1/2/3/4> <save:0/1> <auto_call:0/1> <apn/null> : Set apn.\n");
+    printf("apn <cid> <ip_type:1/2/3/4> <save:0/1> <auto_call:0/1> <def_route:0/1> <as_dns:0/1> <apn/null> : Set apn.\n");
     printf("apn_del <cid> <save:0/1> : Delete APN.\n");
-    printf("data_call <0/1/2> <cid> <timeout>: Stop/Start/State data call.\n");
+    printf("data_call <0/1/2> <cid> <auto_boot_call> <def_route> <as_dns>: Stop/Start/State data call.\n");
     printf("call: Call the phone number.\n");
     printf("answer: Answer the phone call.\n");
     printf("hangup: Hang up all phone call. No id.\n");
@@ -654,19 +654,22 @@
                     mbtk_apn_info_t apn;
                     memset(&apn, 0, sizeof(mbtk_apn_info_t));
 #if 1
-                    int cid, ip_type, auto_save, auto_boot_call;
-                    int count = sscanf(cmd, "apn %d %d %d %d %s",
-                                    &cid, &ip_type, &auto_save, &auto_boot_call, apn.apn);
+                    int cid, ip_type, auto_save, auto_boot_call, def_route, as_dns;
+                    int count = sscanf(cmd, "apn %d %d %d %d %d %d %s",
+                                    &cid, &ip_type, &auto_save, &auto_boot_call,
+                                    &def_route, &as_dns, apn.apn);
 
                     // Delete APN
                     if(strcmp(apn.apn,"null") == 0 || strcmp(apn.apn,"NULL") == 0) {
                         memset(apn.apn, 0, sizeof(apn.apn));
                     }
-                    if(count == 5) {
+                    if(count == 7) {
                         apn.cid = (mbtk_ril_cid_enum)cid;
                         apn.ip_type = (mbtk_ip_type_enum)ip_type;
                         apn.auto_save = (uint8)auto_save;
                         apn.auto_boot_call = (uint8)auto_boot_call;
+                        apn.def_route = (uint8)def_route;
+                        apn.as_dns = (uint8)as_dns;
                     }
 #else
                     char *ptr = strstr(cmd, " ");
@@ -698,6 +701,113 @@
                     }
                 }
             }
+            else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
+                // mbtk_ril_cid_enum cid, bool auto_boot_call, bool def_route, int retry_interval, int timeout, mbtk_ip_info_t *rsp_info
+                // data_call <0/1/2> <cid> <timeout>
+                int type, cid, auto_boot_call, def_route, as_dns;
+                int count = sscanf(cmd, "data_call %d %d %d %d %d", &type, &cid, &auto_boot_call, &def_route, &as_dns);
+                if(count != 5) {
+                    count = sscanf(cmd, "data_call %d %d", &type, &cid);
+                }
+
+                if(count == 5 || count == 2) {
+                    mbtk_ip_info_t ip;
+                    memset(&ip, 0, sizeof(mbtk_ip_info_t));
+                    if(type == MBTK_DATA_CALL_START) {
+                        err = mbtk_data_call_start((mbtk_ril_cid_enum)cid, (bool)auto_boot_call, (bool)def_route, (bool)as_dns, 10, 10, &ip);
+                    } else if(type == MBTK_DATA_CALL_STOP) {
+                        err = mbtk_data_call_stop((mbtk_ril_cid_enum)cid, 10);
+                    } else {
+                        err = mbtk_data_call_state_get((mbtk_ril_cid_enum)cid, &ip);
+                    }
+                    if(err) {
+                        printf("Error : %d\n", err);
+                    } else {
+                        printf("DATA_CALL success\n");
+                        if(type == MBTK_DATA_CALL_START || type == MBTK_DATA_CALL_STATE) {
+                            if(ip.ipv4.valid) {
+                                // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
+                                char ip_tmp[20];
+
+                                memset(ip_tmp, 0, 20);
+                                if(inet_ntop(AF_INET, &(ip.ipv4.IPAddr), ip_tmp, 20) == NULL) {
+                                    printf("IP error.\n");
+                                } else {
+                                    printf("IP : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 20);
+                                if(inet_ntop(AF_INET, &(ip.ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
+                                    printf("PrimaryDNS error.\n");
+                                } else {
+                                    printf("PrimaryDNS : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 20);
+                                if(inet_ntop(AF_INET, &(ip.ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
+                                    printf("SecondaryDNS error.\n");
+                                } else {
+                                    printf("SecondaryDNS : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 20);
+                                if(inet_ntop(AF_INET, &(ip.ipv4.GateWay), ip_tmp, 20) == NULL) {
+                                    printf("GateWay error.\n");
+                                } else {
+                                    printf("GateWay : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 20);
+                                if(inet_ntop(AF_INET, &(ip.ipv4.NetMask), ip_tmp, 20) == NULL) {
+                                    printf("NetMask error.\n");
+                                } else {
+                                    printf("NetMask : %s\n", ip_tmp);
+                                }
+                            }
+
+                            if(ip.ipv6.valid) {
+                                // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
+                                char ip_tmp[50];
+
+                                memset(ip_tmp, 0, 50);
+                                if(ipv6_2_str(&(ip.ipv6.IPV6Addr), ip_tmp)) {
+                                    printf("IP error.\n");
+                                } else {
+                                    printf("IP : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 50);
+                                if(ipv6_2_str(&(ip.ipv6.PrimaryDNS), ip_tmp)) {
+                                    printf("PrimaryDNS error.\n");
+                                } else {
+                                    printf("PrimaryDNS : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 50);
+                                if(ipv6_2_str(&(ip.ipv6.SecondaryDNS), ip_tmp)) {
+                                    printf("SecondaryDNS error.\n");
+                                } else {
+                                    printf("SecondaryDNS : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 50);
+                                if(ipv6_2_str(&(ip.ipv6.GateWay), ip_tmp)) {
+                                    printf("GateWay error.\n");
+                                } else {
+                                    printf("GateWay : %s\n", ip_tmp);
+                                }
+
+                                memset(ip_tmp, 0, 50);
+                                if(ipv6_2_str(&(ip.ipv6.NetMask), ip_tmp)) {
+                                    printf("NetMask error.\n");
+                                } else {
+                                    printf("NetMask : %s\n", ip_tmp);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
             else if(!strncasecmp(cmd, "cell", 4)){
                 char *ptr = strstr(cmd, ",");	 //CPMS,ME,ME,ME
 				if(ptr == NULL)
@@ -1262,124 +1372,6 @@
                         printf("Time type:%d.\n", time_type);
                     }
                 }
-            } else if(!strncasecmp(cmd, "data_call", 9)){ // data_call <0/1/2> <cid> <timeout>
-                // data_call <0/1/2> <cid> <timeout>
-                char *ptr = strstr(cmd, " ");
-                if(ptr == NULL)
-                    continue;
-                while(*ptr != '\0' && *ptr == ' ')
-                    ptr++;
-                mbtk_data_call_type_enum type = (mbtk_data_call_type_enum)atoi(ptr);
-
-                ptr = strstr(ptr, " ");
-                if(ptr == NULL)
-                    continue;
-                while(*ptr != '\0' && *ptr == ' ')
-                    ptr++;
-                int cid = atoi(ptr);
-
-                ptr = strstr(ptr, " ");
-                if(ptr == NULL)
-                    continue;
-                while(*ptr != '\0' && *ptr == ' ')
-                    ptr++;
-                int timeout = atoi(ptr);
-
-                if(type == MBTK_DATA_CALL_START) {
-                    err = mbtk_data_call_start(info_handle, cid, 0, FALSE, timeout);
-                } else if(type == MBTK_DATA_CALL_STOP) {
-                    err = mbtk_data_call_stop(info_handle, cid, timeout);
-                } else {
-                    mbtk_ipv4_info_t ipv4;
-                    mbtk_ipv6_info_t ipv6;
-                    err = mbtk_data_call_state_get(info_handle, cid, &ipv4, &ipv6);
-                    if(!err) {
-                        if(ipv4.valid) {
-                            // log_hex("IPv4", &ipv4, sizeof(mbtk_ipv4_info_t));
-                            char ip_tmp[20];
-
-                            memset(ip_tmp, 0, 20);
-                            if(inet_ntop(AF_INET, &(ipv4.IPAddr), ip_tmp, 20) == NULL) {
-                                printf("IP error.\n");
-                            } else {
-                                printf("IP : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 20);
-                            if(inet_ntop(AF_INET, &(ipv4.PrimaryDNS), ip_tmp, 20) == NULL) {
-                                printf("PrimaryDNS error.\n");
-                            } else {
-                                printf("PrimaryDNS : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 20);
-                            if(inet_ntop(AF_INET, &(ipv4.SecondaryDNS), ip_tmp, 20) == NULL) {
-                                printf("SecondaryDNS error.\n");
-                            } else {
-                                printf("SecondaryDNS : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 20);
-                            if(inet_ntop(AF_INET, &(ipv4.GateWay), ip_tmp, 20) == NULL) {
-                                printf("GateWay error.\n");
-                            } else {
-                                printf("GateWay : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 20);
-                            if(inet_ntop(AF_INET, &(ipv4.NetMask), ip_tmp, 20) == NULL) {
-                                printf("NetMask error.\n");
-                            } else {
-                                printf("NetMask : %s\n", ip_tmp);
-                            }
-                        }
-
-                        if(ipv6.valid) {
-                            // log_hex("IPv6", &ipv6, sizeof(mbtk_ipv6_info_t));
-                            char ip_tmp[50];
-
-                            memset(ip_tmp, 0, 50);
-                            if(ipv6_2_str(&(ipv6.IPV6Addr), ip_tmp)) {
-                                printf("IP error.\n");
-                            } else {
-                                printf("IP : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 50);
-                            if(ipv6_2_str(&(ipv6.PrimaryDNS), ip_tmp)) {
-                                printf("PrimaryDNS error.\n");
-                            } else {
-                                printf("PrimaryDNS : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 50);
-                            if(ipv6_2_str(&(ipv6.SecondaryDNS), ip_tmp)) {
-                                printf("SecondaryDNS error.\n");
-                            } else {
-                                printf("SecondaryDNS : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 50);
-                            if(ipv6_2_str(&(ipv6.GateWay), ip_tmp)) {
-                                printf("GateWay error.\n");
-                            } else {
-                                printf("GateWay : %s\n", ip_tmp);
-                            }
-
-                            memset(ip_tmp, 0, 50);
-                            if(ipv6_2_str(&(ipv6.NetMask), ip_tmp)) {
-                                printf("NetMask error.\n");
-                            } else {
-                                printf("NetMask : %s\n", ip_tmp);
-                            }
-                        }
-                    }
-                }
-                if(err) {
-                    printf("Error : %d\n", err);
-                } else {
-                    printf("DATA_CALL success\n");
-                }
             }
 #endif
             else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {