summaryrefslogtreecommitdiff
path: root/code/esp32/components/eos/wifi.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/esp32/components/eos/wifi.c')
-rwxr-xr-xcode/esp32/components/eos/wifi.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/code/esp32/components/eos/wifi.c b/code/esp32/components/eos/wifi.c
index 31aefea..3dd90ba 100755
--- a/code/esp32/components/eos/wifi.c
+++ b/code/esp32/components/eos/wifi.c
@@ -16,7 +16,7 @@
#include "net.h"
#include "wifi.h"
-// XXX: No DHCP server
+// XXX: WiFi fail due to no DHCP server
#define WIFI_MAX_SCAN_RECORDS 20
#define WIFI_MAX_CONNECT_ATTEMPTS 3
@@ -45,7 +45,7 @@ static uint8_t wifi_action;
static uint8_t wifi_state;
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) {
- esp_err_t ret;
+ esp_err_t ret = ESP_OK;
char _disconnect;
uint8_t _action, _state;
unsigned char *rbuf;
@@ -188,6 +188,9 @@ void eos_wifi_init(void) {
ret = esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_sta_config);
assert(ret == ESP_OK);
+ ret = esp_wifi_stop();
+ assert(ret == ESP_OK);
+
mutex = xSemaphoreCreateBinary();
xSemaphoreGive(mutex);
@@ -260,7 +263,6 @@ int eos_wifi_connect(void) {
if (rv) return rv;
-
esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_sta_config);
if (_wifi_state == WIFI_STATE_STOPPED) {