Prefix defines.h, messages.h and types.h headers by "nfc-"

Rename dev_info struct to nfc_device_t
Some code cleanup
Rename pn531.h/c to pn531_usb.h/c
Rename pn533.h/c to pn533_usb.h/c
This commit is contained in:
Romuald Conty 2009-11-09 11:23:33 +00:00
parent 9ce99b80d3
commit 854dc3aceb
31 changed files with 419 additions and 433 deletions

View file

@ -24,7 +24,7 @@
#ifndef _LIBNFC_MIFARE_TAG_H_
#define _LIBNFC_MIFARE_TAG_H_
#include "defines.h"
#include "nfc-defines.h"
typedef struct {
byte_t abtUID[4];

View file

@ -24,7 +24,7 @@
#ifndef _LIBNFC_MIFARE_UL_TAG_H_
#define _LIBNFC_MIFARE_UL_TAG_H_
#include "defines.h"
#include "nfc-defines.h"
typedef struct {
byte_t sn0[3];

View file

@ -30,7 +30,7 @@
#include <nfc.h>
#include "messages.h"
#include "nfc-messages.h"
#include "bitutils.h"
#define SAK_FLAG_ATS_SUPPORTED 0x20
@ -40,7 +40,7 @@ static size_t szRxBits;
static size_t szRxLen;
static byte_t abtUid[10];
static size_t szUidLen = 4;
static dev_info* pdi;
static nfc_device_t* pnd;
bool quiet_output = false;
@ -61,7 +61,7 @@ bool transmit_bits(const byte_t* pbtTx, const size_t szTxBits)
}
// Transmit the bit frame command, we don't use the arbitrary parity feature
if (!nfc_initiator_transceive_bits(pdi,pbtTx,szTxBits,NULL,abtRx,&szRxBits,NULL)) return false;
if (!nfc_initiator_transceive_bits(pnd,pbtTx,szTxBits,NULL,abtRx,&szRxBits,NULL)) return false;
// Show received answer
if(!quiet_output)
@ -85,7 +85,7 @@ bool transmit_bytes(const byte_t* pbtTx, const size_t szTxLen)
}
// Transmit the command bytes
if (!nfc_initiator_transceive_bytes(pdi,pbtTx,szTxLen,abtRx,&szRxLen)) return false;
if (!nfc_initiator_transceive_bytes(pnd,pbtTx,szTxLen,abtRx,&szRxLen)) return false;
// Show received answer
if(!quiet_output)
@ -126,32 +126,32 @@ int main(int argc,char* argv[])
}
// Try to open the NFC reader
pdi = nfc_connect(NULL);
pnd = nfc_connect(NULL);
if (!pdi)
if (!pnd)
{
printf("Error connecting NFC reader\n");
return 1;
}
nfc_initiator_init(pdi);
nfc_initiator_init(pnd);
// Drop the field for a while
nfc_configure(pdi,DCO_ACTIVATE_FIELD,false);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,false);
// Configure the CRC and Parity settings
nfc_configure(pdi,DCO_HANDLE_CRC,false);
nfc_configure(pdi,DCO_HANDLE_PARITY,true);
nfc_configure(pnd,DCO_HANDLE_CRC,false);
nfc_configure(pnd,DCO_HANDLE_PARITY,true);
// Enable field so more power consuming cards can power themselves up
nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,true);
printf("\nConnected to NFC reader: %s\n\n",pdi->acName);
printf("\nConnected to NFC reader: %s\n\n",pnd->acName);
// Send the 7 bits request command specified in ISO 14443A (0x26)
if (!transmit_bits(abtReqa,7))
{
printf("Error: No tag available\n");
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}
@ -198,6 +198,6 @@ int main(int argc,char* argv[])
printf("%014llx\n",swap_endian64(abtUid)&0x00ffffffffffffffull);
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 0;
}

View file

