2010-01-12 12:50:09 +01:00
|
|
|
/*-
|
2009-10-12 16:52:26 +02:00
|
|
|
* Public platform independent Near Field Communication (NFC) library
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, Roel Verdult
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2010-01-12 12:50:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-01-10 19:14:26 +01:00
|
|
|
* @file nfc.h
|
2010-01-12 12:50:09 +01:00
|
|
|
* @brief libnfc interface
|
2009-08-27 12:49:45 +02:00
|
|
|
*
|
2009-10-12 16:52:26 +02:00
|
|
|
* Provide all usefull functions (API) to handle NFC devices.
|
2009-08-27 12:49:45 +02:00
|
|
|
*/
|
|
|
|
|
2009-10-13 14:43:52 +02:00
|
|
|
#ifndef _LIBNFC_H_
|
2009-10-12 16:52:26 +02:00
|
|
|
#define _LIBNFC_H_
|
|
|
|
|
2009-05-27 12:13:19 +02:00
|
|
|
#include <stdint.h>
|
2009-05-27 16:05:07 +02:00
|
|
|
#include <stdbool.h>
|
2009-05-27 12:13:19 +02:00
|
|
|
|
2010-03-31 16:03:12 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
/* Windows platform */
|
|
|
|
#ifndef _WINDLL
|
|
|
|
/* CMake compilation */
|
|
|
|
#ifdef nfc_EXPORTS
|
|
|
|
#define NFC_EXPORT __declspec(dllexport)
|
|
|
|
#else /* nfc_EXPORTS */
|
|
|
|
#define NFC_EXPORT __declspec(dllimport)
|
|
|
|
#endif /* nfc_EXPORTS */
|
|
|
|
#else /* _WINDLL */
|
|
|
|
/* Manual makefile */
|
|
|
|
#define NFC_EXPORT
|
|
|
|
#endif /* _WINDLL */
|
|
|
|
#else /* _WIN32 */
|
|
|
|
#define NFC_EXPORT
|
|
|
|
#endif /* _WIN32 */
|
2009-11-10 10:47:59 +01:00
|
|
|
|
2009-12-01 15:23:00 +01:00
|
|
|
#include <nfc/nfc-types.h>
|
2009-04-29 14:47:41 +02:00
|
|
|
|
2009-11-02 08:46:29 +01:00
|
|
|
#ifdef __cplusplus
|
2009-12-08 15:34:07 +01:00
|
|
|
extern "C" {
|
2009-11-02 08:46:29 +01:00
|
|
|
#endif // __cplusplus
|
|
|
|
|
2010-01-12 12:50:09 +01:00
|
|
|
/* NFC Device/Hardware manipulation */
|
2010-03-22 21:34:02 +01:00
|
|
|
NFC_EXPORT void nfc_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound);
|
|
|
|
NFC_EXPORT nfc_device_t* nfc_connect(nfc_device_desc_t* pndd);
|
|
|
|
NFC_EXPORT void nfc_disconnect(nfc_device_t* pnd);
|
|
|
|
NFC_EXPORT bool nfc_configure(nfc_device_t* pnd, const nfc_device_option_t ndo, const bool bEnable);
|
2009-08-27 12:49:45 +02:00
|
|
|
|
2010-01-12 12:50:09 +01:00
|
|
|
/* NFC initiator: act as "reader" */
|
2010-03-22 21:34:02 +01:00
|
|
|
NFC_EXPORT bool nfc_initiator_init(const nfc_device_t* pnd);
|
2010-07-21 12:37:37 +02:00
|
|
|
NFC_EXPORT bool nfc_initiator_select_passive_target(const nfc_device_t* pnd, const nfc_modulation_t nmInitModulation, const byte_t* pbtInitData, const size_t szInitDataLen, nfc_target_info_t* pti);
|
2010-03-22 21:34:02 +01:00
|
|
|
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);
|
2010-07-21 12:37:37 +02:00
|
|
|
NFC_EXPORT bool nfc_initiator_deselect_target(const nfc_device_t* pnd);
|
2010-04-09 18:20:47 +02:00
|
|
|
NFC_EXPORT bool nfc_initiator_poll_targets(const nfc_device_t* pnd, const nfc_target_type_t* pnttTargetTypes, const size_t szTargetTypes, const byte_t btPollNr, const byte_t btPeriod, nfc_target_t* pntTargets, size_t* pszTargetFound);
|
2010-03-22 21:34:02 +01:00
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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);
|
2010-01-12 12:50:09 +01:00
|
|
|
|
|
|
|
/* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
|
2010-03-22 21:34:02 +01:00
|
|
|
NFC_EXPORT bool nfc_target_init(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits);
|
|
|
|
NFC_EXPORT bool nfc_target_receive_bits(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxBits, byte_t* pbtRxPar);
|
|
|
|
NFC_EXPORT bool nfc_target_receive_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
|
|
|
|
NFC_EXPORT bool nfc_target_receive_dep_bytes(const nfc_device_t* pnd, byte_t* pbtRx, size_t* pszRxLen);
|
|
|
|
NFC_EXPORT bool nfc_target_send_bits(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar);
|
|
|
|
NFC_EXPORT bool nfc_target_send_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
|
|
|
|
NFC_EXPORT bool nfc_target_send_dep_bytes(const nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
|
2009-09-03 15:47:26 +02:00
|
|
|
|
2010-01-10 19:14:26 +01:00
|
|
|
/* Special data accessors */
|
2010-03-22 21:34:02 +01:00
|
|
|
NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd);
|
2009-12-14 20:18:29 +01:00
|
|
|
|
2010-01-10 19:14:26 +01:00
|
|
|
/* Misc. functions */
|
2010-03-31 12:09:06 +02:00
|
|
|
NFC_EXPORT void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc);
|
2010-04-16 18:38:57 +02:00
|
|
|
NFC_EXPORT void append_iso14443a_crc(byte_t* pbtData, size_t szLen);
|
2010-03-22 21:34:02 +01:00
|
|
|
NFC_EXPORT const char* nfc_version(void);
|
2010-07-22 15:41:20 +02:00
|
|
|
NFC_EXPORT nfc_device_desc_t* nfc_parse_device_desc(int argc, const char *argv[], size_t* szFound);
|
2010-01-10 19:14:26 +01:00
|
|
|
|
2009-11-02 08:46:29 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif // __cplusplus
|
|
|
|
|
|
|
|
|
2009-02-12 13:39:05 +01:00
|
|
|
#endif // _LIBNFC_H_
|
|
|
|
|