mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-25 07:43:04 +05:00
feat: merge master Ethernet support into dev
Adapt W5500 to the native network event queue and select STA or ETH from NetworkSettings. Preserve the existing dev network settings and add a separate C6 Ethernet build without BLE to fit the OTA slot. Validate with S3 and C6 Ethernet firmware builds, the shared LittleFS image, binary layout checks and targeted network transition checks.
This commit is contained in:
commit
4e71915222
21 files changed
+1007
-158
No files matched your search
+26
-8
@@ -7,6 +7,7 @@
|
||||
#include "types.h"
|
||||
#include "Sensors.h"
|
||||
|
||||
// Keep the existing WiFi settings at the start of the persisted structure.
|
||||
struct NetworkSettings {
|
||||
char hostname[25] = DEFAULT_HOSTNAME;
|
||||
bool useDhcp = true;
|
||||
@@ -19,16 +20,33 @@ struct NetworkSettings {
|
||||
} staticConfig;
|
||||
|
||||
struct {
|
||||
char ssid[33] = DEFAULT_AP_SSID;
|
||||
char password[65] = DEFAULT_AP_PASSWORD;
|
||||
uint8_t channel = 6;
|
||||
} ap;
|
||||
struct {
|
||||
char ssid[33] = DEFAULT_AP_SSID;
|
||||
char password[65] = DEFAULT_AP_PASSWORD;
|
||||
uint8_t channel = 6;
|
||||
} ap;
|
||||
|
||||
struct {
|
||||
char ssid[33] = DEFAULT_STA_SSID;
|
||||
char password[65] = DEFAULT_STA_PASSWORD;
|
||||
uint8_t channel = 0;
|
||||
} sta;
|
||||
} wifi;
|
||||
|
||||
struct {
|
||||
char ssid[33] = DEFAULT_STA_SSID;
|
||||
char password[65] = DEFAULT_STA_PASSWORD;
|
||||
uint8_t channel = 0;
|
||||
} sta;
|
||||
EthernetType type = EthernetType::W5500;
|
||||
|
||||
struct {
|
||||
uint8_t clk = DEFAULT_ETH_CLK_GPIO;
|
||||
uint8_t mosi = DEFAULT_ETH_MOSI_GPIO;
|
||||
uint8_t miso = DEFAULT_ETH_MISO_GPIO;
|
||||
uint8_t cs = DEFAULT_ETH_CS_GPIO;
|
||||
uint8_t irq = DEFAULT_ETH_IRQ_GPIO;
|
||||
uint8_t rst = DEFAULT_ETH_RST_GPIO;
|
||||
} w5500;
|
||||
} ethernet;
|
||||
|
||||
NetworkMode type = NetworkMode::STA;
|
||||
};
|
||||
|
||||
struct SystemSettings {
|
||||
|
||||
@@ -144,6 +144,13 @@ void onNetworkEvent(NetworkEventCallback callback);
|
||||
void onNetworkStateChange(NetworkStateCallback callback);
|
||||
NetworkState getNetworkState(NetworkMode mode = NetworkMode::STA);
|
||||
NetworkMode getNetworkMode();
|
||||
const char* getNetworkConnectionType();
|
||||
IPAddress getNetworkIp();
|
||||
IPAddress getNetworkSubnet();
|
||||
IPAddress getNetworkGateway();
|
||||
IPAddress getNetworkDns();
|
||||
String getNetworkMac();
|
||||
bool isEthernetConfigured(const NetworkSettings& config = networkSettings);
|
||||
bool isNetworkInterfaceStarted(NetworkMode mode);
|
||||
// Last state published by the system worker, including during event callbacks.
|
||||
bool isNetworkConnected();
|
||||
|
||||
@@ -63,6 +63,11 @@
|
||||
#define USE_BLE false
|
||||
#endif
|
||||
|
||||
// W5500 support is enabled by the dedicated C6 Ethernet build.
|
||||
#ifndef USE_ETHERNET
|
||||
#define USE_ETHERNET false
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_HOSTNAME
|
||||
#define DEFAULT_HOSTNAME ""
|
||||
#endif
|
||||
@@ -91,6 +96,30 @@
|
||||
#define DEFAULT_STATUS_LED_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_CLK_GPIO
|
||||
#define DEFAULT_ETH_CLK_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_MOSI_GPIO
|
||||
#define DEFAULT_ETH_MOSI_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_MISO_GPIO
|
||||
#define DEFAULT_ETH_MISO_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_CS_GPIO
|
||||
#define DEFAULT_ETH_CS_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_IRQ_GPIO
|
||||
#define DEFAULT_ETH_IRQ_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_ETH_RST_GPIO
|
||||
#define DEFAULT_ETH_RST_GPIO GPIO_IS_NOT_CONFIGURED
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_PORTAL_LOGIN
|
||||
#define DEFAULT_PORTAL_LOGIN ""
|
||||
#endif
|
||||
|
||||
@@ -51,13 +51,17 @@ inline const char S_CHANNEL[] = "channel";
|
||||
inline const char S_CH2_ALWAYS_ENABLED[] = "ch2_always_enabled";
|
||||
inline const char S_CH2_DISABLING_ACTION[] = "ch2_disabling_action";
|
||||
inline const char S_CHIP[] = "chip";
|
||||
inline const char S_CLK[] = "clk";
|
||||
inline const char S_CODE[] = "code";
|
||||
inline const char S_COMMIT[] = "commit";
|
||||
inline const char S_CONFIGURED[] = "configured";
|
||||
inline const char S_CONNECTED[] = "connected";
|
||||
inline const char S_CONNECTION_TYPE[] = "connection_type";
|
||||
inline const char S_COOLING[] = "cooling";
|
||||
inline const char S_COOLING_SUPPORT[] = "cooling_support";
|
||||
inline const char S_CORE[] = "core";
|
||||
inline const char S_CORES[] = "cores";
|
||||
inline const char S_CS[] = "cs";
|
||||
inline const char S_CURRENT_TEMP[] = "current_temp";
|
||||
inline const char S_DATE[] = "date";
|
||||
inline const char S_DEADBAND[] = "deadband";
|
||||
@@ -76,11 +80,13 @@ inline const char S_EMERGENCY[] = "emergency";
|
||||
inline const char S_ENABLED[] = "enabled";
|
||||
inline const char S_ENV[] = "env";
|
||||
inline const char S_EQUITHERM[] = "equitherm";
|
||||
inline const char S_ETHERNET[] = "ethernet";
|
||||
inline const char S_EXPONENT[] = "exponent";
|
||||
inline const char S_EXTERNAL_PUMP[] = "ext_pump";
|
||||
inline const char S_FACTOR[] = "factor";
|
||||
inline const char S_FALSE[] = "false";
|
||||
inline const char S_FAULT[] = "fault";
|
||||
inline const char S_FEATURES[] = "features";
|
||||
inline const char S_FREEZE_PROTECTION[] = "freeze_protection";
|
||||
inline const char S_FREEZING[] = "freezing";
|
||||
inline const char S_FILTERING[] = "filtering";
|
||||
@@ -115,6 +121,7 @@ inline const char S_INPUT[] = "input";
|
||||
inline const char S_INTERVAL[] = "interval";
|
||||
inline const char S_INVERT_STATE[] = "invert_state";
|
||||
inline const char S_IP[] = "ip";
|
||||
inline const char S_IRQ[] = "irq";
|
||||
inline const char S_I_FACTOR[] = "i_factor";
|
||||
inline const char S_I_MULTIPLIER[] = "i_multiplier";
|
||||
inline const char S_LOGIN[] = "login";
|
||||
@@ -135,8 +142,10 @@ inline const char S_MIN_FREE[] = "min_free";
|
||||
inline const char S_MIN_MAX_FREE_BLOCK[] = "min_max_free_block";
|
||||
inline const char S_MIN_POWER[] = "min_power";
|
||||
inline const char S_MIN_TEMP[] = "min_temp";
|
||||
inline const char S_MISO[] = "miso";
|
||||
inline const char S_MODEL[] = "model";
|
||||
inline const char S_MODULATION[] = "modulation";
|
||||
inline const char S_MOSI[] = "mosi";
|
||||
inline const char S_MQTT[] = "mqtt";
|
||||
inline const char S_NAME[] = "name";
|
||||
inline const char S_SLUG[] = "slug";
|
||||
@@ -174,6 +183,7 @@ inline const char S_RESTART[] = "restart";
|
||||
inline const char S_RETURN_TEMP[] = "return_temp";
|
||||
inline const char S_REV[] = "rev";
|
||||
inline const char S_RSSI[] = "rssi";
|
||||
inline const char S_RST[] = "rst";
|
||||
inline const char S_RX_LED_GPIO[] = "rx_led_gpio";
|
||||
inline const char S_SDK[] = "sdk";
|
||||
inline const char S_SENSORS[] = "sensors";
|
||||
@@ -218,3 +228,4 @@ inline const char S_USER[] = "user";
|
||||
inline const char S_VALUE[] = "value";
|
||||
inline const char S_VERSION[] = "version";
|
||||
inline const char S_WEBSERIAL[] = "web_serial";
|
||||
inline const char S_WIFI[] = "wifi";
|
||||
@@ -14,6 +14,11 @@ enum class ChannelDisablingAction : uint8_t {
|
||||
OFF_AND_ZERO_SETPOINT = 2
|
||||
};
|
||||
|
||||
enum class EthernetType : uint8_t {
|
||||
NONE = 0,
|
||||
W5500 = 1
|
||||
};
|
||||
|
||||
struct SettingResult {
|
||||
bool changed = false;
|
||||
bool accepted = false;
|
||||
@@ -77,6 +82,13 @@ enum class NetworkEvent : uint8_t {
|
||||
STA_GOT_IP,
|
||||
STA_LOST_IP,
|
||||
STA_GOT_IP6,
|
||||
ETH_STARTED,
|
||||
ETH_STOPPED,
|
||||
ETH_CONNECTED,
|
||||
ETH_DISCONNECTED,
|
||||
ETH_GOT_IP,
|
||||
ETH_LOST_IP,
|
||||
ETH_GOT_IP6,
|
||||
AP_STARTED,
|
||||
AP_STOPPED,
|
||||
AP_CLIENT_CONNECTED,
|
||||
|
||||
Reference in new issue
Block a user