add debug info to wifi.c

This commit is contained in:
liuzhifu 2016-08-17 16:28:57 +08:00 committed by Wu Jian Gang
parent 00ea21f736
commit 34ac96994b

View File

@ -56,6 +56,8 @@ do{\
}\ }\
} while(0) } while(0)
static void esp_wifi_task(void *pvParameters) static void esp_wifi_task(void *pvParameters)
{ {
esp_err_t err; esp_err_t err;
@ -65,29 +67,35 @@ static void esp_wifi_task(void *pvParameters)
do { do {
err = esp_wifi_init(&cfg); err = esp_wifi_init(&cfg);
if (err != ESP_OK) { if (err != ESP_OK) {
WIFI_DEBUG("esp_wifi_init fail, ret=%d\n", err);
break; break;
} }
if (startup_cb) { if (startup_cb) {
err = (*startup_cb)(); err = (*startup_cb)();
if (err != ESP_OK) { if (err != ESP_OK) {
WIFI_DEBUG("startup_cb fail, ret=%d\n", err);
break; break;
} }
} }
err = esp_wifi_start(); err = esp_wifi_start();
if (err != ESP_OK) { // TODO: if already started, it's also OK if (err != ESP_OK) {
WIFI_DEBUG("esp_wifi_start fail, ret=%d\n", err);
break; break;
} }
#if CONFIG_WIFI_AUTO_CONNECT #if CONFIG_WIFI_AUTO_CONNECT
wifi_mode_t mode; wifi_mode_t mode;
err = esp_wifi_get_mode(&mode);
esp_wifi_get_mode(&mode); if (err != ESP_OK){
WIFI_DEBUG("esp_wifi_get_mode fail, ret=%d\n", err);
}
if (mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA) { if (mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA) {
err = esp_wifi_connect(); err = esp_wifi_connect();
if (err != ESP_OK) { if (err != ESP_OK) {
WIFI_DEBUG("esp_wifi_connect fail, ret=%d\n", err);
break; break;
} }
} }
@ -95,6 +103,7 @@ static void esp_wifi_task(void *pvParameters)
} while (0); } while (0);
if (err != ESP_OK) { if (err != ESP_OK) {
WIFI_DEBUG("wifi startup fail, deinit\n");
esp_wifi_deinit(); esp_wifi_deinit();
} }