Implemented Ethernet
This commit is contained in:
@@ -12,6 +12,10 @@ set(sources
|
||||
)
|
||||
|
||||
set(dependencies
|
||||
arduino-esp32
|
||||
lwip
|
||||
esp_netif
|
||||
|
||||
cpputils
|
||||
espchrono
|
||||
espcpputils
|
||||
@@ -19,6 +23,8 @@ set(dependencies
|
||||
fmt
|
||||
)
|
||||
|
||||
message(STATUS "${dependencies}")
|
||||
|
||||
idf_component_register(
|
||||
INCLUDE_DIRS
|
||||
src
|
||||
|
3736
src/espwifistack.cpp
3736
src/espwifistack.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// system includes
|
||||
#include <string>
|
||||
#include <array>
|
||||
@@ -74,12 +76,14 @@ struct wifi_entry
|
||||
|
||||
struct sta_config
|
||||
{
|
||||
bool enabled;
|
||||
std::array<wifi_entry, 10> wifis;
|
||||
int8_t min_rssi;
|
||||
|
||||
friend bool operator==(const sta_config &left, const sta_config &right)
|
||||
{
|
||||
return left.wifis == right.wifis &&
|
||||
return left.enabled == right.enabled &&
|
||||
left.wifis == right.wifis &&
|
||||
left.min_rssi == right.min_rssi;
|
||||
}
|
||||
|
||||
@@ -118,19 +122,45 @@ struct ap_config
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ETH_ENABLED
|
||||
struct eth_config
|
||||
{
|
||||
bool enabled;
|
||||
std::optional<static_ip_config> static_ip;
|
||||
static_dns_config static_dns;
|
||||
|
||||
friend bool operator==(const eth_config &left, const eth_config &right)
|
||||
{
|
||||
return left.enabled == right.enabled &&
|
||||
left.static_ip == right.static_ip &&
|
||||
left.static_dns == right.static_dns;
|
||||
}
|
||||
|
||||
friend bool operator!=(const eth_config &left, const eth_config &right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct config
|
||||
{
|
||||
bool wifiEnabled;
|
||||
std::string hostname;
|
||||
sta_config sta;
|
||||
ap_config ap;
|
||||
#ifdef CONFIG_ETH_ENABLED
|
||||
eth_config eth;
|
||||
#endif
|
||||
|
||||
friend bool operator==(const config &left, const config &right)
|
||||
{
|
||||
return left.wifiEnabled == right.wifiEnabled &&
|
||||
left.hostname == right.hostname &&
|
||||
return left.hostname == right.hostname &&
|
||||
left.sta == right.sta &&
|
||||
left.ap == right.ap;
|
||||
left.ap == right.ap
|
||||
#ifdef CONFIG_ETH_ENABLED
|
||||
&& left.eth == right.eth
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
friend bool operator!=(const config &left, const config &right)
|
||||
|
@@ -14,7 +14,7 @@ namespace {
|
||||
constexpr const char * const TAG = "WIFI_STACK";
|
||||
} // namespace
|
||||
|
||||
bool goe_wifi_ap_config_equal(const wifi_ap_config_t& lhs, const wifi_ap_config_t& rhs)
|
||||
bool wifi_ap_config_equal(const wifi_ap_config_t& lhs, const wifi_ap_config_t& rhs)
|
||||
{
|
||||
auto leftSsid = lhs.ssid_len ?
|
||||
std::string_view{reinterpret_cast<const char*>(lhs.ssid), lhs.ssid_len} :
|
||||
@@ -33,7 +33,7 @@ bool goe_wifi_ap_config_equal(const wifi_ap_config_t& lhs, const wifi_ap_config_
|
||||
lhs.pairwise_cipher == rhs.pairwise_cipher;
|
||||
}
|
||||
|
||||
bool goe_wifi_sta_config_equal(const wifi_sta_config_t& lhs, const wifi_sta_config_t& rhs)
|
||||
bool wifi_sta_config_equal(const wifi_sta_config_t& lhs, const wifi_sta_config_t& rhs)
|
||||
{
|
||||
return std::string_view{reinterpret_cast<const char*>(lhs.ssid)} == std::string_view{reinterpret_cast<const char*>(rhs.ssid)} &&
|
||||
std::string_view{reinterpret_cast<const char*>(lhs.password)} == std::string_view{reinterpret_cast<const char*>(rhs.password)} &&
|
||||
@@ -165,7 +165,7 @@ std::string toString(const ip_address_t &address)
|
||||
return fmt::format("{}.{}.{}.{}", address[0], address[1], address[2], address[3]);
|
||||
}
|
||||
|
||||
ip_address_t goe_wifi_calculate_network_id(ip_address_t ip, ip_address_t subnet)
|
||||
ip_address_t wifi_calculate_network_id(ip_address_t ip, ip_address_t subnet)
|
||||
{
|
||||
ip_address_t networkID;
|
||||
|
||||
@@ -175,7 +175,7 @@ ip_address_t goe_wifi_calculate_network_id(ip_address_t ip, ip_address_t subnet)
|
||||
return networkID;
|
||||
}
|
||||
|
||||
ip_address_t goe_wifi_calculate_broadcast(ip_address_t ip, ip_address_t subnet)
|
||||
ip_address_t wifi_calculate_broadcast(ip_address_t ip, ip_address_t subnet)
|
||||
{
|
||||
ip_address_t broadcastIp;
|
||||
|
||||
@@ -185,7 +185,7 @@ ip_address_t goe_wifi_calculate_broadcast(ip_address_t ip, ip_address_t subnet)
|
||||
return broadcastIp;
|
||||
}
|
||||
|
||||
uint8_t goe_wifi_calculate_subnet_cidr(ip_address_t subnetMask)
|
||||
uint8_t wifi_calculate_subnet_cidr(ip_address_t subnetMask)
|
||||
{
|
||||
uint8_t CIDR = 0;
|
||||
|
||||
|
@@ -16,8 +16,8 @@
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
namespace wifi_stack {
|
||||
bool goe_wifi_ap_config_equal(const wifi_ap_config_t& lhs, const wifi_ap_config_t& rhs);
|
||||
bool goe_wifi_sta_config_equal(const wifi_sta_config_t& lhs, const wifi_sta_config_t& rhs);
|
||||
bool wifi_ap_config_equal(const wifi_ap_config_t& lhs, const wifi_ap_config_t& rhs);
|
||||
bool wifi_sta_config_equal(const wifi_sta_config_t& lhs, const wifi_sta_config_t& rhs);
|
||||
|
||||
std::string toString(wifi_auth_mode_t authMode);
|
||||
std::string toString(wifi_cipher_type_t cipherType);
|
||||
@@ -94,9 +94,9 @@ public:
|
||||
|
||||
std::string toString(const ip_address_t &val);
|
||||
|
||||
ip_address_t goe_wifi_calculate_network_id(ip_address_t ip, ip_address_t subnet);
|
||||
ip_address_t goe_wifi_calculate_broadcast(ip_address_t ip, ip_address_t subnet);
|
||||
uint8_t goe_wifi_calculate_subnet_cidr(ip_address_t subnetMask);
|
||||
ip_address_t wifi_calculate_network_id(ip_address_t ip, ip_address_t subnet);
|
||||
ip_address_t wifi_calculate_broadcast(ip_address_t ip, ip_address_t subnet);
|
||||
uint8_t wifi_calculate_subnet_cidr(ip_address_t subnetMask);
|
||||
|
||||
std::string toString(ip4_addr_t val);
|
||||
std::string toString(const ip6_addr_t &val);
|
||||
|
Reference in New Issue
Block a user