+
+ // set SAK based on cardsize
+ switch (cardsize) {
+ case '0': rSAKfinal[0] = 0x09; break; // Mifare Mini
+ case '2': rSAKfinal[0] = 0x10; break; // Mifare 2K
+ case '4': rSAKfinal[0] = 0x18; break; // Mifare 4K
+ default: rSAKfinal[0] = 0x08; // Mifare 1K
+ }
+ ComputeCrc14443(CRC_14443_A, rSAKfinal, 1, rSAKfinal + 1, rSAKfinal + 2);
+ if (MF_DBGLEVEL >= MF_DBG_INFO) {
+ Dbprintf("SAK: %02x", rSAKfinal[0]);
+ }
+
+ // set SAK for incomplete UID
+ rSAK1[0] = 0x04; // Bit 3 indicates incomplete UID
+ ComputeCrc14443(CRC_14443_A, rSAK1, 1, rSAK1 + 1, rSAK1 + 2);
+
+ // set ATQA based on cardsize and UIDlen
+ if (cardsize == '4') {
+ rATQA[0] = 0x02;
+ } else {
+ rATQA[0] = 0x04;
+ }
+ if (*uid_len == 7) {
+ rATQA[0] |= 0x40;
+ }
+ if (MF_DBGLEVEL >= MF_DBG_INFO) {
+ Dbprintf("ATQA: %02x %02x", rATQA[1], rATQA[0]);
+ }
+