From 2688de65009b7a7a87a9b8136addf797fef96ca2 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 21 Jul 2010 10:37:37 +0000 Subject: [PATCH] API change: nfc_initiator_select_tag() is now nfc_initiator_select_passive_target() AND nfc_initiator_deselect_tag() is now nfc_initiator_deselect_target() --- examples/doc/quick_start_example1.c | 2 +- examples/nfc-list.c | 8 ++++---- examples/nfc-mfclassic.c | 8 ++++---- examples/nfc-mfultralight.c | 4 ++-- examples/nfc-sam.c | 2 +- examples/nfcip-initiator.c | 2 +- include/nfc/nfc.h | 4 ++-- libnfc/nfc.c | 12 ++++++------ 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/doc/quick_start_example1.c b/examples/doc/quick_start_example1.c index 9810e37..b6c8c13 100644 --- a/examples/doc/quick_start_example1.c +++ b/examples/doc/quick_start_example1.c @@ -42,7 +42,7 @@ int main(int argc, const char* argv[]) printf("Connected to NFC reader: %s\n",pnd->acName); // Poll for a ISO14443A (MIFARE) tag - if (nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti)) { + if (nfc_initiator_select_passive_target(pnd,NM_ISO14443A_106,NULL,0,&nti)) { printf("The following (NFC) ISO14443A tag was found:\n"); printf(" ATQA (SENS_RES): "); print_hex(nti.nai.abtAtqa,2); printf(" UID (NFCID%c): ",(nti.nai.abtUid[0]==0x08?'3':'1')); print_hex(nti.nai.abtUid,nti.nai.szUidLen); diff --git a/examples/nfc-list.c b/examples/nfc-list.c index 67de9e9..f8d9d56 100644 --- a/examples/nfc-list.c +++ b/examples/nfc-list.c @@ -126,14 +126,14 @@ int main(int argc, const char* argv[]) printf("\nConnected to NFC reader: %s\n\n",pnd->acName); // Poll for a ISO14443A (MIFARE) tag - if (nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti)) + if (nfc_initiator_select_passive_target(pnd,NM_ISO14443A_106,NULL,0,&nti)) { printf("The following (NFC) ISO14443A tag was found:\n\n"); print_nfc_iso14443a_info (nti.nai); } // Poll for a Felica tag - if (nfc_initiator_select_tag(pnd,NM_FELICA_212,abtFelica,5,&nti) || nfc_initiator_select_tag(pnd,NM_FELICA_424,abtFelica,5,&nti)) + if (nfc_initiator_select_passive_target(pnd,NM_FELICA_212,abtFelica,5,&nti) || nfc_initiator_select_passive_target(pnd,NM_FELICA_424,abtFelica,5,&nti)) { printf("The following (NFC) Felica tag was found:\n\n"); printf("%18s","ID (NFCID2): "); print_hex(nti.nfi.abtId,8); @@ -141,7 +141,7 @@ int main(int argc, const char* argv[]) } // Poll for a ISO14443B tag - if (nfc_initiator_select_tag(pnd,NM_ISO14443B_106,(byte_t*)"\x00",1,&nti)) + if (nfc_initiator_select_passive_target(pnd,NM_ISO14443B_106,(byte_t*)"\x00",1,&nti)) { printf("The following (NFC) ISO14443-B tag was found:\n\n"); printf(" ATQB: "); print_hex(nti.nbi.abtAtqb,12); @@ -155,7 +155,7 @@ int main(int argc, const char* argv[]) } // Poll for a Jewel tag - if (nfc_initiator_select_tag(pnd,NM_JEWEL_106,NULL,0,&nti)) + if (nfc_initiator_select_passive_target(pnd,NM_JEWEL_106,NULL,0,&nti)) { // No test results yet printf("jewel\n"); diff --git a/examples/nfc-mfclassic.c b/examples/nfc-mfclassic.c index d186742..0efdbbe 100644 --- a/examples/nfc-mfclassic.c +++ b/examples/nfc-mfclassic.c @@ -152,7 +152,7 @@ authenticate (uint32_t uiBlock) return true; } - nfc_initiator_select_tag (pnd, NM_ISO14443A_106, mp.mpa.abtUid, 4, NULL); + nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, mp.mpa.abtUid, 4, NULL); } } @@ -179,7 +179,7 @@ read_card (void) // Show if the readout went well if (bFailure) { // When a failure occured we need to redo the anti-collision - if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { + if (!nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { printf ("!\nError: tag was removed\n"); return false; } @@ -240,7 +240,7 @@ write_card (void) // Show if the readout went well if (bFailure) { // When a failure occured we need to redo the anti-collision - if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { + if (!nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { printf ("!\nError: tag was removed\n"); return false; } @@ -426,7 +426,7 @@ main (int argc, const char *argv[]) printf ("Connected to NFC reader: %s\n", pnd->acName); // Try to find a MIFARE Classic tag - if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { + if (!nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { printf ("Error: no tag was found\n"); nfc_disconnect (pnd); exit (EXIT_FAILURE); diff --git a/examples/nfc-mfultralight.c b/examples/nfc-mfultralight.c index bbd67f0..f98e008 100644 --- a/examples/nfc-mfultralight.c +++ b/examples/nfc-mfultralight.c @@ -114,7 +114,7 @@ write_card (void) // Show if the readout went well if (bFailure) { // When a failure occured we need to redo the anti-collision - if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { + if (!nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { ERR ("tag was removed"); return false; } @@ -201,7 +201,7 @@ main (int argc, const char *argv[]) printf ("Connected to NFC reader: %s\n", pnd->acName); // Try to find a MIFARE Ultralight tag - if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { + if (!nfc_initiator_select_passive_target (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { ERR ("no tag was found\n"); nfc_disconnect (pnd); return 1; diff --git a/examples/nfc-sam.c b/examples/nfc-sam.c index 0aeb42d..3e7758f 100644 --- a/examples/nfc-sam.c +++ b/examples/nfc-sam.c @@ -145,7 +145,7 @@ int main(int argc, const char* argv[]) nfc_configure(pnd,NDO_ACTIVATE_FIELD,true); // Read the SAM's info - if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti)) { + if (!nfc_initiator_select_passive_target(pnd,NM_ISO14443A_106,NULL,0,&nti)) { ERR("%s", "Reading of SAM info failed."); return EXIT_FAILURE; } diff --git a/examples/nfcip-initiator.c b/examples/nfcip-initiator.c index 5c931de..fd447a4 100644 --- a/examples/nfcip-initiator.c +++ b/examples/nfcip-initiator.c @@ -66,7 +66,7 @@ int main(int argc, const char *argv[]) abtRecv[szRecvBits] = 0; printf("Received: %s\n", abtRecv); - nfc_initiator_deselect_tag(pnd); + nfc_initiator_deselect_target(pnd); nfc_disconnect(pnd); return 0; } diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index a81913c..3ac66be 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -61,9 +61,9 @@ NFC_EXPORT bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, /* NFC initiator: act as "reader" */ NFC_EXPORT bool nfc_initiator_init(const nfc_device_t* pnd); -NFC_EXPORT bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti); +NFC_EXPORT bool nfc_initiator_select_passive_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti); NFC_EXPORT bool nfc_initiator_select_dep_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtPidData, const size_t szPidDataLen, const byte_t* pbtNFCID3i, const size_t szNFCID3iDataLen, const byte_t *pbtGbData, const size_t szGbDataLen, nfc_target_info_t* pti); -NFC_EXPORT bool nfc_initiator_deselect_tag(const nfc_device_t* pnd); +NFC_EXPORT bool nfc_initiator_deselect_target(const nfc_device_t* pnd); NFC_EXPORT bool nfc_initiator_poll_targets(const nfc_device_t* pnd, const nfc_target_type_t* pnttTargetTypes, const size_t szTargetTypes, const byte_t btPollNr, const byte_t btPeriod, nfc_target_t* pntTargets, size_t* pszTargetFound); NFC_EXPORT bool nfc_initiator_transceive_bits(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar); NFC_EXPORT bool nfc_initiator_transceive_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index b5ceb88..aaa10c2 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -229,7 +229,7 @@ nfc_device_t* nfc_connect(nfc_device_desc_t* pndd) void nfc_disconnect(nfc_device_t* pnd) { // Release and deselect all active communications - nfc_initiator_deselect_tag(pnd); + nfc_initiator_deselect_target(pnd); // Disable RF field to avoid heating nfc_configure(pnd,NDO_ACTIVATE_FIELD,false); // Disconnect, clean up and release the device @@ -403,7 +403,7 @@ bool nfc_initiator_select_dep_target(const nfc_device_t* pnd, const nfc_modulati } /** - * @fn nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti) + * @fn nfc_initiator_select_passive_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti) * @brief Select a passive or emulated tag * @return Returns true if action was successfully performed; otherwise returns false. * @param pnd nfc_device_t struct pointer that represent currently used device @@ -414,7 +414,7 @@ bool nfc_initiator_select_dep_target(const nfc_device_t* pnd, const nfc_modulati * The NFC device will try to find the available passive tags. Some NFC devices are capable to emulate passive tags. The standards (ISO18092 and ECMA-340) describe the modulation that can be used for reader to passive communications. The chip needs to know with what kind of tag it is dealing with, therefore the initial modulation and speed (106, 212 or 424 kbps) should be supplied. * @note For every initial modulation type there is a different collection of information returned (in nfc_target_info_t pointer pti) They all fit in the data-type which is called nfc_target_info_t. This is a union which contains the tag information that belongs to the according initial modulation type. */ -bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pnti) +bool nfc_initiator_select_passive_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pnti) { byte_t abtInit[MAX_FRAME_LEN]; size_t szInitLen; @@ -544,14 +544,14 @@ bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nm } /** - * @fn nfc_initiator_deselect_tag(const nfc_device_t* pnd); + * @fn nfc_initiator_deselect_target(const nfc_device_t* pnd); * @brief Deselect a selected passive or emulated tag * @return Returns true if action was successfully performed; otherwise returns false. * @param pnd nfc_device_t struct pointer that represent currently used device * - * After selecting and communicating with a passive tag, this function could be used to deactivate and release the tag. This is very useful when there are multiple tags available in the field. It is possible to use the nfc_initiator_select_tag() function to select the first available tag, test it for the available features and support, deselect it and skip to the next tag until the correct tag is found. + * After selecting and communicating with a passive tag, this function could be used to deactivate and release the tag. This is very useful when there are multiple tags available in the field. It is possible to use the nfc_initiator_select_passive_target() function to select the first available tag, test it for the available features and support, deselect it and skip to the next tag until the correct tag is found. */ -bool nfc_initiator_deselect_tag(const nfc_device_t* pnd) +bool nfc_initiator_deselect_target(const nfc_device_t* pnd) { return (pn53x_transceive(pnd,pncmd_initiator_deselect,3,NULL,NULL)); }