Skip to content

fix: guard WiFi.disconnect() to avoid STA not started error on ESP32-C6#9

Merged
DTTerastar merged 1 commit intomainfrom
fix-c6-sta-disconnect
Feb 11, 2026
Merged

fix: guard WiFi.disconnect() to avoid STA not started error on ESP32-C6#9
DTTerastar merged 1 commit intomainfrom
fix-c6-sta-disconnect

Conversation

@sensiebot
Copy link
Contributor

@sensiebot sensiebot bot commented Feb 11, 2026

On ESP32-C6 with Arduino Core 3.x, calling WiFi.disconnect() before STA has been started results in error:

[E][STA.cpp:530] disconnect(): STA not started! You must call begin first.

Fix:
Add check to only call disconnect() if STA mode is active:

if (WiFi.getMode() & WIFI_STA) {
    WiFi.disconnect(true, true);
}

This prevents the error during first-boot portal startup when no WiFi credentials exist.

Fixes #8

On ESP32-C6 with Arduino Core 3.x, calling WiFi.disconnect() before STA
has been started results in error:
  [E][STA.cpp:530] disconnect(): STA not started! You must call begin first.

Add check to only call disconnect() if STA mode is active. This prevents
the error during first-boot portal startup when no WiFi credentials exist.

Fixes #8
@sensiebot sensiebot bot requested a review from DTTerastar as a code owner February 11, 2026 03:02
@DTTerastar DTTerastar merged commit ded7afc into main Feb 11, 2026
1 check passed
@DTTerastar DTTerastar deleted the fix-c6-sta-disconnect branch February 11, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESP32-C6: STA disconnect error on startup before AP portal (STA not started)

1 participant