Remove turn signal & sonar, add RFID auth
Define AUTH_UID and AUTH_UID_SIZE constants. Introduce motor control pins IN_1‑IN_4 and set them as outputs. Comment out turn‑signal and sonar pin definitions and related code. Refactor Display to remove updateDirection functionality. Extend RFIDReader with reset() and matches() methods; use them to toggle carEnabled based on RFID authentication. Update the main loop to operate only when the RFID tag matches the authorized UID.
This commit is contained in:
@@ -11,18 +11,30 @@ void RFIDReader::begin() {
|
||||
bool RFIDReader::check() {
|
||||
if (!_rfid.PICC_IsNewCardPresent()) return false;
|
||||
if (!_rfid.PICC_ReadCardSerial()) return false;
|
||||
// _rfid.PICC_HaltA(); // stop the tag
|
||||
// _rfid.PCD_StopCrypto1(); // clear RC522 crypto
|
||||
return true;
|
||||
}
|
||||
|
||||
void RFIDReader::reset() {
|
||||
_rfid.PICC_HaltA();
|
||||
_rfid.PCD_StopCrypto1();
|
||||
}
|
||||
|
||||
bool RFIDReader::matches(const byte* expectedUid, byte expectedSize) const {
|
||||
if (_rfid.uid.size != expectedSize) return false;
|
||||
for (byte i = 0; i < expectedSize; ++i) {
|
||||
if (_rfid.uid.uidByte[i] != expectedUid[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RFIDReader::printUID() const {
|
||||
Serial.print(F("RFID Tag UID:"));
|
||||
for (byte i = 0; i < _rfid.uid.size; i++) {
|
||||
Serial.print(_rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
|
||||
Serial.print(_rfid.uid.uidByte[i], HEX);
|
||||
}
|
||||
Serial.println();
|
||||
Serial.println(F("RFID Tag UID:"));
|
||||
// for (byte i = 0; i < _rfid.uid.size; i++) {
|
||||
// Serial.print(_rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
|
||||
// Serial.print(_rfid.uid.uidByte[i], HEX);
|
||||
// }
|
||||
}
|
||||
|
||||
const byte* RFIDReader::getUID() const {
|
||||
|
||||
Reference in New Issue
Block a user