cancel
Showing results for 
Search instead for 
Did you mean: 

What is the difference between Android 11 and Android 13 for NFC

SFish.1
Associate II

I am working with an App developer to read/write to an ST25DV Dynamic Tag. The project does the following:

1 App writes to the ST25DV a short NDEF Text record (15 bytes), the App then goes into some kind of wait mode

2 Host micro reads the tag using I2C

3 Host decodes data read and sends a reply record using I2C

4 After approx 1 second the App reads the ST25DV tag.

This works perfectly with phones running Android 8 and Android 11 but does not work properly with Android 13. The ST25DV is written OK. The host micro read/writes properly but the the app returns an error message Last Exception,"Bad state:no Element".

What does this message mean and wht would I get it when the older Android versions seem to work fine.

Any help would be great.

1 ACCEPTED SOLUTION

Accepted Solutions
Olivier L
ST Employee

Hi Steve,

We suspect that your problem is related to the smartphone's presence check. The smartphone will periodically check if something is present in the RF field and, when a tag is found, it will also check periodically if it is still present. The presence check usually happens every 130ms. The difficulty is that each phone has a different way of handling the RF object detection, the anti collision and the inventory. So different phones may behave differently and may lead to different results.

If a presence check command happens during an I2C command, it will fail with a TimeOut because the NFC Tag will not be able to answer it. This can cause some problems during your sequence because the smartphone may think that the tag is gone (and this is here that different phone will behave differently).

In a previous project, we had such problem and here is how we have worked it around:

Instead of using the standard mode we have used a reader mode (see this link) which allows to control the periodicity of the presence checks thanks to EXTRA_READER_PRESENCE_CHECK_DELAY. By increasing the presence check period to 500 ms we avoided the problem.

It seems that this mode is also available on Flutter: https://pub.dev/packages/nfc_manager

You may want to try it.

FYI, I would like also to mention that the ST25DV has a Fast Transfer Mode feature that is well adapted to bidirectional communication and much faster than communication via tag's EEPROM memory. It uses a RAM of 256 bytes present in the ST25DV. When some data are put in this mailbox, the MCU can be informed by the interruption so it avoids that the MCU does some polling to know if an NDEF has been written.

Our ST25SDK has an API to simplify the use of this Fast Transfer Mode. A single API function can be called to send or receive data of any size. The ST25SDK will take care of the transmission.

This looks well adapted to your need, unfortunately it is not available by default on Flutter so some porting is necessary.

Regards

Olivier

View solution in original post

8 REPLIES 8
Olivier L
ST Employee

We are not aware of this issue and have never seen this exception. Which phone did you use for this test?

I have a Google Pixel 6 running Android 12. This week I will update it to Android 13 and I will keep you informed.

Regards

Hi Olivier L Thanks for getting back to me. We found this with Samsung Galaxy A52, Samsung Galaxy A32 and Google Pixel4. Same issue on all 3. Since writing this we have made some discoveries of our own and found that there was a change of NFC function at Android 12 to do with use of the phone as a key fob, maybe this is related?. We also found that if we put the ST26DV RF to Sleep during the App wait time and then wake it up again this seems to get rid of the problem, unfortunately this then stops the Android 11 phones from working!! Again any help would be appreciated. Steve Fisher SPF Design Solutions Limited Newcastle-upon-Tyne UK Mobile: (+44) 07748 757174 [View my profile on LinkedIn]<>
Olivier L
ST Employee

Hi Steve,

Yes, it might be related. You see the same issue with 3 different phones (from different brands) so something has changed for sure. We will test and come back to you.

Regards

Olivier

Olivier L
ST Employee

Hi Steve,

