   digitalWrite(YELLOW, HIGH);
   digitalWrite(GREEN, LOW);
   
-  if (espActive) {
+  if (ESP_ACTIVE) {
     if (!sendATConnectServer()) return false;
     if (!sendATPrepareUnlockDoor()) return false;
     if (!sendATUnlockDoor()) return false;

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

  digitalWrite(YELLOW, LOW);
  digitalWrite(GREEN, LOW);
  
  if (ESP_ACTIVE) {
    if (!sendATConnectServer()) return false;
    if (!sendATPrepareLockDoor()) return false;
    if (!sendATLockDoor()) return false;
