Skip to content

[UNO R4 WIFI][WifiS3] Non blocking option for Wifi.begin #337

Closed
@LatchT

Description

@LatchT

Hello,

The timeout in use when calling Wifi.begin is hardcoded and set to 10000 ms (see code below).
That makes it difficult to handle reconnection is some cases, because loop execution will be locked for 10s if no WiFi is available.

// ArduinoCore-renesas/libraries/WiFiS3/src/WiFi.cpp

/* -------------------------------------------------------------------------- */
int CWifi::begin(const char* ssid, const char *passphrase) {
/* -------------------------------------------------------------------------- */
 ...

   unsigned long start_time = millis();
   while(millis() - start_time < 10000){
      if(status() == WL_CONNECTED) {
         return WL_CONNECTED;
      } 
   }
  return WL_CONNECT_FAILED;
}

User should be able to set his own timeout value.

So Is there any way to perform a non-blocking reconnection ? If not, is it possible to update the interface to something like this?:

int CWifi::begin(const char* ssid, const char *passphrase, unsigned int timeout = 10000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions