libnfc
1.4.2
Main Page
Data Structures
Files
File List
Globals
include
nfc
nfc-types.h
Go to the documentation of this file.
1
25
#ifndef __NFC_TYPES_H__
26
# define __NFC_TYPES_H__
27
34
# include <stddef.h>
35
# include <stdint.h>
36
# include <stdbool.h>
37
# include <stdio.h>
38
39
typedef
uint8_t byte_t;
40
41
typedef
enum
{
42
NC_PN531 = 0x10,
43
NC_PN532 = 0x20,
44
NC_PN533 = 0x30,
45
} nfc_chip_t;
46
47
struct
driver_callbacks
;
// Prototype the callback struct
48
49
typedef
void
*nfc_device_spec_t;
// Device connection specification
50
51
# define DEVICE_NAME_LENGTH 256
52
56
typedef
struct
{
58
const
struct
driver_callbacks
*
pdc
;
60
char
acName[DEVICE_NAME_LENGTH];
62
nfc_chip_t
nc
;
64
nfc_device_spec_t
nds
;
66
bool
bActive
;
68
bool
bCrc
;
70
bool
bPar
;
72
bool
bEasyFraming
;
74
bool
bAutoIso14443_4
;
76
uint8_t
ui8TxBits
;
78
uint8_t
ui8Parameters
;
80
byte_t
btSupportByte
;
89
int
iLastError
;
90
}
nfc_device_t
;
91
92
99
typedef
struct
{
101
char
acDevice[DEVICE_NAME_LENGTH];
103
char
*
pcDriver
;
105
char
*
pcPort
;
107
uint32_t
uiSpeed
;
109
uint32_t
uiBusIndex
;
110
}
nfc_device_desc_t
;
111
116
struct
chip_callbacks
{
118
const
char
*(*strerror) (
const
nfc_device_t
* pnd);
119
};
120
125
struct
driver_callbacks
{
127
const
char
*
acDriver
;
129
const
struct
chip_callbacks
*
pcc
;
131
nfc_device_desc_t
*(*pick_device) (void);
133
bool (*
list_devices
) (
nfc_device_desc_t
pnddDevices[],
size_t
szDevices,
size_t
* pszDeviceFound);
135
nfc_device_t
*(*connect) (
const
nfc_device_desc_t
* pndd);
137
void (*
init
) (
nfc_device_t
* pnd);
139
bool (*
transceive
) (
nfc_device_t
* pnd,
const
byte_t * pbtTx,
const
size_t
szTx, byte_t * pbtRx,
size_t
* pszRx);
141
void (*
disconnect
) (
nfc_device_t
* pnd);
142
};
143
144
// Compiler directive, set struct alignment to 1 byte_t for compatibility
145
# pragma pack(1)
146
151
typedef
enum
{
159
NDO_HANDLE_CRC
= 0x00,
167
NDO_HANDLE_PARITY
= 0x01,
170
NDO_ACTIVATE_FIELD
= 0x10,
174
NDO_ACTIVATE_CRYPTO1
= 0x11,
180
NDO_INFINITE_SELECT
= 0x20,
184
NDO_ACCEPT_INVALID_FRAMES
= 0x30,
191
NDO_ACCEPT_MULTIPLE_FRAMES
= 0x31,
199
NDO_AUTO_ISO14443_4
= 0x40,
201
NDO_EASY_FRAMING
= 0x41,
203
NDO_FORCE_ISO14443_A
= 0x42,
204
}
nfc_device_option_t
;
205
210
typedef
enum
{
211
NDM_UNDEFINED = 0,
212
NDM_PASSIVE,
213
NDM_ACTIVE,
214
}
nfc_dep_mode_t
;
215
220
typedef
struct
{
222
byte_t abtNFCID3[10];
224
byte_t
btDID
;
226
byte_t
btBS
;
228
byte_t
btBR
;
230
byte_t
btTO
;
232
byte_t
btPP
;
234
byte_t abtGB[48];
235
size_t
szGB;
237
nfc_dep_mode_t
ndm
;
238
}
nfc_dep_info_t
;
239
244
typedef
struct
{
245
byte_t abtAtqa[2];
246
byte_t btSak;
247
size_t
szUidLen;
248
byte_t abtUid[10];
249
size_t
szAtsLen;
250
byte_t abtAts[254];
// Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
251
}
nfc_iso14443a_info_t
;
252
257
typedef
struct
{
258
size_t
szLen;
259
byte_t btResCode;
260
byte_t abtId[8];
261
byte_t abtPad[8];
262
byte_t abtSysCode[2];
263
}
nfc_felica_info_t
;
264
269
typedef
struct
{
271
byte_t abtPupi[4];
273
byte_t abtApplicationData[4];
275
byte_t abtProtocolInfo[3];
277
uint8_t
ui8CardIdentifier
;
278
}
nfc_iso14443b_info_t
;
279
284
typedef
struct
{
285
byte_t btSensRes[2];
286
byte_t btId[4];
287
}
nfc_jewel_info_t
;
288
293
typedef
union
{
294
nfc_iso14443a_info_t
nai;
295
nfc_felica_info_t
nfi;
296
nfc_iso14443b_info_t
nbi;
297
nfc_jewel_info_t
nji;
298
nfc_dep_info_t
ndi;
299
}
nfc_target_info_t
;
300
305
typedef
enum
{
306
NBR_UNDEFINED = 0,
307
NBR_106,
308
NBR_212,
309
NBR_424,
310
NBR_847,
311
}
nfc_baud_rate_t
;
312
317
typedef
enum
{
318
NMT_ISO14443A,
319
NMT_ISO14443B,
320
NMT_FELICA,
321
NMT_JEWEL,
322
NMT_DEP,
323
}
nfc_modulation_type_t
;
324
329
typedef
struct
{
330
nfc_modulation_type_t
nmt;
331
nfc_baud_rate_t
nbr;
332
}
nfc_modulation_t
;
333
338
typedef
struct
{
339
nfc_target_info_t
nti;
340
nfc_modulation_t
nm;
341
}
nfc_target_t
;
342
343
// Reset struct alignment to default
344
# pragma pack()
345
346
#endif // _LIBNFC_TYPES_H_
Generated by
1.8.1.2