From 82ddc73c12c1811da24ea2424da9a0f9c15381fd Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Wed, 15 Jan 2020 17:21:37 +0100 Subject: [PATCH] cpu/esp32: add Kconfig for module esp_wifi --- cpu/esp32/doc.txt | 12 +++--- cpu/esp32/esp-wifi/Kconfig | 30 +++++++++++++++ cpu/esp32/esp-wifi/doc.txt | 12 +++--- cpu/esp32/esp-wifi/esp_wifi_netdev.c | 16 ++++---- cpu/esp32/esp-wifi/esp_wifi_params.h | 56 ++++++++++++++++++++++++---- 5 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 cpu/esp32/esp-wifi/Kconfig diff --git a/cpu/esp32/doc.txt b/cpu/esp32/doc.txt index 34b311b7ab1f7..af5b68f44f5ab 100644 --- a/cpu/esp32/doc.txt +++ b/cpu/esp32/doc.txt @@ -1004,11 +1004,11 @@ Furthermore, the following configuration parameters have to be defined:
-Parameter | Default | Description -:------------------|:--------------------------|:------------ -ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. -ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). -ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread. +Parameter | Default | Description +:--------------------------|:--------------------------|:------------ +#CONFIG_ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread.
@@ -1018,7 +1018,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` diff --git a/cpu/esp32/esp-wifi/Kconfig b/cpu/esp32/esp-wifi/Kconfig new file mode 100644 index 0000000000000..ad80dd5d80be7 --- /dev/null +++ b/cpu/esp32/esp-wifi/Kconfig @@ -0,0 +1,30 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_MODULE_ESP_WIFI + bool "Configure ESP-WiFi netdev" + depends on MODULE_ESP_WIFI + help + Configure ESP-Wifi netdev when module esp_wifi is used. + +if KCONFIG_MODULE_ESP_WIFI + +config ESP_WIFI_SSID + string "SSID" + default "RIOT_AP" + help + This string defines the SSID of the AP to be used. + +config ESP_WIFI_PASS + string "Passphrase for WPA2" + default "ThisistheRIOTporttoESP" + help + This string defines the passphrase as plain text, which is used for + the AP during WPA2 authentication. It can be up to 64 characters long. + +endif # KCONFIG_MODULE_ESP_WIFI + diff --git a/cpu/esp32/esp-wifi/doc.txt b/cpu/esp32/esp-wifi/doc.txt index d3e064e417630..49727cb42d5f2 100644 --- a/cpu/esp32/esp-wifi/doc.txt +++ b/cpu/esp32/esp-wifi/doc.txt @@ -29,11 +29,11 @@ USEMODULE += esp_wifi Furthermore, the following configuration parameters have to be defined: -Configuration Parameter | Description -------------------------|------------ -ESP_WIFI_SSID | SSID of the AP to be used. -ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). -ESP_WIFI_STACKSIZE | Stack size used for the WiFi netdev driver thread. +Configuration Parameter | Description +--------------------------|------------ +#CONFIG_ESP_WIFI_SSID | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE| Stack size used for the WiFi netdev driver thread. These configuration parameter definitions, as well as enabling the `esp_wifi` module, can be done either in the makefile of the project or at make command @@ -41,7 +41,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` diff --git a/cpu/esp32/esp-wifi/esp_wifi_netdev.c b/cpu/esp32/esp-wifi/esp_wifi_netdev.c index c28e715818561..911f2d8805d4e 100644 --- a/cpu/esp32/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp32/esp-wifi/esp_wifi_netdev.c @@ -99,7 +99,7 @@ static unsigned int rx_buf_write = 0; static unsigned int rx_buf_read = 0; /* device thread stack */ -static char _esp_wifi_stack[ESP_WIFI_STACKSIZE]; +static char _esp_wifi_stack[CONFIG_ESP_WIFI_STACKSIZE]; extern esp_err_t esp_system_event_add_handler (system_event_cb_t handler, void *arg); @@ -291,8 +291,8 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t * /* we use predefined station configuration */ static wifi_config_t wifi_config_sta = { .sta = { - .ssid = ESP_WIFI_SSID, - .password = ESP_WIFI_PASS, + .ssid = CONFIG_ESP_WIFI_SSID, + .password = CONFIG_ESP_WIFI_PASS, .bssid_set = 0, .channel = 0, .scan_method = WIFI_ALL_CHANNEL_SCAN, @@ -578,14 +578,14 @@ void auto_init_esp_wifi (void) esp_wifi_setup(&_esp_wifi_dev); _esp_wifi_dev.netif = gnrc_netif_ethernet_create(_esp_wifi_stack, - ESP_WIFI_STACKSIZE, + CONFIG_ESP_WIFI_STACKSIZE, #ifdef MODULE_ESP_NOW - ESP_WIFI_PRIO - 1, + CONFIG_ESP_WIFI_PRIO - 1, #else - ESP_WIFI_PRIO, + CONFIG_ESP_WIFI_PRIO, #endif - "esp-wifi", - (netdev_t *)&_esp_wifi_dev); + "esp-wifi", + (netdev_t *)&_esp_wifi_dev); } #endif /* MODULE_ESP_WIFI */ diff --git a/cpu/esp32/esp-wifi/esp_wifi_params.h b/cpu/esp32/esp-wifi/esp_wifi_params.h index e6c0c9adfb103..c43fa384b1470 100644 --- a/cpu/esp32/esp-wifi/esp_wifi_params.h +++ b/cpu/esp32/esp-wifi/esp_wifi_params.h @@ -22,37 +22,77 @@ #if defined(MODULE_ESP_WIFI) || defined(DOXYGEN) +/** + * @name Legacy defintions of default configuration parameters + * @{ + */ + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_STACKSIZE is deprecated, please use #CONFIG_ESP_WIFI_STACKSIZE + * instead. + */ +#ifndef ESP_WIFI_STACKSIZE +#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PRIO is deprecated, please use #CONFIG_ESP_WIFI_PRIO instead. + */ +#ifndef ESP_WIFI_PRIO +#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_SSID is deprecated, please use #CONFIG_ESP_WIFI_SSID instead. + */ +#ifndef ESP_WIFI_SSID +#define ESP_WIFI_SSID "RIOT_AP" +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PASS is deprecated, please use #CONFIG_ESP_WIFI_PASS instead. + */ +#ifndef ESP_WIFI_PASS +#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#endif + /** * @name Set default configuration parameters for the ESP WiFi netdev driver * @{ */ +/** @} */ + /** * @brief The size of the stack used for the ESP WIFI netdev driver thread. */ -#ifndef ESP_WIFI_STACKSIZE -#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#ifndef CONFIG_ESP_WIFI_STACKSIZE +#define CONFIG_ESP_WIFI_STACKSIZE ESP_WIFI_STACKSIZE #endif /** * @brief The priority of the ESP WiFi netdev driver thread. Should not be changed. */ -#ifndef ESP_WIFI_PRIO -#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#ifndef CONFIG_ESP_WIFI_PRIO +#define CONFIG_ESP_WIFI_PRIO ESP_WIFI_PRIO #endif /** * @brief SSID of the AP to be used. */ -#ifndef ESP_WIFI_SSID -#define ESP_WIFI_SSID "RIOT_AP" +#ifndef CONFIG_ESP_WIFI_SSID +#define CONFIG_ESP_WIFI_SSID ESP_WIFI_SSID #endif /** * @brief Passphrase used for the AP as clear text (max. 64 chars). */ -#ifndef ESP_WIFI_PASS -#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#ifndef CONFIG_ESP_WIFI_PASS +#define CONFIG_ESP_WIFI_PASS ESP_WIFI_PASS #endif /**@}*/