Skip to content

Conversation

@me-no-dev
Copy link
Member

This pull request refactors the order of operations in the STAClass::disconnect method to improve reliability and maintain correct behavior when disconnecting from WiFi. The main change is moving the logic that clears the WiFi configuration (eraseap block) to execute after the disconnect operation, rather than before.

WiFi disconnect logic refactor:

  • The code that handles clearing the WiFi configuration (eraseap logic) now runs after the call to esp_wifi_disconnect, ensuring the device is disconnected before erasing its settings. (libraries/WiFi/src/STA.cpp, [1] [2]
  • Removed the check for whether the device is already disconnected, so disconnect is always attempted regardless of current connection state. (libraries/WiFi/src/STA.cpp, libraries/WiFi/src/STA.cppL528-L546)

Fixes: #11742

@me-no-dev me-no-dev added Status: Review needed Issue or PR is awaiting review Area: WiFi Issue related to WiFi labels Nov 10, 2025
@github-actions
Copy link
Contributor

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello me-no-dev, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against aedff64

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Test Results

 76 files   76 suites   16m 6s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit aedff64.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32C5💚 -600.000.00000.000.00
ESP32P4💚 -2280💚 -0.030.00000.000.00
ESP32S3💚 -2400.000.00000.000.00
ESP32S2💚 -24⚠️ +360.000.00000.000.00
ESP32C3💚 -600.000.00000.000.00
ESP32C6💚 -1000.000.00000.000.00
ESP32H2000.000.00000.000.00
ESP32💚 -2800.000.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32C5ESP32P4ESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/ArduinoOTA/examples/BasicOTA💚 -60💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/AsyncUDP/examples/AsyncUDPClient💚 -60💚 -40💚 -120💚 -160💚 -40💚 -60--💚 -120
libraries/AsyncUDP/examples/AsyncUDPMulticastServer💚 -40💚 -60💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/AsyncUDP/examples/AsyncUDPServer💚 -40💚 -40💚 -120💚 -160💚 -40💚 -60--💚 -120
libraries/DNSServer/examples/CaptivePortal💚 -60💚 -2240💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/ESP32/examples/Time/SimpleTime💚 -60💚 -60💚 -120💚 -160💚 -60💚 -40--💚 -120
libraries/ESP_NOW/examples/ESP_NOW_Broadcast_Master💚 -40--💚 -240💚 -160💚 -40💚 -40--💚 -120
libraries/ESP_NOW/examples/ESP_NOW_Broadcast_Slave💚 -40--💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/ESP_NOW/examples/ESP_NOW_Network💚 -60--💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/ESP_NOW/examples/ESP_NOW_Serial💚 -40--💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/ESPmDNS/examples/mDNS-SD_Extended💚 -6000💚 -120💚 -40💚 -60💚 -60--💚 -120
libraries/ESPmDNS/examples/mDNS_Web_Server💚 -40💚 -40💚 -160💚 -160💚 -40💚 -40--💚 -120
libraries/Ethernet/examples/ETH_WIFI_BRIDGE💚 -40💚 -2280💚 -120💚 -160💚 -40💚 -60--💚 -120
libraries/FFat/examples/FFat_time0000💚 -120💚 -2000000--💚 -120
libraries/HTTPClient/examples/Authorization💚 -40💚 -6000💚 -120💚 -60💚 -40--💚 -120
libraries/HTTPClient/examples/BasicHttpClient💚 -40💚 -6000💚 -120💚 -60💚 -40--💚 -120
libraries/HTTPClient/examples/BasicHttpsClient💚 -400000💚 -160💚 -60💚 -40--💚 -120
libraries/HTTPClient/examples/CustomHeaders💚 -40💚 -4000💚 -120💚 -40💚 -40--💚 -120
libraries/HTTPClient/examples/HTTPClientEnterprise💚 -40--00💚 -160💚 -40💚 -60--💚 -120
libraries/HTTPClient/examples/ReuseConnection💚 -60💚 -4000💚 -120💚 -40💚 -40--💚 -120
libraries/HTTPClient/examples/StreamHttpClient💚 -40💚 -4000💚 -120💚 -60💚 -60--💚 -120
libraries/HTTPUpdate/examples/httpUpdate💚 -60💚 -60💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/HTTPUpdate/examples/httpUpdateSPIFFS💚 -60💚 -60💚 -120💚 -16000💚 -60--💚 -120
libraries/HTTPUpdate/examples/httpUpdateSecure💚 -40💚 -4000💚 -120💚 -40💚 -40--💚 -120
libraries/HTTPUpdateServer/examples/WebUpdater💚 -6000💚 -120💚 -200💚 -60💚 -60--💚 -120
libraries/Insights/examples/DiagnosticsSmokeTest💚 -40--00💚 -120💚 -40💚 -40--💚 -120
libraries/Insights/examples/MinimalDiagnostics💚 -40--00💚 -120💚 -60💚 -40--💚 -120
libraries/LittleFS/examples/LITTLEFS_time0000💚 -120💚 -16000💚 -100--💚 -120
libraries/Matter/examples/MatterColorLight00--00💚 -120000000💚 -160
libraries/Matter/examples/MatterCommissionTest00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterComposedLights00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterContactSensor00--00💚 -160000000💚 -120
libraries/Matter/examples/MatterDimmableLight00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterEnhancedColorLight00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterEvents00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterFan00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterHumiditySensor00--00💚 -120000000💚 -280
libraries/Matter/examples/MatterLambdaSingleCallbackManyEPs00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterMinimum00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterOccupancySensor00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterOnIdentify00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterOnOffLight00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterOnOffPlugin00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterPressureSensor00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterSmartButton00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterTemperatureLight00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterTemperatureSensor00--00💚 -120000000💚 -120
libraries/Matter/examples/MatterThermostat00--00💚 -120000000💚 -120
libraries/NetBIOS/examples/ESP_NBNST💚 -40💚 -40💚 -120💚 -200💚 -40💚 -40--💚 -160
libraries/NetworkClientSecure/examples/WiFiClientInsecure💚 -60💚 -60💚 -120💚 -120💚 -60💚 -60--💚 -120
libraries/NetworkClientSecure/examples/WiFiClientPSK💚 -60💚 -60💚 -120⚠️ +360💚 -60💚 -60--💚 -120
libraries/NetworkClientSecure/examples/WiFiClientSecure💚 -60💚 -60💚 -160💚 -160💚 -60💚 -60--💚 -160
libraries/NetworkClientSecure/examples/WiFiClientSecureEnterprise💚 -40--00💚 -120💚 -40💚 -40--💚 -120
libraries/NetworkClientSecure/examples/WiFiClientSecureProtocolUpgrade💚 -40💚 -4000💚 -160💚 -40💚 -60--💚 -120
libraries/NetworkClientSecure/examples/WiFiClientShowPeerCredentials00💚 -6000💚 -120💚 -60💚 -60--💚 -120
libraries/NetworkClientSecure/examples/WiFiClientTrustOnFirstUse💚 -60💚 -4000💚 -160💚 -40💚 -40--💚 -120
libraries/PPP/examples/PPP_WIFI_BRIDGE💚 -60💚 -2240💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/RainMaker/examples/RMakerCustom00--00💚 -160💚 -4000----
libraries/RainMaker/examples/RMakerCustomAirCooler💚 -40--00💚 -120💚 -40💚 -40----
libraries/RainMaker/examples/RMakerSonoffDualR3💚 -60--00💚 -120💚 -40💚 -60----
libraries/RainMaker/examples/RMakerSwitch💚 -60--00💚 -120💚 -40💚 -100----
libraries/SD/examples/SD_time💚 -60💚 -60💚 -120💚 -200💚 -60💚 -60--💚 -120
libraries/SPIFFS/examples/SPIFFS_time0000💚 -120💚 -1600000--💚 -120
libraries/Update/examples/AWS_S3_OTA_Update💚 -6000💚 -120💚 -160💚 -6000--💚 -120
libraries/Update/examples/HTTPS_OTA_Update💚 -40💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/Update/examples/HTTP_Client_AES_OTA_Update💚 -60💚 -60💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/Update/examples/HTTP_Server_AES_OTA_Update💚 -60💚 -2240💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/Update/examples/OTAWebUpdater💚 -60💚 -2220💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/WebServer/examples/AdvancedWebServer💚 -40💚 -60💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WebServer/examples/ChunkWriting💚 -40💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WebServer/examples/FSBrowser💚 -60💚 -6000💚 -120💚 -60💚 -60--💚 -120
libraries/WebServer/examples/Filters💚 -40💚 -60💚 -160💚 -160💚 -40💚 -40--💚 -120
libraries/WebServer/examples/HelloServer💚 -40💚 -40💚 -120💚 -160💚 -60💚 -40--💚 -120
libraries/WebServer/examples/HttpAdvancedAuth💚 -40💚 -6000💚 -160💚 -4000--💚 -120
libraries/WebServer/examples/HttpAuthCallback💚 -400000💚 -160💚 -60💚 -40--💚 -120
libraries/WebServer/examples/HttpAuthCallbackInline💚 -40💚 -6000💚 -160💚 -40💚 -40--💚 -160
libraries/WebServer/examples/HttpBasicAuth💚 -40💚 -4000💚 -160💚 -40💚 -40--💚 -120
libraries/WebServer/examples/HttpBasicAuthSHA1💚 -40💚 -4000💚 -120💚 -40💚 -40--💚 -120
libraries/WebServer/examples/HttpBasicAuthSHA1orBearerToken💚 -40💚 -4000💚 -120💚 -40💚 -40--💚 -120
libraries/WebServer/examples/Middleware💚 -40--💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WebServer/examples/MultiHomedServers0000💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/WebServer/examples/PathArgServer💚 -60💚 -60💚 -160💚 -200💚 -60💚 -60--💚 -120
libraries/WebServer/examples/SDWebServer💚 -60💚 -60💚 -40💚 -120💚 -60💚 -60--00
libraries/WebServer/examples/SimpleAuthentification0000💚 -120💚 -1600000--💚 -120
libraries/WebServer/examples/UploadHugeFile💚 -60💚 -60💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/WebServer/examples/WebServer💚 -60💚 -60💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/WebServer/examples/WebUpdate💚 -40💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/FTM/FTM_Initiator💚 -40💚 -40💚 -120💚 -160💚 -40💚 -60--💚 -120
libraries/WiFi/examples/FTM/FTM_Responder💚 -40💚 -2280💚 -120💚 -200💚 -60💚 -60--💚 -120
libraries/WiFi/examples/SimpleWiFiServer💚 -40💚 -60💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WPS💚 -40--💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiAccessPoint💚 -40💚 -2240💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiBlueToothSwitch💚 -40--💚 -120--💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiClient💚 -60💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiClientBasic💚 -60💚 -6000💚 -160💚 -60💚 -60--💚 -120
libraries/WiFi/examples/WiFiClientConnect💚 -40💚 -40💚 -120💚 -160💚 -60💚 -60--💚 -120
libraries/WiFi/examples/WiFiClientEnterprise💚 -60--00💚 -120💚 -60💚 -60--💚 -120
libraries/WiFi/examples/WiFiClientEvents💚 -40💚 -60💚 -120💚 -160💚 -40💚 -60--💚 -120
libraries/WiFi/examples/WiFiClientStaticIP💚 -40💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiExtender💚 -40💚 -40💚 -120💚 -160💚 -60💚 -40--💚 -120
libraries/WiFi/examples/WiFiIPv6💚 -40💚 -40💚 -120💚 -160💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiMulti💚 -40💚 -40💚 -120💚 -240💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiMultiAdvanced💚 -600000💚 -120💚 -6000--💚 -120
libraries/WiFi/examples/WiFiScan💚 -40💚 -2260💚 -120💚 -160💚 -6000--💚 -160
libraries/WiFi/examples/WiFiScanAsync💚 -40💚 -40💚 -120💚 -160💚 -60💚 -40--💚 -120
libraries/WiFi/examples/WiFiScanDualAntenna💚 -60💚 -40💚 -160💚 -160💚 -4000--💚 -120
libraries/WiFi/examples/WiFiScanTime💚 -60💚 -40💚 -120💚 -40💚 -40💚 -40--💚 -120
libraries/WiFi/examples/WiFiSmartConfig💚 -40--💚 -120💚 -160💚 -60💚 -40--💚 -120
libraries/WiFi/examples/WiFiTelnetToSerial💚 -40💚 -60💚 -120💚 -240💚 -60💚 -40--💚 -120
libraries/WiFi/examples/WiFiUDPClient💚 -40💚 -40💚 -160💚 -160💚 -40💚 -40--💚 -120
libraries/WiFiProv/examples/WiFiProv💚 -60--00💚 -160💚 -40💚 -60--💚 -160
libraries/Zigbee/examples/Zigbee_Gateway💚 -60--00💚 -120💚 -60----💚 -120
libraries/SD_MMC/examples/SDMMC_time--💚 -60💚 -120--------💚 -120
libraries/ESP32/examples/Camera/CameraWebServer----💚 -120💚 -160------💚 -160
ESP32/examples/Camera/CameraWebServer (2)----00💚 -240------💚 -120
ESP32/examples/Camera/CameraWebServer (3)----00----------

@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Nov 10, 2025
@me-no-dev me-no-dev merged commit 3500d3e into master Nov 10, 2025
106 of 110 checks passed
@me-no-dev me-no-dev deleted the bugfix/wifi_disconnect branch November 10, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: WiFi Issue related to WiFi Status: Pending Merge Pull Request is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WiFi.disconnect(true,true) not working correctly in "IDE SDK=v3.3.0"

5 participants