Skip to content

do not reboot during health check #49

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 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ void app_main(void) {
static uint8_t brightness_pct = DISPLAY_DEFAULT_BRIGHTNESS;

ESP_LOGI(TAG, "Fetching from URL: %s", url_to_use);
if (remote_get(url_to_use, &webp, &len, &brightness_pct,
&app_dwell_secs)) {
ESP_LOGE(TAG, "Failed to get webp");
if (!wifi_is_connected() || remote_get(url_to_use, &webp, &len,
&brightness_pct, &app_dwell_secs)) {
ESP_LOGE(TAG, "No WiFi or Failed to get webp");
vTaskDelay(pdMS_TO_TICKS(1 * 5000));
} else {
// Successful remote_get
Expand Down
16 changes: 8 additions & 8 deletions src/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,11 @@ void wifi_health_check(void) {

// WiFi is not connected, increment counter
s_wifi_disconnect_counter++;
ESP_LOGW(TAG, "WiFi Health check. Disconnect count: %d/15", s_wifi_disconnect_counter);
ESP_LOGW(TAG, "WiFi Health check. Disconnect count: %d/*", s_wifi_disconnect_counter);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The log message format Disconnect count: %d/* is a bit unconventional and might be unclear to others reading the logs. The /* seems to indicate that the previous threshold (e.g., /15) for rebooting is no longer applicable. It would be more explicit to either remove this part or clarify the meaning for better log readability.

    ESP_LOGW(TAG, "WiFi Health check. Disconnect count: %d (reboot on disconnect disabled)", s_wifi_disconnect_counter);


// Try to reconnect
if (strlen(s_wifi_ssid) > 0) {
ESP_LOGI(TAG, "Attempting to reconnect to WiFi...");
ESP_LOGI(TAG, "Reconnecting in Health check...");
esp_err_t err = esp_wifi_connect();
if (err != ESP_OK) {
ESP_LOGW(TAG, "WiFi reconnect attempt failed: %s", esp_err_to_name(err));
Expand All @@ -797,10 +797,10 @@ void wifi_health_check(void) {
}

// If counter reaches threshold, reboot the system
if (s_wifi_disconnect_counter >= 15) {
ESP_LOGE(TAG, "WiFi disconnected for 15 consecutive checks. Rebooting system...");
// Wait a moment before rebooting
vTaskDelay(pdMS_TO_TICKS(1000));
esp_restart();
}
// if (s_wifi_disconnect_counter >= 15) {
// ESP_LOGE(TAG, "WiFi disconnected for 15 consecutive checks. Rebooting system...");
// // Wait a moment before rebooting
// vTaskDelay(pdMS_TO_TICKS(1000));
// esp_restart();
// }
Comment on lines +800 to +805

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code, which handles system reboot after repeated WiFi disconnections, has been commented out. If the decision to remove this reboot functionality is permanent (as implied by the PR title "do not reboot during health check"), it's recommended to delete this commented-out code. Leaving dead code can reduce readability and long-term maintainability.

If there's a possibility this feature might be re-enabled in the future, consider using a compile-time configuration (e.g., a Kconfig option) or a runtime flag instead of commented-out code for better control and clarity.

}