-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
v5.5.1
Espressif SoC revision.
ESP32-C6
Operating System used.
macOS
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
Custom board
Power Supply used.
External 5V
What is the expected behavior?
- After
IP_EVENT_STA_GOT_IP, the station should not be in a "connecting" state, so updating the config should be allowed esp_wifi_set_configshould return an error code instead ofESP_OKwhen the Wi-Fi stack rejects the configuration update
What is the actual behavior?
The Wi-Fi stack logs wifi:sta is connecting, cannot set config despite this failure, esp_wifi_set_config returns ESP_OK, making it impossible to detect the error programmatically
Steps to reproduce.
auto ret = esp_wifi_set_storage(WIFI_STORAGE_FLASH);
if (ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to set Wi-Fi storage to FLASH: %s", esp_err_to_name(ret));
return;
}
ESP_LOGI(__func__, "esp_wifi_set_storage ret = %d", ret);
ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
if (ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to persist Wi-Fi config in flash: %s", esp_err_to_name(ret));
return;
}
ESP_LOGI(__func__, "esp_wifi_set_config ret = %d", ret);Debug Logs.
W (93779) wifi:(itwt)itwt_stop_process!
I (98591) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1, snd_ch_cfg:0x0
I (98591) wifi:(connect)dot11_authmode:0x3, pairwise_cipher:0x3, group_cipher:0x3
I (98591) wifi:state: init -> auth (0xb0)
I (98593) wifi:state: auth -> assoc (0x0)
I (98597) wifi:state: assoc -> run (0x10)
I (98599) wifi:(trc)phytype:CBW20-SGI, snr:38, maxRate:144, highestRateIdx:0
W (98599) wifi:(trc)band:2G, phymode:3, highestRateIdx:0, lowestRateIdx:11, dataSchedTableSize:14
I (98599) wifi:(trc)band:2G, rate(S-MCS7, rateIdx:0), ampdu(rate:S-MCS7, schedIdx(0, stop:8)), snr:38, ampduState:wait operational
I (98599) wifi:ifidx:0, rssi:-53, nf:-91, phytype(0x3, CBW20-SGI), phymode(0x3, 11bgn), max_rate:144, he:0, vht:0, ht:1
I (98599) wifi:(ht)max.RxAMPDULenExponent:3(65535 bytes), MMSS:5(4 us)
I (98609) wifi:connected with xxxxxxxxxx, aid = 6, channel 1, BW20, bssid = xx:xx:xx:xx:xx:xx
I (98609) wifi:security: WPA2-PSK, phy:bgn, rssi:-53, cipher(pairwise:0x3, group:0x3), pmf:0,
I (98611) wifi:pm start, type: 0, twt_start:0
I (98611) wifi:pm start, type:0, aid:0x6, trans-BSSID:xx:xx:xx:xx:xx:xx, BSSID[5]:0x92, mbssid(max-indicator:0, index:0), he:0
I (98611) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (98611) wifi:set rx beacon pti, rx_bcn_pti: 10, bcn_timeout: 25000, mt_pti: 10, mt_time: 10000
E (98611) wifi:sta is connecting, cannot set config
I (98611) wifi:[ADDBA]TX addba request, tid:0, dialogtoken:1, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (98613) wifi:[ADDBA]TX addba request, tid:7, dialogtoken:2, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x20)
I (98613) wifi:[ADDBA]TX addba request, tid:5, dialogtoken:3, bufsize:64, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (98615) wifi:[ADDBA]RX addba response, status:0, tid:0/tb:1(0xa1), bufsize:64, batimeout:0, txa_wnd:64
I (98615) wifi:[ADDBA]RX addba response, status:0, tid:7/tb:1(0xa1), bufsize:64, batimeout:0, txa_wnd:64
I (98617) wifi:[ADDBA]RX addba response, status:0, tid:5/tb:1(0xa1), bufsize:64, batimeout:0, txa_wnd:64
I (98697) wifi:AP's beacon interval = 102400 us, DTIM period = 1
W (99621) wifi:<ba-add>idx:0, ifx:0, tid:0, TAHI:0x10092bb, TALO:0xabe4fbb6, (ssn:1, win:64, cur_ssn:1), CONF:0xc0000005
I (100629) esp_netif_handlers: sta ip: 192.168.92.140, mask: 255.255.255.0, gw: 192.168.92.1
I (100657) registerDeviceToCloud: Provisioning to xxxxxx.com
I (100659) OTA: Checking for updates...
I (100661) DevicesManager: Starting polling tasks if needed
I (100661) DevicesManager: Starting Device poll task
I (100663) CloudManager: TLS keepalive cfg: enable=1 idle=5 interval=2 count=2
I (100665) main_task: Returned from app_main()
I (100899) OTA: HTTP request attempt 1
I (101405) esp-x509-crt-bundle: Certificate validated
I (101991) registerDeviceToCloud: Register device request completed, checking response...
I (101991) registerDeviceToCloud: Device registered successfully, status code 201
I (101991) registerDeviceToCloud: esp_wifi_set_storage ret = 0
I (101993) registerDeviceToCloud: esp_wifi_set_config ret = 0
Diagnostic report archive.
No response
More Information.
My provisioning state machine first saves the credentials in RAM, then later persists them to flash. The relevant logic looks like this:
wifi_config_t wifi_config = {};
strlcpy((char *)wifi_config.sta.ssid, ssidVal.c_str(), sizeof(wifi_config.sta.ssid));
strlcpy((char *)wifi_config.sta.password, passwordVal.c_str(), sizeof(wifi_config.sta.password));
wifi_config.sta.channel = 0; // auto
wifi_config.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; // scan all channels
wifi_config.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; // prefer strongest BSSID
wifi_config.sta.bssid_set = false; // set true and fill bssid[] if you want to lock to one AP
// Only associate if signal is decent; adjust to your environment
wifi_config.sta.threshold.rssi = WIFI_RSSI_MIN_THRESHOLD; // e.g., -70..-75 is a good reliability floor
wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; // minimum; WPA3 will still be accepted
// PMF and WPA3 settings (use if available in your ESP‑IDF)
wifi_config.sta.pmf_cfg.capable = true;
wifi_config.sta.pmf_cfg.required = false; // don’t hard‑require to keep compatibility
wifi_config.sta.sae_pwe_h2e = WPA3_SAE_PWE_BOTH; // WPA3 SAE both modes (if supported)
wifi_config.sta.sae_pk_mode = WPA3_SAE_PK_MODE_AUTOMATIC;
// Roaming/robustness helpers
wifi_config.sta.rm_enabled = 1; // 802.11k radio measurements
wifi_config.sta.btm_enabled = 1; // 802.11v BSS transition
#ifdef CONFIG_ESP_WIFI_MBO_SUPPORT
wifi_config.sta.mbo_enabled = 1; // Agile Multiband
#endif
#ifdef CONFIG_ESP_WIFI_11R_SUPPORT
wifi_config.sta.ft_enabled = 1; // 802.11r fast transition
#endif
if (auto ret = esp_wifi_set_storage(WIFI_STORAGE_RAM); ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to set Wi-Fi storage RAM: %s", esp_err_to_name(ret));
return;
}
if (auto ret = esp_wifi_disconnect(); ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to disconnect Wi-Fi: %s", esp_err_to_name(ret));
return;
}
if (auto ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_config); ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to set Wi-Fi config in RAM: %s", esp_err_to_name(ret));
return;
}
if (auto ret = esp_wifi_connect(); ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to connect Wi-Fi: %s", esp_err_to_name(ret));
return;
}
...
(talks to the cloud, check for OTA)
...
auto ret = esp_wifi_set_storage(WIFI_STORAGE_FLASH);
if (ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to set Wi-Fi storage to FLASH: %s", esp_err_to_name(ret));
return;
}
ESP_LOGI(__func__, "esp_wifi_set_storage ret = %d", ret);
ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
if (ret != ESP_OK)
{
ESP_LOGE(__func__, "Failed to persist Wi-Fi config in flash: %s", esp_err_to_name(ret));
return;
}
ESP_LOGI(__func__, "esp_wifi_set_config ret = %d", ret);