try to auto choose STA vs ETH and also choose IPv4 or IPv6 depending on config

change printf to ESP_LOGI in net_functions
add missing components to network interface

Signed-off-by: Karl Osterseher <karli_o@gmx.at>
This commit is contained in:
Karl Osterseher
2025-01-26 23:35:11 +01:00
Unverified
parent 1d7dc2dc00
commit 6bec0e9469
9 changed files with 245 additions and 35 deletions

View File

@@ -34,6 +34,16 @@
static const char *TAG = "NET_IF";
/* types of ipv6 addresses to be displayed on ipv6 events */
const char *ipv6_addr_types_to_str[6] = {
"ESP_IP6_ADDR_IS_UNKNOWN", "ESP_IP6_ADDR_IS_GLOBAL",
"ESP_IP6_ADDR_IS_LINK_LOCAL", "ESP_IP6_ADDR_IS_SITE_LOCAL",
"ESP_IP6_ADDR_IS_UNIQUE_LOCAL", "ESP_IP6_ADDR_IS_IPV4_MAPPED_IPV6"};
static bool netif_desc_matches_with(esp_netif_t *netif, void *ctx) {
return strcmp(ctx, esp_netif_get_desc(netif)) == 0;
}
/**
* @brief Checks the netif description if it contains specified prefix.
* All netifs created withing common connect component are prefixed with the
@@ -43,6 +53,16 @@ bool network_is_our_netif(const char *prefix, esp_netif_t *netif) {
return strncmp(prefix, esp_netif_get_desc(netif), strlen(prefix) - 1) == 0;
}
/**
*/
esp_netif_t *network_get_netif_from_desc(const char *desc) {
return esp_netif_find_if(netif_desc_matches_with, (void *)desc);
}
bool network_is_netif_up(esp_netif_t *esp_netif) {
return esp_netif_is_netif_up(esp_netif);
}
void network_init(void) {
esp_netif_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());