Files
libnfc/src/target.c
Romuald Conty be55ba2955 WARNING: API changed: nfc_connect() now take one argument. Have a look at nfc-list example (list.c) or at directly at function Doxygen comment (libnfc.h).
Add configure option: --disable-serial-autoprobe to fix Issue 2 (Autotools and CMake).
Fix Issue 11: it is now possible to specify a wanted device using new struct "nfc_device_desc_t".
Code cleanup.
2009-09-04 13:24:34 +00:00

32 lines
704 B
C

#include <stdio.h>
#include "libnfc.h"
int main(int argc, const char *argv[])
{
byte_t abtRecv[MAX_FRAME_LEN];
uint32_t uiRecvBits;
byte_t send[] = "Hello Mars!";
dev_info *pdi = nfc_connect(NULL);
if (!pdi || !nfc_target_init(pdi, abtRecv, &uiRecvBits)) {
printf("unable to connect or initialize\n");
return 1;
}
if (!nfc_target_receive_dep_bytes(pdi, abtRecv, &uiRecvBits)) {
printf("unable to receive data\n");
return 1;
}
abtRecv[uiRecvBits] = 0;
printf("Received: %s\n", abtRecv);
printf("Sending : %s\n", send);
if (!nfc_target_send_dep_bytes(pdi, send, 11)) {
printf("unable to send data\n");
return 1;
}
nfc_disconnect(pdi);
return 0;
}