37 #endif // HAVE_CONFIG_H
47 # define SUSP_TIME 1 // secs.
50 # include "../contrib/windows.h"
53 # define SUSP_TIME 1000 // msecs.
62 #define MAX_FRAME_LEN 264
63 #define TIMEOUT 60 // secs.
66 #define VIRTUAL_CARD_MODE 2
67 #define WIRED_CARD_MODE 3
68 #define DUAL_CARD_MODE 4
73 byte_t pncmd_sam_config[] = { 0xD4, 0x14, 0x00, 0x00 };
76 byte_t abtRx[MAX_FRAME_LEN];
79 pncmd_sam_config[2] = mode;
82 case VIRTUAL_CARD_MODE:
85 szCmd =
sizeof (pncmd_sam_config);
91 szCmd =
sizeof (pncmd_sam_config) - 1;
96 if (!pn53x_transceive (pnd, pncmd_sam_config, szCmd, abtRx, &szRx)) {
98 ERR (
"%s %d",
"Unable to execute SAMConfiguration command with mode byte:", mode);
113 while (secs < TIMEOUT) {
124 main (
int argc,
const char *argv[])
133 printf (
"%s use libnfc %s\n", argv[0], acLibnfcVersion);
139 ERR (
"%s",
"Unable to connect to NFC device.");
143 printf (
"Connected to NFC device: %s\n", pnd->
acName);
146 printf (
"\nSelect the communication mode:\n");
147 printf (
"[1] Virtual card mode.\n");
148 printf (
"[2] Wired card mode.\n");
149 printf (
"[3] Dual card mode.\n");
153 char input = getchar ();
154 int mode = input -
'0' + 1;
156 if (mode < VIRTUAL_CARD_MODE || mode > DUAL_CARD_MODE) {
157 ERR (
"%s",
"Invalid selection.");
161 sam_connection (pnd, mode);
164 case VIRTUAL_CARD_MODE:
167 printf (
"Now the SAM is readable for 1 minute from an external reader.\n");
172 case WIRED_CARD_MODE:
196 .nmt = NMT_ISO14443A,
200 nfc_perror (pnd,
"nfc_initiator_select_passive_target");
201 ERR (
"%s",
"Reading of SAM info failed.");
205 printf (
"The following ISO14443A tag (SAM) was found:\n\n");
206 print_nfc_iso14443a_info (nt.nti.nai,
true);
212 byte_t abtRx[MAX_FRAME_LEN];
216 .nm.nmt = NMT_ISO14443A,
217 .nm.nbr = NBR_UNDEFINED,
218 .nti.nai.abtAtqa = { 0x04, 0x00 },
219 .nti.nai.abtUid = { 0x08, 0xad, 0xbe, 0xef },
220 .nti.nai.btSak = 0x20,
221 .nti.nai.szUidLen = 4,
222 .nti.nai.szAtsLen = 0,
224 printf (
"Now both, NFC device (configured as target) and SAM are readables from an external NFC initiator.\n");
225 printf (
"Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
236 sam_connection (pnd, NORMAL_MODE);