uhf_data.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdlib.h>
  4. #define MAX_DATA_SIZE 128
  5. #define MAX_BANK_SIZE 64
  6. typedef struct UHFData {
  7. uint8_t data[MAX_DATA_SIZE];
  8. size_t word_length;
  9. size_t length;
  10. bool start;
  11. bool end;
  12. struct UHFData* next;
  13. } UHFData;
  14. typedef struct UHFResponseData {
  15. UHFData* head;
  16. UHFData* tail;
  17. size_t size;
  18. } UHFResponseData;
  19. typedef struct UHFTag {
  20. // RESERVED BANK (RFU) (00)
  21. uint8_t KILL_PWD[2]; // 0x00-0x10
  22. uint8_t ACCESS_PWD[2]; // 0x10-0x20
  23. // EPC Bank
  24. uint8_t CRC[2]; // 0x00-0x10
  25. uint8_t PC[2]; // 0x10-0x20
  26. uint8_t EPC[MAX_BANK_SIZE]; // 0x20-0x210
  27. size_t epc_length;
  28. uint8_t XPC[2]; // 0x210-0x21F
  29. size_t xpc_length;
  30. // TID Bank
  31. uint8_t TID[MAX_BANK_SIZE]; // 0x00-END
  32. size_t tid_length;
  33. // USER Bank
  34. uint8_t USER[MAX_BANK_SIZE]; // 0x00-END
  35. size_t user_length;
  36. } UHFTag;
  37. UHFData* uhf_data_alloc();
  38. int uhf_data_append(UHFData* uhf_data, uint8_t data);
  39. void uhf_data_reset(UHFData* uhf_data);
  40. uint8_t uhf_data_calculate_checksum(UHFData* uhf_data);
  41. bool uhf_data_verfiy_checksum(UHFData* uhf_data);
  42. void uhf_data_free(UHFData* uhf_data);
  43. UHFResponseData* uhf_response_data_alloc();
  44. UHFData* uhf_response_data_add_new_uhf_data(UHFResponseData* uhf_response_data);
  45. UHFData* uhf_response_data_get_uhf_data(UHFResponseData* uhf_response_data, uint index);
  46. void uhf_response_data_reset(UHFResponseData* uhf_response_data);
  47. void uhf_response_data_free(UHFResponseData* uhf_response_data);
  48. UHFBank* uhf_tag_alloc();
  49. void uhf_tag_free(UHFTag* uhf_tag);