From 979430ecd1989911e854c6441a87cefbd292a0d2 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 13 Oct 2010 19:17:51 +0000 Subject: [PATCH] nfc_target_t have now nfc_modulation_t instead of nfc_modulatation_type_t --- examples/nfc-dep-target.c | 3 ++- examples/nfc-emulate-forum-tag4.c | 3 ++- examples/nfc-emulate-tag.c | 9 ++++++--- examples/nfc-emulate-uid.c | 3 ++- examples/nfc-poll.c | 2 +- examples/nfc-relay.c | 3 ++- examples/nfc-utils.c | 31 +++++++++++++++++++++++++------ examples/pn53x-sam.c | 3 ++- include/nfc/nfc-types.h | 3 ++- libnfc/chips/pn53x.c | 6 +++--- 10 files changed, 47 insertions(+), 19 deletions(-) diff --git a/examples/nfc-dep-target.c b/examples/nfc-dep-target.c index c140c81..1af716e 100644 --- a/examples/nfc-dep-target.c +++ b/examples/nfc-dep-target.c @@ -66,7 +66,8 @@ main (int argc, const char *argv[]) } const nfc_target_t nt = { - .nmt = NMT_DEP, + .nm.nmt = NMT_DEP, + .nm.nbr = NBR_UNDEFINED, .nti.ndi.abtNFCID3 = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff, 0x00, 0x00 }, .nti.ndi.szGB = 4, .nti.ndi.abtGB = { 0x12, 0x34, 0x56, 0x78 }, diff --git a/examples/nfc-emulate-forum-tag4.c b/examples/nfc-emulate-forum-tag4.c index e05c6b9..11b3c50 100644 --- a/examples/nfc-emulate-forum-tag4.c +++ b/examples/nfc-emulate-forum-tag4.c @@ -112,7 +112,8 @@ main (int argc, char *argv[]) printf ("Emulating NDEF tag now, please touch it with a second NFC device\n"); nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x00, 0x04 }, .nti.nai.abtUid = { 0x08, 0x00, 0xb0, 0x0b }, .nti.nai.btSak = 0x20, diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index 8523947..7ea2cff 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -173,7 +173,8 @@ main (int argc, char *argv[]) // Example of a Mifare Classic Mini // Note that crypto1 is not implemented in this example nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x00, 0x04 }, .nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef }, .nti.nai.btSak = 0x09, @@ -183,7 +184,8 @@ main (int argc, char *argv[]) /* // Example of a FeliCa nfc_target_t nt = { - .nmt = NMT_FELICA, + .nm.nmt = NMT_FELICA, + .nm.nbr = NBR_UNDEFINED, .nti.nfi.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF }, .nti.nfi.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF }, .nti.nfi.abtSysCode = { 0xFF, 0xFF }, @@ -192,7 +194,8 @@ main (int argc, char *argv[]) /* // Example of a ISO14443-4 (DESfire) nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x03, 0x44 }, .nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef }, .nti.nai.btSak = 0x20, diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index 407fad2..be56d0c 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -132,7 +132,8 @@ main (int argc, char *argv[]) // Note: We have to build a "fake" nfc_target_t in order to do exactly the same that was done before the new nfc_target_init() was introduced. nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x04, 0x00 }, .nti.nai.abtUid = { 0xde, 0xad, 0xbe, 0xaf }, .nti.nai.btSak = 0x20, diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 5a22414..81e4443 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -117,7 +117,7 @@ main (int argc, const char *argv[]) uint8_t n; printf ("%ld target(s) have been found.\n", (unsigned long) szTargetFound); for (n = 0; n < szTargetFound; n++) { - printf ("T%d: targetType=%02x ", n + 1, antTargets[n].nmt); + printf ("T%d: ", n + 1); print_nfc_target ( antTargets[n] ); } diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index 64e1c8f..4550633 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -127,7 +127,8 @@ main (int argc, char *argv[]) printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n"); nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x04, 0x00 }, .nti.nai.abtUid = { 0xde, 0xad, 0xbe, 0xef }, .nti.nai.btSak = 0x20, diff --git a/examples/nfc-utils.c b/examples/nfc-utils.c index 4ec7804..dfcea21 100644 --- a/examples/nfc-utils.c +++ b/examples/nfc-utils.c @@ -255,28 +255,47 @@ parse_device_desc (int argc, const char *argv[], size_t * szFound) return pndd; } +const char * +str_nfc_baud_rate (const nfc_baud_rate_t nbr) +{ + switch(nbr) { + case NBR_UNDEFINED: + return "undefined baud rate"; + break; + case NBR_106: + return "106 kbps"; + break; + case NBR_212: + return "212 kbps"; + break; + case NBR_424: + return "424 kbps"; + break; + } +} + void print_nfc_target (const nfc_target_t nt) { - switch(nt.nmt) { + switch(nt.nm.nmt) { case NMT_ISO14443A: - printf ("ISO/IEC 14443A target:\n"); + printf ("ISO/IEC 14443A (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_iso14443a_info (nt.nti.nai); break; case NMT_JEWEL: - printf ("Innovision Jewel target:\n"); + printf ("Innovision Jewel (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_jewel_info (nt.nti.nji); break; case NMT_FELICA: - printf ("FeliCa target:\n"); + printf ("FeliCa (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_felica_info (nt.nti.nfi); break; case NMT_ISO14443B: - printf ("ISO/IEC 14443-4B target:\n"); + printf ("ISO/IEC 14443-4B (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_iso14443b_info (nt.nti.nbi); break; case NMT_DEP: - printf ("D.E.P. target:\n"); + printf ("D.E.P. (%s) target:\n", str_nfc_baud_rate(nt.nm.nbr)); print_nfc_dep_info (nt.nti.ndi); break; } diff --git a/examples/pn53x-sam.c b/examples/pn53x-sam.c index 6b245b5..1f3dee4 100644 --- a/examples/pn53x-sam.c +++ b/examples/pn53x-sam.c @@ -202,7 +202,8 @@ main (int argc, const char *argv[]) size_t szRx; nfc_target_t nt = { - .nmt = NMT_ISO14443A, + .nm.nmt = NMT_ISO14443A, + .nm.nbr = NBR_UNDEFINED, .nti.nai.abtAtqa = { 0x04, 0x00 }, .nti.nai.abtUid = { 0x08, 0xad, 0xbe, 0xaf }, .nti.nai.btSak = 0x20, diff --git a/include/nfc/nfc-types.h b/include/nfc/nfc-types.h index 0b3a0d0..51d7628 100644 --- a/include/nfc/nfc-types.h +++ b/include/nfc/nfc-types.h @@ -268,6 +268,7 @@ typedef enum { * @brief NFC baud rate enumeration */ typedef enum { + NBR_UNDEFINED = 0, NBR_106, NBR_212, NBR_424, @@ -301,7 +302,7 @@ typedef struct { */ typedef struct { nfc_target_info_t nti; - nfc_modulation_type_t nmt; + nfc_modulation_t nm; } nfc_target_t; // Reset struct alignment to default diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 3ccfd94..6a43ce5 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -652,7 +652,7 @@ pn53x_InAutoPoll (nfc_device_t * pnd, /* 1st target */ // Target type pn53x_target_type_t ptt = *(pbt++); - pntTargets[0].nmt = pn53x_ptt_to_nmt(ptt); + pntTargets[0].nm.nmt = pn53x_ptt_to_nmt(ptt); // AutoPollTargetData length ln = *(pbt++); pn53x_decode_target_data (pbt, ln, pnd->nc, ptt, &(pntTargets[0].nti)); @@ -662,7 +662,7 @@ pn53x_InAutoPoll (nfc_device_t * pnd, /* 2nd target */ // Target type ptt = *(pbt++); - pntTargets[1].nmt = pn53x_ptt_to_nmt(*(pbt++)); + pntTargets[1].nm.nmt = pn53x_ptt_to_nmt(*(pbt++)); // AutoPollTargetData length ln = *(pbt++); pn53x_decode_target_data (pbt, ln, pnd->nc, ptt, &(pntTargets[1].nti)); @@ -1115,7 +1115,7 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_ta const byte_t * pbtGB = NULL; size_t szGB = 0; - switch(nt.nmt) { + switch(nt.nm.nmt) { case NMT_ISO14443A: { // Set ATQA (SENS_RES) abtMifareParams[0] = nt.nti.nai.abtAtqa[1];