Arduino Door Opener

Arduino Door Opener

Project for opening door with logging in remote server with api, nfc, keypad, and code valitation from server. User must cross nfc card through nfc reader and enter his code with the keypad if enters for first time in the same date, else just cross the card. Guest can enter their one use code for entering. The codes and the cards are being setup though the custom symfony application in the remote server. Codes are beeing validating every time a user/guest enters.
bool loop_rfid_read() {
    if (!mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial()) {
        return false;
    }

    Debug.PrintDebug(F("**Card Detected:**"));
    DA.initClient();
    for (int i=0; i<4; i++) {
        readcard[i] = mfrc522.uid.uidByte[i];
        array_to_string(readcard, 4, str);
        memcpy(DA.client.cardUID, str, sizeof(str));
    }

    byte buffer[18];
    byte size = sizeof(buffer);

    //Read Name --->
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, BLOCK_NAME_AUTH, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("auth failed name..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    buffer[18] = "";
    size = sizeof(buffer);
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(BLOCK_NAME, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("read failed name..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    memcpy(DA.client.name, buffer, sizeof(DA.client.name));
    Debug.PrintDebug(DA.client.name);
    //<--- Read Name

    //Read Surname --->
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, BLOCK_SURNAME_AUTH, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("auth failed suname..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    buffer[18] = "";
    size = sizeof(buffer);
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(BLOCK_SURNAME, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("read failed suname..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    memcpy(DA.client.surname, buffer, sizeof(DA.client.surname));
    Debug.PrintDebug(DA.client.surname);
    //<--- Read Surname

    //Read HASH --->
    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, BLOCK_USER_HASH_AUTH, &key, &(mfrc522.uid));
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("auth failed hash..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    buffer[18] = "";
    size = sizeof(buffer);
    status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(BLOCK_USER_HASH, buffer, &size);
    if (status != MFRC522::STATUS_OK) {
        Debug.PrintDebug(F("read failed hash..."));
        mfrc522.PICC_HaltA();
        mfrc522.PCD_StopCrypto1();
        delay(1000);
        Debug.PrintDebug(F("**Wait New Card OK!**"));
        return false;
    }
    array_to_string(buffer, 16, DA.client.cardHash);
    Debug.PrintDebug(DA.client.cardHash);
    //<--- Read HASH

    Debug.PrintDebug(F("**Card Read OK!**"));

    mfrc522.PICC_HaltA();
    mfrc522.PCD_StopCrypto1();

    if (DA.getClientByCard()) {
        DA.checkClientCard();
    } else {
        DSTLed.DSLChangeStatus("error");
        DLCD.DLCDWrite("Problem With Server!",1);
        DLCD.DLCDClearLine(2);
        delay(2000);
        DLCD.DLCDInit();
        DSTLed.DSLChangeStatus("none");
    }

    Debug.PrintDebug(F("**Wait New Card OK!**"));
    return true;
}
Piece of code for loop through the nfc card. Waits for next card and reads the card info.
The project has an rfc reader, lcd screen for diplaying the state, network shield for communicating with the server, relay for opening the door, and leds for quick state view.
  • Photo 2020 10 17 14 36 48

  • Photo 2020 10 17 14 36 55

  • Photo 2020 10 17 14 36 58

  • Photo 2020 10 17 14 37 03

Continue reading

Joomla 2.5 Contact Form Correcting bootstrap classes for input and label

To correct the classes in the contact form for correct use with bootstrap, in the override default_form.php add the following:

<?php
$this->form->setFieldAttribute('contact_name', 'class', 'form-control');
$this->form->setFieldAttribute('contact_name', 'labelclass', 'control-label');
$this->form->setFieldAttribute('contact_email', 'class', 'form-control');
$this->form->setFieldAttribute('contact_email', 'labelclass', 'control-label');
$this->form->setFieldAttribute('contact_subject', 'class', 'form-control');
$this->form->setFieldAttribute('contact_subject', 'labelclass', 'control-label');
$this->form->setFieldAttribute('contact_message', 'class', 'form-control');
$this->form->setFieldAttribute('contact_message', 'labelclass', 'control-label');
$this->form->setFieldAttribute('contact_email_copy', 'class', 'form-control');
$this->form->setFieldAttribute('contact_email_copy', 'labelclass', 'control-label');
?>

joomla, contact form, class, bootstrap

Social