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?

  • Then to me it looks OK on the nRF52 side. Regarding the phone side - is the error reported consistently on different phones? We have seen some variation between different phones, but generally NFC Tools seemed stable. Can the NFC Tools read back the newly written content even if reported an error on the Write operation?

Reply Children
No Data
Related