gen4_poller_i.h 2.4 KB

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