# Issues compiling with WiFi.ping()

**URL:** <https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065>\
**Category:** GIGA R1 WiFi\
**Created:** [April 5, 2024, 1:52am UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065 "2024-04-05T01:52:08Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 5, 2024, 1:52am UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/1 "2024-04-05T01:52:08Z")

</div>

Am looking for a little guidance with getting the following code to compile.  
Code was found online and it throws this error while verifying with IDE v2:

_/private/var/folders/4b/qckrgbg9363dj\_tb8wbv29zr0000gn/T/arduino/sketches/A827478510E08D3B5CCE11A06C8E0BA9/sketch/GIGA\_Wifi.ino.cpp.o: In function `loop':* */Users/xxxxxxxxxxxx/Documents/Arduino/GIGA_Wifi/GIGA_Wifi.ino:66: undefined reference to `arduino::WiFiClass::ping(arduino::String const&, unsigned char)'_  
_collect2: error: ld returned 1 exit status_  
_exit status 1_  
_Compilation error: exit status 1_

The issue seems to be with this function ` pingResult = WiFi.ping(hostName, 128);`  
It fails to compile with or without specifying "uint8\_t ttl" value.  
EDITED: The code does compile fine if that one line is commented out and has **NO** issues connecting to the specified SSID.

What am I missing?

```arduino
/*

  This example connects to a encrypted WiFi network (WPA/WPA2).
  Then it prints the MAC address of the WiFi 101 Shield,
  the IP address obtained, and other network details.
  Then it continuously pings given host specified by IP Address or name.

  Circuit:
   WiFi 101 Shield attached / MKR1000

  created 13 July 2010
  by dlf (Metodo2 srl)
  modified 09 June 2016
  by Petar Georgiev
*/
#include <SPI.h>
#include <WiFi.h>

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS; // the WiFi radio's status

// Specify IP address or hostname
// String hostName = "www.google.com";
String hostName = "8, 8, 8, 8";
int pingResult;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi 101 Shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to WiFi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 5 seconds for connection:
    delay(5000);
  }

  // you're connected now, so print out the data:
  Serial.println("You're connected to the network");
  printCurrentNet();
  printWiFiData();
}

void loop() {
  Serial.print("Pinging ");
  Serial.print(hostName);
  Serial.print(": ");

 pingResult = WiFi.ping(hostName, 128);

  if (pingResult >= 0) {
    Serial.print("SUCCESS! RTT = ");
    Serial.print(pingResult);
    Serial.println(" ms");
  } else {
    Serial.print("FAILED! Error code: ");
    Serial.println(pingResult);
  }

  delay(5000);
}

void printWiFiData() {
  // print your WiFi 101 Shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP address : ");
  Serial.println(ip);

  Serial.print("Subnet mask: ");
  Serial.println((IPAddress)WiFi.subnetMask());

  Serial.print("Gateway IP : ");
  Serial.println((IPAddress)WiFi.gatewayIP());

  // print your MAC address:
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC address: ");
  printMacAddress(mac);
}

void printCurrentNet() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print the MAC address of the router you're attached to:
  byte bssid[6];
  WiFi.BSSID(bssid);
  Serial.print("BSSID: ");
  printMacAddress(bssid);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI): ");
  Serial.println(rssi);

  // print the encryption type:
  byte encryption = WiFi.encryptionType();
  Serial.print("Encryption Type: ");
  Serial.println(encryption, HEX);
  Serial.println();
}

void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
    if (i > 0) {
      Serial.print(":");
    }
  }
  Serial.println();
}

```

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 5, 2024, 8:27am UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/2 "2024-04-05T08:27:31Z")

</div>

Hi @endreola. Unfortunately it looks like the developers of the " **GIGA R1 WiFi**" board's "[WiFi](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/WiFi)" library never implemented a `ping` function. So you can't use that function with this board.

> [@endreola](#):
>
> has issues connecting to the specified SSID.

If you would like assistance with that, please provide a detailed description of the "issues" and we'll try to help you with them.

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 5, 2024, 3:18pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/3 "2024-04-05T15:18:57Z")

</div>

Ugg, that's a shame. Who would of thought that a board having built-in paths of communication wouldn't include a basic networking protocol like ping.

I guess to your point, IDE thinks that library function is valid (b/c it pops-up a syntax window when moused over, see screenshot) but that doesn't necessarily mean the HW supports it.

Is there an current cross-reference guide that lists the different Arduino boards and what libraries / functions are supported (and or not supported)? Asking the developers to make that change will take significant time and who knows if the wifi chipset even supports the ICMP protocol, etc., etc.. So in the interim, I'll go purchase a different board but it has to support wifi & ping.

 ![Screenshot 2024-04-05 at 7.37.02 AM](https://europe1.discourse-cdn.com/arduino/original/4X/d/d/9/dd97a6f5129dc22e0811bac90152d08fafaece49.png)

The comment that was made "...has issues connecting to the specified SSID..." should have read "has **NO** issues connecting...". Sorry about that..

Thank you again for your guidance. Much appreciated.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 5, 2024, 5:38pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/4 "2024-04-05T17:38:51Z")

