Skip to content

Commit

Permalink
Update example Copy MSD
Browse files Browse the repository at this point in the history
  • Loading branch information
sabas1080 committed Apr 9, 2020
1 parent 69df5fb commit 8c2e3c5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Examples/NFCopy-MSD/NFCopy-MSD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ void blink(int pin, int msdelay, int times){
}
}

void printData(uint8_t* buff, uint8_t lenbuffer, bool cmd){
char tmp[1];

if (cmd)
Serial.print("Reader command: ");
else
Serial.print("\nNFC Copy Cat answer: ");

for (uint8_t u = 0; u < lenbuffer; u++) {
sprintf(tmp, "0x%.2X",buff[u]);
Serial.print(tmp); Serial.print(" ");
}

if (!cmd)
Serial.println("\n-----");
}

void runTarget(){ //Target emulation mode using a pre-saved token
bool success;
uint8_t apdubuffer[255]= {}, apdulen;
Expand All @@ -102,9 +119,13 @@ void runTarget(){ //Target emulation mode using a pre-saved token
nfc.AsTarget();
success = nfc.getDataTarget(apdubuffer, &apdulen);
if (apdulen){
printData(apdubuffer, apdulen, true);
for (uint8_t i = 0; i < 6; i++){
nfc.setDataTarget(apdus[i], apdusLen[i]);
printData(apdus[i], apdusLen[i], false);

nfc.getDataTarget(apdubuffer, &apdulen);
printData(apdubuffer, apdulen, true);
}
Serial.println("Emulated!");
}
Expand Down

0 comments on commit 8c2e3c5

Please sign in to comment.