- if(!GetIClassCommandFromReader(receivedCmd, &len, 100)) {
- buttonPressed = true;
- break;
- }
- r2t_time = GetCountSspClk();
- //Signal tracer
- LED_C_ON();
-
- // Okay, look at the command now.
- if(receivedCmd[0] == 0x0a ) {
- // Reader in anticollission phase
- resp = resp1; respLen = resp1Len; //order = 1;
- respdata = &sof;
- respsize = sizeof(sof);
- } else if(receivedCmd[0] == 0x0c) {
- // Reader asks for anticollission CSN
- resp = resp2; respLen = resp2Len; //order = 2;
- respdata = response2;
- respsize = sizeof(response2);
- //DbpString("Reader requests anticollission CSN:");
- } else if(receivedCmd[0] == 0x81) {
- // Reader selects anticollission CSN.
- // Tag sends the corresponding real CSN
- resp = resp3; respLen = resp3Len; //order = 3;
- respdata = response3;
- respsize = sizeof(response3);
- //DbpString("Reader selects anticollission CSN:");
- } else if(receivedCmd[0] == 0x88) {
- // Read e-purse (88 02)
- resp = resp4; respLen = resp4Len; //order = 4;
- respdata = response4;
- respsize = sizeof(response4);
- LED_B_ON();
- } else if(receivedCmd[0] == 0x05) {
- // Reader random and reader MAC!!!
- // Do not respond
- // We do not know what to answer, so lets keep quit
- resp = resp1; respLen = 0; //order = 5;
- respdata = NULL;
- respsize = 0;
- if (breakAfterMacReceived){
- // TODO, actually return this to the caller instead of just
- // dbprintf:ing ...
- Dbprintf("CSN: %02x %02x %02x %02x %02x %02x %02x %02x",csn[0],csn[1],csn[2],csn[3],csn[4],csn[5],csn[6],csn[7]);
- Dbprintf("RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x",len,
- receivedCmd[0], receivedCmd[1], receivedCmd[2],
- receivedCmd[3], receivedCmd[4], receivedCmd[5],
- receivedCmd[6], receivedCmd[7], receivedCmd[8]);
- if (reader_mac_buf != NULL)
- {
- memcpy(reader_mac_buf,receivedCmd+1,8);
- }
- exitLoop = true;
- }
- } else if(receivedCmd[0] == 0x00 && len == 1) {
- // Reader ends the session
- resp = resp1; respLen = 0; //order = 0;
- respdata = NULL;
- respsize = 0;
- } else {
- //#db# Unknown command received from reader (len=5): 26 1 0 f6 a 44 44 44 44
- // Never seen this command before
- Dbprintf("Unknown command received from reader (len=%d): %x %x %x %x %x %x %x %x %x",
- len,
- receivedCmd[0], receivedCmd[1], receivedCmd[2],
- receivedCmd[3], receivedCmd[4], receivedCmd[5],
- receivedCmd[6], receivedCmd[7], receivedCmd[8]);
- // Do not respond
- resp = resp1; respLen = 0; //order = 0;
- respdata = NULL;
- respsize = 0;
- }