Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NFC lib restart bug

Hi,


In my application, I'm trying to restart emulation because I want to switch from the NDEF static payload mode to ISO-DEP mode. The problem is that when I stop emulation and call nfc_t4t_done(), I get an invalid state error when I'm trying to set a new callback for the NFC lib with nfc_t4t_setup(my_callback, NULL). 

To be more verbose, I'm initially setting up the library like this:

nfc_t4t_setup(nfc_ndef_callback, NULL);
nfc_t4t_ndef_staticpayload_set(ndef_encoded_payload, ndef_len);
nfc_t4t_emulation_start();

Later on in the application, I have an interrupt which schedules the following:

nfc_t4t_done();
nfc_t4t_emulation_stop();
nfc_t4t_setup(nfc_isodep_callback, NULL);   // This returns NRF_ERROR_INVALID_STATE
nfc_t4t_emulation_start();

It seems like the NFC library does not register that the emulation has stopped.

This was built with nRF5SDK v17.0.2, GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025. The code ran on an nRF52840-DK.

Any suggestions would be appreciated if this is not a bug.


Best regards,

Tofik

Parents
  • Hi Tofik

    At a first glance, I see that you call the done(); call before emulation_stop(); This should be the other way around, as you should stop the emulation before you release the reference to the application callback. Please make sure that both these return NRF_SUCCESS as well.

    Next, it was discovered in this ticket, that the NFCT driver isn't uninitialized inside nfc_t4t_done(); in SDK 17.0.0, so you're correct that it is a bug. You will have to do this yourself in the application by calling nrfx_nfct_uninit() after nfc_t4t_done().

    Best regards,

    Simon

Reply
  • Hi Tofik

    At a first glance, I see that you call the done(); call before emulation_stop(); This should be the other way around, as you should stop the emulation before you release the reference to the application callback. Please make sure that both these return NRF_SUCCESS as well.

    Next, it was discovered in this ticket, that the NFCT driver isn't uninitialized inside nfc_t4t_done(); in SDK 17.0.0, so you're correct that it is a bug. You will have to do this yourself in the application by calling nrfx_nfct_uninit() after nfc_t4t_done().

    Best regards,

    Simon

Children
  • Hi Simon,

    Thanks for the swift reply!

    In my code, I was checking the returns with APP_ERROR_CHECK but I did not include it in the code I attached to my question. Regarding calling emulation_stop before done, I've tried that too.

    However, calling nrfx_nfct_uninit() did the trick! Thanks for that. FYI, it seems like this problem is still present in SDK 17.0.2 (which is what I'm using).


    Thanks,

    Tofik

Related