cancel
Showing results for 
Search instead for 
Did you mean: 

X-NUCLEO-NFC01A1 - ReadURI always returns the same value

BMróz.1928
Associate

My code is little modified Nucleo NFC Sample code. But instead of using WriteURI I want to read URI from Android phone. Every time NFC returns success but variable used with ReadURI function has always the same value as previous.

My snippet:

int main(void)
 {
  /* Reset of all peripherals, Initializes the Flash interface and the systick. */
  HAL_Init();
  /* Configure the system clock */
  SystemClock_Config();
 
  // Init of the Nucleo Board led
  BSP_LED_Init(LED2);
 
  // Init of the M24SR expansion board
  initLED();
  MX_GPIO_Init();
  sURI_Info uri;
  while (TT4_Init() != SUCCESS);
  TT4_ReadURI(&URI);
  // Prepare URI NDEF message content
  while (1)
  {
  }
}

 Anybody knows how to solve this problem?

1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee

Hi @Bartosz Mróz​ ,

It seems that your reader application is not sending the Deselect command to the tag after writing it. So the RF session is not closed correctly. You can test it by cutting the RF (Use RF OFF command on reader App or remove reader from Tag antenna).

You can also use a function that kill the RF session on M24SR side, But you must take care that no RF commands are sent while performing this.

Regards.

View solution in original post

3 REPLIES 3
Rene Lenerve
ST Employee

Hi @Bartosz Mróz​ ,

On my side your code is working as expected.

Are you sure that you correctly change the NDEF on the tag with the Android App? You read the NDEF after reset, then you enter infinite loop, before watching the new content are you sure to have reset the Nucleo?

I'm using the code for the STM32L476 platform and the ST25 NFC Tap App on Android phone (https://www.st.com/content/st_com/en/products/embedded-software/st25-nfc-rfid-software/stsw-st25001.html).

Regards.

Thank you for your explaination.

Like you pointed, everything works fine when I write data to NDEF then read and then I made a Nucleo reset. But I want to achieve continious job - write data, read and handle data. Without any resets.

I did small experiment and add method which read NDEF file on each user button click.

uint16_t TT4_RetriveData(){
	uint16_t status = ERROR;
	uint8_t buff[NDEF_MAX_SIZE];
	NDEF_ReadNDEF(buff);
	sURI_Info source;
	sURI_Info *pURI;
	sRecordInfo *pRecordStruct;
 
	pRecordStruct = &RecordStruct;
	pURI = &source;
	NDEF_IdentifyNDEF(pRecordStruct, buff);
	NDEF_ReadURI(pRecordStruct, pURI);
	status = SUCCESS;
 
	return status;
}

Before I clicked button I write tag 3 times with 3 different URI:

1) http://google.com

2) http://google.net

3) http://google.org

After button click I expected that I will have third URI in my pURI variable but I had first URI.

Any ideas how to resolve that?

Rene Lenerve
ST Employee

Hi @Bartosz Mróz​ ,

It seems that your reader application is not sending the Deselect command to the tag after writing it. So the RF session is not closed correctly. You can test it by cutting the RF (Use RF OFF command on reader App or remove reader from Tag antenna).

You can also use a function that kill the RF session on M24SR side, But you must take care that no RF commands are sent while performing this.

Regards.