</div>

> [@endreola](#):
>
> I guess to your point, IDE thinks that library function is valid (b/c it pops-up a syntax window when moused over, see screenshot)

It think it is valid because the library developers declared the function:

> <https://github.com/arduino/ArduinoCore-mbed/blob/4.1.1/libraries/WiFi/src/WiFi.h#L193-L195>

However, despite the presence of the declarations, the functions don't seem to be defined in the library, thus the error message when you try to use them.

> [@endreola](#):
>
> but that doesn't necessarily mean the HW supports it.

I'm not very knowledgeable about the GIGA R1 WiFi's Wi-Fi radio hardware, or about networking in general, but I think it is as likely that the library developers simply didn't get around to implementing the functions rather than that there is a technical limitation that prevents such a thing.

> [@endreola](#):
>
> Is there an current cross-reference guide that lists the different Arduino boards and what libraries / functions are supported (and or not supported)?

If we are speaking of networking libraries specifically, a community member did just that recently:

> **[GitHub - JAndrassy/Arduino-Networking-API: A repository to document the...](https://github.com/JAndrassy/Arduino-Networking-API)**
>
> A repository to document the Arduino Networking API established by the Arduino Ethernet library, adopted for WiFi with the Arduino WiFi library, evolved with Arduino WiFiNINA library and esp8266 Wi...

This was part of @Juraj's work to improve the standardization of the API of the various networking libraries (official and 3rd party) in the Arduino ecosystem.

It has a table of libraries that provide a `ping` function here:

[https://github.com/JAndrassy/Arduino-Networking-API/blob/main/ArduinoNetAPILibs.md#network-services](https://github.com/JAndrassy/Arduino-Networking-API/blob/main/ArduinoNetAPILibs.md#network-services)

> | library | [hostByName](https://www.arduino.cc/reference/en/libraries/wifinina/wifi.hostbyname/) | ping | getTime |
> | --- | --- | --- | --- |
> | [Ethernet](https://github.com/arduino-libraries/Ethernet/blob/master/src/Ethernet.h#L74) | [PR](https://github.com/arduino-libraries/Ethernet/pull/232) | | |
> | [WiFi](https://github.com/arduino-libraries/WiFi/blob/master/src/WiFi.h#L34) | ✓\* | | |
> | [WiFi101](https://github.com/arduino-libraries/WiFi101/blob/master/src/WiFi101.h#L79) | ✓ | ✓\* | ✓\* |
> | [WiFiNINA](https://github.com/arduino-libraries/WiFiNINA/blob/master/src/WiFi.h#L42) | ✓ | ✓ | ✓ |
> | [WiFiS3](https://github.com/arduino/ArduinoCore-renesas/blob/main/libraries/WiFiS3/src/WiFi.h#L32) | ✓ | | returns 0 |
> | [Mbed WiFi](https://github.com/arduino/ArduinoCore-mbed/blob/main/libraries/WiFi/src/WiFi.h#L51) | ✓ | ✓ | returns 0 |
> | [Mbed Ethernet](https://github.com/arduino/ArduinoCore-mbed/blob/main/libraries/Ethernet/src/Ethernet.h#L55) | ✓ | ✓ | returns 0 |
> | [C33 Wifi](https://github.com/arduino/ArduinoCore-renesas/blob/main/libraries/WiFi/src/WiFiC3.h#L8) | ✓ | | returns 0 |
> | [C33 Ethernet](https://github.com/arduino/ArduinoCore-renesas/blob/main/libraries/Ethernet/src/EthernetC33.h#L31) | PR | | |
> | [esp8266 WiFi](https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h#L62) | ✓ | | |
> | [esp8266 LwipIntfDev](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/LwipIntfDev.h#L57) | | | |
> | [esp32 WiFi](https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.h#L154) | ✓ | | |
> | [esp32 Ethernet](https://github.com/espressif/arduino-esp32/blob/master/libraries/Ethernet/src/ETH.h#L59) | | | |
> | [WiFiEspAT](https://github.com/JAndrassy/WiFiEspAT/blob/master/src/WiFi.h#L57) | ✓ | ✓ | ✓ |
> | [EthernetENC](https://github.com/JAndrassy/EthernetENC/blob/master/src/Ethernet.h#L75) | + | | |
> | [STM32Ethernet](https://github.com/stm32duino/STM32Ethernet/blob/main/src/STM32Ethernet.h#L16) | | | |
> | [QNEthernet](https://github.com/ssilverman/QNEthernet/blob/master/src/QNEthernet.h#L62) | + | | |
> | [RP2040 WiFi](https://github.com/earlephilhower/arduino-pico/blob/master/libraries/WiFi/src/WiFiClass.h#L41) | ✓ | ✓ | returns millis() !!! |
> | [RP2040 LwipIntfDev](https://github.com/earlephilhower/arduino-pico/blob/master/libraries/lwIP_Ethernet/src/LwipIntfDev.h#L57) | ✓ | ✓ | |

> [@endreola](#):
>
> The comment that was made "...has issues connecting to the specified SSID..." should have read "has **NO** issues connecting...". Sorry about that..

No worries. I'm just glad the connectivity is working. Thanks for the clarification!

---

<div class="post-metadata">

**Author:** ![Juraj](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/juraj/32/238785_2.png) [@Juraj](https://forum.arduino.cc/u/Juraj)\
**Post date:** [April 5, 2024, 6:51pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/5 "2024-04-05T18:51:56Z")

</div>

@ptillisch Per thank you for the ping about ping. I read only the header files.  
now I removed the check marks and

> <https://github.com/arduino/ArduinoCore-mbed/pull/862>
>
> \`ping\` and power mode functions do not have an implementation. to avoid confusio…n better remove them.
> 
> https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 5, 2024, 7:22pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/6 "2024-04-05T19:22:51Z")

</div>

@ptillisch & @Juraj - Thank you for the updated info. That really helps me narrow down board of choice.

So, as it stands today, the only Arduino boards that allow WiFi networking functions (in particular "ping") are as follows:

- [WiFi101](https://github.com/arduino-libraries/WiFi101/blob/master/src/WiFi101.h#L79) (with some caveat, ref link).
- [WiFiNINA](https://github.com/arduino-libraries/WiFiNINA/blob/master/src/WiFi.h#L42)
- [WiFiEspAT](https://github.com/JAndrassy/WiFiEspAT/blob/master/src/WiFi.h#L57)
- [RP2040 WiFi](https://github.com/earlephilhower/arduino-pico/blob/master/libraries/WiFi/src/WiFiClass.h#L41)
- [RP2040 LwipIntfDev](https://github.com/earlephilhower/arduino-pico/blob/master/libraries/lwIP_Ethernet/src/LwipIntfDev.h#L57)

Am still not sure where the "ping()" limitation stands with the GIGA r1 wifi board but I would like to see that the "Mbed libraries" get updated so I can use this board as originally planned.

---

<div class="post-metadata">

**Author:** ![Juraj](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/juraj/32/238785_2.png) [@Juraj](https://forum.arduino.cc/u/Juraj)\
**Post date:** [April 5, 2024, 7:50pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/7 "2024-04-05T19:50:15Z")

</div>

are you sure you need ping?

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 5, 2024, 8:49pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/8 "2024-04-05T20:49:56Z")

</div>

ICMP ping is the industry standard protocol for monitoring device availability, if as device is up/down, (barring firewalls, ACLs, etc. in the path).

ICMP is a low cost protocol, meaning it does not impose the additional overhead that protocols like TCP/UDP have, such as TCP 3-way handshake. And UDP is a connection-less protocol meaning there's no acknowledgement that the end-point actually received the packet. So from an IP protocol stack perspective the ICMP protocol is what I require for availability testing using Ardunio. From an ICMP stack perspective I just need two types; echo (type 8) and echo reply (type 0).

Is there another protocol that you have in mind that i should use instead?

---

<div class="post-metadata">

**Author:** ![Juraj](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/juraj/32/238785_2.png) [@Juraj](https://forum.arduino.cc/u/Juraj)\
**Post date:** [April 6, 2024, 6:08am UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/9 "2024-04-06T06:08:51Z")

</div>

I think ICMP is available in Mbed Core

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 6, 2024, 2:15pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/10 "2024-04-06T14:15:06Z")

</div>

Then that’s a good start in getting ping implemented. How does one go about requesting to have it added?

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 6, 2024, 2:35pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/11 "2024-04-06T14:35:54Z")

</div>

@endreola you can submit a request to the issue tracker of the " **Arduino Mbed OS Giga Boards**" platform:

> **[Issues · arduino/ArduinoCore-mbed](https://github.com/arduino/ArduinoCore-mbed/issues)**
>
> Contribute to arduino/ArduinoCore-mbed development by creating an account on GitHub.

That will allow the platform developers and contributors to effectively track the request.

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 6, 2024, 2:58pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/12 "2024-04-06T14:58:43Z")

</div>

Thank you guys for the excellent guidance.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 6, 2024, 3:01pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/13 "2024-04-06T15:01:14Z")

</div>

You are welcome. I'm glad if I was able to be of some assistance.

Regards,  
Per

---

<div class="post-metadata">

**Author:** ![endreola](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@endreola](https://forum.arduino.cc/u/endreola)\
**Post date:** [April 6, 2024, 3:27pm UTC](https://forum.arduino.cc/t/issues-compiling-with-wifi-ping/1244065/14 "2024-04-06T15:27:31Z")

</div>

Just in case others are following, here's the GitHub request [https://github.com/arduino/ArduinoCore-mbed/issues/863](https://github.com/arduino/ArduinoCore-mbed/issues/863)
