Go to the documentation of this file.00001
00024 #ifndef __NFC_TYPES_H__
00025 # define __NFC_TYPES_H__
00026
00033 # include <stddef.h>
00034 # include <stdint.h>
00035 # include <stdbool.h>
00036 # include <stdio.h>
00037
00038 typedef uint8_t byte_t;
00039
00040 typedef enum {
00041 NC_PN531 = 0x10,
00042 NC_PN532 = 0x20,
00043 NC_PN533 = 0x30,
00044 } nfc_chip_t;
00045
00046 struct driver_callbacks;
00047
00048 typedef void *nfc_device_spec_t;
00049
00050 # define DEVICE_NAME_LENGTH 256
00051
00055 typedef struct {
00057 const struct driver_callbacks *pdc;
00059 char acName[DEVICE_NAME_LENGTH];
00061 nfc_chip_t nc;
00063 nfc_device_spec_t nds;
00065 bool bActive;
00067 bool bCrc;
00069 bool bPar;
00071 bool bEasyFraming;
00073 uint8_t ui8TxBits;
00082 int iLastError;
00083 } nfc_device_t;
00084
00085
00092 typedef struct {
00094 char acDevice[DEVICE_NAME_LENGTH];
00096 char *pcDriver;
00098 char *pcPort;
00100 uint32_t uiSpeed;
00102 uint32_t uiBusIndex;
00103 } nfc_device_desc_t;
00104
00109 struct chip_callbacks {
00111 const char *(*strerror) (const nfc_device_t * pnd);
00112 };
00113
00118 struct driver_callbacks {
00120 const char *acDriver;
00122 const struct chip_callbacks *pcc;
00124 nfc_device_desc_t *(*pick_device) (void);
00126 bool (*list_devices) (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
00128 nfc_device_t *(*connect) (const nfc_device_desc_t * pndd);
00133 bool (*transceive) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxLen, byte_t * pbtRx,
00134 size_t * pszRxLen);
00136 void (*disconnect) (nfc_device_t * pnd);
00137 };
00138
00139
00140 # pragma pack(1)
00141
00146 typedef enum {
00148 NDO_HANDLE_CRC = 0x00,
00150 NDO_HANDLE_PARITY = 0x01,
00152 NDO_ACTIVATE_FIELD = 0x10,
00154 NDO_ACTIVATE_CRYPTO1 = 0x11,
00156 NDO_INFINITE_SELECT = 0x20,
00158 NDO_ACCEPT_INVALID_FRAMES = 0x30,
00160 NDO_ACCEPT_MULTIPLE_FRAMES = 0x31,
00162 NDO_AUTO_ISO14443_4 = 0x40,
00164 NDO_EASY_FRAMING = 0x41,
00165 } nfc_device_option_t;
00166
00168
00169
00174 typedef enum {
00176 NM_ISO14443A_106 = 0x00,
00178 NM_FELICA_212 = 0x01,
00180 NM_FELICA_424 = 0x02,
00182 NM_ISO14443B_106 = 0x03,
00184 NM_JEWEL_106 = 0x04,
00186 NM_ACTIVE_DEP = 0x05,
00188 NM_PASSIVE_DEP = 0x06
00189 } nfc_modulation_t;
00190
00195 typedef struct {
00196 byte_t NFCID3i[10];
00197 byte_t btDID;
00198 byte_t btBSt;
00199 byte_t btBRt;
00200 } nfc_dep_info_t;
00201
00206 typedef struct {
00207 byte_t abtAtqa[2];
00208 byte_t btSak;
00209 size_t szUidLen;
00210 byte_t abtUid[10];
00211 size_t szAtsLen;
00212 byte_t abtAts[36];
00213 } nfc_iso14443a_info_t;
00214
00219 typedef struct {
00220 size_t szLen;
00221 byte_t btResCode;
00222 byte_t abtId[8];
00223 byte_t abtPad[8];
00224 byte_t abtSysCode[2];
00225 } nfc_felica_info_t;
00226
00231 typedef struct {
00232 byte_t abtAtqb[12];
00233 byte_t abtId[4];
00234 byte_t btParam1;
00235 byte_t btParam2;
00236 byte_t btParam3;
00237 byte_t btParam4;
00238 byte_t btCid;
00239 size_t szInfLen;
00240 byte_t abtInf[64];
00241 } nfc_iso14443b_info_t;
00242
00247 typedef struct {
00248 byte_t btSensRes[2];
00249 byte_t btId[4];
00250 } nfc_jewel_info_t;
00251
00256 typedef union {
00257 nfc_iso14443a_info_t nai;
00258 nfc_felica_info_t nfi;
00259 nfc_iso14443b_info_t nbi;
00260 nfc_jewel_info_t nji;
00261 nfc_dep_info_t ndi;
00262 } nfc_target_info_t;
00263
00268 typedef enum {
00270 NTT_GENERIC_PASSIVE_106 = 0x00,
00272 NTT_GENERIC_PASSIVE_212 = 0x01,
00274 NTT_GENERIC_PASSIVE_424 = 0x02,
00276 NTT_ISO14443B_106 = 0x03,
00278 NTT_JEWEL_106 = 0x04,
00280 NTT_MIFARE = 0x10,
00282 NTT_FELICA_212 = 0x11,
00284 NTT_FELICA_424 = 0x12,
00286 NTT_ISO14443A_106 = 0x20,
00288 NTT_ISO14443B_TCL_106 = 0x23,
00290 NTT_DEP_PASSIVE_106 = 0x40,
00292 NTT_DEP_PASSIVE_212 = 0x41,
00294 NTT_DEP_PASSIVE_424 = 0x42,
00296 NTT_DEP_ACTIVE_106 = 0x80,
00298 NTT_DEP_ACTIVE_212 = 0x81,
00300 NTT_DEP_ACTIVE_424 = 0x82,
00301 } nfc_target_type_t;
00302
00307 typedef struct {
00308 nfc_target_info_t nti;
00309 nfc_target_type_t ntt;
00310 } nfc_target_t;
00311
00312
00313 # pragma pack()
00314
00315 #endif // _LIBNFC_TYPES_H_