Loading...
Searching...
No Matches
mf_ultralight_poller_i.h
1#pragma once
2
3#include "mf_ultralight_poller.h"
4#include <lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.h>
5#include <lib/bit_lib/bit_lib.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define MF_ULTRALIGHT_POLLER_STANDARD_FWT_FC (60000)
12#define MF_ULTRALIGHT_MAX_BUFF_SIZE (64)
13
14#define MF_ULTRALIGHT_DEFAULT_PASSWORD (0xffffffffUL)
15
16#define MF_ULTRALIGHT_IS_NTAG_I2C(type) \
17 (((type) == MfUltralightTypeNTAGI2C1K) || ((type) == MfUltralightTypeNTAGI2C2K) || \
18 ((type) == MfUltralightTypeNTAGI2CPlus1K) || ((type) == MfUltralightTypeNTAGI2CPlus2K))
19
20typedef struct {
22 uint8_t page_to_write;
24
25typedef struct {
27 uint8_t start_page;
29
30typedef struct {
32 uint8_t counter_num;
34
35typedef struct {
37 uint8_t tearing_flag_num;
39
49
50typedef enum {
51 MfUltralightPollerStateIdle,
52 MfUltralightPollerStateRequestMode,
53 MfUltralightPollerStateReadVersion,
54 MfUltralightPollerStateDetectMfulC,
55 MfUltralightPollerStateDetectNtag203,
56 MfUltralightPollerStateGetFeatureSet,
57 MfUltralightPollerStateReadSignature,
58 MfUltralightPollerStateReadCounters,
59 MfUltralightPollerStateReadTearingFlags,
60 MfUltralightPollerStateAuth,
61 MfUltralightPollerStateAuthMfulC,
62 MfUltralightPollerStateReadPages,
63 MfUltralightPollerStateTryDefaultPass,
64 MfUltralightPollerStateCheckMfulCAuthStatus,
65 MfUltralightPollerStateReadFailed,
66 MfUltralightPollerStateReadSuccess,
67 MfUltralightPollerStateRequestWriteData,
68 MfUltralightPollerStateWritePages,
69 MfUltralightPollerStateWriteFail,
70 MfUltralightPollerStateWriteSuccess,
71
72 MfUltralightPollerStateNum,
73} MfUltralightPollerState;
74
76 Iso14443_3aPoller* iso14443_3a_poller;
77 MfUltralightPollerState state;
78 MfUltralightPollerMode mode;
79 BitBuffer* tx_buffer;
80 BitBuffer* rx_buffer;
81 MfUltralightData* data;
83 uint32_t feature_set;
84 uint16_t pages_read;
85 uint16_t pages_total;
86 uint8_t counters_read;
87 uint8_t counters_total;
88 uint8_t tearing_flag_read;
89 uint8_t tearing_flag_total;
90 uint16_t current_page;
91 MfUltralightError error;
92 mbedtls_des3_context des_context;
93
94 NfcGenericEvent general_event;
96 MfUltralightPollerEventData mfu_event_data;
97 NfcGenericCallback callback;
98 void* context;
99};
100
101MfUltralightError mf_ultralight_process_error(Iso14443_3aError error);
102
103MfUltralightPoller* mf_ultralight_poller_alloc(Iso14443_3aPoller* iso14443_3a_poller);
104
105void mf_ultralight_poller_free(MfUltralightPoller* instance);
106
107const MfUltralightData* mf_ultralight_poller_get_data(MfUltralightPoller* instance);
108
109bool mf_ultralight_poller_ntag_i2c_addr_lin_to_tag(
110 MfUltralightPoller* instance,
111 uint16_t lin_addr,
112 uint8_t* sector,
113 uint8_t* tag,
114 uint8_t* pages_left);
115
116MfUltralightError mf_ultralight_poller_authentication_test(MfUltralightPoller* instance);
117
118#ifdef __cplusplus
119}
120#endif
NfcCommand(* NfcGenericCallback)(NfcGenericEvent event, void *context)
Generic Nfc event callback type.
Definition nfc_generic_event.h:75
Definition bit_buffer.c:7
Definition iso14443_3a_poller_i.h:42
Definition mf_ultralight.h:178
Definition mf_ultralight.h:95
Definition mf_ultralight.h:99
MfUltralight poller authentication context.
Definition mf_ultralight_poller.h:43
MfUltralight poller event structure.
Definition mf_ultralight_poller.h:66
Definition mf_ultralight_poller_i.h:75
Definition mf_ultralight_poller_i.h:30
Definition mf_ultralight_poller_i.h:25
Definition mf_ultralight_poller_i.h:35
Definition mf_ultralight_poller_i.h:20
Definition mf_ultralight.h:114
Definition mf_ultralight.h:123
Definition mf_ultralight.h:103
Generic Nfc event type.
Definition nfc_generic_event.h:58
Definition mf_ultralight.h:118
Definition mf_ultralight_poller_i.h:40
MfUltralight poller event data.
Definition mf_ultralight_poller.h:54