Skip to content

Commit a803312

Browse files
committed
fixup! cpu/esp32: implement ESP32 SoftAP mode
1 parent 50801ec commit a803312

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

cpu/esp_common/esp-wifi/esp_wifi_netdev.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,10 @@ static wifi_config_t wifi_config_sta = {
827827
*/
828828
static wifi_config_t wifi_config_ap = {
829829
.ap = {
830+
#ifdef ESP_WIFI_SSID
830831
.ssid = ESP_WIFI_SSID,
831832
.ssid_len = ARRAY_SIZE(ESP_WIFI_SSID) - 1,
833+
#endif
832834
#ifdef ESP_WIFI_PASS
833835
.password = ESP_WIFI_PASS,
834836
.authmode = WIFI_AUTH_WPA2_PSK,
@@ -914,6 +916,15 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev)
914916
}
915917

916918
#if defined(MCU_ESP8266) || defined(MODULE_ESP_WIFI_AP)
919+
#ifdef ESP_WIFI_AP_PREFIX
920+
uint8_t mac[ETHERNET_ADDR_LEN];
921+
esp_wifi_get_mac(ESP_MAC_WIFI_SOFTAP, mac);
922+
sprintf((char*)wifi_config_ap.ap.ssid, "%s%02x%02x%02x%02x%02x%02x",
923+
ESP_WIFI_AP_PREFIX,
924+
mac[0], mac[1], mac[2],
925+
mac[3], mac[4], mac[5]);
926+
wifi_config_ap.ap.ssid_len = strlen((char*)wifi_config_ap.ap.ssid);
927+
#endif /* ESP_WIFI_AP_PREFIX */
917928
/* set the SoftAP configuration */
918929
result = esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config_ap);
919930
if (result != ESP_OK) {

cpu/esp_common/esp-wifi/esp_wifi_params.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@
4444
/**
4545
* @brief SSID of the AP to be used.
4646
*/
47-
#ifndef ESP_WIFI_SSID
47+
#if !defined(ESP_WIFI_SSID) && !defined(ESP_WIFI_AP_PREFIX)
4848
#define ESP_WIFI_SSID "RIOT_AP"
4949
#endif
5050

51+
/**
52+
* @brief Prefix to be used as part of the SSID (e.g.: RIOT_AP_aabbccddeeff)
53+
*/
54+
#if !defined(ESP_WIFI_SSID) && !defined(ESP_WIFI_AP_PREFIX)
55+
#define ESP_WIFI_AP_PREFIX "RIOT_AP_"
56+
#endif
57+
5158
/**
5259
* @brief Passphrase used for the AP as clear text (max. 64 chars).
5360
*/

0 commit comments

Comments
 (0)