Fixed OTA Ethernet bug
All checks were successful
Test compiling project / test (push) Successful in 2m28s

This commit is contained in:
2025-02-23 02:38:59 +01:00
parent 2c4344e40d
commit 146a4412e0
6 changed files with 73 additions and 17 deletions

38
documentation/old.md Normal file
View File

@@ -0,0 +1,38 @@
extern "C" {
#include "lwip/netif.h"
}
void listNetworkInterfaces() {
esp_netif_t *netif = NULL;
Serial.println("\n=== Listing Network Interfaces ===");
for (netif = esp_netif_next(NULL); netif != NULL; netif = esp_netif_next(netif)) {
const char* if_key = esp_netif_get_ifkey(netif);
const char* if_desc = esp_netif_get_desc(netif);
Serial.printf("Interface Key: %s\n", if_key);
Serial.printf("Description : %s\n", if_desc);
Serial.println("-----------------------------");
}
}
void setEthernetAsDefault() {
Log.verbose("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
listNetworkInterfaces();
// Attempt to locate the Ethernet network interface.
// (The name may vary—on some systems it might be "eth0")
esp_netif_t* netif = esp_netif_get_handle_from_ifkey("ETH_DEF");
if (netif) {
Serial.println("Netif handle obtained successfully.");
} else {
Serial.println("Failed to obtain netif handle.");
}
struct netif *eth_netif2 = netif_find("ETH_DEF");
if (netif) {
netif_set_default(eth_netif2);
Log.verbose("Ethernet set as default network interface.");
} else {
Log.verbose("Could not find Ethernet netif.");
}
}