You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NfcDevice.cpp 667B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by robin on 6/19/16.
  3. //
  4. #include "NfcDevice.h"
  5. NfcDevice::NfcDevice(const LibNfc* libNfc, const std::string& str)
  6. : _connStr(str)
  7. , _device(0)
  8. , _libNfc(libNfc)
  9. {
  10. }
  11. NfcDevice::~NfcDevice()
  12. {
  13. close();
  14. }
  15. ResultBool NfcDevice::open()
  16. {
  17. _device = nfc_open(_libNfc->getContext(), _connStr.c_str());
  18. if (!_device) {
  19. return ResultBool::error("Failed to open NFC device");
  20. }
  21. return ResultBool::ok(true);
  22. }
  23. void NfcDevice::close()
  24. {
  25. nfc_close(_device);
  26. _device = 0;
  27. }
  28. nfc_device *NfcDevice::getDevice() const
  29. {
  30. return _device;
  31. }
  32. const std::string &NfcDevice::getConnStr() const
  33. {
  34. return _connStr;
  35. }