Finally we have first UID read

This commit is contained in:
Ondrej Mikle 2014-07-19 02:50:05 +02:00
parent 4e1642ca1e
commit a4d676772e
2 changed files with 19 additions and 2 deletions

View file

@ -35,12 +35,28 @@ NFCDevice::NFCDevice()
NFCDevice::~NFCDevice() NFCDevice::~NFCDevice()
{ {
//nfc_close(_nfcDevice);
nfc_exit(_nfcContext); nfc_exit(_nfcContext);
} }
std::string NFCDevice::scanUID() std::string NFCDevice::scanUID()
{ {
return "1234"; int res;
nfc_target nt;
res = nfc_initiator_poll_target(_nfcDevice, _modulations, _modulationsLen, pollNr, pollPeriod, &nt);
if (res < 0) {
throw NFCError("NFC polling error");
}
// we are not interested in non-ISO-14443A cards
if (nt.nm.nmt != NMT_ISO14443A) {
return "";
}
const nfc_iso14443a_info& nai = nt.nti.nai;
return string((const char*)nai.abtUid, nai.szUidLen);
} }
const nfc_modulation NFCDevice::_modulations[5] = { const nfc_modulation NFCDevice::_modulations[5] = {

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
from brmdoor_nfc import NFCDevice from brmdoor_nfc import NFCDevice
from binascii import hexlify
nfc = NFCDevice() nfc = NFCDevice()
print nfc.scanUID() print hexlify(nfc.scanUID())