mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-08-03 10:53:37 +02:00
Explicit unload() 'destructor'
This commit is contained in:
parent
3717cb2563
commit
bbec77f248
3 changed files with 31 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include <nfc/nfc.h>
|
||||
#include <nfc/nfc-types.h>
|
||||
|
@ -13,7 +14,8 @@ NFCDevice::NFCDevice() throw(NFCError):
|
|||
pollPeriod(2),
|
||||
_nfcContext(NULL),
|
||||
_nfcDevice(NULL),
|
||||
_opened(false)
|
||||
_opened(false),
|
||||
_unloaded(false)
|
||||
{
|
||||
nfc_init(&_nfcContext);
|
||||
if (_nfcContext == NULL) {
|
||||
|
@ -26,7 +28,7 @@ NFCDevice::NFCDevice() throw(NFCError):
|
|||
NFCDevice::~NFCDevice()
|
||||
{
|
||||
close();
|
||||
nfc_exit(_nfcContext);
|
||||
unload();
|
||||
}
|
||||
|
||||
void NFCDevice::open() throw(NFCError)
|
||||
|
@ -55,11 +57,26 @@ void NFCDevice::close()
|
|||
return;
|
||||
}
|
||||
|
||||
assert(_nfcDevice);
|
||||
|
||||
nfc_close(_nfcDevice);
|
||||
_nfcDevice = NULL;
|
||||
_opened = false;
|
||||
}
|
||||
|
||||
void NFCDevice::unload()
|
||||
{
|
||||
if (_unloaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(_nfcContext);
|
||||
|
||||
nfc_exit(_nfcContext);
|
||||
_nfcContext = NULL;
|
||||
_unloaded = true;
|
||||
}
|
||||
|
||||
std::string NFCDevice::scanUID() throw(NFCError)
|
||||
{
|
||||
int res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue