Argon unable to sync time with particle cloud, but can access the internet

I’m running into an odd issue on some Argons at the moment with time synchronization -
I have some firmware which syncs the system time and is called at startup:

void syncSystemTime() {
  int WiFiConnectCountdown = kWiFiConnectionTimeout;

  WiFi.on();
  WiFi.connect();
  //wait for WiFi to connect for kWiFiConnectionTimeout
  while(!WiFi.ready() && WiFiConnectCountdown != 0) {
    WiFiConnectCountdown = WiFiConnectCountdown - kWiFiCheckInterval;
    delay(kWiFiCheckInterval);
    WITH_LOCK(Serial) {
      Serial.println(WiFiConnectCountdown);
    }
  }
  if(WiFi.ready()) {
    WITH_LOCK(Serial){
      Serial.println("WiFi connected, syncing time");
    }
    Particle.connect();
    while(!Particle.connected()) {} // wait forever until cloud connects
    Particle.syncTime(); // is async
    while(Particle.syncTimePending()) { // wait for syncTime to complete
      Particle.process();
    }
    WITH_LOCK(Serial){
      Serial.printlnf("Current time is: %s", Time.timeStr().c_str());
    }
  }
  else {
    WITH_LOCK(Serial) {
      Serial.println("WiFi failed to connect, skipping time synchronization");
    }
  }

  WiFi.off();
}

This works correctly on my Argons, however a client’s Argons do not sync their time correctly. I’d normally attribute this to a network issue on their end, but since the devices can access the internet and make a POST request to our backend successfully I’m a bit stumped on what is wrong here.

We’ve tried multiple argons, but it’s always the same issue where the time sync fails in some way and sets the Argon’s date to the default of Jan 1 2000 00:00:00 UTC.

The Argons also appear to be stuck in listening mode while this sync is happening. On my device when Wifi is first enabled, there is a brief dark blue flash, but it changes to blinking green immediately, which I would expect. Supposedly the Argons in the affected location never blink green like they are searching for wifi.

Can you try the absolute basic code, without any of these manual interferences?
With an absolute bare code like this

void setup() {
}
void loop() {
}

the Argon should automatically sync the time as soon the cloud connection gets established (breathing cyan).

3 Likes

Thanks, I’ll give it a shot.