1

I've been trying to find a solution to get amazon-freertos to detect WIFI network down so I can reconnect. I have to say I am still not fully in understanding of how it all should work.

From reading up it looks like the intended way is to wait for callback to vApplicationIPNetworkEventHook where the programmer should implement necessary reconnects. However the problem is that this callback function does not get called for network down events, it only get called for network up events.

Reading FreeRTOS guide I see that for vApplicationIPNetworkEventHook to get a callback for network down event the underlying driver must first tell the TCPIP stack of this event, and it goes on to say not all drivers implement this, so I think I have located the problem now.

My question is how should the driver inform the TCPIP stack? The driver logs the network down event (it doesn't do much more than that) so I can add some code there to alert the TCPIP stack, but how should that be done? I cannot find any instructions for how to make this change, any help or suggestion is much appreciated.

amazon-freertos: https://github.com/MicrochipTech/amazon-freertos MCU Test Board: Microchip curiosity_pic32mzw1

To add I think this should be the place (iot_wifi.c) to implement it:

WIFIReturnCode_t WIFI_RegisterNetworkStateChangeEventCallback( IotNetworkStateChangeEventCallback_t xCallback  )
{
    /** Needs to implement dispatching network state change events **/
    return eWiFiNotSupported;
}

The question is just how.

Thanks, Marcus

CaptainMJ
  • 167
  • 9

1 Answers1

1

You can add a call to vApplicationIPNetworkEventHook() using eNetworkDown as the parameter.

Richard
  • 3,081
  • 11
  • 9
  • Thanks, that works, I then added a call to FreeRTOS_NetworkDown() which triggers the IP Task to reconnect. However now it fails at WIFI_On, due to DRV_HANDLE_INVALID, this seems HW dependent so I have raised a case to Microchip for that. Will update with the solution when it becomes available. – CaptainMJ Sep 09 '21 at 04:20
  • Microchip has now added support for the network event callback, this was previously missing for pic32mzw1. – CaptainMJ Oct 02 '21 at 09:12