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 <stdio.h>
00030 #include <string.h>
00031 #include <nfc/nfc.h>
00032
00033 #define MAX_FRAME_LEN 264
00034
00035 int main(int argc, const char *argv[])
00036 {
00037 nfc_device_t *pnd;
00038 nfc_target_info_t ti;
00039 byte_t abtRecv[MAX_FRAME_LEN];
00040 size_t szRecvBits;
00041 byte_t send[] = "Hello World!";
00042
00043 pnd = nfc_connect(NULL);
00044 if (!pnd || !nfc_initiator_init(pnd)
00045 || !nfc_initiator_select_dep_target(pnd, NM_PASSIVE_DEP, NULL, 0,
00046 NULL, 0, NULL, 0, &ti)) {
00047 printf
00048 ("unable to connect, initialize, or select the target\n");
00049 return 1;
00050 }
00051
00052 printf("Sending : %s\n", send);
00053 if (!nfc_initiator_transceive_dep_bytes(pnd,
00054 send,
00055 strlen((char*)send), abtRecv,
00056 &szRecvBits)) {
00057 printf("unable to send data\n");
00058 return 1;
00059 }
00060
00061 abtRecv[szRecvBits] = 0;
00062 printf("Received: %s\n", abtRecv);
00063
00064 nfc_initiator_deselect_tag(pnd);
00065 nfc_disconnect(pnd);
00066 return 0;
00067 }