Fixed open/close order in case of initiator error

This commit is contained in:
Ondrej Mikle 2014-07-19 15:22:03 +02:00
parent 87f9486fcf
commit a8149abeec
2 changed files with 5 additions and 2 deletions

View file

@ -41,12 +41,12 @@ void NFCDevice::open()
throw NFCError("Unable to open NFC device.");
}
_opened = true;
if (nfc_initiator_init(_nfcDevice) < 0) {
close();
throw NFCError("NFC initiator error");
}
_opened = true;
}
void NFCDevice::close()

View file

@ -7,3 +7,6 @@ nfc.close()
nfc.open()
print hexlify(nfc.scanUID())
print "Device is opened:", nfc.opened()
print "Closing device"
nfc.close()
print "Device is opened:", nfc.opened()