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:
2026-03-11 20:32:15 +01:00
parent 7fbaf77806
commit e89aee7048
6 changed files with 120 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
#include "config.h"
#include "data_model.h"
#include "wifi_manager.h"
struct ReceiverSharedState {
SenderStatus sender_statuses[NUM_SENDERS];
@@ -24,5 +25,11 @@ struct ReceiverSharedState {
uint32_t receiver_last_error_ms;
bool receiver_discovery_sent;
bool ap_mode;
// WiFi configuration and reconnection tracking
WifiMqttConfig wifi_config;
uint32_t last_wifi_reconnect_attempt_ms;
char ap_ssid[32]; // AP SSID for restoring AP mode if reconnection fails
char ap_password[32]; // AP password for restoring AP mode
};