feat: add support for W5500 SPI Ethernet in gateway
- Introduced configuration options for wired Ethernet support in Kconfig and sdkconfig. - Implemented Ethernet initialization and event handling in GatewayNetworkService. - Enhanced app_main to manage Ethernet alongside Wi-Fi. - Updated GatewayRuntime to store Ethernet information. - Modified CMakeLists and include files to accommodate new Ethernet dependencies. - Ensured backward compatibility by allowing Ethernet initialization failures to be ignored. Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -30,6 +30,11 @@ struct WirelessInfo {
|
||||
std::string ip;
|
||||
};
|
||||
|
||||
struct EthernetInfo {
|
||||
std::string mac;
|
||||
std::string ip;
|
||||
};
|
||||
|
||||
struct GatewayRuntimeConfig {
|
||||
std::string_view project_name;
|
||||
std::string_view version;
|
||||
@@ -47,6 +52,7 @@ struct GatewayDeviceInfo {
|
||||
size_t dali_gateway_count{0};
|
||||
bool ble_enabled{false};
|
||||
std::optional<WirelessInfo> wlan;
|
||||
std::optional<EthernetInfo> eth;
|
||||
};
|
||||
|
||||
class GatewaySettingsStore {
|
||||
@@ -119,6 +125,9 @@ class GatewayRuntime {
|
||||
void setGatewayCount(size_t gateway_count);
|
||||
void setWirelessInfo(WirelessInfo info);
|
||||
bool clearWirelessInfo();
|
||||
void setEthernetInfo(EthernetInfo info);
|
||||
void clearEthernetInfo();
|
||||
void clearEthernetIp();
|
||||
void setCommandAddressResolver(std::function<uint8_t(uint8_t gw, uint8_t raw_addr)> resolver);
|
||||
|
||||
GatewayDeviceInfo deviceInfo() const;
|
||||
@@ -159,6 +168,7 @@ class GatewayRuntime {
|
||||
CommandDropReason last_enqueue_drop_reason_{CommandDropReason::kNone};
|
||||
std::function<uint8_t(uint8_t gw, uint8_t raw_addr)> command_address_resolver_;
|
||||
std::optional<WirelessInfo> wireless_info_;
|
||||
std::optional<EthernetInfo> ethernet_info_;
|
||||
SemaphoreHandle_t command_lock_{nullptr};
|
||||
};
|
||||
|
||||
|
||||
@@ -450,6 +450,23 @@ bool GatewayRuntime::clearWirelessInfo() {
|
||||
return settings_.clearWifiCredentials();
|
||||
}
|
||||
|
||||
void GatewayRuntime::setEthernetInfo(EthernetInfo info) {
|
||||
LockGuard guard(command_lock_);
|
||||
ethernet_info_ = std::move(info);
|
||||
}
|
||||
|
||||
void GatewayRuntime::clearEthernetInfo() {
|
||||
LockGuard guard(command_lock_);
|
||||
ethernet_info_.reset();
|
||||
}
|
||||
|
||||
void GatewayRuntime::clearEthernetIp() {
|
||||
LockGuard guard(command_lock_);
|
||||
if (ethernet_info_.has_value()) {
|
||||
ethernet_info_->ip.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GatewayRuntime::setCommandAddressResolver(
|
||||
std::function<uint8_t(uint8_t gw, uint8_t raw_addr)> resolver) {
|
||||
LockGuard guard(command_lock_);
|
||||
@@ -470,6 +487,7 @@ GatewayDeviceInfo GatewayRuntime::deviceInfo() const {
|
||||
info.dali_gateway_count = gateway_count_;
|
||||
info.ble_enabled = ble_enabled_;
|
||||
info.wlan = wireless_info_;
|
||||
info.eth = ethernet_info_;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user