1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // Created by robin on 6/19/16.
- //
-
- #include "NfcDeviceInternal.h"
-
- namespace LibNfc
- {
- namespace Core
- {
-
- NfcDeviceInternal::NfcDeviceInternal(const LibNfcInternal* libNfc, const std::string& str)
- : _connStr(str)
- , _device(0)
- , _libNfc(libNfc)
- {
- }
-
- NfcDeviceInternal::~NfcDeviceInternal()
- {
- close();
- }
-
- LibNfc::Utils::ResultBool NfcDeviceInternal::open()
- {
- _device = nfc_open(_libNfc->getContext(), _connStr.c_str());
- if (!_device) {
- return LibNfc::Utils::ResultBool::error("Failed to open NFC device");
- }
- return LibNfc::Utils::ResultBool::ok(true);
- }
-
- void NfcDeviceInternal::close()
- {
- nfc_close(_device);
- _device = 0;
- }
-
- nfc_device *NfcDeviceInternal::getDevice() const
- {
- return _device;
- }
-
- const std::string &NfcDeviceInternal::getConnStr() const
- {
- return _connStr;
- }
-
- }; // Core
- }; // LibNfc
|