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
00025 #ifdef HAVE_CONFIG_H
00026 # include "config.h"
00027 #endif // HAVE_CONFIG_H
00028
00029 #include <err.h>
00030 #include <stdio.h>
00031 #include <string.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 nfc_device_t *pnd;
00040 nfc_target_info_t ti;
00041 byte_t abtRecv[MAX_FRAME_LEN];
00042 size_t szRecvBits;
00043 byte_t send[] = "Hello World!";
00044
00045 if (argc > 1) {
00046 errx (1, "usage: %s", argv[0]);
00047 }
00048
00049 pnd = nfc_connect (NULL);
00050 if (!pnd || !nfc_initiator_init (pnd)
00051 || !nfc_initiator_select_dep_target (pnd, NM_PASSIVE_DEP, NULL, 0, NULL, 0, NULL, 0, &ti)) {
00052 printf ("unable to connect, initialize, or select the target\n");
00053 return 1;
00054 }
00055
00056 printf ("Sending : %s\n", send);
00057 if (!nfc_initiator_transceive_bytes (pnd, send, strlen ((char *) send), abtRecv, &szRecvBits)) {
00058 printf ("unable to send data\n");
00059 return 1;
00060 }
00061
00062 abtRecv[szRecvBits] = 0;
00063 printf ("Received: %s\n", abtRecv);
00064
00065 nfc_initiator_deselect_target (pnd);
00066 nfc_disconnect (pnd);
00067 return 0;
00068 }