mirror of
https://github.com/meshtastic/firmware.git
synced 2026-06-11 12:56:56 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb395ee9ef | |||
| 0bba962931 | |||
| 71afaeb957 | |||
| 3fcf6ba3dd | |||
| aeca0f4199 |
@@ -401,7 +401,9 @@ static void WiFiEvent(WiFiEvent_t event)
|
||||
WiFi.disconnect(false, true);
|
||||
syslog.disable();
|
||||
needReconnect = true;
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
if (wifiReconnect) {
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE:
|
||||
@@ -431,7 +433,9 @@ static void WiFiEvent(WiFiEvent_t event)
|
||||
WiFi.disconnect(false, true);
|
||||
syslog.disable();
|
||||
needReconnect = true;
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
if (wifiReconnect) {
|
||||
wifiReconnect->setIntervalFromNow(1000);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_WPS_ER_SUCCESS:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "PowerFSM.h"
|
||||
#include "PowerMon.h"
|
||||
#include "configuration.h"
|
||||
#include "esp_idf_version.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "main.h"
|
||||
|
||||
@@ -126,9 +127,12 @@ void esp32Setup()
|
||||
|
||||
nvs_stats_t nvs_stats;
|
||||
auto res = nvs_get_stats(NULL, &nvs_stats);
|
||||
assert(res == ESP_OK);
|
||||
LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d", nvs_stats.used_entries, nvs_stats.free_entries,
|
||||
nvs_stats.total_entries, nvs_stats.namespace_count);
|
||||
if (res != ESP_OK) {
|
||||
LOG_WARN("nvs_get_stats failed: 0x%x", res);
|
||||
} else {
|
||||
LOG_DEBUG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d, NameSpaces %d", nvs_stats.used_entries,
|
||||
nvs_stats.free_entries, nvs_stats.total_entries, nvs_stats.namespace_count);
|
||||
}
|
||||
|
||||
LOG_DEBUG("Setup Preferences in Flash Storage");
|
||||
|
||||
@@ -165,18 +169,34 @@ void esp32Setup()
|
||||
// #define APP_WATCHDOG_SECS 45
|
||||
#define APP_WATCHDOG_SECS 90
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32C6
|
||||
esp_task_wdt_config_t *wdt_config = (esp_task_wdt_config_t *)malloc(sizeof(esp_task_wdt_config_t));
|
||||
wdt_config->timeout_ms = APP_WATCHDOG_SECS * 1000;
|
||||
wdt_config->trigger_panic = true;
|
||||
res = esp_task_wdt_init(wdt_config);
|
||||
assert(res == ESP_OK);
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
// IDF v5.x API: use esp_task_wdt_config_t for both init and reconfigure
|
||||
{
|
||||
esp_task_wdt_config_t wdt_config = {
|
||||
.timeout_ms = APP_WATCHDOG_SECS * 1000,
|
||||
.idle_core_mask = 0,
|
||||
.trigger_panic = true,
|
||||
};
|
||||
// Try reconfigure first (TWDT may already be initialized by the Arduino framework)
|
||||
res = esp_task_wdt_reconfigure(&wdt_config);
|
||||
if (res == ESP_ERR_INVALID_STATE) {
|
||||
// TWDT not yet initialized, initialize it now
|
||||
res = esp_task_wdt_init(&wdt_config);
|
||||
}
|
||||
if (res != ESP_OK) {
|
||||
LOG_WARN("Failed to (re)configure watchdog timer: 0x%x", res);
|
||||
}
|
||||
}
|
||||
#else
|
||||
res = esp_task_wdt_init(APP_WATCHDOG_SECS, true);
|
||||
assert(res == ESP_OK);
|
||||
if (res != ESP_OK) {
|
||||
LOG_WARN("Failed to initialize watchdog timer: 0x%x", res);
|
||||
}
|
||||
#endif
|
||||
res = esp_task_wdt_add(NULL);
|
||||
assert(res == ESP_OK);
|
||||
if (res != ESP_OK && res != ESP_ERR_INVALID_ARG) {
|
||||
LOG_WARN("Failed to add main task to watchdog: 0x%x", res);
|
||||
}
|
||||
|
||||
#if HAS_32768HZ
|
||||
enableSlowCLK();
|
||||
|
||||
Reference in New Issue
Block a user