This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Update NFC content on-the-fly

I want update NFC payload on-the-fly.

My test firmware based on nRF5_SDK_14.2.0_17b948a\examples\nfc\record_text (unable to update SDK. Legacy part.)

At firmware start:

/* Set up NFC */
err_code = nfc_t2t_setup(nfc_callback, NULL);
APP_ERROR_CHECK(err_code);

/* Encode welcome message */
err_code = welcome_msg_encode(m_ndef_msg_buf, &len);
APP_ERROR_CHECK(err_code);

/* Set created message as the NFC payload */
err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len);
APP_ERROR_CHECK(err_code);

/* Start sensing NFC field */
err_code = nfc_t2t_emulation_start();
APP_ERROR_CHECK(err_code);

I am try update NFC payload:

err_code = msg_encode(m_ndef_msg_buf, &len);
APP_ERROR_CHECK(err_code);

err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len);
APP_ERROR_CHECK(err_code);

nfc_t2t_payload_set is return NRF_ERROR_INVALID_STATE

Ok. I will call nfc_t2t_emulation_stop before update payload

err_code = msg_encode(m_ndef_msg_buf, &len);
APP_ERROR_CHECK(err_code);

nfc_t2t_emulation_stop();

/* Set created message as the NFC payload */
err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len);
APP_ERROR_CHECK(err_code);

err_code = nfc_t2t_emulation_start();
APP_ERROR_CHECK(err_code);

That's working.

BUT I have next issue:

When I call nfc_t2t_emulation_stop, nfc_t2t_payload_set and nfc_t2t_emulation_start while tag at field(after NFC_T2T_EVENT_FIELD_ON) something went wrong and NFC tag unavailable for reader forever.

Parents
  • Hi,

    Did you check the return code from call to nfc_t2t_emulation_stop? It may be that you cannot call these functions from interrupt context. Can you try to set a flag in the event handler, and do the payload update in the main context?

    Best regards,
    Jørgen

  • I made a modified version of the NFC record_url example, but I'm not able to reproduce the issue you are seeing:

    <info> app: NFC URL start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_OFF
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_OFF

    Here is the project I used (SDK 14.2.0): record_url_update.zip

    Can you share the project you used to reproduce this?

Reply
  • I made a modified version of the NFC record_url example, but I'm not able to reproduce the issue you are seeing:

    <info> app: NFC URL start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_OFF
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: nfc_t2t_emulation_stop
    <info> app: nfc_t2t_emulation_start
    <info> app: NFC_T2T_EVENT_FIELD_ON
    <info> app: NFC_T2T_EVENT_DATA_READ
    <info> app: NFC_T2T_EVENT_FIELD_OFF

    Here is the project I used (SDK 14.2.0): record_url_update.zip

    Can you share the project you used to reproduce this?

Children
Related