Go to the documentation of this file.
37 # include <sys/time.h>
47 # define NFC_EXPORT __declspec(dllexport)
50 # define NFC_EXPORT __declspec(dllimport)
67 # ifndef __has_attribute
68 # define __has_attribute(x) 0
71 # if __has_attribute(nonnull) || defined(__GNUC__)
72 # define __has_attribute_nonnull 1
75 # if __has_attribute_nonnull
76 # define ATTRIBUTE_NONNULL( param ) __attribute__((nonnull (param)))
78 # define ATTRIBUTE_NONNULL( param )
83 # endif // __cplusplus
105 NFC_EXPORT
int nfc_initiator_deselect_target(
nfc_device *pnd);
136 NFC_EXPORT
void iso14443a_crc(uint8_t *pbtData,
size_t szLen, uint8_t *pbtCrc);
137 NFC_EXPORT
void iso14443a_crc_append(uint8_t *pbtData,
size_t szLen);
138 NFC_EXPORT
void iso14443b_crc(uint8_t *pbtData,
size_t szLen, uint8_t *pbtCrc);
139 NFC_EXPORT
void iso14443b_crc_append(uint8_t *pbtData,
size_t szLen);
140 NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes(uint8_t *pbtAts,
size_t szAts,
size_t *pszTk);
156 #define NFC_SUCCESS 0
166 #define NFC_EINVARG -2
171 #define NFC_EDEVNOTSUPP -3
176 #define NFC_ENOTSUCHDEV -4
181 #define NFC_EOVFLOW -5
186 #define NFC_ETIMEOUT -6
191 #define NFC_EOPABORTED -7
196 #define NFC_ENOTIMPL -8
201 #define NFC_ETGRELEASED -10
206 #define NFC_ERFTRANS -20
211 #define NFC_EMFCAUTHFAIL -30
216 #define NFC_ESOFT -80
221 #define NFC_ECHIP -90
226 # endif // __cplusplus
NFC_EXPORT int nfc_initiator_init(nfc_device *pnd)
Initialize NFC device as initiator (reader)
NFC_EXPORT void nfc_init(nfc_context **context) ATTRIBUTE_NONNULL(1)
Initialize libnfc. This function must be called before calling any other libnfc function.
NFC library context Struct which contains internal options, references, pointers, etc....
struct nfc_driver nfc_driver
const NFC_EXPORT char * nfc_version(void)
Returns the library version.
NFC_EXPORT int nfc_target_init(nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout)
Initialize NFC device as an emulated tag.
NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt)
Get supported modulations.
NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1)
NFC_EXPORT int nfc_initiator_poll_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout)
Poll a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
NFC_EXPORT int nfc_initiator_list_passive_targets(nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets)
List passive or emulated tags.
NFC_EXPORT int nfc_initiator_poll_target(nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt)
Polling for NFC targets.
NFC_EXPORT void nfc_exit(nfc_context *context) ATTRIBUTE_NONNULL(1)
Deinitialize libnfc. Should be called after closing all open devices and before your application term...
NFC_EXPORT int nfc_strerror_r(const nfc_device *pnd, char *buf, size_t buflen)
Renders the last error in pcStrErrBuf for a maximum size of szBufLen chars.
const NFC_EXPORT char * str_nfc_baud_rate(const nfc_baud_rate nbr)
Convert nfc_baud_rate value to string.
int nfc_register_driver(const struct nfc_driver *ndr)
Register an NFC device driver with libnfc. This function registers a driver with libnfc,...
NFC_EXPORT int nfc_target_receive_bits(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar)
Receive bit-frames.
NFC_EXPORT int nfc_initiator_select_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout)
Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
NFC_EXPORT int nfc_initiator_transceive_bits_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar, uint32_t *cycles)
Transceive raw bit-frames to a target.
NFC_EXPORT int nfc_initiator_transceive_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout)
Send data to target then retrieve data from target.
NFC_EXPORT int nfc_device_get_information_about(nfc_device *pnd, char **buf)
Print information about NFC device.
nfc_dep_mode
NFC D.E.P. (Data Exchange Protocol) active/passive mode.
NFC_EXPORT int nfc_initiator_transceive_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar)
Transceive raw bit-frames to a target.
NFC modulation structure.
char nfc_connstring[NFC_BUFSIZE_CONNSTRING]
const NFC_EXPORT char * nfc_device_get_connstring(nfc_device *pnd)
Returns the device connection string.
const NFC_EXPORT char * nfc_device_get_name(nfc_device *pnd)
Returns the device name.
const NFC_EXPORT char * nfc_strerror(const nfc_device *pnd)
Return the last error string.
NFC_EXPORT nfc_device * nfc_open(nfc_context *context, const nfc_connstring connstring) ATTRIBUTE_NONNULL(1)
Open a NFC device.
nfc_baud_rate
NFC baud rate enumeration.
NFC_EXPORT int nfc_initiator_select_passive_target(nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt)
Select a passive or emulated tag.
NFC_EXPORT void nfc_perror(const nfc_device *pnd, const char *s)
Display the last error occured on a nfc_device.
NFC_EXPORT size_t nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], size_t connstrings_len) ATTRIBUTE_NONNULL(1)
Scan for discoverable supported devices (ie. only available for some drivers)
NFC_EXPORT int nfc_initiator_init_secure_element(nfc_device *pnd)
Initialize NFC device as initiator with its secure element initiator (reader)
NFC_EXPORT int nfc_target_send_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar)
Send raw bit-frames.
NFC_EXPORT int nfc_initiator_transceive_bytes_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, uint32_t *cycles)
Send data to target then retrieve data from target.
NFC_EXPORT int nfc_abort_command(nfc_device *pnd)
Abort current running command.
nfc_modulation_type
NFC modulation type enumeration.
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value)
Set a device's integer-property value.
NFC_EXPORT void nfc_close(nfc_device *pnd)
Close from a NFC device.
NFC_EXPORT int nfc_device_get_last_error(const nfc_device *pnd)
Returns last error occured on a nfc_device.
nfc_mode
NFC mode type enumeration.
NFC_EXPORT int str_nfc_target(char **buf, const nfc_target *pnt, bool verbose)
Convert nfc_modulation_type value to string.
NFC_EXPORT int nfc_idle(nfc_device *pnd)
Turn NFC device in idle mode.
NFC_EXPORT int nfc_target_receive_bytes(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, int timeout)
Receive bytes and APDU frames.
NFC_EXPORT int nfc_target_send_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout)
Send bytes and APDU frames.
NFC_EXPORT int nfc_device_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable)
Set a device's boolean-property value.
const NFC_EXPORT char * str_nfc_modulation_type(const nfc_modulation_type nmt)
Convert nfc_modulation_type value to string.
NFC_EXPORT int nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target *pnt)
Check target presence.
NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
Get supported baud rates.
NFC_EXPORT void nfc_free(void *p)
Free buffer allocated by libnfc.