 #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

void reportStats() {
  char buff[255];
  snprintf(buff, sizeof(buff),
           "[%s] alive-uptime %02ld:%02ld "
           "mqtt: %s (state %d) "
           "swipes %ld, opens %ld, closes %ld, fails %ld, mis-swipes %ld, mqtt reconnects %ld, mqtt fails %ld, "
           "door %s, state %s(%d)",
           pname, cnt_minutes / 60, (cnt_minutes % 60),
           client.connected() ? "connected" : "not-connected", client.state(),
           cnt_cards,
           cnt_opens, cnt_closes, cnt_fails, cnt_misreads, cnt_reconnects, cnt_mqttfails,
           isOpen() ? "open" : "closed",
           doorstates_names[doorstate], doorstate
          );
  client.publish(log_topic, buff);
  Serial.println(buff);
