Skip to content

add wifi_shutdown_ap timer for 2 minute timeout #46

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

Merged
merged 5 commits into from
Jun 17, 2025
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
10 changes: 9 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,15 @@ void app_main(void) {
}
}

ESP_LOGI(TAG, "WiFi Connected, continuing main task thread . . . ");
// Create a timer to auto-shutdown the AP after 5 minutes
TimerHandle_t ap_shutdown_timer =
xTimerCreate("ap_shutdown_timer",
pdMS_TO_TICKS(5 * 60 * 1000), // 5 minutes in milliseconds
pdFALSE, // One-shot timer
NULL, (TimerCallbackFunction_t)wifi_shutdown_ap);

xTimerStart(ap_shutdown_timer, 0);
ESP_LOGI(TAG, "AP will automatically shut down in 5 minutes");

// Get the image URL from WiFi manager
const char* image_url = wifi_get_image_url();
Expand Down
7 changes: 7 additions & 0 deletions src/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ static bool has_saved_config = false;
return 0;
}

// Shudwont the AP by switching wifi mode to STA
void wifi_shutdown_ap() {
ESP_LOGI(TAG, "Shuting down config portal");
stop_webserver();
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
}

// Shutdown WiFi
void wifi_shutdown() {
// Stop the web server if it's running
Expand Down
6 changes: 6 additions & 0 deletions src/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
*/
int wifi_initialize(const char *ssid, const char *password);


/**
* @brief Shutdown WiFi Config Portal
*/
void wifi_shutdown_ap();

/**
* @brief Shutdown WiFi
*/
Expand Down