Index: azure_iot_hub_f767zi/trunk/app_iothub_client/src/envcmd.c
===================================================================
--- azure_iot_hub_f767zi/trunk/app_iothub_client/src/envcmd.c	(revision 472)
+++ azure_iot_hub_f767zi/trunk/app_iothub_client/src/envcmd.c	(revision 473)
@@ -253,4 +253,7 @@
 }
 
+bool prepare_esp_at();
+extern int use_wifi;
+
 int set_wifi_main(int argc, char **argv)
 {
@@ -261,5 +264,12 @@
 	set_ssid_pwd(argv[1], argv[2]);
 
-	prepare_esp_at();
+	if (!prepare_esp_at()) {
+		use_wifi = 0;
+	}
+	else {
+		use_wifi = 1;
+	}
+
+	return 0;
 }
 
Index: azure_iot_hub_f767zi/trunk/app_iothub_client/src/esp_at_socket.c
===================================================================
--- azure_iot_hub_f767zi/trunk/app_iothub_client/src/esp_at_socket.c	(revision 472)
+++ azure_iot_hub_f767zi/trunk/app_iothub_client/src/esp_at_socket.c	(revision 473)
@@ -1575,4 +1575,6 @@
 }
 
+extern int use_wifi;
+
 int esp_at_socket_connect(ESP_AT_SOCKET_HANDLE espAtSocketHandle, const char *host, const int port)
 {
@@ -1587,6 +1589,8 @@
 	if (!prepare_esp_at()) {
 		printf("prepare_esp_at error\n");
+		use_wifi = 0;
 		return -MU_FAILURE;
 	}
+	use_wifi = 1;
 
 	connection->state = connection_state_connecting;
Index: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/platform_toppers.c
===================================================================
--- azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/platform_toppers.c	(revision 472)
+++ azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/platform_toppers.c	(revision 473)
@@ -62,4 +62,17 @@
 }
 
+const IO_INTERFACE_DESCRIPTION* socketio_esp_at_get_interface_description(void);
+const IO_INTERFACE_DESCRIPTION* socketio_lwip_get_interface_description(void);
+
+const IO_INTERFACE_DESCRIPTION* socketio_get_interface_description(void)
+{
+	if (use_wifi) {
+		return socketio_esp_at_get_interface_description();
+	}
+	else {
+		return socketio_lwip_get_interface_description();
+	}
+}
+
 STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options)
 {
Index: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_esp_at.c
===================================================================
--- azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_esp_at.c	(revision 472)
+++ azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_esp_at.c	(revision 473)
@@ -45,6 +45,14 @@
 } SOCKET_IO_INSTANCE;
 
+CONCRETE_IO_HANDLE socketio_esp_at_create(void* io_create_parameters);
+void socketio_esp_at_destroy(CONCRETE_IO_HANDLE socket_io);
+int socketio_esp_at_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
+int socketio_esp_at_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);
+int socketio_esp_at_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);
+void socketio_esp_at_dowork(CONCRETE_IO_HANDLE socket_io);
+int socketio_esp_at_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value);
+
 /*this function will clone an option given by name and value*/
-static void* socketio_CloneOption(const char* name, const void* value)
+static void* socketio_esp_at_CloneOption(const char* name, const void* value)
 {
     (void)name;
@@ -54,5 +62,5 @@
 
 /*this function destroys an option previously created*/
-static void socketio_DestroyOption(const char* name, const void* value)
+static void socketio_esp_at_DestroyOption(const char* name, const void* value)
 {
     (void)name;
@@ -60,9 +68,9 @@
 }
 
-static OPTIONHANDLER_HANDLE socketio_retrieveoptions(CONCRETE_IO_HANDLE socket_io)
+static OPTIONHANDLER_HANDLE socketio_esp_at_retrieveoptions(CONCRETE_IO_HANDLE socket_io)
 {
     OPTIONHANDLER_HANDLE result;
     (void)socket_io;
-    result = OptionHandler_Create(socketio_CloneOption, socketio_DestroyOption, socketio_setoption);
+    result = OptionHandler_Create(socketio_esp_at_CloneOption, socketio_esp_at_DestroyOption, socketio_esp_at_setoption);
     if (result == NULL)
     {
@@ -78,12 +86,12 @@
 static const IO_INTERFACE_DESCRIPTION socket_io_interface_description =
 {
-    socketio_retrieveoptions,
-    socketio_create,
-    socketio_destroy,
-    socketio_open,
-    socketio_close,
-    socketio_send,
-    socketio_dowork,
-    socketio_setoption
+    socketio_esp_at_retrieveoptions,
+    socketio_esp_at_create,
+    socketio_esp_at_destroy,
+    socketio_esp_at_open,
+    socketio_esp_at_close,
+    socketio_esp_at_send,
+    socketio_esp_at_dowork,
+    socketio_esp_at_setoption
 };
 
@@ -269,5 +277,5 @@
 }
 
-CONCRETE_IO_HANDLE socketio_create(void* io_create_parameters)
+CONCRETE_IO_HANDLE socketio_esp_at_create(void* io_create_parameters)
 {
     SOCKETIO_CONFIG* socket_io_config = io_create_parameters;
@@ -318,5 +326,5 @@
 }
 
-void socketio_destroy(CONCRETE_IO_HANDLE socket_io)
+void socketio_esp_at_destroy(CONCRETE_IO_HANDLE socket_io)
 {
     if (socket_io != NULL)
@@ -352,5 +360,5 @@
 }
 
-int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context)
+int socketio_esp_at_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context)
 {
     int result;
@@ -403,5 +411,5 @@
 }
 
-int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context)
+int socketio_esp_at_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context)
 {
     int result = 0;
@@ -433,5 +441,5 @@
 }
 
