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.

FreeFareTagBusiness.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Created by robin on 7/22/16.
  3. //
  4. #include "FreeFareTagBusiness.h"
  5. FreeFareTagBusiness::FreeFareTagBusiness(std::shared_ptr<FreeFareTag> tag)
  6. : _tag(tag)
  7. {
  8. }
  9. ResultBool FreeFareTagBusiness::authenticate(int sector, int block, std::string key, int keyType)
  10. {
  11. return _tag->authenticate(sector, block, key, keyType);
  12. }
  13. ResultString FreeFareTagBusiness::readBlock(int sector, int block, std::string key, int keyType)
  14. {
  15. return _tag->readBlock(sector, block, key, keyType);
  16. }
  17. ResultString FreeFareTagBusiness::readSector(int sector, std::string key, int keyType)
  18. {
  19. std::string res;
  20. int lastBlock = _tag->getSectorBlockCount(sector);
  21. for (int i = 0; i < lastBlock; ++i) {
  22. auto data = readBlock(sector, i, key, keyType);
  23. if (data) {
  24. res += data.getData();
  25. }
  26. else {
  27. return data;
  28. }
  29. }
  30. return ResultString::ok(res);
  31. }
  32. const std::string &FreeFareTagBusiness::getUid() const
  33. {
  34. return _tag->getUid();
  35. }
  36. freefare_tag_type FreeFareTagBusiness::getType() const
  37. {
  38. return _tag->getType();
  39. }
  40. std::shared_ptr<FreeFareTag> FreeFareTagBusiness::getTag() const
  41. {
  42. return _tag;
  43. }