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 
00034 #include <nfc/nfc-types.h>
00035 
00036 #ifdef __cplusplus 
00037     extern "C" {
00038 #endif // __cplusplus
00039 
00040 /* NFC Device/Hardware manipulation */
00041 void nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound);
00042 nfc_device_t* nfc_connect(nfc_device_desc_t* pndd);
00043 void nfc_disconnect(nfc_device_t* pnd);
00044 bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEnable);
00045 
00046 /* NFC initiator: act as "reader" */
00047 bool nfc_initiator_init(const nfc_device_t* pnd);
00048 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);
00049 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);
00050 bool nfc_initiator_deselect_tag(const nfc_device_t* pnd);
00051 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);
00052 bool nfc_initiator_transceive_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
00053 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);
00054 bool nfc_initiator_mifare_cmd(const nfc_device_t* pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param* pmp);
00055 
00056 /* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
00057 bool nfc_target_init(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits);
00058 bool nfc_target_receive_bits(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar);
00059 bool nfc_target_receive_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
00060 bool nfc_target_receive_dep_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
00061 bool nfc_target_send_bits(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar);
00062 bool nfc_target_send_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
00063 bool nfc_target_send_dep_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
00064 
00065 /* Special data accessors */
00066 const char* nfc_device_name(nfc_device_t* pnd);
00067 
00068 /* Misc. functions */
00069 const char* nfc_version(void);
00070 
00071 #ifdef __cplusplus 
00072 }
00073 #endif // __cplusplus
00074 
00075 
00076 #endif // _LIBNFC_H_
00077