nfc.h

Go to the documentation of this file.
00001 /*-
00002  * Public platform independent Near Field Communication (NFC) library
00003  * 
00004  * Copyright (C) 2009, Roel Verdult
00005  * 
00006  * This program is free software: you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by the
00008  * Free Software Foundation, either version 3 of the License, or (at your
00009  * option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00014  * more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00027 #ifndef _LIBNFC_H_
00028 #define _LIBNFC_H_
00029 
00030 #include <stdint.h>
00031 #include <stdbool.h>
00032 
00033 #ifdef _WIN32
00034   /* Windows platform */
00035   #ifndef _WINDLL
00036     /* CMake compilation */
00037     #ifdef nfc_EXPORTS
00038       #define  NFC_EXPORT __declspec(dllexport)
00039     #else /* nfc_EXPORTS */
00040       #define  NFC_EXPORT __declspec(dllimport)
00041     #endif /* nfc_EXPORTS */
00042   #else /* _WINDLL */
00043     /* Manual makefile */
00044     #define NFC_EXPORT
00045   #endif /* _WINDLL */
00046 #else /* _WIN32 */
00047   #define NFC_EXPORT
00048 #endif /* _WIN32 */
00049 
00050 #include <nfc/nfc-types.h>
00051 
00052 #ifdef __cplusplus 
00053     extern "C" {
00054 #endif // __cplusplus
00055 
00056 /* NFC Device/Hardware manipulation */
00057 NFC_EXPORT void nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound);
00058 NFC_EXPORT nfc_device_t* nfc_connect(nfc_device_desc_t* pndd);
00059 NFC_EXPORT void nfc_disconnect(nfc_device_t* pnd);
00060 NFC_EXPORT bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEnable);
00061 
00062 /* NFC initiator: act as "reader" */
00063 NFC_EXPORT bool nfc_initiator_init(const nfc_device_t* pnd);
00064 NFC_EXPORT bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti);
00065 NFC_EXPORT bool nfc_initiator_select_dep_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtPidData, const size_t szPidDataLen, const byte_t* pbtNFCID3i, const size_t szNFCID3iDataLen, const byte_t *pbtGbData, const size_t szGbDataLen, nfc_target_info_t* pti);
00066 NFC_EXPORT bool nfc_initiator_deselect_tag(const nfc_device_t* pnd);
00067 NFC_EXPORT bool nfc_initiator_transceive_bits(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar);
00068 NFC_EXPORT bool nfc_initiator_transceive_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
00069 NFC_EXPORT bool nfc_initiator_transceive_dep_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
00070 NFC_EXPORT bool nfc_initiator_mifare_cmd(const nfc_device_t* pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp);
00071 
00072 /* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
00073 NFC_EXPORT bool nfc_target_init(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits);
00074 NFC_EXPORT bool nfc_target_receive_bits(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar);
00075 NFC_EXPORT bool nfc_target_receive_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
00076 NFC_EXPORT bool nfc_target_receive_dep_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
00077 NFC_EXPORT bool nfc_target_send_bits(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar);
00078 NFC_EXPORT bool nfc_target_send_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
00079 NFC_EXPORT bool nfc_target_send_dep_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
00080 
00081 /* Special data accessors */
00082 NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd);
00083 
00084 /* Misc. functions */
00085 NFC_EXPORT void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc);
00086 NFC_EXPORT const char* nfc_version(void);
00087 
00088 #ifdef __cplusplus 
00089 }
00090 #endif // __cplusplus
00091 
00092 
00093 #endif // _LIBNFC_H_
00094 

Generated on 8 May 2010 for libnfc by  doxygen 1.6.1