refactor network code

This commit is contained in:
proddy
2026-05-01 08:07:05 +02:00
parent 0e08334132
commit 751c540cb3
38 changed files with 999 additions and 852 deletions

View File

@@ -5,9 +5,6 @@
#include "FSPersistence.h"
#include "JsonUtils.h"
#include <DNSServer.h>
#include <IPAddress.h>
#ifndef FACTORY_AP_PROVISION_MODE
#define FACTORY_AP_PROVISION_MODE AP_MODE_DISCONNECTED
#endif
@@ -47,14 +44,10 @@
#define AP_SETTINGS_FILE "/config/apSettings.json"
#define AP_SETTINGS_SERVICE_PATH "/rest/apSettings"
#define AP_MODE_ALWAYS 0
#define AP_MODE_DISCONNECTED 1
#define AP_MODE_NEVER 2
#define MANAGE_NETWORK_DELAY 10000
#define DNS_PORT 53
enum APNetworkStatus { ACTIVE = 0, INACTIVE, LINGERING };
enum APNetworkStatus { ACTIVE = 0, INACTIVE };
class APSettings {
public:
@@ -84,26 +77,11 @@ class APSettingsService : public StatefulService<APSettings> {
APSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager);
void begin();
void loop();
APNetworkStatus getAPNetworkStatus();
private:
HttpEndpoint<APSettings> _httpEndpoint;
FSPersistence<APSettings> _fsPersistence;
// for the captive portal
DNSServer * _dnsServer;
// for the management delay loop
volatile unsigned long _lastManaged;
volatile bool _reconfigureAp;
volatile uint8_t _connected;
void reconfigureAP();
void manageAP();
void startAP();
void stopAP();
void handleDNS();
};
#endif