- r2t_time = GetCountSspClk();
- //Signal tracer
- LED_C_ON();
-
- // Okay, look at the command now.
- if(receivedCmd[0] == 0x0a ) {
- // Reader in anticollission phase
- modulated_response = resp1; modulated_response_size = resp1Len; //order = 1;
- trace_data = response1;
- trace_data_size = sizeof(response1);
- } else if(receivedCmd[0] == 0x0c) {
- // Reader asks for anticollission CSN
- modulated_response = resp2; modulated_response_size = resp2Len; //order = 2;
- trace_data = response2;
- trace_data_size = sizeof(response2);
- //DbpString("Reader requests anticollission CSN:");
- } else if(receivedCmd[0] == 0x81) {
- // Reader selects anticollission CSN.
- // Tag sends the corresponding real CSN
- modulated_response = resp3; modulated_response_size = resp3Len; //order = 3;
- trace_data = response3;
- trace_data_size = sizeof(response3);
- //DbpString("Reader selects anticollission CSN:");
- } else if(receivedCmd[0] == 0x88) {
- // Read e-purse (88 02)
- modulated_response = resp4; modulated_response_size = resp4Len; //order = 4;
- trace_data = response4;
- trace_data_size = 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 quiet
- modulated_response = resp1; modulated_response_size = 0; //order = 5;
- trace_data = NULL;
- trace_data_size = 0;
- if (breakAfterMacReceived){
- // 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
- modulated_response = resp1; modulated_response_size = 0; //order = 0;
- trace_data = NULL;
- trace_data_size = 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
- modulated_response = resp1; modulated_response_size = 0; //order = 0;
- trace_data = NULL;
- trace_data_size = 0;
- }
-
- if(cmdsRecvd > 100) {
- //DbpString("100 commands later...");
- //break;
- }
- else {
- cmdsRecvd++;
- }
- /**
- A legit tag has about 380us delay between reader EOT and tag SOF.
- **/
- if(modulated_response_size > 0) {
- SendIClassAnswer(modulated_response, modulated_response_size, 1);
- t2r_time = GetCountSspClk();
- }