Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/esp_common: use generic WIFI_SSID/WIFI_PASS defines #19286

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,8 @@ 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 | - | Passphrase used for the AP as clear text (max. 64 chars).
#WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
#WIFI_PASS | - | 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.

</center><br>
Expand All @@ -1573,14 +1573,14 @@ line, for example:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE=esp_wifi \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DWIFI_PASS=\"MyPassphrase\"' \
make -C examples/gnrc_networking BOARD=...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@note
- Module `esp_wifi` is not enabled automatically when module
`netdev_default` is used.
- Leave 'ESP_WIFI_PASS' undefined to connect to an open WiFi access point.
- Leave 'WIFI_PASS' undefined to connect to an open WiFi access point.
- The Wifi network interface (module `esp_wifi`) and the
[ESP-NOW network interface](#esp32_esp_now_network_interface) (module `esp_now`)
can be used simultaneously, for example, to realize a border router for
Expand Down Expand Up @@ -1612,7 +1612,7 @@ following configuration parameters have to be defined:

Parameter | Default | Description
:-------------------|:----------|:------------
#ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
#WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
ESP_WIFI_EAP_ID | none | Optional anonymous identity used in phase 1 (outer) EAP authentication.[1]
ESP_WIFI_EAP_USER | none | User name used in phase 2 (inner) EAP authentication.
ESP_WIFI_EAP_PASS | none | Password used in phase 2 (inner) EAP authentication.
benpicco marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -1630,7 +1630,7 @@ line, for example:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE=esp_wifi_enterprise \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_EAP_ID=\"anonymous\" -DESP_WIFI_EAP_USER=\"MyUserName\" -DESP_WIFI_EAP_PASS=\"MyPassphrase\"' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DESP_WIFI_EAP_ID=\"anonymous\" -DESP_WIFI_EAP_USER=\"MyUserName\" -DESP_WIFI_EAP_PASS=\"MyPassphrase\"' \
benpicco marked this conversation as resolved.
Show resolved Hide resolved
make -C examples/gnrc_networking BOARD=...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -1660,8 +1660,8 @@ The following parameters can be configured:

Parameter | Default | Description
:-------------------------|:--------------------------|:-------------
#ESP_WIFI_SSID | "RIOT_AP" | Static SSID definition for the SoftAP
#ESP_WIFI_PASS | none | The password for the WiFi SoftAP network interface.[1]
#WIFI_SSID | "RIOT_AP" | Static SSID definition for the SoftAP
#WIFI_PASS | none | The password for the WiFi SoftAP network interface.[1]
#ESP_WIFI_SSID_DYNAMIC | 0 | Defines whether dynamic SSID is used for the SoftAP [2].
#ESP_WIFI_SSID_HIDDEN | 0 | Defines whether the SoftAP SSID should be hidden.
#ESP_WIFI_MAX_CONN | 4 | The maximum number of connections for the SoftAP.
Expand All @@ -1673,7 +1673,7 @@ Parameter | Default | Description
[1] If no password is provided, the interface will be "open", otherwise it
uses WPA2-PSK authentication mode.<br>
[2] If `#ESP_WIFI_SSID_DYNAMIC` is set to 1, a dynamic SSID is generated for the
SoftAP by extending the defined SSID (`ESP_WIFI_SSID`) with the MAC address
SoftAP by extending the defined SSID (`WIFI_SSID`) with the MAC address
of the SoftAP interface used, e.g.: `RIOT_AP_aabbccddeeff`

These configuration parameter definitions, as well as enabling the `esp_wifi_ap`
Expand All @@ -1682,7 +1682,7 @@ line, for example:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE=esp_wifi_ap \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\" -DESP_WIFI_MAX_CONN=1' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DWIFI_PASS=\"MyPassphrase\" -DESP_WIFI_MAX_CONN=1' \
make -C examples/gnrc_networking BOARD=...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
16 changes: 8 additions & 8 deletions cpu/esp8266/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@ 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 | - | Passphrase used for the AP as clear text (max. 64 chars).
#WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
#WIFI_PASS | - | 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.

</center>
Expand All @@ -729,14 +729,14 @@ line, e.g.:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE=esp_wifi \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DWIFI_PASS=\"MyPassphrase\"' \
make -C examples/gnrc_networking BOARD=...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@note
- Module `esp_wifi` is not enabled automatically when module
`netdev_default` is used.
- Leave `ESP_WIFI_PASS` undefined to connect to an open WiFi access point.
- Leave `WIFI_PASS` undefined to connect to an open WiFi access point.
- The Wifi network interface (module `esp_wifi`) and the
[ESP-NOW network interface](#esp8266_esp_now_network_interface)
(module `esp_now`) can be used simultaneously, for example, to realize a
Expand All @@ -758,8 +758,8 @@ The following parameters can be configured:

Parameter | Default | Description
:-------------------------|:--------------------------|:-------------
#ESP_WIFI_SSID | "RIOT_AP" | Static SSID definition for the SoftAP
#ESP_WIFI_PASS | none | The password for the WiFi SoftAP network interface.[1]
#WIFI_SSID | "RIOT_AP" | Static SSID definition for the SoftAP
#WIFI_PASS | none | The password for the WiFi SoftAP network interface.[1]
#ESP_WIFI_SSID_DYNAMIC | 0 | Defines whether dynamic SSID is used for the SoftAP [2].
#ESP_WIFI_SSID_HIDDEN | 0 | Defines whether the SoftAP SSID should be hidden.
#ESP_WIFI_MAX_CONN | 4 | The maximum number of connections for the SoftAP.
Expand All @@ -771,7 +771,7 @@ Parameter | Default | Description
[1] If no password is provided, the interface will be "open", otherwise it
uses WPA2-PSK authentication mode.<br>
[2] If #ESP_WIFI_SSID_DYNAMIC is set to 1, a dynamic SSID is generated for the
SoftAP by extending the defined SSID (`ESP_WIFI_SSID`) with the MAC address
SoftAP by extending the defined SSID (`WIFI_SSID`) with the MAC address
of the SoftAP interface used, e.g.: `RIOT_AP_aabbccddeeff`

These configuration parameter definitions, as well as enabling the `esp_wifi_ap`
Expand All @@ -780,7 +780,7 @@ line, for example:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE=esp_wifi_ap \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\" -DESP_WIFI_MAX_CONN=1' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DWIFI_PASS=\"MyPassphrase\" -DESP_WIFI_MAX_CONN=1' \
make -C examples/gnrc_networking BOARD=...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 6 additions & 6 deletions cpu/esp_common/esp-wifi/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ 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 | - | Passphrase used for the AP as clear text (max. 64 chars).
WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
WIFI_PASS | - | 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.

</center>
Expand All @@ -50,14 +50,14 @@ line, for example:

```
USEMODULE=esp_wifi \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DWIFI_PASS=\"MyPassphrase\"' \
make -C examples/gnrc_networking BOARD=...
```

@note
- Module `esp_wifi` is not enabled automatically when module
`netdev_default` is used.
- Leave 'ESP_WIFI_PASS' undefined to connect to an open WiFi access point.
- Leave 'WIFI_PASS' undefined to connect to an open WiFi access point.
- The Wifi network interface (module `esp_wifi`) and the
ESP-NOW network interface (module `esp_now`)
can be used simultaneously, for example, to realize a border router for
Expand Down Expand Up @@ -87,7 +87,7 @@ following configuration parameters have to be defined:

Parameter | Default | Description
:------------------|:----------|:------------
ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
ESP_WIFI_EAP_ID | none | Optional anonymous identity used in phase 1 (outer) EAP authentication. If it is not defined, the user name defined for phase 2 (inner) EAP authentication is used as idendity in phase 1.
ESP_WIFI_EAP_USER | none | User name used in phase 2 (inner) EAP authentication.
ESP_WIFI_EAP_PASS | none | Password used in phase 2 (inner) EAP authentication.
benpicco marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -101,7 +101,7 @@ line, for example:

```
USEMODULE=esp_wifi_enterprise \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_EAP_ID=\"anonymous\" -DESP_WIFI_EAP_USER=\"MyUserName\" -DESP_WIFI_EAP_PASS=\"MyPassphrase\"' \
CFLAGS='-DWIFI_SSID=\"MySSID\" -DESP_WIFI_EAP_ID=\"anonymous\" -DESP_WIFI_EAP_USER=\"MyUserName\" -DESP_WIFI_EAP_PASS=\"MyPassphrase\"' \
benpicco marked this conversation as resolved.
Show resolved Hide resolved
make -C examples/gnrc_networking BOARD=...
```

Expand Down
18 changes: 9 additions & 9 deletions cpu/esp_common/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ static const netdev_driver_t _esp_wifi_driver =
*/
static wifi_config_t wifi_config_sta = {
.sta = {
.ssid = ESP_WIFI_SSID,
#if !defined(MODULE_ESP_WIFI_ENTERPRISE) && defined(ESP_WIFI_PASS)
.password = ESP_WIFI_PASS,
.ssid = WIFI_SSID,
#if !defined(MODULE_ESP_WIFI_ENTERPRISE) && defined(WIFI_PASS)
.password = WIFI_PASS,
#endif
.channel = 0,
.scan_method = WIFI_ALL_CHANNEL_SCAN,
Expand Down Expand Up @@ -830,12 +830,12 @@ static wifi_config_t wifi_config_sta = {
*/
static wifi_config_t wifi_config_ap = {
.ap = {
#ifdef ESP_WIFI_SSID
.ssid = ESP_WIFI_SSID,
.ssid_len = ARRAY_SIZE(ESP_WIFI_SSID) - 1,
#ifdef WIFI_SSID
.ssid = WIFI_SSID,
.ssid_len = sizeof(WIFI_SSID) - 1,
#endif
#ifdef ESP_WIFI_PASS
.password = ESP_WIFI_PASS,
#ifdef WIFI_PASS
.password = WIFI_PASS,
.authmode = WIFI_AUTH_WPA2_PSK,
#else
.authmode = WIFI_AUTH_OPEN,
Expand Down Expand Up @@ -923,7 +923,7 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev)
uint8_t mac[ETHERNET_ADDR_LEN];
esp_wifi_get_mac(ESP_MAC_WIFI_SOFTAP, mac);
sprintf((char*)wifi_config_ap.ap.ssid, "%s_%02x%02x%02x%02x%02x%02x",
ESP_WIFI_SSID, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
WIFI_SSID, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
wifi_config_ap.ap.ssid_len = strlen((char*)wifi_config_ap.ap.ssid);
#endif /* IS_ACTIVE(ESP_WIFI_SSID_DYNAMIC) */
/* set the SoftAP configuration */
Expand Down
16 changes: 12 additions & 4 deletions cpu/esp_common/esp-wifi/esp_wifi_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,23 @@
/**
* @brief SSID of the AP to be used.
*/
#ifndef ESP_WIFI_SSID
#define ESP_WIFI_SSID "RIOT_AP"
#ifndef WIFI_SSID
#ifdef ESP_WIFI_SSID
#define WIFI_SSID ESP_WIFI_SSID
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already done here

#else
#define WIFI_SSID "RIOT_AP"
#endif
#endif

/**
* @brief Passphrase used for the AP as clear text (max. 64 chars).
*/
#ifdef DOXYGEN
#define ESP_WIFI_PASS "ThisistheRIOTporttoESP"
#define WIFI_PASS "ThisistheRIOTporttoESP"
#endif

#if !defined(WIFI_PASS) && defined(ESP_WIFI_PASS)
#define WIFI_PASS ESP_WIFI_PASS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok 👍

#endif

#if defined(MODULE_ESP_WIFI_AP) || defined(DOXYGEN)
Expand All @@ -61,7 +69,7 @@
* @brief Use dynamic SSID for the SoftAP
*
* If set to 1, the SSID for the SoftAP is generated dynamically by extending
* the defined SSID (`ESP_WIFI_SSID`) with the MAC address of the SoftAP
* the defined SSID (`WIFI_SSID`) with the MAC address of the SoftAP
* interface used, e.g.: `RIOT_AP_aabbccddeeff`
*/
#ifndef ESP_WIFI_SSID_DYNAMIC
Expand Down
4 changes: 2 additions & 2 deletions examples/gnrc_border_router/Makefile.wifi.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CFLAGS += -DESP_WIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DESP_WIFI_PASS=\"$(WIFI_PASS)\"
CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DWIFI_PASS=\"$(WIFI_PASS)\"
4 changes: 2 additions & 2 deletions examples/paho-mqtt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ USEMODULE += ztimer_msec
include $(RIOTBASE)/Makefile.include

ifneq (,$(filter arch_esp,$(FEATURES_USED)))
CFLAGS += -DESP_WIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DESP_WIFI_PASS=\"$(WIFI_PASS)\"
CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DWIFI_PASS=\"$(WIFI_PASS)\"
endif
2 changes: 1 addition & 1 deletion tests/nimble_esp_wifi_coexist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ESP32x WiFi interface simultaneously.

Comile and flash the application with command
```
CFLAGS='-DESP_WIFI_SSID=\"myssid\" -DESP_WIFI_PASS=\"mypass\"'
CFLAGS='-DWIFI_SSID=\"myssid\" -DWIFI_PASS=\"mypass\"'
BOARD=esp32-wroom-32 make -C tests/nimble_esp_wifi_coexist flash term
```
Once the test application is flashed and the WiFi connection is established,
Expand Down