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.

FreeFareDeviceInternal.cpp 887B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // Created by robin on 6/19/16.
  3. //
  4. #include "FreeFareDeviceInternal.h"
  5. namespace LibNfc
  6. {
  7. namespace FreeFare
  8. {
  9. FreeFareDeviceInternal::FreeFareDeviceInternal(std::shared_ptr<LibNfc::Core::NfcDeviceInternal> device)
  10. : _device(device)
  11. {
  12. }
  13. LibNfc::Utils::Result<std::vector<std::shared_ptr<FreeFareTagInternal>>> FreeFareDeviceInternal::getTags()
  14. {
  15. FreefareTag* tags = freefare_get_tags(_device->getDevice());
  16. if (!tags) {
  17. return LibNfc::Utils::Result<std::vector<std::shared_ptr<FreeFareTagInternal>>>::error("Failed to get MIFARE tags");
  18. }
  19. std::vector<std::shared_ptr<FreeFareTagInternal>> tagList;
  20. for (size_t i = 0; tags[i] != 0; ++i) {
  21. tagList.push_back(std::make_shared<FreeFareTagInternal>(tags[i]));
  22. }
  23. return LibNfc::Utils::Result<std::vector<std::shared_ptr<FreeFareTagInternal>>>::ok(tagList);
  24. }
  25. }; // FreeFare
  26. }; // LibNfc