Go to the documentation of this file.00001
00025 #ifndef __NFC_TYPES_H__
00026 # define __NFC_TYPES_H__
00027
00034 # include <stddef.h>
00035 # include <stdint.h>
00036 # include <stdbool.h>
00037 # include <stdio.h>
00038
00039 typedef uint8_t byte_t;
00040
00041 typedef enum {
00042 NC_PN531 = 0x10,
00043 NC_PN532 = 0x20,
00044 NC_PN533 = 0x30,
00045 } nfc_chip_t;
00046
00047 struct driver_callbacks;
00048
00049 typedef void *nfc_device_spec_t;
00050
00051 # define DEVICE_NAME_LENGTH 256
00052
00056 typedef struct {
00058 const struct driver_callbacks *pdc;
00060 char acName[DEVICE_NAME_LENGTH];
00062 nfc_chip_t nc;
00064 nfc_device_spec_t nds;
00066 bool bActive;
00068 bool bCrc;
00070 bool bPar;
00072 bool bEasyFraming;
00074 bool bAutoIso14443_4;
00076 uint8_t ui8TxBits;
00078 uint8_t ui8Parameters;
00080 byte_t btSupportByte;
00089 int iLastError;
00090 } nfc_device_t;
00091
00092
00099 typedef struct {
00101 char acDevice[DEVICE_NAME_LENGTH];
00103 char *pcDriver;
00105 char *pcPort;
00107 uint32_t uiSpeed;
00109 uint32_t uiBusIndex;
00110 } nfc_device_desc_t;
00111
00116 struct chip_callbacks {
00118 const char *(*strerror) (const nfc_device_t * pnd);
00119 };
00120
00125 struct driver_callbacks {
00127 const char *acDriver;
00129 const struct chip_callbacks *pcc;
00131 nfc_device_desc_t *(*pick_device) (void);
00133 bool (*list_devices) (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
00135 nfc_device_t *(*connect) (const nfc_device_desc_t * pndd);
00137 void (*init) (nfc_device_t * pnd);
00139 bool (*transceive) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx);
00141 void (*disconnect) (nfc_device_t * pnd);
00142 };
00143
00144
00145 # pragma pack(1)
00146
00151 typedef enum {
00159 NDO_HANDLE_CRC = 0x00,
00167 NDO_HANDLE_PARITY = 0x01,
00170 NDO_ACTIVATE_FIELD = 0x10,
00174 NDO_ACTIVATE_CRYPTO1 = 0x11,
00180 NDO_INFINITE_SELECT = 0x20,
00184 NDO_ACCEPT_INVALID_FRAMES = 0x30,
00191 NDO_ACCEPT_MULTIPLE_FRAMES = 0x31,
00199 NDO_AUTO_ISO14443_4 = 0x40,
00201 NDO_EASY_FRAMING = 0x41,
00203 NDO_FORCE_ISO14443_A = 0x42,
00204 } nfc_device_option_t;
00205
00210 typedef enum {
00211 NDM_UNDEFINED = 0,
00212 NDM_PASSIVE,
00213 NDM_ACTIVE,
00214 } nfc_dep_mode_t;
00215
00220 typedef struct {
00222 byte_t abtNFCID3[10];
00224 byte_t btDID;
00226 byte_t btBS;
00228 byte_t btBR;
00230 byte_t btTO;
00232 byte_t btPP;
00234 byte_t abtGB[48];
00235 size_t szGB;
00237 nfc_dep_mode_t ndm;
00238 } nfc_dep_info_t;
00239
00244 typedef struct {
00245 byte_t abtAtqa[2];
00246 byte_t btSak;
00247 size_t szUidLen;
00248 byte_t abtUid[10];
00249 size_t szAtsLen;
00250 byte_t abtAts[254];
00251 } nfc_iso14443a_info_t;
00252
00257 typedef struct {
00258 size_t szLen;
00259 byte_t btResCode;
00260 byte_t abtId[8];
00261 byte_t abtPad[8];
00262 byte_t abtSysCode[2];
00263 } nfc_felica_info_t;
00264
00269 typedef struct {
00271 byte_t abtPupi[4];
00273 byte_t abtApplicationData[4];
00275 byte_t abtProtocolInfo[3];
00277 uint8_t ui8CardIdentifier;
00278 } nfc_iso14443b_info_t;
00279
00284 typedef struct {
00285 byte_t btSensRes[2];
00286 byte_t btId[4];
00287 } nfc_jewel_info_t;
00288
00293 typedef union {
00294 nfc_iso14443a_info_t nai;
00295 nfc_felica_info_t nfi;
00296 nfc_iso14443b_info_t nbi;
00297 nfc_jewel_info_t nji;
00298 nfc_dep_info_t ndi;
00299 } nfc_target_info_t;
00300
00305 typedef enum {
00306 NBR_UNDEFINED = 0,
00307 NBR_106,
00308 NBR_212,
00309 NBR_424,
00310 NBR_847,
00311 } nfc_baud_rate_t;
00312
00317 typedef enum {
00318 NMT_ISO14443A,
00319 NMT_ISO14443B,
00320 NMT_FELICA,
00321 NMT_JEWEL,
00322 NMT_DEP,
00323 } nfc_modulation_type_t;
00324
00329 typedef struct {
00330 nfc_modulation_type_t nmt;
00331 nfc_baud_rate_t nbr;
00332 } nfc_modulation_t;
00333
00338 typedef struct {
00339 nfc_target_info_t nti;
00340 nfc_modulation_t nm;
00341 } nfc_target_t;
00342
00343
00344 # pragma pack()
00345
00346 #endif // _LIBNFC_TYPES_H_