2009-09-03 15:47:26 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "libnfc.h"
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
{
|
|
|
|
byte_t abtRecv[MAX_FRAME_LEN];
|
2009-10-02 11:52:02 +02:00
|
|
|
size_t szRecvBits;
|
2009-09-03 15:47:26 +02:00
|
|
|
byte_t send[] = "Hello Mars!";
|
2009-09-04 15:24:34 +02:00
|
|
|
dev_info *pdi = nfc_connect(NULL);
|
2009-09-03 15:47:26 +02:00
|
|
|
|
2009-10-02 11:52:02 +02:00
|
|
|
if (!pdi || !nfc_target_init(pdi, abtRecv, &szRecvBits)) {
|
2009-09-03 15:47:26 +02:00
|
|
|
printf("unable to connect or initialize\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-02 11:52:02 +02:00
|
|
|
if (!nfc_target_receive_dep_bytes(pdi, abtRecv, &szRecvBits)) {
|
2009-09-03 15:47:26 +02:00
|
|
|
printf("unable to receive data\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2009-10-02 11:52:02 +02:00
|
|
|
abtRecv[szRecvBits] = 0;
|
2009-09-03 15:47:26 +02:00
|
|
|
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;
|
|
|
|
}
|