Reconfigure and restart FreeRTOS-TCP

sdcandy wrote on Friday, May 24, 2019:

I have a system where the network settings i.e. whether to use DHCP or static IP address details are stored in non-volatile memory and are read before FreeRTOS_IPInit() is called. When the network comes up vApplicationIPNetworkEventHook() takes care of starting a web server and a couple of other network services each as a separate FreeRTOS task.

The network settings can be changed through the web interface. At the moment it is writing the new values to the non-volatile storage and then requires a reboot of the device. Is there a more elegant way of achieving the restart of the network interface and related services without the full reboot?

If I call xSendEventToIPTask(eNetworkDownEvent) then I can use that to shut everything down cleanly but what do I use to force the network to come back up or will it just happen anyway? When it does come back up will it go far enough back in the initialisation process to perform the DHCP negotiation if it is switched from static to dynamic addressing (for example).

-Andy.

heinbali01 wrote on Saturday, May 25, 2019:

Hi Andy,

I’m sure that you have seen the DHCP application hook:

#if( ipconfigUSE_DHCP_HOOK != 0 )
    eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t ePhase, uint32_t ulIPAddress )
    {
    }
#endif

With this hook, you can instruct the DHCP module to either stop or continue the negotiation.

FreeRTOS_IPInit() can be called only once because it creates a queue and it starts the IP-task.

I’m afraid there is no way to re-initialise the IP-stack, other than a reset of the CPU.

If there is only a small change, like the assigning a new IP-address and netmask, and provided that there are no open sockets, you might not need to reboot.