NetworkUp event on FreeRTOS_init_Multi()

Hi.

This is the below code which I am using

The problem here is - I get the events in the following order

NetweorkUp
NetworkDown
DFCP events
NetworkUp

I am perplexed why the networkUp event occurs as soon as I call FreeRTOS_IPInit_Multi as I expect it to come only after the DHCP link is established.

 pxFSP_Eth_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
        FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
#if ( ipconfigUSE_DHCP != 0 )
        {
            xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
        }
#endif /* ipconfigUSE_DHCP */
        sock_err = FreeRTOS_IPInit_Multi();
        if (1 == sock_err)
        {
            /*do nothing */
        }
        else
        {
            //TEST_PROCESS_PRINT(TEST_ERROR,"FREERTOS_IPINIT FAILED.\r\n");
        }
        while (pdFALSE == FreeRTOS_IsNetworkUp())
        {
            vTaskDelay(10);
        }
        flag=false;
        while(flag==false)
        {
            vTaskDelay(10);
        }
        while (pdFALSE == FreeRTOS_IsNetworkUp())
        {
            vTaskDelay(10);
        }
        xClientSocket = FreeRTOS_socket( FREERTOS_AF_INET,
                                         FREERTOS_SOCK_STREAM ,  /* SOCK_STREAM for TCP. */
                                         FREERTOS_IPPROTO_TCP  );

vIPNetworkUpCalls is called from prvCheckLinkStatusTask

Hello Siddharth,

Welcome to FreeRTOS community.

Have you registered vApplicationIPNetworkEventHook_Multi? If not can you register for it? I also recommend you to use the initialization flow mentioned here or you can refer to our demo on how to initialize

Hi Nikhil,

YEs I have indeed registered the [vApplicationIPNetworkEventHook_Multi] and I do get the network events in the order as mentioned below

**NetweorkUp**
NetworkDown
DFCP events
NetworkUp
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent, struct xNetworkEndPoint * pxEndPoint )
{
    FSP_PARAMETER_NOT_USED(eNetworkEvent);
    FSP_PARAMETER_NOT_USED(pxEndPoint);
}

I don’t do anything with the events though

I am not sure why I get a NetworkUp event when I call the FreeRTOS_IPInit_Multi function.

After a bit of debug I did find that prvCheckLinkStatusTask is being invoked after the FreeRTOS_IPInit_Multi Which then receievs a NetworkUp event… Not sure from where I get the NetworkUp event just after the Init call… I expect it to be after the IP is assigned after the DHCP has assigned an address.

Can you please shed some light on this?

FreeRTOS_IPInit_Multi triggers a dummy network down event first as per the code here . This should then trigger the vApplicationIPNetworkEventHook_Multi hook here before going on to initialize the Network Interface here.
How are you confirming that NetworkUp event came before the down event?

Can you please implement vApplicationIPNetworkEventHook_Multi() with If else blocks for both up and down event and use the debugger breakpoints to confirm, please?