Pages: [1]   Go Down
Author Topic: EthernetDHCP.begin  (Read 1366 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oooh what a lovely code snippet.

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

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5853
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh ;(
that is a problem.

Is there any kind of workaround for that?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was looking at the EthernetDHCP library for another thread, and I see that the begin() method has two overloads:
Code:
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.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 189
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help paul

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

Pages: [1]   Go Up
Jump to: