Go to the documentation of this file.
44 #endif // HAVE_CONFIG_H
55 #define MAX_FRAME_LEN 264
60 static void stop_dep_communication(
int sig)
72 main(
int argc,
const char *argv[])
75 uint8_t abtRx[MAX_FRAME_LEN];
76 uint8_t abtTx[] =
"Hello World!";
79 printf(
"Usage: %s\n", argv[0]);
84 if (context == NULL) {
85 ERR(
"Unable to init libnfc (malloc)");
91 ERR(
"Unable to open NFC device.");
97 signal(SIGINT, stop_dep_communication);
107 nfc_perror(pnd,
"nfc_initiator_select_dep_target");
112 print_nfc_target(&nt,
false);
114 printf(
"Sending: %s\n", abtTx);
117 nfc_perror(pnd,
"nfc_initiator_transceive_bytes");
124 printf(
"Received: %s\n", abtRx);
126 if (nfc_initiator_deselect_target(pnd) < 0) {
127 nfc_perror(pnd,
"nfc_initiator_deselect_target");
int nfc_initiator_init(nfc_device *pnd)
Initialize NFC device as initiator (reader)
void nfc_init(nfc_context **context)
Initialize libnfc. This function must be called before calling any other libnfc function.
NFC library context Struct which contains internal options, references, pointers, etc....
void nfc_exit(nfc_context *context)
Deinitialize libnfc. Should be called after closing all open devices and before your application term...
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)
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.
const char * nfc_device_get_name(nfc_device *pnd)
Returns the device name.
nfc_device * nfc_open(nfc_context *context, const nfc_connstring connstring)
Open a NFC device.
void nfc_perror(const nfc_device *pnd, const char *pcString)
Display the last error occured on a nfc_device.
#define ERR(...)
Print a error message.
int nfc_abort_command(nfc_device *pnd)
Abort current running command.
void nfc_close(nfc_device *pnd)
Close from a NFC device.
Provide some examples shared functions like print, parity calculation, options parsing.