-int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context)
+int socketio_esp_at_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context)
 {
     int result;
@@ -455,5 +463,5 @@
         else
         {
-            // Queue the data, and the socketio_dowork sends the package later
+            // Queue the data, and the socketio_esp_at_dowork sends the package later
             if (add_pending_io(socket_io_instance, buffer, size, on_send_complete, callback_context) != 0)
             {
@@ -466,5 +474,5 @@
 }
 
-void socketio_dowork(CONCRETE_IO_HANDLE socket_io)
+void socketio_esp_at_dowork(CONCRETE_IO_HANDLE socket_io)
 {
     if (socket_io != NULL)
@@ -485,5 +493,5 @@
 }
 
-int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value)
+int socketio_esp_at_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value)
 {
     /* Not implementing any options, do nothing */
@@ -491,5 +499,5 @@
 }
 
-const IO_INTERFACE_DESCRIPTION* socketio_get_interface_description(void)
+const IO_INTERFACE_DESCRIPTION* socketio_esp_at_get_interface_description(void)
 {
     return &socket_io_interface_description;
Index: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_lwip.c
===================================================================
--- azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_lwip.c	(revision 472)
+++ azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/adapters/socketio_lwip.c	(revision 473)
@@ -111,5 +111,5 @@
 
 /*this function will clone an option given by name and value*/
-static void* socketio_CloneOption(const char* name, const void* value)
+static void* socketio_lwip_CloneOption(const char* name, const void* value)
 {
     void* result;
@@ -152,5 +152,5 @@
 
 /*this function destroys an option previously created*/
-static void socketio_DestroyOption(const char* name, const void* value)
+static void socketio_lwip_DestroyOption(const char* name, const void* value)
 {
     if (name != NULL)
@@ -163,5 +163,13 @@
 }
 
-static OPTIONHANDLER_HANDLE socketio_retrieveoptions(CONCRETE_IO_HANDLE handle)
+CONCRETE_IO_HANDLE socketio_lwip_create(void* io_create_parameters);
+void socketio_lwip_destroy(CONCRETE_IO_HANDLE socket_io);
+int socketio_lwip_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
+int socketio_lwip_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);
+int socketio_lwip_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);
+void socketio_lwip_dowork(CONCRETE_IO_HANDLE socket_io);
+int socketio_lwip_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value);
+
+static OPTIONHANDLER_HANDLE socketio_lwip_retrieveoptions(CONCRETE_IO_HANDLE handle)
 {
     OPTIONHANDLER_HANDLE result;
@@ -176,5 +184,5 @@
         SOCKET_IO_INSTANCE* socket_io_instance = (SOCKET_IO_INSTANCE*)handle;
 
-        result = OptionHandler_Create(socketio_CloneOption, socketio_DestroyOption, socketio_setoption);
+        result = OptionHandler_Create(socketio_lwip_CloneOption, socketio_lwip_DestroyOption, socketio_lwip_setoption);
         if (result == NULL)
         {
@@ -195,12 +203,12 @@
 static const IO_INTERFACE_DESCRIPTION socket_io_interface_description =
 {
-    socketio_retrieveoptions,
-    socketio_create,
-    socketio_destroy,
-    socketio_open,
-    socketio_close,
-    socketio_send,
-    socketio_dowork,
-    socketio_setoption
+    socketio_lwip_retrieveoptions,
+    socketio_lwip_create,
+    socketio_lwip_destroy,
+    socketio_lwip_open,
+    socketio_lwip_close,
+    socketio_lwip_send,
+    socketio_lwip_dowork,
+    socketio_lwip_setoption
 };
 
@@ -678,5 +686,5 @@
 }
 
-CONCRETE_IO_HANDLE socketio_create(void* io_create_parameters)
+CONCRETE_IO_HANDLE socketio_lwip_create(void* io_create_parameters)
 {
     SOCKETIO_CONFIG* socket_io_config = io_create_parameters;
@@ -750,5 +758,5 @@
 }
 
-void socketio_destroy(CONCRETE_IO_HANDLE socket_io)
+void socketio_lwip_destroy(CONCRETE_IO_HANDLE socket_io)
 {
     if (socket_io != NULL)
@@ -780,5 +788,5 @@
 }
 
-int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context)
+int socketio_lwip_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context)
 {
     int result;
@@ -867,5 +875,5 @@
 }
 
-int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context)
+int socketio_lwip_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context)
 {
     int result = 0;
@@ -898,5 +906,5 @@
 }
 
-int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context)
+int socketio_lwip_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context)
 {
     int result;
@@ -978,5 +986,5 @@
 }
 
-void socketio_dowork(CONCRETE_IO_HANDLE socket_io)
+void socketio_lwip_dowork(CONCRETE_IO_HANDLE socket_io)
 {
     if (socket_io != NULL)
@@ -1117,5 +1125,5 @@
 #endif // __APPLE__
 
-static int socketio_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance, const char* addressType)
+static int socketio_lwip_setaddresstype_option(SOCKET_IO_INSTANCE* socket_io_instance, const char* addressType)
 {
     int result;
@@ -1145,5 +1153,5 @@
 }
 
-int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value)
+int socketio_lwip_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value)
 {
     int result;
@@ -1210,5 +1218,5 @@
         else if (strcmp(optionName, OPTION_ADDRESS_TYPE) == 0)
         {
-            result = socketio_setaddresstype_option(socket_io_instance, (const char*)value);
+            result = socketio_lwip_setaddresstype_option(socket_io_instance, (const char*)value);
         }
         else
@@ -1221,5 +1229,5 @@
 }
 
-const IO_INTERFACE_DESCRIPTION* socketio_get_interface_description(void)
+const IO_INTERFACE_DESCRIPTION* socketio_lwip_get_interface_description(void)
 {
     return &socket_io_interface_description;
