Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifdef HAVE_CONFIG_H
00027 # include "config.h"
00028 #endif // HAVE_CONFIG_H
00029
00030 #include <err.h>
00031 #include <stdio.h>
00032 #include <nfc/nfc.h>
00033
00034 #define MAX_FRAME_LEN 264
00035
00036 int
00037 main (int argc, const char *argv[])
00038 {
00039 byte_t abtRecv[MAX_FRAME_LEN];
00040 size_t szRecvBits;
00041 byte_t send[] = "Hello Mars!";
00042 nfc_device_t *pnd = nfc_connect (NULL);
00043
00044 if (argc > 1) {
00045 errx (1, "usage: %s", argv[0]);
00046 }
00047
00048 if (!pnd || !nfc_target_init (pnd, abtRecv, &szRecvBits)) {
00049 printf ("unable to connect or initialize\n");
00050 return 1;
00051 }
00052
00053 if (!nfc_target_receive_bytes (pnd, abtRecv, &szRecvBits)) {
00054 printf ("unable to receive data\n");
00055 return 1;
00056 }
00057 abtRecv[szRecvBits] = 0;
00058 printf ("Received: %s\n", abtRecv);
00059 printf ("Sending : %s\n", send);
00060
00061 if (!nfc_target_send_bytes (pnd, send, 11)) {
00062 printf ("unable to send data\n");
00063 return 1;
00064 }
00065
00066 nfc_disconnect (pnd);
00067 return 0;
00068 }