add espMillis() to replace esp_timer_get_time() / 1000

This commit is contained in:
technyon
2024-10-20 14:25:04 +02:00
parent 1d079a9aad
commit 9ca377870f
15 changed files with 62 additions and 48 deletions

View File

@@ -87,7 +87,7 @@ void EthernetDevice::initialize()
criticalEthFailure = false;
if(!_ipConfiguration->dhcpEnabled())
{
_checkIpTs = (esp_timer_get_time() / 1000) + 2000;
_checkIpTs = espMillis() + 2000;
}
}
#endif
@@ -126,7 +126,7 @@ void EthernetDevice::update()
{
Log->println(F("ETH Set static IP"));
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
_checkIpTs = (esp_timer_get_time() / 1000) + 2000;
_checkIpTs = espMillis() + 2000;
}
else
{
@@ -213,7 +213,7 @@ bool EthernetDevice::isApOpen()
void EthernetDevice::onDisconnected()
{
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000))
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
{
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "IPConfiguration.h"
#include "../EspMillis.h"
class NetworkDevice
{

View File

@@ -235,7 +235,7 @@ bool WifiDevice::connect()
{
Log->print("No network found with SSID: ");
Log->println(ssid);
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000))
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
{
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
}
@@ -287,7 +287,7 @@ bool WifiDevice::connect()
if (status != WL_CONNECTED)
{
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000))
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
{
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
_connecting = false;
@@ -349,7 +349,7 @@ void WifiDevice::onDisconnected()
if(_connected)
{
_connected = false;
_disconnectTs = (esp_timer_get_time() / 1000);
_disconnectTs = espMillis();
Log->println(F("Wi-Fi disconnected"));
//QUICK RECONNECT
@@ -377,7 +377,7 @@ void WifiDevice::onDisconnected()
if(!isConnected())
{
if(_preferences->getBool(preference_restart_on_disconnect, false) && ((esp_timer_get_time() / 1000) > 60000))
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
{
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
}