|
From: | Tim Lambrix |
Subject: | Re: [lwip-users] DHCP, switch to static IP if no answer |
Date: | Wed, 22 Jun 2011 15:09:06 +0000 |
I just wanted to mention that I was having DHCP issues with my lwIP product in getting an address from the server. It turned out in the end that the latest
Netgear switches were causing addresses from the DHCP server to be assigned up to 2 minutes! after attaching to the network. The old switch was doling out IP’s in about 3-5 seconds. I don’t know if Netgear has done anything to make the time better yet or
if there is a standard time for DHCP to complete in. Walter, 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. Bill From: lwip-users-bounces+address@hidden [mailto:lwip-users-bounces+address@hidden
On Behalf Of Walter Saegesser 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 );
Thanks a lot. Walter |
[Prev in Thread] | Current Thread | [Next in Thread] |