Does using time_t still result in time rollover when using configTime?

tyczj0
Posts: 1
Joined: Tue Jun 04, 2019 12:39 am

Does using time_t still result in time rollover when using configTime?

Postby tyczj0 » Tue Jun 04, 2019 1:09 am

I am using my esp32 to connect to Google Cloud IoT Core and I am trying to track down very sporadic connectivity issues and it either has to be my connection to IoT Core or just the network connection

When the sketch starts I set the time on the board with

Code: Select all

configTime(0, 0, "pool.ntp.org", "time.nist.gov");
then to create the Json Web Token I check the time against the current expire time to see if it needs refreshing and I wonder if I am unable to connect sometimes because the time rolled back to zero?

here is my JWT refresh method

Code: Select all

String getJwt() {
  if (iss == 0 || time(nullptr) - iss > 82800) {
    iss = time(nullptr);
    Serial.print("Time");
    Serial.println(iss);
    Serial.println("Refreshing JWT");
    jwt = device->createJWT(iss);
    Serial.println(jwt);
  } else {
    Serial.println("Reusing still-valid JWT");
  }
  return jwt;
}
Do I need to handle things differently somehow?

Who is online

Users browsing this forum: Baidu [Spider] and 161 guests