Wifi.ping() = -120, Argon, Device OS: 2.0.1

Hello,

My Argon, which is connected to the Device Cloud and that can be pinged from my several PCs in my network is unable to ping any other device (neither the gateway nor any other resource e.g. 8.8.8.8).
DNS resolutions works as expected.

Maybee I’m missing some important steps.
Best regards

Welcome to the community :wave:

Can you show us how exactly you wrote the WiFi.ping() call?


Update:
Just tried it myself with this code

SerialLogHandler logger(LOG_LEVEL_WARN, {{ "app", LOG_LEVEL_ALL }});

void setup() {}
void loop() {
    Log.info("ping: %lu", WiFi.ping(IPAddress(8,8,8,8), 5));
    delay(1000);
}

which works fine on a Photon (2.0.1) but does not on Argon (2.0.1 nor 3.0.0-rc.2)
@marekparticle???

There seems to be a unit test for WiFi.ping() but this may not have been executed properly for the Argon :wink:

It’s documented but was apparently never implemented for Gen3 hence we still get the “not-supported”-error.

1 Like

Code:

// Use primary serial over USB interface for logging output
SerialLogHandler logHandler(LOG_LEVEL_ALL, { // Logging level for non-application messages
    { "app", LOG_LEVEL_ALL } // Logging level for application messages
});

// polling interval
const long interval = 2000;

// setup() runs once, when the device is first turned on.
void setup() {
  // Put initialization like pinMode and begin functions here.
  // Format text message
  Log.info("System version: %s", (const char*)System.version());
}

unsigned long lastTime = 0;

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.
  unsigned long now = System.millis();
  
  if ((now - lastTime) >= interval) {
		lastTime = now;
		
    while (!WiFi.ready()) {
      Particle.process();
    }

    Log.trace("Wifi available");
    Log.info("ip: %s", WiFi.localIP().toString().c_str());
    Log.info("subnet: %s", WiFi.subnetMask().toString().c_str());
    Log.info("gateway: %s", WiFi.gatewayIP().toString().c_str());
    Log.info("Pinging started...");  


    IPAddress remoteIP(8, 8, 8, 8);
    remoteIP = WiFi.resolve("www.google.com");
    if(remoteIP) {
      // IP address was resolved
      Log.info("ip address: %s", remoteIP.toString().c_str());
      int numberOfReceivedPackage = WiFi.ping(remoteIP, 10);
      Log.info("ping res=%d", numberOfReceivedPackage);
    } else {
      // name resolution failed
      Log.error("Resolution failed");
    }
  }
}

@ScruffR, thanks for the quick reply, do you know of any problems using the UDP client (my project will require to query NTP servers using UDP).

I’m not aware of any problems, but is there a particular reason for using NTP over Particle’s own Time object?

It’s just a personal preference for using NTP, as I would like to connect to a geographically near time server (Austria).

Oooh, a fellow Austrian! :+1:

Servus! @ScruffR - how exactly is your Argon reporting an error here? Are you just not seeing the ping go through, or is something else happening?

Answer of WiFi.ping() is always -120. I can’t find any errors in the log-outputs.

@marekparticle, exactly that ^^^ :wink:
I’d guess SYSTEM_ERROR_NOT_SUPPORTED would evaluate to -120.

Sorry for the delay, I’ll be looking at this today!

1 Like

I can reproduce; I have brought to our Device OS team for further comment.

1 Like

Hey! Interesting finding; Wifi.ping() was not implemented on the Argon. I’ve raised this gap internally to request that either documentation is adjusted and/or this API implementation is adopted.

In the meantime, our Engineering Team has the following implementation via the Gen3 Socket API: particle_gen3_ping.cpp · GitHub