 #else
 #define REPORTING_PERIOD        (10*1000)   //  10 seconds -- -- how often to report our states; in milli seconds.
 #define PREFIX "test"
+#define MQTT_KEEPALIVE          (10)        // seconds -- keep alive check; default is 2 minutes - but it is 
+// easier to keep this short during debugging - i.e. when testing breaking connections. Note that this may not
+// work if the Arduino CPP gets the order wrong.
 #endif
 
-
 typedef enum doorstates { CLOSED, CHECKINGCARD, OPEN } doorstate_t;
-const char doorstates_names[OPEN+1][15] = { "closed", "checking-card", "open" };
+const char doorstates_names[OPEN + 1][15] = { "closed", "checking-card", "open" };
 
 doorstate_t doorstate;
 unsigned long long last_doorstatechange = 0;


  if (lastdoorstate != doorstate) {
    char msg[255];
    snprintf(msg, sizeof(msg), "Change from state %s(%d) to (%s)%d\n",
             doorstates_names[lastdoorstate], lastdoorstate, doorstates_names[doorstate], doorstate);
    Serial.println(msg);
#ifndef LOCALMQTT

  {
    static unsigned long tock = 0;
    if (millis() - tock > REPORTING_PERIOD) {
      static unsigned long last_min = 0;
      unsigned long delta = millis() - last_min;
      unsigned int mins = delta / 60 / 1000;
      if (mins > 0) {
        cnt_minutes += mins;
        last_min += mins * 60 * 1000;
      }
      reportStats();
      tock = millis();
    }
