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.

FreeFareTag.h 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Created by robin on 7/22/16.
  3. //
  4. #ifndef MIFARE_TOOLS_FREEFARETAGBUSINESS_H
  5. #define MIFARE_TOOLS_FREEFARETAGBUSINESS_H
  6. #include <boost/shared_ptr.hpp>
  7. #include <libnfc_cpptools/FreeFareSector.h>
  8. namespace LibNfc
  9. {
  10. namespace FreeFare
  11. {
  12. class FreeFareTagInternal;
  13. typedef std::vector<std::pair<std::string, std::string>> MappedKeys;
  14. class FreeFareTag
  15. {
  16. public:
  17. enum FreeFareTagType {
  18. UNKNOWN,
  19. FELICA,
  20. MIFARE_MINI,
  21. MIFARE_CLASSIC_1K,
  22. MIFARE_CLASSIC_4K,
  23. MIFARE_DESFIRE,
  24. MIFARE_ULTRALIGHT,
  25. MIFARE_ULTRALIGHT_C
  26. };
  27. static std::string getTagTypeString(FreeFareTagType type);
  28. FreeFareTag(std::shared_ptr<FreeFareTagInternal> tag);
  29. LibNfc::Utils::ResultBool authenticate(int sector, std::string key, int keyType);
  30. LibNfc::Utils::Result<MappedKeys> mapKeys(std::vector<std::string> keys, std::function<void(int, int)> cb = 0);
  31. LibNfc::Utils::ResultString readBlock(int sector, int block, std::string key, int keyType);
  32. LibNfc::Utils::Result<FreeFareSector> readSector(int sector, std::string key, int keyType);
  33. LibNfc::Utils::Result<std::vector<FreeFareSector>> read(MappedKeys keys, std::function<void(int, int)> cb = 0);
  34. LibNfc::Utils::Result<std::vector<FreeFareSector>> read(std::vector<std::string> keys, std::function<void(int, int)> mapCb = 0,
  35. std::function<void(int, int)> readCb = 0);
  36. LibNfc::Utils::ResultBool writeBlock(int sector, int block, std::string key, int keyType, const std::string& data);
  37. LibNfc::Utils::ResultBool writeSector(int sector, std::string key, int keyType, const std::string& data);
  38. LibNfc::Utils::ResultBool write(MappedKeys keys, const std::string& data, bool writeSector0, std::function<void(int, int)> cb = 0);
  39. LibNfc::Utils::ResultBool write(std::vector<std::string> keys, const std::string& data, bool writeSector0,
  40. std::function<void(int, int)> mapCb = 0, std::function<void(int, int)> writeCb = 0);
  41. const std::string& getUid() const;
  42. FreeFareTagType getType() const;
  43. std::shared_ptr<FreeFareTagInternal> getTag() const;
  44. protected:
  45. std::shared_ptr<FreeFareTagInternal> _tag;
  46. };
  47. }; // FreeFare
  48. }; // LibNfc
  49. #endif //MIFARE_TOOLS_FREEFARETAGBUSINESS_H