I have flashed my google Pixel 6 phone with Android 13 (I'm using the image oriole-tq1a.230205.002-factory-f6f5ac27).

I have installed ST25 NFC Tap application and tested some tags (ST25DV64KC and ST25DV04K) but I don't see problems.

Can you please tell me the reference of the tag that you're using? In Tag Info, you can read the UID and in System File you can read the ICRef. Please send me these info.

Then, with a working smartpone (you mentioned Android 8 or 11 phones), please go to Memory tab -> Read memory. Dump the first 64 bytes of the memory and please send me a screen shot. It will help me to see the CC File present in the tag.

Thank you

Regards

Olivier

Olivier L
ST Employee

I was rereading your first message. I see that Android 13 phone is in fact writing an NDEF successfully, right? The problem seems to come later on.

"the App then goes into some kind of wait mode"

Would you have more info about his?

Can you please give the content of the two NDEF messages exchanged? It is possible that the smartphone doesn't "like" the NDEF message written by the host.

Do you respect the procedure when writing this NDEF? The NDEF length should be set to 0 and updated as a last operation when all the bytes are ready.

We have also thought to a possible collision between a RF command and an I2C command. In that case you would have the following result:

  • If the RF command is addressed, you would have a time out
  • If the RF command is not addressed, you would have the error 01 0F

It doesn't seem to be what you have.

One last thing. Are you using the ST25SDK? If yes, you should take care to the Cache.

When the smartphone writes the first NDEF, the content will be saved in the cache.

The tag's memory is then updated by the host (let's call that NDEF2) but the smartphone is not aware of that.

If the smartphone tries to read the NDEF message, it will get the NDEF1 present in Cache.

That's why it is important to flush the cache.

Regards

Hi Olivier You are correct that the NDEF file is written correctly. I mentioned in my last email to you that we have a "work around" of sorts for Android 13. Once the NDEF1 has been written to the Tag the Host micro will read this then put the TAG RF to sleep using RF_MNGT_Dyn register. This time is set to around 200-300ms then returns to Normal Operation (using same register). This approach seems to work OK and the App running on Android 13 will now Read the NDEF2 message successfully. The problem then is that the App running on Android 11 will no longer function, similar problem ie will write but not read after the 1 second delay. I spoke with the App developer about what he means by a "wait state" and he tells me that the App code simply Writes to the Tag, then does nothing for the 1000ms period then Reads from the TAG. There are no commands or modes entered. He uses the Flutter Library if that helps! The NDEF files are definitely correct, we have looked at the raw memory dumps so many times and these are not the issue. I am using the ST25DV04KC-I, I have a lot of them but one UID is E0 02 50 00 22 69 28 09. We have had instances in the past where the App reads back the wrong NDEF message, we are aware of this and clear the cache each time, this did not resolve the issue. Once again thanks for your help on this. Regards Steve Fisher SPF Design Solutions Limited Newcastle-upon-Tyne UK Mobile: (+44) 07748 757174 [View my profile on LinkedIn]<>
Olivier L
ST Employee

Hi Steve,

We suspect that your problem is related to the smartphone's presence check. The smartphone will periodically check if something is present in the RF field and, when a tag is found, it will also check periodically if it is still present. The presence check usually happens every 130ms. The difficulty is that each phone has a different way of handling the RF object detection, the anti collision and the inventory. So different phones may behave differently and may lead to different results.

If a presence check command happens during an I2C command, it will fail with a TimeOut because the NFC Tag will not be able to answer it. This can cause some problems during your sequence because the smartphone may think that the tag is gone (and this is here that different phone will behave differently).

In a previous project, we had such problem and here is how we have worked it around:

Instead of using the standard mode we have used a reader mode (see this link) which allows to control the periodicity of the presence checks thanks to EXTRA_READER_PRESENCE_CHECK_DELAY. By increasing the presence check period to 500 ms we avoided the problem.

It seems that this mode is also available on Flutter: https://pub.dev/packages/nfc_manager

You may want to try it.

FYI, I would like also to mention that the ST25DV has a Fast Transfer Mode feature that is well adapted to bidirectional communication and much faster than communication via tag's EEPROM memory. It uses a RAM of 256 bytes present in the ST25DV. When some data are put in this mailbox, the MCU can be informed by the interruption so it avoids that the MCU does some polling to know if an NDEF has been written.

Our ST25SDK has an API to simplify the use of this Fast Transfer Mode. A single API function can be called to send or receive data of any size. The ST25SDK will take care of the transmission.

This looks well adapted to your need, unfortunately it is not available by default on Flutter so some porting is necessary.

Regards

Olivier

Olivier L
ST Employee

Hi Steve,

FYI, a change of behavior happened on Android 13 concerning the peristence of the Android Tag handle.

More information is available on this thread:

https://community.st.com/s/question/0D53W00002CIynmSAD/st25nfcapplicationv370-crashes-on-android-13-pixel6a

A fix has been implemented.

Regards

Olivier