I am trying to detect internet availability of an access point(AP) that was connected. My implementation consists of using LwIP Stack and also two network interfaces. The scenario is described below:
Case 1: Ping Successful
- Interface 0 connects to AP1 (with internet)
- Interface 1 connects to AP2 (without internet)
- ping www.google.com
- LwIP stack uses default network interface which is Interface 0 to ping google.
In this case, ping will be successful since I have internet connection on AP1 but if the connection is reversed, ping will fail because it uses the default network interface.
Case 2: Ping Fail
- Interface 0 connects to AP2 (without internet)
- Interface 1 connects to AP1 (with internet)
- ping www.google.com
- LwIP stack uses default network interface which is Interface 0 to ping google.
Is there anyway that I can detect or check for internet connection before deciding which interface to use to send the ping packets?
From what I observed on my laptop by connecting the Wi-Fi and Ethernet, it can ping successfully in both cases. Please help thank you.
BR Sue~