[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] DHCP, switch to static IP if no answer

From: Bill Auerbach
Subject: Re: [lwip-users] DHCP, switch to static IP if no answer
Date: Wed, 22 Jun 2011 10:01:38 -0400



I used dhcp_start and then checked in a loop netif_is_up for a connection for 5 seconds.  If the 5 seconds ran out, I used dhcp_stop, netif_set_down, netif_set_addr, netif_set_up, and dhcp_inform to set a static IP address.  This worked well for me.  I guess the dhcp_inform isn’t needed but I used this same code if I was simply setting a static IP address in which case I wanted the DHCP server to know about this.




From: address@hidden [mailto:address@hidden On Behalf Of Walter Saegesser
Sent: Wednesday, June 22, 2011 8:37 AM
To: address@hidden
Subject: [lwip-users] DHCP, switch to static IP if no answer


In the current project DHCP is enabled by default, assuming that in most cases there is a DHCP server around.

But what, if not.

1.       How can I realize there is no answer from a DHCP server? Do I have to wait for some time, say a minute, and then check whether the netif IP address is still 0? Or is there a better and more convenient way? (I’m working with netconn API).

2.       Assuming I have detected the failure, what do I have to do to switch to a static default IP (and GW, and mask)? Would this be the correct code?

            dhcp_stop ( &mNetIf );
.flags &= ~NETIF_FLAG_DHCP;
netif_set_addr ( &mNetIf, &xIpAddr, &xNetMask, &xGwAddr );


Thanks a lot.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]