From 5068ff2be86f480080dbc57e9257ca94f3b8ea35 Mon Sep 17 00:00:00 2001 From: liuzhifu Date: Tue, 30 Aug 2016 18:04:22 +0800 Subject: [PATCH] TW6785 - add sta auto connect api --- components/esp32/include/esp_wifi.h | 4 ++++ components/esp32/wifi.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index 827dfb50d2..c1c84fb359 100755 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -234,6 +234,10 @@ typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void* eb); esp_err_t esp_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn); +esp_err_t esp_wifi_set_auto_connect(bool en); + +esp_err_t esp_wifi_get_auto_connect(bool *en); + #ifdef __cplusplus } #endif diff --git a/components/esp32/wifi.c b/components/esp32/wifi.c index e617ee7566..5ac3c990b8 100644 --- a/components/esp32/wifi.c +++ b/components/esp32/wifi.c @@ -69,12 +69,14 @@ static void esp_wifi_task(void *pvParameters) #if CONFIG_WIFI_AUTO_CONNECT wifi_mode_t mode; + bool auto_connect; err = 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) { + err = esp_wifi_get_auto_connect(&auto_connect); + if ((mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA) && auto_connect) { err = esp_wifi_connect(); if (err != ESP_OK) { WIFI_DEBUG("esp_wifi_connect fail, ret=%d\n", err); -- 2.40.0