 #define BLINK_COUNT 1
 #define BLINK_DURATION 500
 
-#define ESP_ACTIVE false
+#define ESP_ACTIVE true
 
 String commandLock = "GET /log_visit_state/0 HTTP/1.0\r\n\r\n";
 String commandUnlock = "GET /log_visit_state/1 HTTP/1.0\r\n\r\n";
 
 int gCount;
 int gLastState;
+bool gStateChanged = false;
 int gCourtesyDelay = 6;
 long gLastStateTimestamp;
 

void onLockStateChange() {
  long now = millis();
  int state = digitalRead(SWITCH);
  if (state != gLastState && now - gLastStateTimestamp > 50) {
    gLastStateTimestamp = millis();
    gLastState = state;
    if (gLastState == LOW) {
      sendLock();
    } else {
      sendUnlock();
    }
  }
}



  digitalWrite(GREEN, HIGH);

  if (!ESP_ACTIVE) {
    return; // bail to loop
  }
  
  // setup serial with esp-01
  digitalWrite(LED, HIGH);
  digitalWrite(GREEN, LOW);
  Serial.begin(115200);
  Serial.setTimeout(10000);

