mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
parent
4e0d89e7db
commit
bf8da394d5
7 changed files with 26 additions and 15 deletions
16
Network.cpp
16
Network.cpp
|
|
@ -231,18 +231,12 @@ bool Network::connectWired() {
|
|||
if(!this->ethStarted) {
|
||||
this->ethStarted = true;
|
||||
WiFi.mode(WIFI_OFF);
|
||||
if(!settings.IP.dhcp) {
|
||||
if(!ETH.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
|
||||
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
}
|
||||
else
|
||||
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
WiFi.onEvent(this->networkEvent);
|
||||
if(settings.hostname[0] != '\0') ETH.setHostname(settings.hostname);
|
||||
Serial.print("Set hostname to:");
|
||||
Serial.println(ETH.getHostname());
|
||||
|
||||
if(!ETH.begin(settings.Ethernet.phyAddress, settings.Ethernet.PWRPin, settings.Ethernet.MDCPin, settings.Ethernet.MDIOPin, settings.Ethernet.phyType, settings.Ethernet.CLKMode)) {
|
||||
|
||||
Serial.println("Ethernet Begin failed");
|
||||
if(settings.connType == conn_types::ethernetpref) {
|
||||
this->wifiFallback = true;
|
||||
|
|
@ -251,6 +245,14 @@ bool Network::connectWired() {
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
if(!settings.IP.dhcp) {
|
||||
if(!ETH.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
|
||||
Serial.println("Unable to configure static IP address....");
|
||||
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
}
|
||||
else
|
||||
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
|
||||
uint32_t wait = millis();
|
||||
while(millis() - wait < 7000) {
|
||||
if(this->connected()) return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue