WiFi.Ping() returns -120 on Argon

argon
Tags: #<Tag:0x00007fe223c68128>

#1

My Argon can connect to the network and connect to the Particle cloud. I am trying to test my Argon’s ability to reach devices on the network, and can’t seem to understand what WiFi.Ping() is doing for me. Everything I try returns -120. Does that mean that it can’t reach the destination, or what?

The code and the results I get are shown below.

The Code

IPAddress remoteIP(10, 245, 77, 21);
int numberOfReceivedPackage = 0;

void setup() {
    
    Serial.begin(9600);
}

void loop() {
Serial.println(WiFi.localIP());
Serial.println(WiFi.subnetMask());
Serial.println(WiFi.gatewayIP());

    while(!Serial.available()) SPARK_WLAN_Loop();
    
    Serial.println("Pinging started...");
    
    numberOfReceivedPackage = WiFi.ping(remoteIP, 25);
    
    Serial.print("Pinging ended ->");
    Serial.println((int)numberOfReceivedPackage);


delay(5000);
}
----------------------------------------------------------------------------
The Results
----------------------------------------------------------------------------
10.245.77.21
255.255.255.0
10.245.77.254
Pinging started...
Pinging ended ->-120

#2

Is your ping target actually responding to pings? If not WiFi.ping() will just timeout.
Have you tried pinging that IP from your computer?

BTW, SPARK_WLAN_Loop() has been superceded ages ago by Particle.process().


#3

Thats a good point. I had the Argon pinging itself. I pinged it from my PC and saw that it didn’t respond to pings.

I changed it so the Argon would ping my PC, but got the same -120.
I have tried pinging google.com and particle.io using the IP address resolved by ping from my PC, and got the same -120 response.

I didn’t realize that. I got the ping code from the forum here, and did the ol’ cut and paste. I’ll read up on the particle.process()