Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

NfcDeviceInternal.cpp 854B

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