back at work.. and moving ahead..
I skip to the loop() function..
as I dont understand 'much' above... or how, in general, you 'talk' with the RFID card.. i thought I had proposed it correctly above?
anyways.. getting to the main loop..
seems it a huge 'check' over and over..
update a var called status (with different values or calls/writes to the card).. then an immediate check on the new/current state of 'status'...
I found (by running test sketch/and looking at print out text) the 'section' where it just 'checks' for a card/id in the area..
void loop()
{
status = MFRC522_Request(PICC_REQIDL, str);
if (status == MI_OK)
{
Serial.println("CARD IN PROXIMITY....CHECKING");
//Serial.print(str[0],BIN);
//Serial.print(" , ");
//Serial.print(str[1],BIN);
//Serial.println(" ");
//delay(1000);
}
//Serial.println(" ");
MFRC522_Halt(); // calls a fucntion outlined later in the sketch but above my knowledge to know exactly what it is doing
delay(200); //I added this to delay the speed of the 'checks' for now..
//which bring us/me to the first part of the code I sorta identify as the CARD PROXIMITY CHECKING code snippet
status = MFRC522_Request(PICC_REQIDL, str); //updating 'status' to be a function/result/return of MFRC522_Request(PICC_REQIDL, str) **** (function posted below)
//now check status value against some conditions
if (status == MI_OK)
{
Serial.println("CARD IN PROXIMITY....CHECKING");
//Serial.print(str[0],BIN);
//Serial.print(" , ");
//Serial.print(str[1],BIN);
//Serial.println(" ");
//delay(1000);
}
}
I wish there was some better documentation on the functions/methods available in this class/lib.. =(
but this function:
MFRC522_Request(); seems to be the method available for checking/seeing if there is an RFID in the area
I commented out the print() lines... because Im not really 'sure' what/where those values are coming from?
seems to be printing out the values/index's of an array (str[])..and outputting it in binary? but str[] is? how it got populated to begine with and with what? (and why print it out now) Im still un clear about)
just to make things easier for anyone curious or following along on this thread.. here are the full methods that are called above.
function from above:
uchar MFRC522_Request(uchar reqMode, uchar *TagType)
{
uchar status;
uint backBits; //????????
Write_MFRC522(BitFramingReg, 0x07); //TxLastBists = BitFramingReg[2..0] ???
TagType[0] = reqMode;
status = MFRC522_ToCard(PCD_TRANSCEIVE, TagType, 1, TagType, &backBits);
if ((status != MI_OK) || (backBits != 0x10))
{
status = MI_ERR;
}
return status;
}
HALT function noted above:
void MFRC522_Halt(void)
{
uchar status;
uint unLen;
uchar buff[4];
buff[0] = PICC_HALT;
buff[1] = 0;
CalulateCRC(buff, 2, &buff[2]);
status = MFRC522_ToCard(PCD_TRANSCEIVE, buff, 4, buff,&unLen);
}
I have played with some Arduino sketches before.. timers, no delays.. using interrupts.. matrix set-up's..etc..
but the RFID (or at least this library/version) if rather difficult learning curve.. and not what "I" am used to as far as good documentation (probably just spoiled!)
anyways.. moving on.. just going to try and figure out
- see what that 'sectorNewKeyA' stuff is all about.. and how you actually change that password/key
- what section(s) on the card 'can' be written to to hold certain data.
- figure out to write to one of the custom/user allowed, writable areas