   while (WiFi.status() != WL_CONNECTED) {
     unsigned long now = millis();
     if (now - connectStart > 5000) {
-      unsigned long sleepMillis = 5000;
-      systemState.connectMillisCumulated += now - systemStart;
-
-      if (systemState.connectMillisCumulated >= connectInvainThreshold) {
-        systemState.connectMillisCumulated = 0;
-        sleepMillis = 45 * 60 * 1000L; // sleep long
-      }
-      
-      systemState.writeToRtc(0, sizeof(SystemState));
-
-      Serial.print("Waiting ");
-      Serial.println(sleepMillis);
-      
-      ESP.deepSleep(sleepMillis * 1000, RF_NO_CAL); // NOTE this must be taken plus the wait time above
+      sleepNowForFailedConnect(5000L, now - systemStart);
 
       /*
       // This has 15mA instead of 70mA (above) or 1mA with deep sleep


}

void sleepNowForServer(short serverSecondsUntilOff, unsigned long systemOnMillis)
{
  unsigned long sleepMillis = 1;

  } else {
    bme_ok = true;
  }

  // TODO get rid of dummy values
  randomSeed(analogRead(A0));
  float t = 49.7 + random(7);
  float h = 76.5 - random(5);
