gen4_poller_i.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. #include "gen4_poller.h"
  3. #include <nfc/nfc_poller.h>
  4. #include <nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
  5. #include <bit_lib/bit_lib.h>
  6. #define TAG "Gen4Poller"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define GEN4_POLLER_MAX_BUFFER_SIZE (64U)
  11. #define GEN4_POLLER_MAX_FWT (200000U)
  12. #define GEN4_POLLER_BLOCK_SIZE (16)
  13. #define GEN4_POLLER_BLOCKS_TOTAL (256)
  14. typedef enum {
  15. Gen4PollerStateIdle,
  16. Gen4PollerStateRequestMode,
  17. Gen4PollerStateRequestWriteData,
  18. Gen4PollerStateWrite,
  19. Gen4PollerStateWipe,
  20. Gen4PollerStateChangePassword,
  21. Gen4PollerStateGetInfo,
  22. Gen4PollerStateSetDefaultConfig,
  23. Gen4PollerStateSetShadowMode,
  24. Gen4PollerStateSetDirectWriteBlock0,
  25. Gen4PollerStateSuccess,
  26. Gen4PollerStateFail,
  27. Gen4PollerStateNum,
  28. } Gen4PollerState;
  29. struct Gen4Poller {
  30. NfcPoller* poller;
  31. Iso14443_3aPoller* iso3_poller;
  32. Gen4PollerState state;
  33. Gen4* gen4_data;
  34. Gen4Password password;
  35. Gen4Password new_password;
  36. Gen4Config config;
  37. Gen4ShadowMode shadow_mode;
  38. Gen4DirectWriteBlock0Mode direct_write_block_0_mode;
  39. BitBuffer* tx_buffer;
  40. BitBuffer* rx_buffer;
  41. uint16_t current_block;
  42. uint16_t total_blocks;
  43. NfcProtocol protocol;
  44. const NfcDeviceData* data;
  45. Gen4PollerEvent gen4_event;
  46. Gen4PollerEventData gen4_event_data;
  47. Gen4PollerCallback callback;
  48. void* context;
  49. };
  50. Gen4PollerError gen4_poller_set_config(
  51. Gen4Poller* instance,
  52. Gen4Password password,
  53. const Gen4Config* config,
  54. size_t config_size,
  55. bool fuse);
  56. Gen4PollerError gen4_poller_write_block(
  57. Gen4Poller* instance,
  58. Gen4Password password,
  59. uint8_t block_num,
  60. const uint8_t* data);
  61. Gen4PollerError gen4_poller_change_password(
  62. Gen4Poller* instance,
  63. Gen4Password pwd_current,
  64. Gen4Password pwd_new);
  65. Gen4PollerError gen4_poller_get_revision(
  66. Gen4Poller* instance,
  67. Gen4Password password,
  68. Gen4Revision* revision_result);
  69. Gen4PollerError
  70. gen4_poller_get_config(Gen4Poller* instance, Gen4Password password, Gen4Config* config_result);
  71. Gen4PollerError
  72. gen4_poller_set_shadow_mode(Gen4Poller* instance, Gen4Password password, Gen4ShadowMode mode);
  73. Gen4PollerError gen4_poller_set_direct_write_block_0_mode(
  74. Gen4Poller* instance,
  75. Gen4Password password,
  76. Gen4DirectWriteBlock0Mode mode);
  77. #ifdef __cplusplus
  78. }
  79. #endif