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

NFC_T4T_EVENT_NDEF_UPDATED gets fired twice per NFC Write?

It looks like NFC_T4T_EVENT_NDEF_UPDATED gets passed as the event attribute in the nfc_callback function whenever a new NDEF message is written.

Is this expected behavior? Is the first one fired when the write starts and the second one when the write ends? It looks like that's the case. datalength is 0 on the first NDEF_UPDATED event, and is a perfect match with the written data length on the second event.

For example, this is the code snippit I've been using, and every time I send something over NFC using my smartphone, the text "NDEF UPDATED fired!" shows up twice in RTT Viewer.

	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:
                    SEGGER_RTT_printf(0, "NDEF UPDATED fired! Data length: 0x%02X\n", dataLength);
		break;
	default:
		break;
	}
Related