mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 00:24:00 +02:00
Fixed open/close order in case of initiator error
This commit is contained in:
parent
87f9486fcf
commit
a8149abeec
2 changed files with 5 additions and 2 deletions
|
@ -41,12 +41,12 @@ void NFCDevice::open()
|
||||||
throw NFCError("Unable to open NFC device.");
|
throw NFCError("Unable to open NFC device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_opened = true;
|
||||||
|
|
||||||
if (nfc_initiator_init(_nfcDevice) < 0) {
|
if (nfc_initiator_init(_nfcDevice) < 0) {
|
||||||
close();
|
close();
|
||||||
throw NFCError("NFC initiator error");
|
throw NFCError("NFC initiator error");
|
||||||
}
|
}
|
||||||
|
|
||||||
_opened = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NFCDevice::close()
|
void NFCDevice::close()
|
||||||
|
|
3
runme.py
3
runme.py
|
@ -7,3 +7,6 @@ nfc.close()
|
||||||
nfc.open()
|
nfc.open()
|
||||||
print hexlify(nfc.scanUID())
|
print hexlify(nfc.scanUID())
|
||||||
print "Device is opened:", nfc.opened()
|
print "Device is opened:", nfc.opened()
|
||||||
|
print "Closing device"
|
||||||
|
nfc.close()
|
||||||
|
print "Device is opened:", nfc.opened()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue