   Connect2Wifi();
 }
 
-void loop() {
+void loop() 
+{
   CloseDoor();
 
-  //prepare the key "xinfab" to the card
-  MFRC522::MIFARE_Key newKey;
-  newKey.keyByte[0] = 0x78;
-  newKey.keyByte[1] = 0x69;
-  newKey.keyByte[2] = 0x6e;
-  newKey.keyByte[3] = 0x66;
-  newKey.keyByte[4] = 0x61;
-  newKey.keyByte[5] = 0x62;
-
   // Look for new cards
-  if (!mfrc522.PICC_IsNewCardPresent()) {
+  if (!mfrc522.PICC_IsNewCardPresent()) 
+  {
     delay(50);
     return;
   }
   // Select one of the cards
-  if (!mfrc522.PICC_ReadCardSerial()) {
+  if (!mfrc522.PICC_ReadCardSerial()) 
+  {
     delay(50);
     return;
   }


    //wait for response and set time out
    unsigned long timeout = millis();
    while (client.available() == 0) {
      if (millis() - timeout > 3000) {
        Serial.println(">>> Client Timeout !");
        client.stop();
        return;
      }
    }

    while (client.available()) {
      String line = client.readStringUntil('\n');
      if (DEBUGMODE) Serial.println(line);
      if (line == "\r") {
        if (DEBUGMODE) Serial.println("headers received");
      }
      if (line.startsWith("state:success")) {
        //if (DEBUGMODE) Serial.println(line);
        if (DEBUGMODE) Serial.println("Receive response successfull!");
            OpenDoor();
        break;
      }
      if (line.startsWith("state:fail")) {   
        warnForNoAuthCard();
        break;
      }

        digitalWrite(Buzzer,LOW);
}

//di~-di--di~-di
void warnForNoServer() 
{
        digitalWrite(Buzzer,HIGH);
        delay (1000); 
        digitalWrite(Buzzer,LOW);
