Skip to content

Ethernet.begin() does not return under certian circumstances #4

@pulli7

Description

@pulli7

In the past, with the Arduino-Ethernet-Shield, I used the following code to wait for ethernet connection to get available, so that I can have at least some limited functionality when ethernet is not available at this time, and automatically jump to full functionality as soon as link gets available.

void setup()
{
  if (Ethernet.begin(mac) == 0)
  {
    FallBackMode();
  } 
}
void FallBackMode()
{
  int Timestamp = millis();
  while(1)
  {
     if ( millis() - Timestamp > 300000)  //try reconnect every 5min
     {
       if (Ethernet.begin(mac, 30000) != 0)  //Problem here
       {                                   
         break;  //successfully connected
       }
       Timestamp = millis();
    }
    //call  "offline application"  here, which serves all functionality that does not need Ethernet
  }//ENDwhile
}

With the Nucleo 429ZI this does not work. As long as the cable is unplugged everthing is fine, but as soon as it is plugged in and ethernet gets available, the program gets locked inside the Ethernet.begin() function and never returns.

Am I misusing the function and it worked just coincidentally with the standard ethernet-shield, or is this a bug?
If this usage of the begin() function is not intended, is there another way to achieve that the board tries reconnecting itself?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions