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

Determine the end of an NFC Write?

Is there a way to determine the end of an NFC write besides waiting for the NFC_T4T_EVENT_FIELD_OFF event? We want to update the NDEF message from within firmware after data is written but before the NFC_T4T_EVENT_FIELD_OFF event fires. We tried doing the update on NFC_T4T_EVENT_NDEF_UPDATED when data_length is greater than 0 in nfc_callback, but that doesn't work.

UpdateNdefMessage reads the ndef message that was just written to the device, and then updates the ndef message based on what was written.

Is there a way to determine when a write is finished without relying on NFC_T4T_EVENT_FIELD_OFF?

	static void nfc_callback(
  void          * context     __attribute__((unused)),
	nfc_t4t_event_t event       __attribute__((unused)),
	const uint8_t * data        __attribute__((unused)),
	size_t          dataLength  __attribute__((unused)),
	uint32_t        flags       __attribute__((unused)))
{
	switch (event)
	{
	case NFC_T4T_EVENT_NDEF_READ:
		break;
	case NFC_T4T_EVENT_NDEF_UPDATED:
		if (dataLength > 0)
		{
			UpdateNdefMessage();
		}
		break;
	default:
		break;
	}
}
Parents
  • Let me add a couple of details regarding the NFC_T4T_EVENT_NDEF_UPDATED event:

    • it will only be triggered if the NDEF content was set as Read/Write i.e. using nfc_t4t_ndef_rwpayload_set - is it how you set it in your application?

    • the event is triggered each time the UPDATE_BINARY APDU is received with offset <= 1 (NLEN field)

    Additionally, do you get any NFC_T4T_EVENT_NDEF_UPDATED event, e.g. when the Reader/Writer (PCD) clears the NLEN field? For short messages, some PCD could write NLEN together with the rest of the NDEF content (as part of a single UPDATE_BINARY Command APDU)

    Also, is the write operation successful at all?

  • The NDEF content is set as Read/Write. We get 2 NFC_T4T_EVENT_NDEF_UPDATED events every time we write. The data_length parameter is 0 on the first write, and is the written NDEF message length on the second write. The write operation is successful on the nRF52. However, the application side (we're using NFC Tools on Android phones) reports back with a generic write error.

Reply
  • The NDEF content is set as Read/Write. We get 2 NFC_T4T_EVENT_NDEF_UPDATED events every time we write. The data_length parameter is 0 on the first write, and is the written NDEF message length on the second write. The write operation is successful on the nRF52. However, the application side (we're using NFC Tools on Android phones) reports back with a generic write error.

Children
No Data
Related