- 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
30 lines
780 B
C
30 lines
780 B
C
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <Preferences.h>
|
|
|
|
struct WifiMqttConfig {
|
|
String ssid;
|
|
String password;
|
|
String mqtt_host;
|
|
uint16_t mqtt_port;
|
|
String mqtt_user;
|
|
String mqtt_pass;
|
|
String ntp_server_1;
|
|
String ntp_server_2;
|
|
String web_user;
|
|
String web_pass;
|
|
bool valid;
|
|
};
|
|
|
|
void wifi_manager_init();
|
|
bool wifi_load_config(WifiMqttConfig &config);
|
|
bool wifi_save_config(const WifiMqttConfig &config);
|
|
|
|
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);
|