2009-09-03 13:47:26 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "libnfc.h"
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
{
|
|
|
|
dev_info *pdi;
|
|
|
|
tag_info ti;
|
|
|
|
byte_t abtRecv[MAX_FRAME_LEN];
|
2009-10-02 09:52:02 +00:00
|
|
|
size_t szRecvBits;
|
2009-09-03 13:47:26 +00:00
|
|
|
byte_t send[] = "Hello World!";
|
|
|
|
|
2009-09-04 13:24:34 +00:00
|
|
|
pdi = nfc_connect(NULL);
|
2009-09-03 13:47:26 +00:00
|
|
|
if (!pdi || !nfc_initiator_init(pdi)
|
|
|
|
|| !nfc_initiator_select_dep_target(pdi, IM_PASSIVE_DEP, NULL, 0,
|
|
|
|
NULL, 0, NULL, 0, &ti)) {
|
|
|
|
printf
|
|
|
|
("unable to connect, initialize, or select the target\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Sending : %s\n", send);
|
|
|
|
if (!nfc_initiator_transceive_dep_bytes(pdi,
|
|
|
|
send,
|
2009-10-05 09:12:48 +00:00
|
|
|
strlen((char*)send), abtRecv,
|
2009-10-02 09:52:02 +00:00
|
|
|
&szRecvBits)) {
|
2009-09-03 13:47:26 +00:00
|
|
|
printf("unable to send data\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-02 09:52:02 +00:00
|
|
|
abtRecv[szRecvBits] = 0;
|
2009-09-03 13:47:26 +00:00
|
|
|
printf("Received: %s\n", abtRecv);
|
|
|
|
|
|
|
|
nfc_initiator_deselect_tag(pdi);
|
|
|
|
nfc_disconnect(pdi);
|
|
|
|
return 0;
|
|
|
|
}
|