- 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
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "config.h"
|
|
#include "data_model.h"
|
|
#include "wifi_manager.h"
|
|
|
|
struct ReceiverSharedState {
|
|
SenderStatus sender_statuses[NUM_SENDERS];
|
|
FaultCounters sender_faults_remote[NUM_SENDERS];
|
|
FaultCounters sender_faults_remote_published[NUM_SENDERS];
|
|
FaultType sender_last_error_remote[NUM_SENDERS];
|
|
FaultType sender_last_error_remote_published[NUM_SENDERS];
|
|
uint32_t sender_last_error_remote_utc[NUM_SENDERS];
|
|
uint32_t sender_last_error_remote_ms[NUM_SENDERS];
|
|
bool sender_discovery_sent[NUM_SENDERS];
|
|
uint16_t last_batch_id_rx[NUM_SENDERS];
|
|
|
|
FaultCounters receiver_faults;
|
|
FaultCounters receiver_faults_published;
|
|
FaultType receiver_last_error;
|
|
FaultType receiver_last_error_published;
|
|
uint32_t receiver_last_error_utc;
|
|
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
|
|
};
|
|
|