From aa2871dc98087ee71893ae9765cb94cdf082a854 Mon Sep 17 00:00:00 2001 From: Nadeflore Date: Thu, 7 Nov 2013 12:43:23 +0100 Subject: [PATCH] fixed slotted readers emulation bug --- acrealio/RR10.h | 1 - acrealio/Reader.cpp | 39 ++++++++++++++++++++++++++++----------- acrealio/Reader.h | 6 +++--- acrealio/acrealio.ino | 2 +- acrealio/pinoutconfig.h | 10 +++++----- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/acrealio/RR10.h b/acrealio/RR10.h index a5615ea..9486f6d 100644 --- a/acrealio/RR10.h +++ b/acrealio/RR10.h @@ -32,7 +32,6 @@ private: byte rfidp[256]; // rfid response buffer byte rf_i; //response buffer size - //(who needs enum type ?) }; #endif diff --git a/acrealio/Reader.cpp b/acrealio/Reader.cpp index f1fd814..294bdd7 100644 --- a/acrealio/Reader.cpp +++ b/acrealio/Reader.cpp @@ -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) diff --git a/acrealio/Reader.h b/acrealio/Reader.h index 623b38d..f2ecec4 100644 --- a/acrealio/Reader.h +++ b/acrealio/Reader.h @@ -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 diff --git a/acrealio/acrealio.ino b/acrealio/acrealio.ino index 24f491e..6702482 100644 --- a/acrealio/acrealio.ino +++ b/acrealio/acrealio.ino @@ -68,7 +68,7 @@ Reader nod1;//first reader Reader nod2;//second reader Ddr nod3; - +//LedBoard nod3("LEDB");//led board #endif diff --git a/acrealio/pinoutconfig.h b/acrealio/pinoutconfig.h index ea42468..7b7c272 100644 --- a/acrealio/pinoutconfig.h +++ b/acrealio/pinoutconfig.h @@ -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