Add WiFi reconnection retry logic to recover from unreliable WiFi
- Implement periodic WiFi reconnection attempts when stuck in AP mode - Add WIFI_RECONNECT_INTERVAL_MS config (default 60s) for configurable retry frequency - Prevent data loss by automatically attempting to switch back to STA mode - Maintain AP mode for manual configuration if reconnection fails - Track WiFi config and last reconnection attempt time in shared state - Add wifi_try_reconnect_sta() and wifi_restore_ap_mode() helper functions - Log reconnection attempts and results for debugging
This commit is contained in:
@@ -63,6 +63,7 @@ constexpr uint8_t METER_BATCH_MAX_SAMPLES = 30;
|
||||
constexpr uint8_t BATCH_QUEUE_DEPTH = 10;
|
||||
constexpr BatchRetryPolicy BATCH_RETRY_POLICY = BatchRetryPolicy::Keep;
|
||||
constexpr uint32_t WATCHDOG_TIMEOUT_SEC = 120;
|
||||
constexpr uint32_t WIFI_RECONNECT_INTERVAL_MS = 60000; // WiFi reconnection retry interval (1 minute)
|
||||
constexpr bool ENABLE_HA_DISCOVERY = true;
|
||||
#ifndef SERIAL_DEBUG_MODE_FLAG
|
||||
#define SERIAL_DEBUG_MODE_FLAG 0
|
||||
|
||||
@@ -25,3 +25,5 @@ bool wifi_connect_sta(const WifiMqttConfig &config, uint32_t timeout_ms = 10000)
|
||||
void wifi_start_ap(const char *ap_ssid, const char *ap_pass);
|
||||
bool wifi_is_connected();
|
||||
String wifi_get_ssid();
|
||||
bool wifi_try_reconnect_sta(const WifiMqttConfig &config, uint32_t timeout_ms = 5000);
|
||||
void wifi_restore_ap_mode(const char *ap_ssid, const char *ap_pass);
|
||||
|
||||
Reference in New Issue
Block a user