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.