diff --git a/examples/protocols/mqtt/main/MQTTEcho.c b/examples/protocols/mqtt/main/MQTTEcho.c
index 8b3bad24..303ff187 100644
--- a/examples/protocols/mqtt/main/MQTTEcho.c
+++ b/examples/protocols/mqtt/main/MQTTEcho.c
@@ -18,6 +18,10 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "esp_sta.h"
+#include "esp_system.h"
+#include "esp_wifi.h"
+
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 
@@ -33,19 +37,19 @@ static xTaskHandle mqttc_client_handle;
 
 static void messageArrived(MessageData* data)
 {
-    printf("Message arrived: %s\n", data->message->payload);
+    printf("Message arrived: %s\n", (char *)data->message->payload);
 }
 
 static void mqtt_client_thread(void* pvParameters)
 {
-    printf("mqtt client thread starts\n");
     MQTTClient client;
     Network network;
     unsigned char sendbuf[80], readbuf[80] = {0};
     int rc = 0, count = 0;
     MQTTPacket_connectData connectData = MQTTPacket_connectData_initializer;
 
-    pvParameters = 0;
+    printf("mqtt client thread starts\n");
+
     NetworkInit(&network);
     MQTTClientInit(&client, &network, 30000, sendbuf, sizeof(sendbuf), readbuf, sizeof(readbuf));
 
@@ -118,3 +122,99 @@ void user_conn_init(void)
         printf("mqtt create client thread %s failed\n", MQTT_CLIENT_THREAD_NAME);
     }
 }
