Loading...
Searching...
No Matches
iso15693_3.h
1#pragma once
2
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define ISO15693_3_UID_SIZE (8U)
12
13#define ISO15693_3_GUARD_TIME_US (5000U)
14#define ISO15693_3_FDT_POLL_FC (4202U)
15#define ISO15693_3_FDT_LISTEN_FC (4320U)
16#define ISO15693_3_POLL_POLL_MIN_US (1500U)
17
18#define ISO15693_3_REQ_FLAG_SUBCARRIER_1 (0U << 0)
19#define ISO15693_3_REQ_FLAG_SUBCARRIER_2 (1U << 0)
20#define ISO15693_3_REQ_FLAG_DATA_RATE_LO (0U << 1)
21#define ISO15693_3_REQ_FLAG_DATA_RATE_HI (1U << 1)
22#define ISO15693_3_REQ_FLAG_INVENTORY_T4 (0U << 2)
23#define ISO15693_3_REQ_FLAG_INVENTORY_T5 (1U << 2)
24#define ISO15693_3_REQ_FLAG_EXTENSION (1U << 3)
25
26#define ISO15693_3_REQ_FLAG_T4_SELECTED (1U << 4)
27#define ISO15693_3_REQ_FLAG_T4_ADDRESSED (1U << 5)
28#define ISO15693_3_REQ_FLAG_T4_OPTION (1U << 6)
29
30#define ISO15693_3_REQ_FLAG_T5_AFI_PRESENT (1U << 4)
31#define ISO15693_3_REQ_FLAG_T5_N_SLOTS_16 (0U << 5)
32#define ISO15693_3_REQ_FLAG_T5_N_SLOTS_1 (1U << 5)
33#define ISO15693_3_REQ_FLAG_T5_OPTION (1U << 6)
34
35#define ISO15693_3_RESP_FLAG_NONE (0U)
36#define ISO15693_3_RESP_FLAG_ERROR (1U << 0)
37#define ISO15693_3_RESP_FLAG_EXTENSION (1U << 3)
38
39#define ISO15693_3_RESP_ERROR_NOT_SUPPORTED (0x01U)
40#define ISO15693_3_RESP_ERROR_FORMAT (0x02U)
41#define ISO15693_3_RESP_ERROR_OPTION (0x03U)
42#define ISO15693_3_RESP_ERROR_UNKNOWN (0x0FU)
43#define ISO15693_3_RESP_ERROR_BLOCK_UNAVAILABLE (0x10U)
44#define ISO15693_3_RESP_ERROR_BLOCK_ALREADY_LOCKED (0x11U)
45#define ISO15693_3_RESP_ERROR_BLOCK_LOCKED (0x12U)
46#define ISO15693_3_RESP_ERROR_BLOCK_WRITE (0x13U)
47#define ISO15693_3_RESP_ERROR_BLOCK_LOCK (0x14U)
48#define ISO15693_3_RESP_ERROR_CUSTOM_START (0xA0U)
49#define ISO15693_3_RESP_ERROR_CUSTOM_END (0xDFU)
50
51#define ISO15693_3_CMD_MANDATORY_START (0x01U)
52#define ISO15693_3_CMD_INVENTORY (0x01U)
53#define ISO15693_3_CMD_STAY_QUIET (0x02U)
54#define ISO15693_3_CMD_MANDATORY_RFU (0x03U)
55#define ISO15693_3_CMD_OPTIONAL_START (0x20U)
56#define ISO15693_3_CMD_READ_BLOCK (0x20U)
57#define ISO15693_3_CMD_WRITE_BLOCK (0x21U)
58#define ISO15693_3_CMD_LOCK_BLOCK (0x22U)
59#define ISO15693_3_CMD_READ_MULTI_BLOCKS (0x23U)
60#define ISO15693_3_CMD_WRITE_MULTI_BLOCKS (0x24U)
61#define ISO15693_3_CMD_SELECT (0x25U)
62#define ISO15693_3_CMD_RESET_TO_READY (0x26U)
63#define ISO15693_3_CMD_WRITE_AFI (0x27U)
64#define ISO15693_3_CMD_LOCK_AFI (0x28U)
65#define ISO15693_3_CMD_WRITE_DSFID (0x29U)
66#define ISO15693_3_CMD_LOCK_DSFID (0x2AU)
67#define ISO15693_3_CMD_GET_SYS_INFO (0x2BU)
68#define ISO15693_3_CMD_GET_BLOCKS_SECURITY (0x2CU)
69#define ISO15693_3_CMD_OPTIONAL_RFU (0x2DU)
70#define ISO15693_3_CMD_CUSTOM_START (0xA0U)
71
72#define ISO15693_3_MANDATORY_COUNT (ISO15693_3_CMD_MANDATORY_RFU - ISO15693_3_CMD_MANDATORY_START)
73#define ISO15693_3_OPTIONAL_COUNT (ISO15693_3_CMD_OPTIONAL_RFU - ISO15693_3_CMD_OPTIONAL_START)
74
75#define ISO15693_3_SYSINFO_FLAG_DSFID (1U << 0)
76#define ISO15693_3_SYSINFO_FLAG_AFI (1U << 1)
77#define ISO15693_3_SYSINFO_FLAG_MEMORY (1U << 2)
78#define ISO15693_3_SYSINFO_FLAG_IC_REF (1U << 3)
79
80typedef enum {
81 Iso15693_3ErrorNone,
82 Iso15693_3ErrorNotPresent,
83 Iso15693_3ErrorBufferEmpty,
84 Iso15693_3ErrorBufferOverflow,
85 Iso15693_3ErrorFieldOff,
86 Iso15693_3ErrorWrongCrc,
87 Iso15693_3ErrorTimeout,
88 Iso15693_3ErrorFormat,
89 Iso15693_3ErrorIgnore,
90 Iso15693_3ErrorNotSupported,
91 Iso15693_3ErrorUidMismatch,
92 Iso15693_3ErrorFullyHandled,
93 Iso15693_3ErrorUnexpectedResponse,
94 Iso15693_3ErrorInternal,
95 Iso15693_3ErrorCustom,
96 Iso15693_3ErrorUnknown,
97} Iso15693_3Error;
98
99typedef struct {
100 uint8_t flags;
101 uint8_t dsfid;
102 uint8_t afi;
103 uint8_t ic_ref;
104 uint16_t block_count;
105 uint8_t block_size;
107
108typedef struct {
109 bool dsfid;
110 bool afi;
112
113typedef struct {
114 Iso15693_3LockBits lock_bits;
116
117typedef struct {
118 uint8_t uid[ISO15693_3_UID_SIZE];
119 Iso15693_3SystemInfo system_info;
120 Iso15693_3Settings settings;
121 SimpleArray* block_data;
122 SimpleArray* block_security;
124
125Iso15693_3Data* iso15693_3_alloc(void);
126
127void iso15693_3_free(Iso15693_3Data* data);
128
129void iso15693_3_reset(Iso15693_3Data* data);
130
131void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other);
132
133bool iso15693_3_verify(Iso15693_3Data* data, const FuriString* device_type);
134
135bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version);
136
137bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff);
138
139bool iso15693_3_is_equal(const Iso15693_3Data* data, const Iso15693_3Data* other);
140
141const char* iso15693_3_get_device_name(const Iso15693_3Data* data, NfcDeviceNameType name_type);
142
143const uint8_t* iso15693_3_get_uid(const Iso15693_3Data* data, size_t* uid_len);
144
145bool iso15693_3_set_uid(Iso15693_3Data* data, const uint8_t* uid, size_t uid_len);
146
147Iso15693_3Data* iso15693_3_get_base_data(const Iso15693_3Data* data);
148
149// Getters and tests
150
151bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index);
152
153uint8_t iso15693_3_get_manufacturer_id(const Iso15693_3Data* data);
154
155uint16_t iso15693_3_get_block_count(const Iso15693_3Data* data);
156
157uint8_t iso15693_3_get_block_size(const Iso15693_3Data* data);
158
159const uint8_t* iso15693_3_get_block_data(const Iso15693_3Data* data, uint8_t block_index);
160
161#ifdef __cplusplus
162}
163#endif
Flipper File Format helper library.
Common top-level types for the NFC protocol stack.
NfcDeviceNameType
Verbosity level of the displayed NFC device name.
Definition nfc_device_base.h:14
This file provides a simple (non-type safe) array for elements with (optional) in-place construction ...
Definition flipper_format.c:12
Definition string.c:4
Definition iso15693_3.h:117
Definition iso15693_3.h:108
Definition iso15693_3.h:113
Definition iso15693_3.h:99
Definition simple_array.c:5