Fix WDT, Web refresh bug

This commit is contained in:
2025-07-09 10:48:51 -06:00
parent 4f3535947f
commit a4fa347557

View File

@ -116,7 +116,7 @@ static const char* html_page =
" <p><strong>Speed:</strong> <span id=\"speed\">0</span>%</p>"
" <p><strong>Target:</strong> <span id=\"target\">0</span>%</p>"
" <div id=\"rampStatus\" class=\"ramping\" style=\"display: none;\">"
" <strong>Ramping in progress...</strong>"
" <strong>Ramping in progress...</strong>"
" </div>"
" </div>"
" "
@ -209,15 +209,28 @@ static void apply_motor_pwm(int speed_percent);
void init_watchdog(void) {
ESP_LOGI(TAG, "Setting up watchdog monitoring...");
// The system watchdog is already monitoring the main task
// We don't need to add anything, just need to reset it properly
ESP_LOGI(TAG, "Using system watchdog - will reset from main context");
// Get current task handle and add to watchdog
main_task_handle = xTaskGetCurrentTaskHandle();
esp_err_t result = esp_task_wdt_add(main_task_handle);
if (result == ESP_OK) {
ESP_LOGI(TAG, "Main task added to watchdog monitoring");
} else if (result == ESP_ERR_INVALID_ARG) {
ESP_LOGI(TAG, "Task already monitored by watchdog");
} else {
ESP_LOGW(TAG, "Watchdog not available: %s", esp_err_to_name(result));
main_task_handle = NULL; // Disable watchdog feeding
}
}
// Feed the watchdog
void feed_watchdog(void) {
// Simply reset the watchdog for the current task context
esp_task_wdt_reset();
if (main_task_handle != NULL) {
esp_err_t result = esp_task_wdt_reset();
if (result != ESP_OK) {
ESP_LOGD(TAG, "Watchdog reset failed: %s", esp_err_to_name(result));
}
}
}
// WiFi event handler