How to send command and receive response to contact less card (currently using ISO14443-4A)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to send command and receive response to contact less card (currently using ISO14443-4A)

982 Views
phanids
Contributor I

Hi NXP Team,

I have bought PN7462 development board (OM27462CDKP) and working on the couple of contact and contact less card. 

For Contact card, I was able to figure out on how to send the commands and receive response once the card is inserted (and receiving ATR). For this all I did was (a) In phExMain_Ct.c added below code once the ATR is received 

uint8_t SelectApplet[12] = {0x00, 0xa4, 0x04, 0x00, 0x07, 0xa0, 0x00, 0x00, 0x03, 0x11, 0x00, 0x10};

eStatus = phpalCt_Transceive( (uint8_t *)&SelectApplet[0],12,bApduRespBuffer,&wReceiveSize);

LOG_AU8("Response for SelectApplet:\n",bApduRespBuffer, wReceiveSize);

The response received matches with expected response (from the card manufacturer - basically we are developing a unit which works for both contact and contact less cards).

Now on the same lines, I want to send couple of Applets (as above) for Contact less cards.

We have given a couple of contact less cards and when I run the code, I see the card gets detected and gets the ATR as well. The logs I see are as below.

BootUp

Oct 21 2023

19:31:26

Wkup=1

STARTUP_POR

Entering Polling mode..

Type A Card - ISO14443-4A - UID : Len=7

04 5E 2B 5A 34 61 80

Exchange successful at 106

Baud Rate changed

Exchange successful at 212

Baud Rate changed

Exchange successful at 424

ActivateCard:3A Failed

Operation not successful

Remove the CL card.

Seems the card is identified, tried to communicate it with different baud rates etc. When I put a breakpoint in one of the prints, I see the flow of calls as below.

Once the card is detected - not sure how it detects - it calls 

phExMain_ClifTask() -> phExMain_ClifMain () -> phExMain_Poll_Main () -> phExMain_PollA () and this is doing all the above detection/ ATR/ different bauds etc.

Now I am confused, where should I add my code to (phpalClif)_Transceive - not even sure if this is the interface followed.

 

Couple of questions 

a. Is there any user guide which explain this - so that I can refer which could help me to debug the current issue (of not able to send some applet commands to contact less card)

b. Is there any pre-reading I need to get myself aware to understand the details (if my questions are dumb)

 

Please let me know if any of you have any pointers to me. 

With best regards,

//Ph

 

0 Kudos
Reply
2 Replies

956 Views
phanids
Contributor I

Hi NXP Team,

1. I was just going through the code and seems phpalI14443p4_Exchange function can be used for exchange of data. Is my understanding correct?

2. Basically when I send this uint8_t SelectApplet[12] = {0x00, 0xa4, 0x04, 0x00, 0x07, 0xa0, 0x00, 0x00, 0x03, 0x11, 0x00, 0x10}; command - I should receive 0x90 0x00 (2 bytes). Which is happening in Contact card

I just called above function phpalI14443p4_Exchange()  in phExMain_TypeA_L4Exchange.c. This function is called when the contact less card is  detected. I called the below function after phpalI14443p4_SetConfig  

//Code starts here

uint8_t SelectApplet[12] = {0x00, 0xa4, 0x04, 0x00, 0x07, 0xa0, 0x00, 0x00, 0x03, 0x11, 0x00, 0x10};

//eStatus = phpalCt_Transceive( (uint8_t *)&SelectApplet[0], 12, bApduRespBuffer,&wReceiveSize);

memset (ppRxBuffer_Ph, 0, 100); //This is local buffer to receive the data

status = phpalI14443p4_Exchange(psDiscLoopParams->pPal14443p4DataParams,

//0, //wOption, //Response Ph : Response for SelectApplet: Len=2, \n 51 0C

//1, //wOption, //Response Ph : Response for SelectApplet: Len=1, \n 50

//2, //wOption, //Response Ph : Response for SelectApplet: Exchange failed

//3, //wOption, //Response Ph : Response for SelectApplet: Exchange failed

//PH_EXCHANGE_BUFFERED_BIT, //this is 0x8000. wOption, //Response Ph : Response for SelectApplet: Len=0

PH_EXCHANGE_LEAVE_BUFFER_BIT, //this is 0x4000. wOption, //Response Ph : Response for SelectApplet: Len=2, \n 51 0C

&SelectApplet[0], //pTxBuffer,

12,

&ppRxBuffer_Phani[0], //&ppRxBuffer,

&pRxLength);

if(status != PH_ERR_SUCCESS)

{

LOG_TXT("Ph : Exchange failed at ");

LOG_TXT(gkphExMain_LogInfo[bDsi]);

break;

}

LOG_AU8("Ph : Response for SelectApplet:\n",ppRxBuffer_Phani, pRxLength);

//Code Ends here

and some how the response is not correct or I am not interpreting it properly. But response changes when I change the wOption in phpalI14443p4_Exchange calling function. Basically all I need is to send some APDU commands to contact less cards and get response.

Let me know if you have any suggestion for me.

With best regards,

//Ph

0 Kudos
Reply

831 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi 

I would suggest you refer to the NXP NFC Reader Library documents, it described the library structure  and components, including the API  reference.

SW368332-v707\docs\NxpNfcRdLib\NXP-NFCReaderLibrary-apiguide\

danielchen_1-1703138824918.png

 

Regards

Daniel

Tags (1)
0 Kudos
Reply