Skip to content
Snippets Groups Projects
Commit 3ef35e1b authored by Gunar Schorcht's avatar Gunar Schorcht Committed by Schorcht
Browse files

cpu/esp32: use static WiFi config in esp_wifi

The WiFi configuration has to be static to avoid memory access problems when WiFi AP is reconnected.
parent d24d73da
No related branches found
No related tags found
No related merge requests found
...@@ -137,6 +137,19 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t * ...@@ -137,6 +137,19 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
#define CONFIG_WIFI_STA_RSSI -127 #define CONFIG_WIFI_STA_RSSI -127
#define CONFIG_WIFI_STA_AUTHMODE WIFI_AUTH_WPA_WPA2_PSK #define CONFIG_WIFI_STA_AUTHMODE WIFI_AUTH_WPA_WPA2_PSK
/* we use predefined station configuration */
static wifi_config_t wifi_config_sta = {
.sta = {
.ssid = CONFIG_WIFI_STA_SSID,
.password = CONFIG_WIFI_STA_PASSWORD,
.channel = CONFIG_WIFI_STA_CHANNEL,
.scan_method = CONFIG_WIFI_STA_SCAN_METHOD,
.sort_method = CONFIG_WIFI_STA_SORT_METHOD,
.threshold.rssi = CONFIG_WIFI_STA_RSSI,
.threshold.authmode = CONFIG_WIFI_STA_AUTHMODE
}
};
static void esp_wifi_setup (esp_wifi_netdev_t* dev) static void esp_wifi_setup (esp_wifi_netdev_t* dev)
{ {
DEBUG("%s: %p\n", __func__, dev); DEBUG("%s: %p\n", __func__, dev);
...@@ -171,19 +184,6 @@ static void esp_wifi_setup (esp_wifi_netdev_t* dev) ...@@ -171,19 +184,6 @@ static void esp_wifi_setup (esp_wifi_netdev_t* dev)
/* TODO */ /* TODO */
#endif #endif
/* we use predefined station configuration */
wifi_config_t wifi_config_sta = {
.sta = {
.ssid = CONFIG_WIFI_STA_SSID,
.password = CONFIG_WIFI_STA_PASSWORD,
.channel = CONFIG_WIFI_STA_CHANNEL,
.scan_method = CONFIG_WIFI_STA_SCAN_METHOD,
.sort_method = CONFIG_WIFI_STA_SORT_METHOD,
.threshold.rssi = CONFIG_WIFI_STA_RSSI,
.threshold.authmode = CONFIG_WIFI_STA_AUTHMODE
}
};
result = esp_wifi_set_mode(WIFI_MODE_STA); result = esp_wifi_set_mode(WIFI_MODE_STA);
if (result != ESP_OK) { if (result != ESP_OK) {
LOG_TAG_ERROR("esp_wifi", "esp_wifi_set_mode failed with return value %d\n", result); LOG_TAG_ERROR("esp_wifi", "esp_wifi_set_mode failed with return value %d\n", result);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment