Cellular
ping() [Cellular]
Since 6.3.0:
Cellular.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, but it does use cellular data so you should not use it excessively.
// 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.