EthernetDHCP.begin

Is there a way to allow the Arduino to continue even if it is not plugged into a router so cannot receive its DHCP data?

Is there a way to allow the Arduino to continue even if it is not plugged into a router so cannot receive its DHCP data?

To continue to do what? What is stopping it?

Hey
Basically unless an ethernet cable is plugged in to the device so that it can get an IP address it will not make it to the loop.

it will not make it to the loop.

Either because some function blocks inappropriately, or because you wrote your code wrong. But, since you won't post code, we can't help you.

Oooh what a lovely code snippet.

Now, post all of your code, and explain what the problem is.

@PaulS: Has the DHCP module been added to Arduino? I see it available in one of the options in the w5100 library, but I do not see it added to the Ethernet library here. That would be handy.

basically it will work perfectly but if i unplug the ethernet cable it will not pass the ethernetDHCP.begin

Back on reply #3, I mentioned two possibilities. One was that some function blocks inappropriately. Now, you are saying that EthernetDHCP.begin() never returns if there is not ethernet cable connected. I think that that qualifies as an inappropriately blocking function.

I suggest that you contact the EthernetDHCP library author, and express your displeasure.

Oh ;(
that is a problem.

Is there any kind of workaround for that?

I was looking at the EthernetDHCP library for another thread, and I see that the begin() method has two overloads:

int EthernetDHCPClass::begin(uint8_t* macAddr)
{
   return this->begin(macAddr, 0);
}

// return values:
// 1 on success
// 0 on error
int EthernetDHCPClass::begin(uint8_t* macAddr, int pollingMode)
{
   int rv = 0;
 	 	   
   memset(&this->_dhcpData, 0, sizeof(DhcpDataInternal_t));
   this->_state = DhcpStateNone;
   this->_lastSendMillis = 0;
   
   memcpy(this->_dhcpData.macAddr, macAddr, 6);

   ethernet_compat_init(this->_dhcpData.macAddr,
                        this->_dhcpData.ipAddr,
                        RX_TX_BUF_SIZE);
   
   this->_socket = -1;
    	
 	if (0 < this->_requestDhcpLease()) {
      rv = 1;
 	   
      if (!pollingMode)
         while(DhcpStateLeased != this->poll())
            delay(10);
   }
 	   
   return rv;
}

Looks to me like you want to be using the polling mode overload, which is non-blocking, rather than the single-argument method, which is blocking.

Thanks for all the help paul

I actually got an email from the developer 5 minutes before replied saying the same thing