     }
     cycle = (cycle + 1) % 6000;
     ApplicationMonitor.IAmAlive();
+    unsigned long thisWatchTime = micros();
+    if(thisWatchTime > lastWatchTime) {
+      lastWatch = thisWatchTime - lastWatchTime;
+    } else {
+      lastWatch = 4294967295 - lastWatchTime + thisWatchTime;
+    }
+    lastWatchTime = thisWatchTime;
+    if(lastWatch > maxWatch) {
+      maxWatch = lastWatch;
+    }
     delay(100);
   }
 }

  http->LogMessage(buf);
}

void writeStatus() {
  char buf[128];
  PString pBuf(buf, 128);
  pBuf << "Status: free memory: " << freeMemory() << ", Lowest: " << http->_minFreeMemory;
  http->LogMessage(buf);
}


  startupDelay();
  
  ApplicationMonitor.EnableWatchdog(Watchdog::CApplicationMonitor::Timeout_8s);
  unsigned long lastWatchTime = micros();
  unsigned long lastWatch = 0;
  unsigned long maxWatch = 0;
    
  int cycle = 0;  
  http->LogMessage("Primary loop initialized");
