|
FabGL
ESP32 Display Controller and Graphics Library
|
#include <ICMP.h>
ICMP Implementation.
Used to ping a network device using its IP or its host name.
Example:
fabgl::ICMP icmp;
while (true) {
// CTRL-C ?
if (Terminal.available() && Terminal.read() == 0x03)
break;
int t = icmp.ping("www.fabgl.com");
if (t >= 0) {
Terminal.printf("%d bytes from %s: icmp_seq=%d ttl=%d time=%.3f ms\r\n", icmp.receivedBytes(), icmp.hostIP().toString().c_str(), icmp.receivedSeq(), icmp.receivedTTL(), (double)t/1000.0);
delay(1000);
} else if (t == -2) {
Terminal.printf("Cannot resolve %s: Unknown host\r\n", host);
break;
} else {
Terminal.printf("Request timeout for icmp_seq %d\r\n", icmp.receivedSeq());
}
}