libnfc  1.4.2
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;
76  uint8_t ui8TxBits;
78  uint8_t ui8Parameters;
80  byte_t btSupportByte;
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;
111 
118  const char *(*strerror) (const nfc_device_t * pnd);
119 };
120 
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 {
205 
210 typedef enum {
211  NDM_UNDEFINED = 0,
212  NDM_PASSIVE,
213  NDM_ACTIVE,
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;
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
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];
264 
269 typedef struct {
271  byte_t abtPupi[4];
273  byte_t abtApplicationData[4];
275  byte_t abtProtocolInfo[3];
279 
284 typedef struct {
285  byte_t btSensRes[2];
286  byte_t btId[4];
288 
293 typedef union {
295  nfc_felica_info_t nfi;
297  nfc_jewel_info_t nji;
298  nfc_dep_info_t ndi;
300 
305 typedef enum {
306  NBR_UNDEFINED = 0,
307  NBR_106,
308  NBR_212,
309  NBR_424,
310  NBR_847,
312 
317 typedef enum {
318  NMT_ISO14443A,
319  NMT_ISO14443B,
320  NMT_FELICA,
321  NMT_JEWEL,
322  NMT_DEP,
324 
329 typedef struct {
331  nfc_baud_rate_t nbr;
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_