miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.73k stars 1.42k forks source link

Message spam if the approximate card is not registered (how to solve it?) #592

Closed ogabrielborges closed 6 months ago

ogabrielborges commented 1 year ago

Hello, I have a problem as I don't know the library very well!

In my code, when receiving a valid and registered card, in "void handleRFID", it releases my lock and prints on the serial monitor, a message saying that the approximate card is registered.

And I have an else, which executes a print on the serial monitor if the approximate card is not registered.

It happens that whenever I approach an unregistered card, the serial monitor receives spam messages saying that the card is not registered.

How can I solve?

void handleRFID() {
    if (RFID_card_is_not_present()) return;

    String card_id            = get_RFID_card_ID();
    bool   RFID_card_is_valid = validate_RFID_card(card_id);

    if (RFID_card_is_valid) {
        Serial.printf("O cartao RFID \"%s\" e valido.\r\n", card_id.c_str());

        unlock_with_auto_relock();
        send_lock_state(false);
    } else {
        Serial.printf("O cartao RFID \"%s\" nao e valido.\r\n", card_id.c_str());
    }
}