add astylerc and apply code formatting
This commit is contained in:
@@ -7,44 +7,44 @@ RTC_NOINIT_ATTR bool criticalEthFailure;
|
||||
extern char WiFi_fallbackDetect[14];
|
||||
|
||||
EthernetDevice::EthernetDevice(const String& hostname, Preferences* preferences, const IPConfiguration* ipConfiguration, const std::string& deviceName, uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t ethtype, eth_clock_mode_t clock_mode)
|
||||
: NetworkDevice(hostname, ipConfiguration),
|
||||
_deviceName(deviceName),
|
||||
_phy_addr(phy_addr),
|
||||
_power(power),
|
||||
_mdc(mdc),
|
||||
_mdio(mdio),
|
||||
_type(ethtype),
|
||||
_clock_mode(clock_mode),
|
||||
_useSpi(false),
|
||||
_preferences(preferences)
|
||||
: NetworkDevice(hostname, ipConfiguration),
|
||||
_deviceName(deviceName),
|
||||
_phy_addr(phy_addr),
|
||||
_power(power),
|
||||
_mdc(mdc),
|
||||
_mdio(mdio),
|
||||
_type(ethtype),
|
||||
_clock_mode(clock_mode),
|
||||
_useSpi(false),
|
||||
_preferences(preferences)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
EthernetDevice::EthernetDevice(const String &hostname,
|
||||
Preferences *preferences,
|
||||
const IPConfiguration *ipConfiguration,
|
||||
const std::string &deviceName,
|
||||
uint8_t phy_addr,
|
||||
int cs,
|
||||
int irq,
|
||||
int rst,
|
||||
int spi_sck,
|
||||
int spi_miso,
|
||||
int spi_mosi,
|
||||
eth_phy_type_t ethtype)
|
||||
: NetworkDevice(hostname, ipConfiguration),
|
||||
_deviceName(deviceName),
|
||||
_phy_addr(phy_addr),
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_spi_sck(spi_sck),
|
||||
_spi_miso(spi_miso),
|
||||
_spi_mosi(spi_mosi),
|
||||
_type(ethtype),
|
||||
_useSpi(true),
|
||||
_preferences(preferences)
|
||||
Preferences *preferences,
|
||||
const IPConfiguration *ipConfiguration,
|
||||
const std::string &deviceName,
|
||||
uint8_t phy_addr,
|
||||
int cs,
|
||||
int irq,
|
||||
int rst,
|
||||
int spi_sck,
|
||||
int spi_miso,
|
||||
int spi_mosi,
|
||||
eth_phy_type_t ethtype)
|
||||
: NetworkDevice(hostname, ipConfiguration),
|
||||
_deviceName(deviceName),
|
||||
_phy_addr(phy_addr),
|
||||
_cs(cs),
|
||||
_irq(irq),
|
||||
_rst(rst),
|
||||
_spi_sck(spi_sck),
|
||||
_spi_miso(spi_miso),
|
||||
_spi_mosi(spi_mosi),
|
||||
_type(ethtype),
|
||||
_useSpi(true),
|
||||
_preferences(preferences)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -78,7 +78,7 @@ void EthernetDevice::initialize()
|
||||
_hardwareInitialized = ETH.begin(_type, _phy_addr, _cs, _irq, _rst, SPI);
|
||||
criticalEthFailure = false;
|
||||
}
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
else
|
||||
{
|
||||
Log->println(F("Use RMII"));
|
||||
@@ -90,7 +90,7 @@ void EthernetDevice::initialize()
|
||||
_checkIpTs = (esp_timer_get_time() / 1000) + 2000;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(_hardwareInitialized)
|
||||
{
|
||||
@@ -138,55 +138,56 @@ void EthernetDevice::update()
|
||||
|
||||
void EthernetDevice::onNetworkEvent(arduino_event_id_t event, arduino_event_info_t info)
|
||||
{
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_ETH_START:
|
||||
Log->println("ETH Started");
|
||||
ETH.setHostname(_hostname.c_str());
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||
Log->println("ETH Connected");
|
||||
if(!localIP().equals("0.0.0.0"))
|
||||
{
|
||||
_connected = true;
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
Log->printf("ETH Got IP: '%s'\n", esp_netif_get_desc(info.got_ip.esp_netif));
|
||||
Log->println(ETH);
|
||||
|
||||
// For RMII devices, this check is handled in the update() method.
|
||||
if(_useSpi && !_ipConfiguration->dhcpEnabled() && _ipConfiguration->ipAddress() != ETH.localIP())
|
||||
{
|
||||
Log->printf("Static IP not used, retrying to set static IP");
|
||||
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
|
||||
ETH.begin(_type, _phy_addr, _cs, _irq, _rst, SPI);
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case ARDUINO_EVENT_ETH_START:
|
||||
Log->println("ETH Started");
|
||||
ETH.setHostname(_hostname.c_str());
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||
Log->println("ETH Connected");
|
||||
if(!localIP().equals("0.0.0.0"))
|
||||
{
|
||||
_connected = true;
|
||||
if(_preferences->getBool(preference_ntw_reconfigure, false))
|
||||
{
|
||||
_preferences->putBool(preference_ntw_reconfigure, false);
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_LOST_IP:
|
||||
Log->println("ETH Lost IP");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
Log->println("ETH Disconnected");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_STOP:
|
||||
Log->println("ETH Stopped");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
default:
|
||||
Log->print("ETH Event: ");
|
||||
Log->println(event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
Log->printf("ETH Got IP: '%s'\n", esp_netif_get_desc(info.got_ip.esp_netif));
|
||||
Log->println(ETH);
|
||||
|
||||
// For RMII devices, this check is handled in the update() method.
|
||||
if(_useSpi && !_ipConfiguration->dhcpEnabled() && _ipConfiguration->ipAddress() != ETH.localIP())
|
||||
{
|
||||
Log->printf("Static IP not used, retrying to set static IP");
|
||||
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
|
||||
ETH.begin(_type, _phy_addr, _cs, _irq, _rst, SPI);
|
||||
}
|
||||
|
||||
_connected = true;
|
||||
if(_preferences->getBool(preference_ntw_reconfigure, false))
|
||||
{
|
||||
_preferences->putBool(preference_ntw_reconfigure, false);
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_LOST_IP:
|
||||
Log->println("ETH Lost IP");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
Log->println("ETH Disconnected");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_STOP:
|
||||
Log->println("ETH Stopped");
|
||||
_connected = false;
|
||||
onDisconnected();
|
||||
break;
|
||||
default:
|
||||
Log->print("ETH Event: ");
|
||||
Log->println(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +213,10 @@ bool EthernetDevice::isApOpen()
|
||||
|
||||
void EthernetDevice::onDisconnected()
|
||||
{
|
||||
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000)) restartEsp(RestartReason::RestartOnDisconnectWatchdog);
|
||||
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000))
|
||||
{
|
||||
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
|
||||
}
|
||||
}
|
||||
|
||||
int8_t EthernetDevice::signalStrength()
|
||||
|
||||
Reference in New Issue
Block a user