Skip to content

Commit

Permalink
cpu/esp32: add Kconfig for module esp_wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Jan 15, 2020
1 parent 94e5c25 commit 82ddc73
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 28 deletions.
12 changes: 6 additions & 6 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,11 @@ Furthermore, the following configuration parameters have to be defined:

<center>

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.

</center>

Expand All @@ -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=...
```

Expand Down
30 changes: 30 additions & 0 deletions cpu/esp32/esp-wifi/Kconfig
Original file line number Diff line number Diff line change
@@ -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

12 changes: 6 additions & 6 deletions cpu/esp32/esp-wifi/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ 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
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=...
```

Expand Down
16 changes: 8 additions & 8 deletions cpu/esp32/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down
56 changes: 48 additions & 8 deletions cpu/esp32/esp-wifi/esp_wifi_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**@}*/
Expand Down

0 comments on commit 82ddc73

Please sign in to comment.