00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #ifndef _LIBNFC_H_
00029 # define _LIBNFC_H_
00030
00031 # include <stdint.h>
00032 # include <stdbool.h>
00033
00034 # ifdef _WIN32
00035
00036 # ifndef _WINDLL
00037
00038 # ifdef nfc_EXPORTS
00039 # define NFC_EXPORT __declspec(dllexport)
00040 # else
00041
00042 # define NFC_EXPORT __declspec(dllimport)
00043 # endif
00044
00045 # else
00046
00047
00048 # define NFC_EXPORT
00049 # endif
00050
00051 # else
00052
00053 # define NFC_EXPORT
00054 # endif
00055
00056
00057 # include <nfc/nfc-types.h>
00058
00059 # ifdef __cplusplus
00060 extern "C" {
00061 # endif // __cplusplus
00062
00063
00064 NFC_EXPORT nfc_device_t *nfc_connect (nfc_device_desc_t * pndd);
00065 NFC_EXPORT void nfc_disconnect (nfc_device_t * pnd);
00066 NFC_EXPORT void nfc_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
00067 NFC_EXPORT bool nfc_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
00068
00069
00070 NFC_EXPORT bool nfc_initiator_init (nfc_device_t * pnd);
00071 NFC_EXPORT bool nfc_initiator_select_passive_target (nfc_device_t * pnd, const nfc_modulation_t nm,
00072 const byte_t * pbtInitData, const size_t szInitData,
00073 nfc_target_t * pnt);
00074 NFC_EXPORT bool nfc_initiator_list_passive_targets (nfc_device_t * pnd, const nfc_modulation_t nm,
00075 nfc_target_t ant[], const size_t szTargets,
00076 size_t * pszTargetFound);
00077 NFC_EXPORT bool nfc_initiator_poll_targets (nfc_device_t * pnd, const nfc_modulation_t * pnmTargetTypes,
00078 const size_t szTargetTypes, const byte_t btPollNr, const byte_t btPeriod,
00079 nfc_target_t * pntTargets, size_t * pszTargetFound);
00080 NFC_EXPORT bool nfc_initiator_select_dep_target (nfc_device_t * pnd,
00081 const nfc_dep_mode_t ndm, const nfc_baud_rate_t nbr,
00082 const nfc_dep_info_t * pndiInitiator,
00083 nfc_target_t * pnt);
00084 NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device_t * pnd);
00085 NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
00086 byte_t * pbtRx, size_t * pszRx);
00087 NFC_EXPORT bool nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
00088 const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
00089 byte_t * pbtRxPar);
00090
00091
00092 NFC_EXPORT bool nfc_target_init (nfc_device_t * pnd, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
00093 NFC_EXPORT bool nfc_target_send_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx);
00094 NFC_EXPORT bool nfc_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx);
00095 NFC_EXPORT bool nfc_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
00096 const byte_t * pbtTxPar);
00097 NFC_EXPORT bool nfc_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
00098
00099
00100 NFC_EXPORT const char *nfc_strerror (const nfc_device_t * pnd);
00101 NFC_EXPORT int nfc_strerror_r (const nfc_device_t * pnd, char *pcStrErrBuf, size_t szBufLen);
00102 NFC_EXPORT void nfc_perror (const nfc_device_t * pnd, const char *pcString);
00103
00104
00105 NFC_EXPORT const char *nfc_device_name (nfc_device_t * pnd);
00106
00107
00108 NFC_EXPORT void iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc);
00109 NFC_EXPORT void iso14443a_crc_append (byte_t * pbtData, size_t szLen);
00110 NFC_EXPORT byte_t * iso14443a_locate_historical_bytes (byte_t * pbtAts, size_t szAts, size_t * pszTk);
00111 NFC_EXPORT const char *nfc_version (void);
00112
00113
00114
00115 #define ETIMEOUT 0x01
00116 #define ECRC 0x02
00117 #define EPARITY 0x03
00118 #define EBITCOUNT 0x04
00119 #define EFRAMING 0x05
00120 #define EBITCOLL 0x06
00121 #define ESMALLBUF 0x07
00122 #define EBUFOVF 0x09
00123 #define ERFTIMEOUT 0x0a
00124 #define ERFPROTO 0x0b
00125 #define EOVHEAT 0x0d
00126 #define EINBUFOVF 0x0e
00127 #define EINVPARAM 0x10
00128 #define EDEPUNKCMD 0x12
00129 #define EINVRXFRAM 0x13
00130 #define EMFAUTH 0x14
00131 #define ENSECNOTSUPP 0x18 // PN533 only
00132 #define EBCC 0x23
00133 #define EDEPINVSTATE 0x25
00134 #define EOPNOTALL 0x26
00135 #define ECMD 0x27
00136 #define ETGREL 0x29
00137 #define ECID 0x2a
00138 #define ECDISCARDED 0x2b
00139 #define ENFCID3 0x2c
00140 #define EOVCURRENT 0x2d
00141 #define ENAD 0x2e
00142
00143
00144 #define ETGUIDNOTSUP 0x0100
00145
00146
00147 #define DEIO 0x1000
00148 #define DEINVAL 0x2000
00149 #define DETIMEOUT 0x3000
00150
00151 # ifdef __cplusplus
00152 }
00153 # endif // __cplusplus
00154 #endif // _LIBNFC_H_