mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 16:36:25 +02:00
Finally we have first UID read
This commit is contained in:
parent
4e1642ca1e
commit
a4d676772e
2 changed files with 19 additions and 2 deletions
|
@ -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] = {
|
||||||
|
|
3
runme.py
3
runme.py
|
@ -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())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue