nfc-types.h   nfc-types.h 
skipping to change at line 38 skipping to change at line 38
# define __NFC_TYPES_H__ # define __NFC_TYPES_H__
# include <stddef.h> # include <stddef.h>
# include <stdint.h> # include <stdint.h>
# include <stdbool.h> # include <stdbool.h>
# include <stdio.h> # include <stdio.h>
typedef uint8_t byte_t; typedef uint8_t byte_t;
# define DEVICE_NAME_LENGTH 256 # define DEVICE_NAME_LENGTH 256
# define DEVICE_PORT_LENGTH 64
/** /**
* @struct nfc_device_t * @struct nfc_device_t
* @brief NFC device information * @brief NFC device information
*/ */
typedef struct { typedef struct {
/** Driver's functions for handling device specific wrapping */ /** Driver's functions for handling device specific wrapping */
const struct nfc_driver_t *driver; const struct nfc_driver_t *driver;
void* driver_data; void* driver_data;
void* chip_data; void* chip_data;
/** Device name string, including device wrapper firmware */ /** Device name string, including device wrapper firmware */
char acName[DEVICE_NAME_LENGTH]; char acName[DEVICE_NAME_LENGTH];
/** Is the crc automaticly added, checked and removed from the frames */ /** Is the crc automaticly added, checked and removed from the frames */
bool bCrc; bool bCrc;
/** Does the PN53x chip handles parity bits, all parities are handled as da ta */ /** Does the chip handle parity bits, all parities are handled as data */
bool bPar; bool bPar;
/** Should the PN53x chip handle frames encapsulation and chaining */ /** Should the chip handle frames encapsulation and chaining */
bool bEasyFraming; bool bEasyFraming;
/** Should the PN53x chip switch automatically in ISO14443-4 when ISO14443 /** Should the chip switch automatically activate ISO14443-4 when
*/ selecting tags supporting it? */
bool bAutoIso14443_4; bool bAutoIso14443_4;
/** Supported modulation encoded in a byte */ /** Supported modulation encoded in a byte */
byte_t btSupportByte; byte_t btSupportByte;
/** Last error reported by the PCD / encountered by the PCD driver /** Last error reported by the PCD / encountered by the PCD driver
* MSB LSB * MSB LSB
* | 00 | 00 | * | 00 | 00 |
* || || * || ||
* || ++----- Chip-level error (as reported by the PCD) * || ++----- Chip-level error (as reported by the PCD)
* |+---------- Driver-level specific error * |+---------- Driver-level specific error
* +----------- Driver-level general error (common to all drivers) * +----------- Driver-level general error (common to all drivers)
*/ */
int iLastError; int iLastError;
int iAbortFds[2];
} nfc_device_t; } nfc_device_t;
/** /**
* @struct nfc_device_desc_t * @struct nfc_device_desc_t
* @brief NFC device description * @brief NFC device description
* *
* This struct is used to try to connect to a specified nfc device when nfc _connect(...) * This struct is used to try to connect to a specified nfc device when nfc _connect(...)
*/ */
typedef struct { typedef struct {
/** Device name (e.g. "ACS ACR 38U-CCID 00 00") */ /** Device name (e.g. "ACS ACR 38U-CCID 00 00") */
char acDevice[DEVICE_NAME_LENGTH]; char acDevice[DEVICE_NAME_LENGTH];
/** Driver name (e.g. "PN532_UART")*/ /** Driver name (e.g. "PN532_UART")*/
char *pcDriver; char *pcDriver;
/** Port (e.g. "/dev/ttyUSB0") */ /** Port (e.g. "/dev/ttyUSB0") */
char *pcPort; char acPort[DEVICE_PORT_LENGTH];
/** Port speed (e.g. "115200") */ /** Port speed (e.g. "115200") */
uint32_t uiSpeed; uint32_t uiSpeed;
/** Device index for backward compatibility (used to choose one specific device in USB or PSCS devices list) */ /** Device index for backward compatibility (used to choose one specific device in USB or PSCS devices list) */
uint32_t uiBusIndex; uint32_t uiBusIndex;
} nfc_device_desc_t; } nfc_device_desc_t;
/**
* @struct chip_callbacks
* @brief Functions for chip specific functions.
*/
struct chip_callbacks {
/** Error lookup */
const char *(*strerror) (const nfc_device_t * pnd);
};
// Compiler directive, set struct alignment to 1 byte_t for compatibility // Compiler directive, set struct alignment to 1 byte_t for compatibility
# pragma pack(1) # pragma pack(1)
/** /**
* @enum nfc_device_option_t * @enum nfc_device_option_t
* @brief NFC device option * @brief NFC device option
*/ */
typedef enum { typedef enum {
/** Let the PN53X chip handle the CRC bytes. This means that the chip appen ds /** Let the PN53X chip handle the CRC bytes. This means that the chip appen ds
* the CRC bytes to the frames that are transmitted. It will parse the last * the CRC bytes to the frames that are transmitted. It will parse the last
skipping to change at line 160 skipping to change at line 153
* In initiator mode, it means that NFC chip will send RATS automatically w hen * In initiator mode, it means that NFC chip will send RATS automatically w hen
* select and it will automatically poll for ISO14443-4 card when ISO14443A is * select and it will automatically poll for ISO14443-4 card when ISO14443A is
* requested. * requested.
* In target mode, with a NFC chip compiliant (ie. PN532), the chip will * In target mode, with a NFC chip compiliant (ie. PN532), the chip will
* emulate a 14443-4 PICC using hardware capability */ * emulate a 14443-4 PICC using hardware capability */
NDO_AUTO_ISO14443_4 = 0x40, NDO_AUTO_ISO14443_4 = 0x40,
/** Use automatic frames encapsulation and chaining. */ /** Use automatic frames encapsulation and chaining. */
NDO_EASY_FRAMING = 0x41, NDO_EASY_FRAMING = 0x41,
/** Force the chip to switch in ISO14443-A */ /** Force the chip to switch in ISO14443-A */
NDO_FORCE_ISO14443_A = 0x42, NDO_FORCE_ISO14443_A = 0x42,
/** Force the chip to switch in ISO14443-B */
NDO_FORCE_ISO14443_B = 0x43,
/** Force the chip to run at 106 kbps */
NDO_FORCE_SPEED_106 = 0x50,
} nfc_device_option_t; } nfc_device_option_t;
/** /**
* @enum nfc_dep_mode_t * @enum nfc_dep_mode_t
* @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode * @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode
*/ */
typedef enum { typedef enum {
NDM_UNDEFINED = 0, NDM_UNDEFINED = 0,
NDM_PASSIVE, NDM_PASSIVE,
NDM_ACTIVE, NDM_ACTIVE,
skipping to change at line 237 skipping to change at line 234
byte_t abtPupi[4]; byte_t abtPupi[4];
/** abtApplicationData store Application Data contained in ATQB (see ISO144 43-3) */ /** abtApplicationData store Application Data contained in ATQB (see ISO144 43-3) */
byte_t abtApplicationData[4]; byte_t abtApplicationData[4];
/** abtProtocolInfo store Protocol Info contained in ATQB (see ISO14443-3) */ /** abtProtocolInfo store Protocol Info contained in ATQB (see ISO14443-3) */
byte_t abtProtocolInfo[3]; byte_t abtProtocolInfo[3];
/** ui8CardIdentifier store CID (Card Identifier) attributted by PCD to the PICC */ /** ui8CardIdentifier store CID (Card Identifier) attributted by PCD to the PICC */
uint8_t ui8CardIdentifier; uint8_t ui8CardIdentifier;
} nfc_iso14443b_info_t; } nfc_iso14443b_info_t;
/** /**
* @struct nfc_iso14443bi_info_t
* @brief NFC ISO14443B' tag information
*/
typedef struct {
/** DIV: 4 LSBytes of tag serial number */
byte_t abtDIV[4];
/** Software version & type of REPGEN */
byte_t btVerLog;
/** Config Byte, present if long REPGEN */
byte_t btConfig;
/** ATR, if any */
size_t szAtrLen;
byte_t abtAtr[33];
} nfc_iso14443bi_info_t;
/**
* @struct nfc_iso14443b2sr_info_t
* @brief NFC ISO14443-2B ST SRx tag information
*/
typedef struct {
byte_t abtUID[8];
} nfc_iso14443b2sr_info_t;
/**
* @struct nfc_iso14443b2ct_info_t
* @brief NFC ISO14443-2B ASK CTx tag information
*/
typedef struct {
byte_t abtUID[4];
byte_t btProdCode;
byte_t btFabCode;
} nfc_iso14443b2ct_info_t;
/**
* @struct nfc_jewel_info_t * @struct nfc_jewel_info_t
* @brief NFC Jewel tag information * @brief NFC Jewel tag information
*/ */
typedef struct { typedef struct {
byte_t btSensRes[2]; byte_t btSensRes[2];
byte_t btId[4]; byte_t btId[4];
} nfc_jewel_info_t; } nfc_jewel_info_t;
/** /**
* @union nfc_target_info_t * @union nfc_target_info_t
* @brief Union between all kind of tags information structures. * @brief Union between all kind of tags information structures.
*/ */
typedef union { typedef union {
nfc_iso14443a_info_t nai; nfc_iso14443a_info_t nai;
nfc_felica_info_t nfi; nfc_felica_info_t nfi;
nfc_iso14443b_info_t nbi; nfc_iso14443b_info_t nbi;
nfc_iso14443bi_info_t nii;
nfc_iso14443b2sr_info_t nsi;
nfc_iso14443b2ct_info_t nci;
nfc_jewel_info_t nji; nfc_jewel_info_t nji;
nfc_dep_info_t ndi; nfc_dep_info_t ndi;
} nfc_target_info_t; } nfc_target_info_t;
/** /**
* @enum nfc_baud_rate_t * @enum nfc_baud_rate_t
* @brief NFC baud rate enumeration * @brief NFC baud rate enumeration
*/ */
typedef enum { typedef enum {
NBR_UNDEFINED = 0, NBR_UNDEFINED = 0,
skipping to change at line 275 skipping to change at line 309
NBR_424, NBR_424,
NBR_847, NBR_847,
} nfc_baud_rate_t; } nfc_baud_rate_t;
/** /**
* @enum nfc_modulation_type_t * @enum nfc_modulation_type_t
* @brief NFC modulation type enumeration * @brief NFC modulation type enumeration
*/ */
typedef enum { typedef enum {
NMT_ISO14443A, NMT_ISO14443A,
NMT_JEWEL,
NMT_ISO14443B, NMT_ISO14443B,
NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
NMT_ISO14443B2SR, // ISO14443-2B ST SRx
NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
NMT_FELICA, NMT_FELICA,
NMT_JEWEL,
NMT_DEP, NMT_DEP,
} nfc_modulation_type_t; } nfc_modulation_type_t;
/** /**
* @struct nfc_modulation_t * @struct nfc_modulation_t
* @brief NFC modulation structure * @brief NFC modulation structure
*/ */
typedef struct { typedef struct {
nfc_modulation_type_t nmt; nfc_modulation_type_t nmt;
nfc_baud_rate_t nbr; nfc_baud_rate_t nbr;
 End of changes. 13 change blocks. 
16 lines changed or deleted 52 lines changed or added


 nfc.h   nfc.h 
skipping to change at line 31 skipping to change at line 31
/** /**
* @file nfc.h * @file nfc.h
* @brief libnfc interface * @brief libnfc interface
* *
* Provide all usefull functions (API) to handle NFC devices. * Provide all usefull functions (API) to handle NFC devices.
*/ */
#ifndef _LIBNFC_H_ #ifndef _LIBNFC_H_
# define _LIBNFC_H_ # define _LIBNFC_H_
# include <sys/time.h>
# include <stdint.h> # include <stdint.h>
# include <stdbool.h> # include <stdbool.h>
# ifdef _WIN32 # ifdef _WIN32
/* Windows platform */ /* Windows platform */
# ifndef _WINDLL # ifndef _WINDLL
/* CMake compilation */ /* CMake compilation */
# ifdef nfc_EXPORTS # ifdef nfc_EXPORTS
# define NFC_EXPORT __declspec(dllexport) # define NFC_EXPORT __declspec(dllexport)
# else # else
skipping to change at line 66 skipping to change at line 68
# include <nfc/nfc-types.h> # include <nfc/nfc-types.h>
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
# endif // __cplusplus # endif // __cplusplus
/* NFC Device/Hardware manipulation */ /* NFC Device/Hardware manipulation */
NFC_EXPORT nfc_device_t *nfc_connect (nfc_device_desc_t * pndd); NFC_EXPORT nfc_device_t *nfc_connect (nfc_device_desc_t * pndd);
NFC_EXPORT void nfc_disconnect (nfc_device_t * pnd); NFC_EXPORT void nfc_disconnect (nfc_device_t * pnd);
NFC_EXPORT void nfc_abort_command (nfc_device_t * pnd); NFC_EXPORT bool nfc_abort_command (nfc_device_t * pnd);
NFC_EXPORT void nfc_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound); NFC_EXPORT void nfc_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
NFC_EXPORT bool nfc_configure (nfc_device_t * pnd, const nfc_device_optio n_t ndo, const bool bEnable); NFC_EXPORT bool nfc_configure (nfc_device_t * pnd, const nfc_device_optio n_t ndo, const bool bEnable);
NFC_EXPORT bool nfc_idle (nfc_device_t * pnd);
/* NFC initiator: act as "reader" */ /* NFC initiator: act as "reader" */
NFC_EXPORT bool nfc_initiator_init (nfc_device_t * pnd); NFC_EXPORT bool nfc_initiator_init (nfc_device_t * pnd);
NFC_EXPORT bool nfc_initiator_select_passive_target (nfc_device_t * pnd, const nfc_modulation_t nm, const byte_t * pbtInitData, const size_t szInitD ata, nfc_target_t * pnt); NFC_EXPORT bool nfc_initiator_select_passive_target (nfc_device_t * pnd, const nfc_modulation_t nm, const byte_t * pbtInitData, const size_t szInitD ata, nfc_target_t * pnt);
NFC_EXPORT bool nfc_initiator_list_passive_targets (nfc_device_t * pnd, c onst nfc_modulation_t nm, nfc_target_t ant[], const size_t szTargets, size_ t * pszTargetFound); NFC_EXPORT bool nfc_initiator_list_passive_targets (nfc_device_t * pnd, c onst nfc_modulation_t nm, nfc_target_t ant[], const size_t szTargets, size_ t * pszTargetFound);
NFC_EXPORT bool nfc_initiator_poll_targets (nfc_device_t * pnd, const nfc _modulation_t * pnmTargetTypes, const size_t szTargetTypes, const byte_t bt PollNr, const byte_t btPeriod, nfc_target_t * pntTargets, size_t * pszTarge tFound); NFC_EXPORT bool nfc_initiator_poll_target (nfc_device_t * pnd, const nfc_ modulation_t * pnmTargetTypes, const size_t szTargetTypes, const uint8_t ui PollNr, const uint8_t uiPeriod, nfc_target_t * pnt);
NFC_EXPORT bool nfc_initiator_select_dep_target (nfc_device_t * pnd, cons t nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_info_t * pnd iInitiator, nfc_target_t * pnt); NFC_EXPORT bool nfc_initiator_select_dep_target (nfc_device_t * pnd, cons t nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr, const nfc_dep_info_t * pnd iInitiator, nfc_target_t * pnt);
NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device_t * pnd); NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device_t * pnd);
NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx); NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, struct timeval *timeout);
NFC_EXPORT bool nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pb tRx, size_t * pszRxBits, byte_t * pbtRxPar); NFC_EXPORT bool nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_t * pb tRx, size_t * pszRxBits, byte_t * pbtRxPar);
NFC_EXPORT bool nfc_initiator_transceive_bytes_timed (nfc_device_t * pnd, NFC_EXPORT bool nfc_initiator_transceive_bytes_timed (nfc_device_t * pnd,
const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, u const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx, u
int16_t * cycles); int32_t * cycles);
NFC_EXPORT bool nfc_initiator_transceive_bits_timed (nfc_device_t * pnd, NFC_EXPORT bool nfc_initiator_transceive_bits_timed (nfc_device_t * pnd,
const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_ const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar, byte_
t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint16_t * cycles); t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar, uint32_t * cycles);
/* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */ /* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
NFC_EXPORT bool nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx); NFC_EXPORT bool nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
NFC_EXPORT bool nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * NFC_EXPORT bool nfc_target_send_bytes (nfc_device_t * pnd, const byte_t *
pbtTx, const size_t szTx); pbtTx, const size_t szTx, struct timeval *timout);
NFC_EXPORT bool nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pb NFC_EXPORT bool nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pb
tRx, size_t * pszRx); tRx, size_t * pszRx, struct timeval *timout);
NFC_EXPORT bool nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar); NFC_EXPORT bool nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, const byte_t * pbtTxPar);
NFC_EXPORT bool nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbt Rx, size_t * pszRxBits, byte_t * pbtRxPar); NFC_EXPORT bool nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbt Rx, size_t * pszRxBits, byte_t * pbtRxPar);
/* Error reporting */ /* Error reporting */
NFC_EXPORT const char *nfc_strerror (const nfc_device_t * pnd); NFC_EXPORT const char *nfc_strerror (const nfc_device_t * pnd);
NFC_EXPORT int nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBu f, size_t szBufLen); NFC_EXPORT int nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBu f, size_t szBufLen);
NFC_EXPORT void nfc_perror (const nfc_device_t * pnd, const char *pcStrin g); NFC_EXPORT void nfc_perror (const nfc_device_t * pnd, const char *pcStrin g);
/* Special data accessors */ /* Special data accessors */
NFC_EXPORT const char *nfc_device_name (nfc_device_t * pnd); NFC_EXPORT const char *nfc_device_name (nfc_device_t * pnd);
skipping to change at line 133 skipping to change at line 136
#define EDEPINVSTATE 0x25 #define EDEPINVSTATE 0x25
#define EOPNOTALL 0x26 #define EOPNOTALL 0x26
#define ECMD 0x27 #define ECMD 0x27
#define ETGREL 0x29 #define ETGREL 0x29
#define ECID 0x2a #define ECID 0x2a
#define ECDISCARDED 0x2b #define ECDISCARDED 0x2b
#define ENFCID3 0x2c #define ENFCID3 0x2c
#define EOVCURRENT 0x2d #define EOVCURRENT 0x2d
#define ENAD 0x2e #define ENAD 0x2e
/* Software level errors */ /* PN53x framing-level errors */
#define ETGUIDNOTSUP 0x0100 /* Target UID not supported */ #define EFRAACKMISMATCH 0x0100 /* Unexpected data */
#define EFRAISERRFRAME 0x0101 /* Error frame */
/* Common device-level errors */ /* Communication-level errors */
#define DEIO 0x1000 /* Input/output error */ #define ECOMIO 0x1000 /* Input/output error */
#define DEINVAL 0x2000 /* Invalid argument */ #define ECOMTIMEOUT 0x1001 /* Operation timeout */
#define DETIMEOUT 0x3000 /* Operation timeout */
#define DEABORT 0x4000 /* Operation aborted */ /* Software level errors */
#define ETGUIDNOTSUP 0xFF00 /* Target UID not supported */
#define EOPABORT 0xFF01 /* Operation aborted */
#define EINVALARG 0xFF02 /* Invalid argument */
#define EDEVNOTSUP 0xFF03 /* Not supported by device */
#define ENOTIMPL 0xFF04 /* Not (yet) implemented in libnfc */
# ifdef __cplusplus # ifdef __cplusplus
} }
# endif // __cplusplus # endif // __cplusplus
#endif // _LIBNFC_H_ #endif // _LIBNFC_H_
 End of changes. 9 change blocks. 
20 lines changed or deleted 29 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/