Refactoring: Module entkoppelt und Aufrufe über main zentralisiert
wifi_mgr vollständig von http_portal und dns_captive entkoppelt - Neues Callback-Interface in http_portal implementiert - Callback-Initialisierung in main.c hinzugefügt (WiFi-Creds, Device-Info) - dns_captive in eigenes Modul ausgelagert (dns_captive.h ergänzt) - Alte Vorwärtsdeklarationen entfernt und öffentliche API in wifi_mgr.h ergänzt - Startreihenfolge der Module neu strukturiert (Orchestrierung in main.c) - Projektabhängigkeiten vereinfacht und Zyklus zwischen Modulen aufgelöst
This commit is contained in:
+15
-11
@@ -23,9 +23,7 @@
|
||||
#include "net_mdns.h"
|
||||
#include "sys_status.h"
|
||||
|
||||
// Captive-DNS ist in http_portal.c implementiert:
|
||||
void dns_captive_start(void);
|
||||
void dns_captive_stop(void);
|
||||
#include "dns_captive.h"
|
||||
|
||||
// ---------- Konfig ----------
|
||||
#define SOFTAP_SSID "nanoPSX"
|
||||
@@ -304,8 +302,6 @@ static void wifi_start_ap_sta(void) {
|
||||
|
||||
// ---------- Öffentliche API ----------
|
||||
void wifi_mgr_init(void) {
|
||||
// NVS (neu über storage)
|
||||
ESP_ERROR_CHECK(storage_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
@@ -326,16 +322,24 @@ void wifi_mgr_init(void) {
|
||||
}
|
||||
|
||||
void wifi_mgr_start(void) {
|
||||
// AP+STA hochfahren
|
||||
wifi_start_ap_sta();
|
||||
ESP_LOGI(TAG, "WiFi AP+STA gestartet.");
|
||||
}
|
||||
|
||||
// HTTP-Portal starten (erzwingt Captive bis Save, s. http_portal.c)
|
||||
ESP_ERROR_CHECK(portal_http_start(wifi_events, EVT_STA_GOTIP, EVT_STA_FAIL, SOFTAP_SSID));
|
||||
EventGroupHandle_t wifi_mgr_get_event_group(void) {
|
||||
return wifi_events;
|
||||
}
|
||||
|
||||
// DNS/Captive starten
|
||||
(void)dns_captive_start();
|
||||
EventBits_t wifi_mgr_evt_sta_got_ip(void) {
|
||||
return EVT_STA_GOTIP;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Bereit. Verbinde dich mit '%s' und öffne beliebige Seite – das Portal erscheint.", SOFTAP_SSID);
|
||||
EventBits_t wifi_mgr_evt_sta_fail(void) {
|
||||
return EVT_STA_FAIL;
|
||||
}
|
||||
|
||||
esp_netif_t *wifi_mgr_get_ap_netif(void) {
|
||||
return netif_ap;
|
||||
}
|
||||
|
||||
// ---------- Hilfsfunktionen ----------
|
||||
|
||||
Reference in New Issue
Block a user