WiFi

ping()

Since 6.3.0:

WiFi.ping() allows you to ping an IP address and returns the number of packets received as an int or a negative error code.

This is an ICMP ping, not the Particle cloud ping and does not use data operations.

// PROTOTYPES
int ping(IPAddress remoteIP, unsigned nTries = 1, unsigned timeoutMs = DEFAULT_PING_TIMEOUT);
int ping(String hostname, unsigned nTries = 1, unsigned timeoutMs = DEFAULT_PING_TIMEOUT);
int ping(IPAddress remoteIP, std::chrono::milliseconds timeout, unsigned nTries = 1);
int ping(String hostname, std::chrono::milliseconds timeout, unsigned nTries = 1);

When using a hostname, a DNS lookup is done. If the hostname is not found, a negative result code (SYSTEM_ERROR_NOT_FOUND, -150) is returned.

The DEFAULT_PING_TIMEOUT is 4000 milliseconds (4 seconds).

These methods are only avaiable in Device OS 6.3.0 and later. They are available in the WiFi, Cellular, Ethernet, and Network classes.

On the Photon 1 and P1, only these methods are available, and only in the WiFi class, but are available on most versions of Device OS for Gen 2.

// PROTOTYPES - Photon 1 and P1 only
int ping(IPAddress remoteIP);
int ping(IPAddress remoteIP, unsigned nTries);