mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-12 01:14:45 +05:00
* feat: implement feature gate & w5500 SPI ethernet * feat: eth conn restart handling, wifi-ap connection type, BLE sensor gate * fix: bring eth down when disabled * fix: disable WiFi scan when ethernet is active * feat: refactor uplink types into separate classes * fix: compare enum, not string * chore: remove dead code * fix: remove out of scope persistNow(), move w5500 to networksettings, add base for future ethernet implementations * fix: keep wifi armed while reconnecting, reset IP when moving from static to DHCP, refactor wifi loop to use return * fix: clear out connectionType string for enum
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#pragma once
|
|
#if defined(ARDUINO_ARCH_ESP8266)
|
|
#include <ESP8266WiFi.h>
|
|
#include "lwip/etharp.h"
|
|
#elif defined(ARDUINO_ARCH_ESP32)
|
|
#include <WiFi.h>
|
|
#endif
|
|
|
|
namespace NetworkUtils {
|
|
struct NetworkConnection {
|
|
enum class Status {
|
|
CONNECTED,
|
|
CONNECTING,
|
|
DISCONNECTED,
|
|
NONE
|
|
};
|
|
|
|
enum class DisconnectReason {
|
|
BEACON_TIMEOUT,
|
|
NO_AP_FOUND,
|
|
AUTH_FAIL,
|
|
ASSOC_FAIL,
|
|
HANDSHAKE_TIMEOUT,
|
|
DHCP_TIMEOUT,
|
|
OTHER,
|
|
NONE
|
|
};
|
|
|
|
static Status status;
|
|
static DisconnectReason disconnectReason;
|
|
static uint8_t rawDisconnectReason;
|
|
|
|
static void setup(bool useDhcp);
|
|
static void setUseDhcp(bool value);
|
|
static void reset();
|
|
static Status getStatus();
|
|
static DisconnectReason getDisconnectReason();
|
|
#if defined(ARDUINO_ARCH_ESP8266)
|
|
static void onEvent(System_Event_t *evt);
|
|
#elif defined(ARDUINO_ARCH_ESP32)
|
|
static void onEvent(WiFiEvent_t event, WiFiEventInfo_t info);
|
|
#endif
|
|
|
|
protected:
|
|
static DisconnectReason convertDisconnectReason(uint8_t reason);
|
|
static bool useDhcp;
|
|
};
|
|
} |