Particle.syncTime() Either Not Sync'ing, or Not Updating timeSyncedLast

Hi all,

Poking away on my project, and I’ve run into an odd behaviour with Particle.syncTime(). Here’s the situation:

  • Argon on rc26
  • SYSTEM_THREAD enabled
  • Automatic Mode
  • Connected to WiFi

The Argon automatically syncs up the time when it connects to WiFi. I need to sync it up again later, so I call the following:

    Particle.syncTime();
    delay(250);
    waitFor(Particle.syncTimeDone, 10000);
    Serial.println(Particle.timeSyncedLast());
    Serial.println(Time.isValid());
    if((Particle.timeSyncedLast() < 250000) && Time.isValid()){
      Serial.println("Actually sync'd");
    }

The code is running, but the Particle.timeSyncedLast never actually updates, it always shows the time since the Argon first connected to the WiFi, ie. 25000 after 25 seconds etc. Any thoughts on this one?

I haven’t tried this yet on the Argon (and it could be that Particle.syncTime() has not yet been implemented), but on the Photon I do the Time Sync as follows:

if (Particle.connected())                    //Only time sync when Cloud connected otherwise it will block
{
    time_t lastSyncTimestamp;
    unsigned long lastSync = Particle.timeSyncedLast(lastSyncTimestamp);
    if (millis() - lastSync >= ONE_DAY_MILLIS)     //More than one day since last time sync
    {
        unsigned long cur = millis();
        Particle.syncTime();               //Request time synchronization from Particle Device Cloud
        waitUntil(Particle.syncTimeDone);  //Wait until Photon receives time from Particle Device Cloud or connection to Particle Device Cloud is lost
        if (Particle.timeSyncedLast() >= cur)          //Check if synchronized successfully
        {
            //do some daily clean up operations here
        }
    }
}