gate ethernet behind soc support

This commit is contained in:
2026-06-19 13:26:33 +02:00
parent 00d2a49ca9
commit 1108ff0a97
2 changed files with 12 additions and 2 deletions

View File

@@ -1,14 +1,18 @@
#include "network.h"
#include <esp_eth.h>
#include <esp_log.h>
#include <esp_netif.h>
#include <esp_sntp.h>
#include <esp_wifi.h>
#include <esp_wifi_types_generic.h>
#include <ethernet_init.h>
#include <nvs_flash.h>
#if SOC_EMAC_SUPPORTED
#include <esp_eth.h>
#include <ethernet_init.h>
#include <driver/gpio.h>
#endif
ESP_EVENT_DEFINE_BASE(SNTP_EVENT);
@@ -118,6 +122,7 @@ static void on_scan_done(void *arg, esp_event_base_t event_base, int32_t event_i
try_next_hidden_network();
}
#if SOC_EMAC_SUPPORTED
void init_ethernet(const char *hostname) {
ESP_ERROR_CHECK(esp_netif_init());
@@ -139,6 +144,7 @@ void init_ethernet(const char *hostname) {
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_get_ip, nullptr));
ESP_ERROR_CHECK(esp_eth_start(eth_handles[0]));
}
#endif
void init_wifi(const struct wifi_networks_t *nets, const char *hostname) {
nvs_flash_init();

View File

@@ -2,6 +2,7 @@
#define NETWORK_H
#include <esp_event.h>
#include <soc/soc_caps.h>
#define POSIX_TIMEZONE_STRING "CET-1CEST,M3.5.0,M10.5.0/3"
#define SNTP_TIME_SYNC_INTERVAL_MINUTES (6 * 60) // 6 hours
@@ -26,6 +27,9 @@ struct wifi_networks_t {
};
void init_wifi(const struct wifi_networks_t *nets, const char *hostname);
#if SOC_EMAC_SUPPORTED
void init_ethernet(const char *hostname);
#endif
#endif