 
 }
 
+void sleepNowForFailedConnect(unsigned long sleepMillis, unsigned long millisSinceSystemStart)
+{
+  systemState.connectMillisCumulated += millisSinceSystemStart;
+
+  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
+}
+
 void sleepNowForServer(short serverSecondsUntilOff, unsigned long systemOnMillis)
 {
   unsigned long sleepMillis = 1;

  }
  Serial.println(millis()-systemStart);

  systemState.connectMillisCumulated = 0;
  // TODO write

  WiFiClient client;
  if (!client.connect(IPAddress(192,168,122,1), 80)) {
    Serial.println("Server connect failed.. Sleeping");

    // TODO consider invain threshold
    ESP.deepSleep(14e6, RF_NO_CAL);
  }
  
  // NOTE/ TODO system start time must also be taken into account
  unsigned long connectionTime = millis();

    h = bme.readHumidity();

    if (isnan(t) || isnan(h)) {
      delay(100);
      t = bme.readTemperature() - 1;
      h = bme.readHumidity();

      if (isnan(t) || isnan(h)) {
        Serial.println("Ooop Cannot get meaningful values..Sleeping");

        // Sleep only light (see below commented)?
        ESP.deepSleep(3e6);
      }
    }
    
    //*
    if (systemState.roundsWithoutTransmission < 5) {
