Skip to content

Commit

Permalink
Fix WiFiClient watchdog usage
Browse files Browse the repository at this point in the history
  • Loading branch information
BlooD2oo1 committed Feb 14, 2022
1 parent 0641791 commit aa04757
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ int WiFiClient::connect(IPAddress ip, uint16_t port) {

unsigned long start = millis();

// wait 4 second for the connection to close
// wait 10 second for the connection to close
while (!connected() && millis() - start < 10000)
{
delay(1);
WiFi.feedWatchdog();
}

if (!connected())
{
Expand All @@ -92,9 +95,12 @@ int WiFiClient::connectSSL(IPAddress ip, uint16_t port)

unsigned long start = millis();

// wait 4 second for the connection to close
// wait 10 second for the connection to close
while (!connected() && millis() - start < 10000)
delay(1);
{
delay(1);
WiFi.feedWatchdog();
}

if (!connected())
{
Expand All @@ -121,9 +127,12 @@ int WiFiClient::connectSSL(const char *host, uint16_t port)

unsigned long start = millis();

// wait 4 second for the connection to close
// wait 10 second for the connection to close
while (!connected() && millis() - start < 10000)
delay(1);
{
delay(1);
WiFi.feedWatchdog();
}

if (!connected())
{
Expand All @@ -150,9 +159,12 @@ int WiFiClient::connectBearSSL(IPAddress ip, uint16_t port)

unsigned long start = millis();

// wait 4 second for the connection to close
// wait 10 second for the connection to close
while (!connected() && millis() - start < 10000)
delay(1);
{
delay(1);
WiFi.feedWatchdog();
}

if (!connected())
{
Expand All @@ -179,9 +191,12 @@ int WiFiClient::connectBearSSL(const char *host, uint16_t port)

unsigned long start = millis();

// wait 4 second for the connection to close
// wait 10 second for the connection to close
while (!connected() && millis() - start < 10000)
delay(1);
{
delay(1);
WiFi.feedWatchdog();
}

if (!connected())
{
Expand Down Expand Up @@ -301,7 +316,10 @@ void WiFiClient::stop() {
int count = 0;
// wait maximum 5 secs for the connection to close
while (status() != CLOSED && ++count < 50)
delay(100);
{
delay(100);
WiFi.feedWatchdog();
}

WiFiSocketBuffer.close(_sock);
_sock = 255;
Expand Down

0 comments on commit aa04757

Please sign in to comment.