@@ -18,11 +18,11 @@ EthernetSettingsService::EthernetSettingsService(PsychicHttpServer *server,
1818 FS *fs,
1919 SecurityManager *securityManager,
2020 EventSocket *socket) : _server(server),
21- _securityManager(securityManager),
22- _httpEndpoint(EthernetSettings::read, EthernetSettings::update, this , server, ETHERNET_SETTINGS_SERVICE_PATH, securityManager,
23- AuthenticationPredicates::IS_ADMIN),
24- _fsPersistence(EthernetSettings::read, EthernetSettings::update, this , fs, ETHERNET_SETTINGS_FILE),
25- _socket(socket)
21+ _securityManager(securityManager),
22+ _httpEndpoint(EthernetSettings::read, EthernetSettings::update, this , server, ETHERNET_SETTINGS_SERVICE_PATH, securityManager,
23+ AuthenticationPredicates::IS_ADMIN),
24+ _fsPersistence(EthernetSettings::read, EthernetSettings::update, this , fs, ETHERNET_SETTINGS_FILE),
25+ _socket(socket)
2626{
2727 addUpdateHandler ([&](const String &originId)
2828 { reconfigureEthernet (); },
@@ -82,11 +82,21 @@ void EthernetSettingsService::configureNetwork(ethernet_settings_t &network)
8282 // configure for DHCP
8383 ETH.config (INADDR_NONE, INADDR_NONE, INADDR_NONE);
8484 }
85- // (re)start ethernet
85+ // (re)start ethernet
86+ #if CONFIG_IDF_TARGET_ESP32
87+ // ESP32 chips with built-in ethernet MAC/PHY
8688 ETH.begin ();
89+ #elif CONFIG_IDF_TARGET_ESP32P4
90+ // todo: setup in P4
91+ #else
92+ #ifdef ETH_PHY_TYPE // only if defined
93+ // For SPI based ethernet modules like W5500, ENC28J60 etc.
94+ SPI.begin (ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
95+ ETH.begin (ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_CS, ETH_PHY_IRQ, ETH_PHY_RST, SPI);
96+ #endif
97+ #endif
8798 // set hostname (again) after (re)starting ethernet due to a bug in the ESP-IDF implementation
8899 ETH.setHostname (_state.hostname .c_str ());
89-
90100}
91101
92102void EthernetSettingsService::reconfigureEthernet ()
0 commit comments