Created
October 18, 2010 14:40
-
-
Save Jonty/632315 to your computer and use it in GitHub Desktop.
Read a single tag UID using libnfc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <nfc/nfc.h> | |
#include <nfc/nfc-messages.h> | |
int main () | |
{ | |
nfc_device_t *nfcDev; | |
nfcDev = nfc_connect(NULL); | |
if (nfcDev == NULL) { | |
printf("Cannot connect to the RFID reader.\n"); | |
return 1; | |
} | |
nfc_initiator_init(nfcDev); | |
// This reader can only get one card ID, so there's no point looking for more | |
nfc_target_info_t targetInfo[1]; | |
int numTargets; | |
if (nfc_initiator_list_passive_targets(nfcDev, NM_ISO14443A_106, targetInfo, 1, &numTargets)) { | |
int uidPos; | |
for (uidPos = 0; uidPos < targetInfo[0].nai.szUidLen; uidPos++) { | |
printf("%02x", targetInfo[0].nai.abtUid[uidPos]); | |
} | |
printf("\n"); | |
} | |
nfc_disconnect(nfcDev); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello I have a problem compiling this. It says: fatal error: nfc/nfc-messages.h: file.or folder not found