How to ping an IP address over Wifi?

Hello,
I'm trying to ping an IP address of a terminal that is on the same wifi network as my Portenta H7 board. I have tried to use the WiFi.ping() function but it shows an error.
Is there any other way to do this ?
Thank you.

Please post your full sketch and full error message using code tags for both

1 Like
//Ping local address
IPAddress localServer(192, 168, 1, 92); 
int serverResult;

void TaskPingWifi(void)
{
	Serialx.begin(115200);
	  while (status != WL_CONNECTED) {
	    Serialx.print("Attempting to connect to Network named: ");
	    Serialx.println(SSID);
	    status = WiFi.begin(SSID, PASS);
	    delay(10000);
	  }


	  Serialx.print("SSID: ");
	  Serialx.println(WiFi.SSID());
	  IPAddress ip = WiFi.localIP();
	  Serialx.print("IP Address: ");
	  Serialx.println(ip);

	while(1)
	{

		  serverResult = WiFi.ping(localServer);

		  Serialx.print("Local Server: ");

		  Serialx.println(serverResult);

		  delay(2000);

	}

}

And this is the error that I'm getting :

\VCU_PortentaH7_M7_V1_00\Release/..\main.cpp:553: undefined reference to `arduino::WiFiClass::ping(arduino::IPAddress, unsigned char)'

Bumping this - the function seems to exist inside of the ArduinoMbed framework, but the compiler doesn't seem to be able to find it.

Hello!

You have here the different ways to ping

You need to add the ttl parameter and you will be set

 serverResult = WiFi.ping(localServer, 128);

Just wanted to update this for any others coming across it.

It looks like ping() was never actually implemented, and was finally removed from the WiFi module's interface.

https://github.com/arduino/ArduinoCore-mbed/issues/863