#include <Arduino.h>
#include <MFRC522.h>
#include <rdm6300.h>
#include "utils.h"
#include "cardReader.h"

MFRC522CardReader::MFRC522CardReader(MFRC522 *reader) {
	iReader = reader;
}

bool MFRC522CardReader::isNewCardPresent() {
	return iReader->PICC_IsNewCardPresent() && iReader->PICC_ReadCardSerial();
}

String MFRC522CardReader::getCardUid() {
	return byteArrayAsHexString(iReader->uid.uidByte, iReader->uid.size);
}

RDM6300CardReader::RDM6300CardReader(Rdm6300 *reader) {
	iReader = reader;
}

bool RDM6300CardReader::isNewCardPresent() {
	return iReader->get_new_tag_id();
}

String RDM6300CardReader::getCardUid() {
	auto uid = iReader->get_tag_id();
	char buf[16];
	sprintf(buf, "%010u", uid);
	return {buf};
}