+
+/******************************************************************************
+ * FunctionName : user_rf_cal_sector_set
+ * Description  : SDK just reversed 4 sectors, used for rf init data and paramters.
+ *                We add this function to force users to set rf cal sector, since
+ *                we don't know which sector is free in user's application.
+ *                sector map for last several sectors : ABCCC
+ *                A : rf cal
+ *                B : rf init data
+ *                C : sdk parameters
+ * Parameters   : none
+ * Returns      : rf cal sector
+*******************************************************************************/
+uint32_t user_rf_cal_sector_set(void)
+{
+    flash_size_map size_map = system_get_flash_size_map();
+    uint32_t rf_cal_sec = 0;
+
+    switch (size_map) {
+        case FLASH_SIZE_4M_MAP_256_256:
+            rf_cal_sec = 128 - 5;
+            break;
+
+        case FLASH_SIZE_8M_MAP_512_512:
+            rf_cal_sec = 256 - 5;
+            break;
+
+        case FLASH_SIZE_16M_MAP_512_512:
+        case FLASH_SIZE_16M_MAP_1024_1024:
+            rf_cal_sec = 512 - 5;
+            break;
+
+        case FLASH_SIZE_32M_MAP_512_512:
+        case FLASH_SIZE_32M_MAP_1024_1024:
+            rf_cal_sec = 1024 - 5;
+            break;
+        case FLASH_SIZE_64M_MAP_1024_1024:
+            rf_cal_sec = 2048 - 5;
+            break;
+        case FLASH_SIZE_128M_MAP_1024_1024:
+            rf_cal_sec = 4096 - 5;
+            break;
+        default:
+            rf_cal_sec = 0;
+            break;
+    }
+
+    return rf_cal_sec;
+}
+
+void wifi_event_handler_cb(System_Event_t *event)
+{
+    if (event == NULL) {
+        return;
+    }
+
+    switch (event->event_id) {
+        case EVENT_STAMODE_GOT_IP:
+            printf("sta got ip ,create task and free heap size is %d\n", system_get_free_heap_size());
+            user_conn_init();
+            break;
+
+        case EVENT_STAMODE_CONNECTED:
+            printf("sta connected\n");
+            break;
+
+        case EVENT_STAMODE_DISCONNECTED:
+            wifi_station_connect();
+            break;
+
+        default:
+            break;
+    }
+}
+
+/******************************************************************************
+ * FunctionName : user_init
+ * Description  : entry of user application, init user function here
+ * Parameters   : none
+ * Returns      : none
+*******************************************************************************/
+void user_init(void)
+{
+    printf("SDK version:%s %d\n", system_get_sdk_version(), system_get_free_heap_size());
+    wifi_set_opmode(STATION_MODE);
+
+    struct station_config config;
+    bzero(&config, sizeof(struct station_config));
+    sprintf((char *)config.ssid, SSID);
+    sprintf((char *)config.password, PASSWORD);
+    wifi_station_set_config(&config);
+
+    wifi_set_event_handler_cb(wifi_event_handler_cb);
+
+    wifi_station_connect();
+}
diff --git a/examples/protocols/mqtt/main/user_main.c b/examples/protocols/mqtt/main/user_main.c
deleted file mode 100644
index 6a904673..00000000
--- a/examples/protocols/mqtt/main/user_main.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* paho MQTT example
-
-   This example code is in the Public Domain (or CC0 licensed, at your option.)
-
-   Unless required by applicable law or agreed to in writing, this
-   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-   CONDITIONS OF ANY KIND, either express or implied.
-*/
-
-#include <stdint.h>
-#include <stdio.h>
-#include <strings.h>
-
-#include "esp_sta.h"
-#include "esp_system.h"
-
-#include "user_config.h"
-
-/******************************************************************************
- * FunctionName : user_rf_cal_sector_set
- * Description  : SDK just reversed 4 sectors, used for rf init data and paramters.
- *                We add this function to force users to set rf cal sector, since
- *                we don't know which sector is free in user's application.
- *                sector map for last several sectors : ABCCC
- *                A : rf cal
- *                B : rf init data
- *                C : sdk parameters
- * Parameters   : none
- * Returns      : rf cal sector
-*******************************************************************************/
-uint32_t user_rf_cal_sector_set(void)
-{
-    flash_size_map size_map = system_get_flash_size_map();
-    uint32_t rf_cal_sec = 0;
-
-    switch (size_map) {
-        case FLASH_SIZE_4M_MAP_256_256:
-            rf_cal_sec = 128 - 5;
-            break;
-
-        case FLASH_SIZE_8M_MAP_512_512:
-            rf_cal_sec = 256 - 5;
-            break;
-
-        case FLASH_SIZE_16M_MAP_512_512:
-        case FLASH_SIZE_16M_MAP_1024_1024:
-            rf_cal_sec = 512 - 5;
-            break;
-
-        case FLASH_SIZE_32M_MAP_512_512:
-        case FLASH_SIZE_32M_MAP_1024_1024:
-            rf_cal_sec = 1024 - 5;
-            break;
-        case FLASH_SIZE_64M_MAP_1024_1024:
-            rf_cal_sec = 2048 - 5;
-            break;
-        case FLASH_SIZE_128M_MAP_1024_1024:
-            rf_cal_sec = 4096 - 5;
-            break;
-        default:
-            rf_cal_sec = 0;
-            break;
-    }
-
-    return rf_cal_sec;
-}
-
-void wifi_event_handler_cb(System_Event_t *event)
-{
-    if (event == NULL) {
-        return;
-    }
-
-    switch (event->event_id) {
-        case EVENT_STAMODE_GOT_IP:
-            printf("sta got ip ,create task and free heap size is %d\n", system_get_free_heap_size());
-            user_conn_init();
-            break;
-
-        case EVENT_STAMODE_CONNECTED:
-            printf("sta connected\n");
-            break;
-
-        case EVENT_STAMODE_DISCONNECTED:
-            wifi_station_connect();
-            break;
-
-        default:
-            break;
-    }
-}
-
-/******************************************************************************
- * FunctionName : user_init
- * Description  : entry of user application, init user function here
- * Parameters   : none
- * Returns      : none
-*******************************************************************************/
-void user_init(void)
-{
-    printf("SDK version:%s %d\n", system_get_sdk_version(), system_get_free_heap_size());
-    wifi_set_opmode(STATION_MODE);
-
-    struct station_config config;
-    bzero(&config, sizeof(struct station_config));
-    sprintf(config.ssid, SSID);
-    sprintf(config.password, PASSWORD);
-    wifi_station_set_config(&config);
-
-    wifi_set_event_handler_cb(wifi_event_handler_cb); 
-
-    wifi_station_connect();
-}