Skip to content

Commit 8c2e3c5

Browse files
committed
Update example Copy MSD
1 parent 69df5fb commit 8c2e3c5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Examples/NFCopy-MSD/NFCopy-MSD.ino

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ void blink(int pin, int msdelay, int times){
8080
}
8181
}
8282

83+
void printData(uint8_t* buff, uint8_t lenbuffer, bool cmd){
84+
char tmp[1];
85+
86+
if (cmd)
87+
Serial.print("Reader command: ");
88+
else
89+
Serial.print("\nNFC Copy Cat answer: ");
90+
91+
for (uint8_t u = 0; u < lenbuffer; u++) {
92+
sprintf(tmp, "0x%.2X",buff[u]);
93+
Serial.print(tmp); Serial.print(" ");
94+
}
95+
96+
if (!cmd)
97+
Serial.println("\n-----");
98+
}
99+
83100
void runTarget(){ //Target emulation mode using a pre-saved token
84101
bool success;
85102
uint8_t apdubuffer[255]= {}, apdulen;
@@ -102,9 +119,13 @@ void runTarget(){ //Target emulation mode using a pre-saved token
102119
nfc.AsTarget();
103120
success = nfc.getDataTarget(apdubuffer, &apdulen);
104121
if (apdulen){
122+
printData(apdubuffer, apdulen, true);
105123
for (uint8_t i = 0; i < 6; i++){
106124
nfc.setDataTarget(apdus[i], apdusLen[i]);
125+
printData(apdus[i], apdusLen[i], false);
126+
107127
nfc.getDataTarget(apdubuffer, &apdulen);
128+
printData(apdubuffer, apdulen, true);
108129
}
109130
Serial.println("Emulated!");
110131
}

0 commit comments

Comments
 (0)