@ -29,12 +29,12 @@
#include <nfc.h>
#include "messages.h"
#include "nfc-messages.h"
#include "bitutils.h"
static byte_t abtRecv[MAX_FRAME_LEN];
static size_t szRecvBits;
static dev_info* pdi;
static nfc_device_t* pnd;
// ISO14443A Anti-Collision response
byte_t abtAtqa [2] = { 0x04,0x00 };
@ -85,20 +85,20 @@ int main(int argc, char *argv[])
}
// Try to open the NFC reader
pdi = nfc_connect(NULL);
pnd = nfc_connect(NULL);
if (pdi == INVALID_DEVICE_INFO)
if (pnd == INVALID_DEVICE_INFO)
{
printf("Error connecting NFC reader\n");
return 1;
}
printf("\n");
printf("[+] Connected to NFC reader: %s\n",pdi->acName);
printf("[+] Connected to NFC reader: %s\n",pnd->acName);
printf("[+] Try to break out the auto-emulation, this requires a second reader!\n");
printf("[+] To do this, please send any command after the anti-collision\n");
printf("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
if (!nfc_target_init(pdi,abtRecv,&szRecvBits))
if (!nfc_target_init(pnd,abtRecv,&szRecvBits))
{
printf("Error: Could not come out of auto-emulation, no command was received\n");
return 1;
@ -106,14 +106,14 @@ int main(int argc, char *argv[])
printf("[+] Received initiator command: ");
print_hex_bits(abtRecv,szRecvBits);
printf("[+] Configuring communication\n");
nfc_configure(pdi,DCO_HANDLE_CRC,false);
nfc_configure(pdi,DCO_HANDLE_PARITY,true);
nfc_configure(pnd,DCO_HANDLE_CRC,false);
nfc_configure(pnd,DCO_HANDLE_PARITY,true);
printf("[+] Done, the emulated tag is initialized with UID: %02X%02X%02X%02X\n\n",abtUidBcc[0],abtUidBcc[1],abtUidBcc[2],abtUidBcc[3]);
while(true)
{
// Test if we received a frame
if (nfc_target_receive_bits(pdi,abtRecv,&szRecvBits,NULL))
if (nfc_target_receive_bits(pnd,abtRecv,&szRecvBits,NULL))
{
// Prepare the command to send back for the anti-collision request
switch(szRecvBits)
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
if(szTxBits)
{
// Send and print the command to the screen
nfc_target_send_bits(pdi,pbtTx,szTxBits,NULL);
nfc_target_send_bits(pnd,pbtTx,szTxBits,NULL);
if(!quiet_output)
{
printf("T: ");
@ -160,6 +160,6 @@ int main(int argc, char *argv[])
}
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
}

View file

@ -29,10 +29,10 @@
#include <nfc.h>
#include "messages.h"
#include "nfc-messages.h"
#include "bitutils.h"
static dev_info* pdi;
static nfc_device_t* pnd;
static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 };
int main(int argc, const char* argv[])
@ -40,7 +40,7 @@ int main(int argc, const char* argv[])
tag_info ti;
// Try to open the NFC device
pdi = nfc_connect(NULL);
pnd = nfc_connect(NULL);
// If specific device is wanted, i.e. an ARYGON device on /dev/ttyUSB0
/*
@ -49,33 +49,33 @@ int main(int argc, const char* argv[])
ndd.pcPort = "/dev/ttyUSB0";
ndd.uiSpeed = 115200;
pdi = nfc_connect(&ndd);
pnd = nfc_connect(&ndd);
*/
if (pdi == INVALID_DEVICE_INFO)
if (pnd == INVALID_DEVICE_INFO)
{
ERR("Unable to connect to NFC device.");
return 1;
}
nfc_initiator_init(pdi);
nfc_initiator_init(pnd);
// Drop the field for a while
nfc_configure(pdi,DCO_ACTIVATE_FIELD,false);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,false);
// Let the reader only try once to find a tag
nfc_configure(pdi,DCO_INFINITE_SELECT,false);
nfc_configure(pnd,DCO_INFINITE_SELECT,false);
// Configure the CRC and Parity settings
nfc_configure(pdi,DCO_HANDLE_CRC,true);
nfc_configure(pdi,DCO_HANDLE_PARITY,true);
nfc_configure(pnd,DCO_HANDLE_CRC,true);
nfc_configure(pnd,DCO_HANDLE_PARITY,true);
// Enable field so more power consuming cards can power themselves up
nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,true);
printf("Connected to NFC reader: %s\n\n",pdi->acName);
printf("Connected to NFC reader: %s\n\n",pnd->acName);
// Poll for a ISO14443A (MIFARE) tag
if (nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("The following (NFC) ISO14443A tag was found:\n\n");
printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
@ -89,7 +89,7 @@ int main(int argc, const char* argv[])
}
// Poll for a Felica tag
if (nfc_initiator_select_tag(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_initiator_select_tag(pdi,IM_FELICA_424,abtFelica,5,&ti))
if (nfc_initiator_select_tag(pnd,IM_FELICA_212,abtFelica,5,&ti) || nfc_initiator_select_tag(pnd,IM_FELICA_424,abtFelica,5,&ti))
{
printf("The following (NFC) Felica tag was found:\n\n");
printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8);
@ -97,7 +97,7 @@ int main(int argc, const char* argv[])
}
// Poll for a ISO14443B tag
if (nfc_initiator_select_tag(pdi,IM_ISO14443B_106,(byte_t*)"\x00",1,&ti))
if (nfc_initiator_select_tag(pnd,IM_ISO14443B_106,(byte_t*)"\x00",1,&ti))
{
printf("The following (NFC) ISO14443-B tag was found:\n\n");
printf(" ATQB: "); print_hex(ti.tib.abtAtqb,12);
@ -111,12 +111,12 @@ int main(int argc, const char* argv[])
}
// Poll for a Jewel tag
if (nfc_initiator_select_tag(pdi,IM_JEWEL_106,NULL,0,&ti))
if (nfc_initiator_select_tag(pnd,IM_JEWEL_106,NULL,0,&ti))
{
// No test results yet
printf("jewel\n");
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}

View file

@ -35,7 +35,7 @@
#include "mifaretag.h"
#include "bitutils.h"
static dev_info* pdi;
static nfc_device_t* pnd;
static tag_info ti;
static mifare_param mp;
static mifare_tag mtKeys;
@ -99,7 +99,7 @@ bool authenticate(uint32_t uiBlock)
}
// Try to authenticate for the current sector
if (nfc_initiator_mifare_cmd(pdi,mc,uiBlock,&mp))
if (nfc_initiator_mifare_cmd(pnd,mc,uiBlock,&mp))
return true;
}
@ -115,7 +115,7 @@ bool authenticate(uint32_t uiBlock)
for (key_index = 0; key_index < num_keys; key_index++)
{
memcpy(mp.mpa.abtKey, keys + (key_index*6), 6);
if (nfc_initiator_mifare_cmd(pdi, mc, uiBlock, &mp))
if (nfc_initiator_mifare_cmd(pnd, mc, uiBlock, &mp))
{
/**
* @note: what about the other key?
@ -128,7 +128,7 @@ bool authenticate(uint32_t uiBlock)
return true;
}
nfc_initiator_select_tag(pdi, IM_ISO14443A_106, mp.mpa.abtUid, 4, NULL);
nfc_initiator_select_tag(pnd, IM_ISO14443A_106, mp.mpa.abtUid, 4, NULL);
}
}
@ -153,7 +153,7 @@ bool read_card()
{
printf("x");
// When a failure occured we need to redo the anti-collision
if (!nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("!\nError: tag was removed\n");
return 1;
@ -176,7 +176,7 @@ bool read_card()
}
// Try to read out the trailer
if (nfc_initiator_mifare_cmd(pdi,MC_READ,iBlock,&mp))
if (nfc_initiator_mifare_cmd(pnd,MC_READ,iBlock,&mp))
{
// Copy the keys over from our key dump and store the retrieved access bits
memcpy(mtDump.amb[iBlock].mbt.abtKeyA,mtKeys.amb[iBlock].mbt.abtKeyA,6);
@ -188,7 +188,7 @@ bool read_card()
if (!bFailure)
{
// Try to read out the data block
if (nfc_initiator_mifare_cmd(pdi,MC_READ,iBlock,&mp))
if (nfc_initiator_mifare_cmd(pnd,MC_READ,iBlock,&mp))
{
memcpy(mtDump.amb[iBlock].mbd.abtData,mp.mpd.abtData,16);
} else {
@ -221,7 +221,7 @@ bool write_card()
{
printf("x");
// When a failure occured we need to redo the anti-collision
if (!nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("!\nError: tag was removed\n");
return false;
@ -252,7 +252,7 @@ bool write_card()
memcpy(mp.mpd.abtData+10,mtDump.amb[uiBlock].mbt.abtKeyB,6);
// Try to write the trailer
nfc_initiator_mifare_cmd(pdi,MC_WRITE,uiBlock,&mp);
nfc_initiator_mifare_cmd(pnd,MC_WRITE,uiBlock,&mp);
} else {
@ -264,7 +264,7 @@ bool write_card()
{
// Try to write the data block
memcpy(mp.mpd.abtData,mtDump.amb[uiBlock].mbd.abtData,16);
if (!nfc_initiator_mifare_cmd(pdi,MC_WRITE,uiBlock,&mp)) bFailure = true;
if (!nfc_initiator_mifare_cmd(pnd,MC_WRITE,uiBlock,&mp)) bFailure = true;
}
}
}
@ -396,33 +396,33 @@ int main(int argc, const char* argv[])
// printf("Successfully opened required files\n");
// Try to open the NFC reader
pdi = nfc_connect(NULL);
if (pdi == INVALID_DEVICE_INFO)
pnd = nfc_connect(NULL);
if (pnd == INVALID_DEVICE_INFO)
{
printf("Error connecting NFC reader\n");
return 1;
}
nfc_initiator_init(pdi);
nfc_initiator_init(pnd);
// Drop the field for a while
nfc_configure(pdi,DCO_ACTIVATE_FIELD,false);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,false);
// Let the reader only try once to find a tag
nfc_configure(pdi,DCO_INFINITE_SELECT,false);
nfc_configure(pdi,DCO_HANDLE_CRC,true);
nfc_configure(pdi,DCO_HANDLE_PARITY,true);
nfc_configure(pnd,DCO_INFINITE_SELECT,false);
nfc_configure(pnd,DCO_HANDLE_CRC,true);
nfc_configure(pnd,DCO_HANDLE_PARITY,true);
// Enable field so more power consuming cards can power themselves up
nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,true);
printf("Connected to NFC reader: %s\n",pdi->acName);
printf("Connected to NFC reader: %s\n",pnd->acName);
// Try to find a MIFARE Classic tag
if (!nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("Error: no tag was found\n");
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}
@ -430,7 +430,7 @@ int main(int argc, const char* argv[])
if ((ti.tia.btSak & 0x08) == 0)
{
printf("Error: tag is not a MIFARE Classic card\n");
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}
@ -476,7 +476,7 @@ int main(int argc, const char* argv[])
}
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
break;
case ACTION_EXTRACT: {

View file

@ -35,7 +35,7 @@
#include "mifareultag.h"
#include "bitutils.h"
static dev_info* pdi;
static nfc_device_t* pnd;
static tag_info ti;
static mifare_param mp;
static mifareul_tag mtDump;
@ -48,7 +48,7 @@ bool read_card()
// these are pages of 4 bytes each; we can read 4 pages at once.
for (page = 0; page <= 0xF; page += 4){
// Try to read out the data block
if (nfc_initiator_mifare_cmd(pdi,MC_READ,page,&mp))
if (nfc_initiator_mifare_cmd(pnd,MC_READ,page,&mp))
{
memcpy(mtDump.amb[page / 4].mbd.abtData, mp.mpd.abtData, 16);
} else {
@ -71,7 +71,7 @@ bool write_card()
{
printf("x");
// When a failure occured we need to redo the anti-collision
if (!nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("!\nError: tag was removed\n");
return false;
@ -95,7 +95,7 @@ bool write_card()
// writes one page at a time.
uiBlock = page / 4;
memcpy(mp.mpd.abtData, mtDump.amb[uiBlock].mbd.abtData + ((page % 4) * 4), 16);
if (!nfc_initiator_mifare_cmd(pdi, MC_WRITE, page, &mp)) bFailure = true;
if (!nfc_initiator_mifare_cmd(pnd, MC_WRITE, page, &mp)) bFailure = true;
}
}
printf("%c|\n",(bFailure)?'x':'.');
@ -148,33 +148,33 @@ int main(int argc, const char* argv[])
printf("Succesful opened the dump file\n");
// Try to open the NFC reader
pdi = nfc_connect(NULL);
if (pdi == INVALID_DEVICE_INFO)
pnd = nfc_connect(NULL);
if (pnd == INVALID_DEVICE_INFO)
{
printf("Error connecting NFC reader\n");
return 1;
}
nfc_initiator_init(pdi);
nfc_initiator_init(pnd);
// Drop the field for a while
nfc_configure(pdi,DCO_ACTIVATE_FIELD,false);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,false);
// Let the reader only try once to find a tag
nfc_configure(pdi,DCO_INFINITE_SELECT,false);
nfc_configure(pdi,DCO_HANDLE_CRC,true);
nfc_configure(pdi,DCO_HANDLE_PARITY,true);
nfc_configure(pnd,DCO_INFINITE_SELECT,false);
nfc_configure(pnd,DCO_HANDLE_CRC,true);
nfc_configure(pnd,DCO_HANDLE_PARITY,true);
// Enable field so more power consuming cards can power themselves up
nfc_configure(pdi,DCO_ACTIVATE_FIELD,true);
nfc_configure(pnd,DCO_ACTIVATE_FIELD,true);
printf("Connected to NFC reader: %s\n",pdi->acName);
printf("Connected to NFC reader: %s\n",pnd->acName);
// Try to find a MIFARE Ultralight tag
if (!nfc_initiator_select_tag(pdi,IM_ISO14443A_106,NULL,0,&ti))
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
{
printf("Error: no tag was found\n");
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}
@ -182,7 +182,7 @@ int main(int argc, const char* argv[])
if (ti.tia.abtAtqa[1] != 0x44){
printf("Error: tag is not a MIFARE Ultralight card\n");
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 1;
}
@ -218,7 +218,7 @@ int main(int argc, const char* argv[])
}
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 0;
}

View file

@ -28,7 +28,7 @@
#include <nfc.h>
#include "messages.h"
#include "nfc-messages.h"
#include "bitutils.h"
static byte_t abtReaderRx[MAX_FRAME_LEN];
@ -37,8 +37,8 @@ static size_t szReaderRxBits;
static byte_t abtTagRx[MAX_FRAME_LEN];
static byte_t abtTagRxPar[MAX_FRAME_LEN];
static size_t szTagRxBits;
static dev_info* pdiReader;
static dev_info* pdiTag;
static nfc_device_t* pndReader;
static nfc_device_t* pndTag;
void print_usage(char* argv[])
{
@ -69,8 +69,8 @@ int main(int argc,char* argv[])
}
// Try to open the NFC emulator device
pdiTag = nfc_connect(NULL);
if (pdiTag == INVALID_DEVICE_INFO)
pndTag = nfc_connect(NULL);
if (pndTag == INVALID_DEVICE_INFO)
{
printf("Error connecting NFC emulator device\n");
return 1;
@ -81,35 +81,35 @@ int main(int argc,char* argv[])
printf("[+] Try to break out the auto-emulation, this requires a second reader!\n");
printf("[+] To do this, please send any command after the anti-collision\n");
printf("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
nfc_target_init(pdiTag,abtReaderRx,&szReaderRxBits);
nfc_target_init(pndTag,abtReaderRx,&szReaderRxBits);
printf("[+] Configuring emulator settings\n");
nfc_configure(pdiTag,DCO_HANDLE_CRC,false);
nfc_configure(pdiTag,DCO_HANDLE_PARITY,false);
nfc_configure(pdiTag,DCO_ACCEPT_INVALID_FRAMES,true);
nfc_configure(pndTag,DCO_HANDLE_CRC,false);
nfc_configure(pndTag,DCO_HANDLE_PARITY,false);
nfc_configure(pndTag,DCO_ACCEPT_INVALID_FRAMES,true);
printf("[+] Thank you, the emulated tag is initialized\n");
// Try to open the NFC reader
pdiReader = INVALID_DEVICE_INFO;
while (pdiReader == INVALID_DEVICE_INFO) pdiReader = nfc_connect(NULL);
pndReader = INVALID_DEVICE_INFO;
while (pndReader == INVALID_DEVICE_INFO) pndReader = nfc_connect(NULL);
printf("[+] Configuring NFC reader settings\n");
nfc_configure(pdiReader,DCO_HANDLE_CRC,false);
nfc_configure(pdiReader,DCO_HANDLE_PARITY,false);
nfc_configure(pdiReader,DCO_ACCEPT_INVALID_FRAMES,true);
nfc_configure(pndReader,DCO_HANDLE_CRC,false);
nfc_configure(pndReader,DCO_HANDLE_PARITY,false);
nfc_configure(pndReader,DCO_ACCEPT_INVALID_FRAMES,true);
printf("[+] Done, relaying frames now!\n\n");
while(true)
{
// Test if we received a frame from the reader
if (nfc_target_receive_bits(pdiTag,abtReaderRx,&szReaderRxBits,abtReaderRxPar))
if (nfc_target_receive_bits(pndTag,abtReaderRx,&szReaderRxBits,abtReaderRxPar))
{
// Drop down the field before sending a REQA command and start a new session
if (szReaderRxBits == 7 && abtReaderRx[0] == 0x26)
{
// Drop down field for a very short time (original tag will reboot)
nfc_configure(pdiReader,DCO_ACTIVATE_FIELD,false);
nfc_configure(pndReader,DCO_ACTIVATE_FIELD,false);
if(!quiet_output)
printf("\n");
nfc_configure(pdiReader,DCO_ACTIVATE_FIELD,true);
nfc_configure(pndReader,DCO_ACTIVATE_FIELD,true);
}
// Print the reader frame to the screen
@ -119,10 +119,10 @@ int main(int argc,char* argv[])
print_hex_par(abtReaderRx,szReaderRxBits,abtReaderRxPar);
}
// Forward the frame to the original tag
if (nfc_initiator_transceive_bits(pdiReader,abtReaderRx,szReaderRxBits,abtReaderRxPar,abtTagRx,&szTagRxBits,abtTagRxPar))
if (nfc_initiator_transceive_bits(pndReader,abtReaderRx,szReaderRxBits,abtReaderRxPar,abtTagRx,&szTagRxBits,abtTagRxPar))
{
// Redirect the answer back to the reader
nfc_target_send_bits(pdiTag,abtTagRx,szTagRxBits,abtTagRxPar);
nfc_target_send_bits(pndTag,abtTagRx,szTagRxBits,abtTagRxPar);
// Print the tag frame to the screen
if(!quiet_output)
@ -134,6 +134,6 @@ int main(int argc,char* argv[])
}
}
nfc_disconnect(pdiTag);
nfc_disconnect(pdiReader);
nfc_disconnect(pndTag);
nfc_disconnect(pndReader);
}

View file

@ -27,15 +27,15 @@
int main(int argc, const char *argv[])
{
dev_info *pdi;
nfc_device_t *pnd;
tag_info ti;
byte_t abtRecv[MAX_FRAME_LEN];
size_t szRecvBits;
byte_t send[] = "Hello World!";
pdi = nfc_connect(NULL);
if (!pdi || !nfc_initiator_init(pdi)
|| !nfc_initiator_select_dep_target(pdi, IM_PASSIVE_DEP, NULL, 0,
pnd = nfc_connect(NULL);
if (!pnd || !nfc_initiator_init(pnd)
|| !nfc_initiator_select_dep_target(pnd, IM_PASSIVE_DEP, NULL, 0,
NULL, 0, NULL, 0, &ti)) {
printf
("unable to connect, initialize, or select the target\n");
@ -43,7 +43,7 @@ int main(int argc, const char *argv[])
}
printf("Sending : %s\n", send);
if (!nfc_initiator_transceive_dep_bytes(pdi,
if (!nfc_initiator_transceive_dep_bytes(pnd,
send,
strlen((char*)send), abtRecv,
&szRecvBits)) {
@ -54,7 +54,7 @@ int main(int argc, const char *argv[])
abtRecv[szRecvBits] = 0;
printf("Received: %s\n", abtRecv);
nfc_initiator_deselect_tag(pdi);
nfc_disconnect(pdi);
nfc_initiator_deselect_tag(pnd);
nfc_disconnect(pnd);
return 0;
}

View file

@ -29,14 +29,14 @@ int main(int argc, const char *argv[])
byte_t abtRecv[MAX_FRAME_LEN];
size_t szRecvBits;
byte_t send[] = "Hello Mars!";
dev_info *pdi = nfc_connect(NULL);
nfc_device_t *pnd = nfc_connect(NULL);
if (!pdi || !nfc_target_init(pdi, abtRecv, &szRecvBits)) {
if (!pnd || !nfc_target_init(pnd, abtRecv, &szRecvBits)) {
printf("unable to connect or initialize\n");
return 1;
}
if (!nfc_target_receive_dep_bytes(pdi, abtRecv, &szRecvBits)) {
if (!nfc_target_receive_dep_bytes(pnd, abtRecv, &szRecvBits)) {
printf("unable to receive data\n");
return 1;
}
@ -44,11 +44,11 @@ int main(int argc, const char *argv[])
printf("Received: %s\n", abtRecv);
printf("Sending : %s\n", send);
if (!nfc_target_send_dep_bytes(pdi, send, 11)) {
if (!nfc_target_send_dep_bytes(pnd, send, 11)) {
printf("unable to send data\n");
return 1;
}
nfc_disconnect(pdi);
nfc_disconnect(pnd);
return 0;
}