1

I'm using X-NUCLEO-NFC05A1 with STM32 NUCLEO-F401RE board to read an NFC-A (ISO14443A) tag. I couldn't find any function for reading the tag. Can anyone help me?

I tried the sample given by ST, I could find write function from there. But I couldn't find any reading function from there.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Jaz
  • 11
  • 2

1 Answers1

0

You can simply use rfalTransceiveBlockingTxRx() from rfal_rf.h provided by the RFAL library. That transceive mechanism applies to all RF technologies.

Since there is no generic commandset for interacting with NFC-A tags, the exact coding of the READ command will depend on your specific tag type. For instance, for a Type 2 tag, the READ command would consist of two bytes: 0x30 <BLOCK-ADDRESS-AS-SINGLE-BYTE>

For such a tag, you could, for instance, use something like this:

uint8_t bufferTx[2];
uint16_t lenTx;
uint8_t bufferRx[16];
uint16_t lenRxMax, lenRx;
ReturnCode status;

lenTx = 0;
bufferTx[lenTx++] = 0x30;
bufferTx[lenTx++] = 0;  // TODO: change this to the read offset

lenRxMax = 16;
lenRx = 0;
status = rfalTransceiveBlockingTxRx(&bufferTx[0], lenTx, &bufferRx[0], lenRxMax, &lenRx, RFAL_TXRX_FLAGS_DEFAULT, rfalConvMsTo1fc(5));

// if status does not indicate error,
// you will now find the response in bufferRx,
// the actual response length is lenRx
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • First of all, I'm a beginner for these subjects (nfc/nfc tags). I'm using a NFC-A T2T device and I could found the uid/nfc id with rfalNfcaListenDevice.nfcId1. Now I want to read the content of it. What do you mean by 'read offset'? What I want to set for bufferTx[lenTx++] in my case? – Jaz May 31 '19 at 05:37
  • I would suggest that you start by reading a book about NFC to get a feeling for the protocols (e.g. [Rankl & Effing](https://www.wiley.com/en-at/Smart+Card+Handbook%2C+4th+Edition-p-9780470743676), though the German version is certainly much better). Since you already seem to know that your tag is a T2T, you could also start by getting a copy of the NFC Forum Type 2 Tag specification (or the older NFC Forum Type 2 Tag Operation specification). It lists all the commands that you need and it also shows you how data on those tags is organized (linear memory layout, hence the read offset). – Michael Roland May 31 '19 at 06:50
  • If you know the exact product type (e.g. NXP NTAG2xx), you might also want to grab a copy of the datasheet for that tag from the manufacturer. The datasheet will also tell you the format and coding of commands, responses, and the exact memory layout. – Michael Roland May 31 '19 at 06:52
  • Btw. read offset is the block address of the block that you want to read from the tag (or actually the first of 4 blocks that you will read from the tag). – Michael Roland May 31 '19 at 06:53