A problem with dhcp on embedded device that we encountered is that for instance after a power outage they boot faster than the dhcp server. This means the FreeRTOS device will fail to get a dynamic IP, and fall back on a static IP. After that it will never request an IP again.
For us this is not desired. It may takes minutes, hours or even days, but once the DHCP server is back, we want our device to get a proper IP address.
To get this done I made a few small modifications to FreeRTOS_DHCP.c. See the modified file attached.
dhcpRETRY_AFTER_FAILURE_PERIOD can be set to a value in milli seconds after which the device will try again to request an IP. The static IP will be used in the meantime.
Another way is to set
dhcpNEVER_GIVEUP to 1. In that case the device will also keep trying to get an IP, but without falling back to a static IP.
Maybe there is a better way to get this kind of behaviour, but I couldn’t find it. If so I surely would like to know.
And for anyone interested in what I did, see the attached file.