<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21329/read-ndef-after-tag-write</link><description>Hi, 
 I am having trouble reading the contents of a record after the NFC tag in the microcontroller has been written by a smartphone. 
 I&amp;#39;m using the t4t emulator. When the tag has been written the callback gets called. In the callback I use the ndef_record_parser</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Jul 2017 17:00:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21329/read-ndef-after-tag-write" /><item><title>RE: Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/thread/83542?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 17:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c05a7cb6-81c2-4a7e-8707-00e85691551c</guid><dc:creator>pctj101</dc:creator><description>&lt;p&gt;Thanks also for posting the example code.  I would have never found that I had to skip the first 2 bytes of the buffer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/thread/83545?ContentTypeID=1</link><pubDate>Tue, 23 May 2017 19:35:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed9dfab6-4b30-4a18-9a25-5d5d6e632da2</guid><dc:creator>Arepa</dc:creator><description>&lt;p&gt;Thanks a lot :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/thread/83544?ContentTypeID=1</link><pubDate>Tue, 23 May 2017 15:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15e308e0-94f1-4678-be5a-bde85ae686ad</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;You would need to include nfc_ndef_msg_parser.c/.h and nfc_ndef_msg_parser_local.c/.h.&lt;/p&gt;
&lt;p&gt;In addition, the NFC NDEF message parser module has to be enabled in sdk_config.h: (see the sdk_config.h file in this folder: \nRF5_SDK_13.0.0_04a0bfd\config )&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// &amp;lt;e&amp;gt; NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module
//==========================================================
#ifndef NFC_NDEF_MSG_PARSER_ENABLED
#define NFC_NDEF_MSG_PARSER_ENABLED 0
#endif
#if  NFC_NDEF_MSG_PARSER_ENABLED
// &amp;lt;e&amp;gt; NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED
#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0
#endif
#if  NFC_NDEF_MSG_PARSER_LOG_ENABLED
// &amp;lt;o&amp;gt; NFC_NDEF_MSG_PARSER_LOG_LEVEL  - Default Severity level
 
// &amp;lt;0=&amp;gt; Off 
// &amp;lt;1=&amp;gt; Error 
// &amp;lt;2=&amp;gt; Warning 
// &amp;lt;3=&amp;gt; Info 
// &amp;lt;4=&amp;gt; Debug 

#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL
#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3
#endif

// &amp;lt;o&amp;gt; NFC_NDEF_MSG_PARSER_INFO_COLOR  - ANSI escape code prefix.
 
// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White 

#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR
#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0
#endif

#endif //NFC_NDEF_MSG_PARSER_LOG_ENABLED
// &amp;lt;/e&amp;gt;

#endif //NFC_NDEF_MSG_PARSER_ENABLED
// &amp;lt;/e&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/thread/83543?ContentTypeID=1</link><pubDate>Tue, 23 May 2017 15:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72f91e86-d2e1-47d5-b3ac-dbdd5b061241</guid><dc:creator>Arepa</dc:creator><description>&lt;p&gt;Hi Kristin, what includes are necessaries to be able to use the functions &lt;code&gt;NFC_NDEF_PARSER_REQIRED_MEMO_SIZE_CALC&lt;/code&gt; and  &lt;code&gt;ndef_msg_printout&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read NDEF after tag write</title><link>https://devzone.nordicsemi.com/thread/83541?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2017 11:45:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cc6a962-7d6b-428a-895f-e42f6a696e30</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I don&amp;#39;t know what your code looks like, so I will just tell how it works.&lt;/p&gt;
&lt;p&gt;When writing to the NFC tag from another device, the initial data will be over written, and stored in the set buffer in &lt;code&gt;nfc_t4t_ndef_rwpayload_set()&lt;/code&gt; during the initialization. In the example writable_ndef_msg, the buffer is &lt;code&gt;m_ndef_msg_buf&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Since &lt;code&gt;m_ndef_msg_buf&lt;/code&gt; is overwritten upon a write, that is where the data to be parsed  is located.  (Note: the &lt;code&gt;data&lt;/code&gt; field in the event &amp;quot;NFC_T4T_EVENT_NDEF_UPDATED&amp;quot; doesn&amp;#39;t contain valid data. The only valid data  for that event is &lt;code&gt;dataLength&lt;/code&gt;.)&lt;/p&gt;
&lt;p&gt;For a Tag Type 4, the written data can be printed out the following way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**
* @brief Callback function for handling NFC events.
*/
static void nfc_callback(void          * context,
                     nfc_t4t_event_t event,
                     const uint8_t * data,
                     size_t          dataLength,
                     uint32_t        flags)
{
    (void)context;
	ret_code_t ret_val;

    uint8_t  read_nfc_buffer[NFC_NDEF_PARSER_REQIRED_MEMO_SIZE_CALC(10)];
    uint32_t read_nfc_buffer_length = sizeof(read_nfc_buffer);		

    switch (event)
    {
        ....

        case NFC_T4T_EVENT_NDEF_UPDATED:
				
			NRF_LOG_INFO(&amp;quot;NFC_T4T_EVENT_NDEF_UPDATED \r\n&amp;quot;);
		
            if (dataLength == 0)
            {
                m_update_state = true;
	            NRF_LOG_INFO(&amp;quot;DataLength:  0 \r\n&amp;quot;);
            }
            else if (m_update_state == true)
            {
	            ret_val = ndef_msg_parser(read_nfc_buffer, &amp;amp;read_nfc_buffer_length, m_ndef_msg_buf+2, &amp;amp;dataLength);
		        //APP_ERROR_CHECK(ret_val);
			    if (ret_val != NRF_SUCCESS)
			    {
			        NRF_LOG_INFO(&amp;quot;Error code: 0x%x \r\n&amp;quot;, ret_val);
				    NRF_LOG_INFO(&amp;quot;Error during parsing a NDEF message.\r\n&amp;quot;);
			    }
			
			    ndef_msg_printout((nfc_ndef_msg_desc_t *) read_nfc_buffer);
                m_update_state = false;
                bsp_board_led_on(BSP_BOARD_LED_1);
            }
            break;

    default:
        break;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>