fixed slotted readers emulation bug

main
Nadeflore 2013-11-07 12:43:23 +01:00
parent eb618cd999
commit aa2871dc98
5 changed files with 37 additions and 21 deletions

View File

@ -32,7 +32,6 @@ private:
byte rfidp[256]; // rfid response buffer
byte rf_i; //response buffer size
//(who needs enum type ?)
};
#endif

View File

@ -142,17 +142,22 @@ void Reader::getStatus(byte* buf)
// set status in buffer
// if a card is present, copy its uid
if(rfmodule->isCardPresent()){
rfmodule->getUID(buf+2);
} else {
for(int i=0;i<8;i++)
{
buf[2+i] = 0x00;
if(holdcard) //when simulating card holding, use stored uid
{
memcpy(buf+2,uid,8);
}
else
{
// if a card is present, copy its uid
if(rfmodule->isCardPresent()){
rfmodule->getUID(buf+2);
} else {
for(int i=0;i<8;i++)
{
buf[2+i] = 0x00;
}
}
}
}
@ -181,7 +186,8 @@ void Reader::getStatus(byte* buf)
// old readers sensors emulation
if(acceptcard && rfmodule->isCardPresent() == 1)//if reader is accepting cards and a card is detected, simulate old reader holding card
{
holdcard = true;
holdcard = true; //until card is ejected, we'll ignore new cards and simulate this card being hold in the reader
rfmodule->getUID(uid); // copy the current card uid
}
if(holdcard) //when holding card, both sensors are on and card is present
@ -300,6 +306,17 @@ short Reader::processRequest(byte* request, byte* answer)
break;
// sleep mode
case 0x3A:
answer[4] = 0x01;
answer[5] = 0x00;
break;
//
// key exchange (for popn new wavepass readers)

View File

@ -24,14 +24,14 @@ public:
virtual void getStatus(byte* buf);
void readRfid();
public:
private:
boolean acceptcard; // reader state, accepting cards or not (for emulating old readers)
boolean holdcard; // reader state, holding card or not (for emulating old readers)
byte uid[8]; // store uid of holding card (for emulating old readers)
private:
boolean keypadInitDone;
boolean keypadInitDone;
word keypad; // keys currently pressed
word keypad_old; // keys pressed before last read
byte keydown; // used to indicated rising edge on keys

View File

@ -68,7 +68,7 @@ Reader nod1;//first reader
Reader nod2;//second reader
Ddr nod3;
//LedBoard nod3("LEDB");//led board
#endif

View File

@ -57,16 +57,16 @@
/*
### Keypad 3x4 Matrix ###
(7)---(8)---(9)---> ROW 1
(7)---(8)---(9)---> ROW 4
| | |
(4)---(5)---(6)---> ROW 2
(4)---(5)---(6)---> ROW 3
| | |
(1)---(2)---(3)---> ROW 3
(1)---(2)---(3)---> ROW 2
| | |
(0)--(00)--([])---> ROW 4
(0)--(00)--([])---> ROW 1
| | |
V V V
COL A COL B COL C
COL C COL B COL A
*/
#define K1_A 27