uhf_tag.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <stddef.h>
  5. // Reserved Memory Bank
  6. typedef struct {
  7. uint8_t kill_password[2]; // 2 bytes (16 bits) for kill password
  8. uint8_t access_password[2]; // 2 bytes (16 bits) for access password
  9. } ReservedMemoryBank;
  10. // EPC Memory Bank
  11. typedef struct {
  12. size_t size; // Size of EPC memory data
  13. uint8_t data[18]; // 2 bytes for CRC16, 2 bytes for PC, and max 14 bytes for EPC
  14. uint16_t pc;
  15. uint16_t crc;
  16. } EPCMemoryBank;
  17. // TID Memory Bank
  18. typedef struct {
  19. size_t size; // Size of TID memory data
  20. uint8_t data[16]; // 4 bytes for Class ID and max 12 bytes for TID data
  21. } TIDMemoryBank;
  22. // User Memory Bank
  23. typedef struct {
  24. size_t size; // Size of user memory data
  25. uint8_t data[64]; // Assuming max 512 bits (64 bytes) for User Memory
  26. } UserMemoryBank;
  27. // EPC Gen 2 Tag containing all memory banks
  28. typedef struct {
  29. ReservedMemoryBank* reserved;
  30. EPCMemoryBank* epc;
  31. TIDMemoryBank* tid;
  32. UserMemoryBank* user;
  33. } UHFTag;
  34. UHFTag* uhf_tag_alloc();
  35. void uhf_tag_free(UHFTag* uhf_tag);
  36. void uhf_tag_set_kill_pwd(UHFTag* uhf_tag, uint8_t* data_in);
  37. void uhf_tag_set_access_pwd(UHFTag* uhf_tag, uint8_t* data_in);
  38. void uhf_tag_set_epc_pc(UHFTag* uhf_tag, uint16_t pc);
  39. void uhf_tag_set_epc_crc(UHFTag* uhf_tag, uint16_t crc);
  40. void uhf_tag_set_epc(UHFTag* uhf_tag, uint8_t* data_in, size_t size);
  41. void uhf_tag_set_tid(UHFTag* uhf_tag, uint8_t* data_in, size_t size);
  42. void uhf_tag_set_user(UHFTag* uhf_tag, uint8_t* data_in, size_t size);
  43. uint8_t* uhf_tag_get_kill_pwd(UHFTag* uhf_tag);
  44. uint8_t* uhf_tag_get_access_pwd(UHFTag* uhf_tag);
  45. uint8_t* uhf_tag_get_epc(UHFTag* uhf_tag);
  46. size_t uhf_tag_get_epc_size(UHFTag* uhf_tag);
  47. uint8_t* uhf_tag_get_tid(UHFTag* uhf_tag);
  48. size_t uhf_tag_get_tid_size(UHFTag* uhf_tag);
  49. uint8_t* uhf_tag_get_user(UHFTag* uhf_tag);
  50. size_t uhf_tag_get_user_size(UHFTag* uhf_tag);