- ComputeCrc14443(CRC_14443_A, response3a, 1, &response3a[1], &response3a[2]);
-
-
-/*
- // Check if the uid uses the (optional) second part
- if (uid_2nd) {
- // Configure the ATQA and SAK accordingly
- response1[0] |= 0x40;
- sak |= 0x04;
- }
-*/
-
-//static const uint8_t response2a[] = { 0x51, 0x48, 0x1d, 0x80, 0x84 }; // uid - cascade2 - 2nd half (4 bytes) of UID+ BCCheck
-
-
- // Prepare protocol messages
- // static const uint8_t cmd1[] = { 0x26 };
-// static const uint8_t response1[] = { 0x02, 0x00 }; // Says: I am Mifare 4k - original line - greg
-//
-// uint8_t response1[] = { 0x44, 0x03 }; // Says: I am a DESFire Tag, ph33r me
-// static const uint8_t response1[] = { 0x44, 0x00 }; // Says: I am a ULTRALITE Tag, 0wn me
-
- // UID response
- // static const uint8_t cmd2[] = { 0x93, 0x20 };
- //static const uint8_t response2[] = { 0x9a, 0xe5, 0xe4, 0x43, 0xd8 }; // original value - greg
-
-// my desfire
-// uint8_t response2[] = { 0x88, 0x04, 0x21, 0x3f, 0x4d }; // known uid - note cascade (0x88), 2nd byte (0x04) = NXP/Phillips
-
-
-// When reader selects us during cascade1 it will send cmd3
-//uint8_t response3[] = { 0x04, 0x00, 0x00 }; // SAK Select (cascade1) successful response (ULTRALITE)
-//uint8_t response3[] = { 0x24, 0x00, 0x00 }; // SAK Select (cascade1) successful response (DESFire)
-//ComputeCrc14443(CRC_14443_A, response3, 1, &response3[1], &response3[2]);
-
-// send cascade2 2nd half of UID
-//static const uint8_t response2a[] = { 0x51, 0x48, 0x1d, 0x80, 0x84 }; // uid - cascade2 - 2nd half (4 bytes) of UID+ BCCheck
-// NOTE : THE CRC on the above may be wrong as I have obfuscated the actual UID
-
-// When reader selects us during cascade2 it will send cmd3a
-//uint8_t response3a[] = { 0x00, 0x00, 0x00 }; // SAK Select (cascade2) successful response (ULTRALITE)
-//uint8_t response3a[] = { 0x20, 0x00, 0x00 }; // SAK Select (cascade2) successful response (DESFire)
-//ComputeCrc14443(CRC_14443_A, response3a, 1, &response3a[1], &response3a[2]);
-
- static const uint8_t response5[] = { 0x00, 0x00, 0x00, 0x00 }; // Very random tag nonce
-
- uint8_t *resp;
- int respLen;
-
- // Longest possible response will be 16 bytes + 2 CRC = 18 bytes
- // This will need
- // 144 data bits (18 * 8)
- // 18 parity bits
- // 2 Start and stop
- // 1 Correction bit (Answer in 1172 or 1236 periods, see FPGA)
- // 1 just for the case
- // ----------- +
- // 166
- //
- // 166 bytes, since every bit that needs to be send costs us a byte
- //
-
- // Respond with card type
- uint8_t *resp1 = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET);
- int resp1Len;
-
- // Anticollision cascade1 - respond with uid
- uint8_t *resp2 = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET + 166);
- int resp2Len;
-
- // Anticollision cascade2 - respond with 2nd half of uid if asked
- // we're only going to be asked if we set the 1st byte of the UID (during cascade1) to 0x88
- uint8_t *resp2a = (((uint8_t *)BigBuf) + 1140);
- int resp2aLen;
-
- // Acknowledge select - cascade 1
- uint8_t *resp3 = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET + (166*2));
- int resp3Len;
-
- // Acknowledge select - cascade 2
- uint8_t *resp3a = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET + (166*3));
- int resp3aLen;
-
- // Response to a read request - not implemented atm
- uint8_t *resp4 = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET + (166*4));
- int resp4Len;
-
- // Authenticate response - nonce
- uint8_t *resp5 = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET + (166*5));
- int resp5Len;
-
- uint8_t *receivedCmd = (((uint8_t *)BigBuf) + RECV_CMD_OFFSET);
-// uint8_t *receivedCmd = (uint8_t *)BigBuf;
- int len;
-
- //int i;
- //int u;
- //uint8_t b;
-
- // To control where we are in the protocol
- int order = 0;
- int lastorder;
-
- // Just to allow some checks
- int happened = 0;
- int happened2 = 0;
-
- int cmdsRecvd = 0;
- uint8_t* respdata = NULL;
- int respsize = 0;
- uint8_t nack = 0x04;
-
- //int fdt_indicator;
-
- memset(receivedCmd, 0x44, RECV_CMD_SIZE);
-
- // Prepare the responses of the anticollision phase
- // there will be not enough time to do this at the moment the reader sends it REQA
-
- // Answer to request
- CodeIso14443aAsTag(response1, sizeof(response1));
- memcpy(resp1, ToSend, ToSendMax); resp1Len = ToSendMax;
-
- // Send our UID (cascade 1)
- CodeIso14443aAsTag(response2, sizeof(response2));
- memcpy(resp2, ToSend, ToSendMax); resp2Len = ToSendMax;
-
- // Answer to select (cascade1)
- CodeIso14443aAsTag(response3, sizeof(response3));
- memcpy(resp3, ToSend, ToSendMax); resp3Len = ToSendMax;