<?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>nfc change url</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15954/nfc-change-url</link><description>Hi 
 Regarding the NFC url example there is any way to change the URL dynamically. My idea is to, at a certain point, be able to modify the URL configured during the setup. 
 I tried different approaches: 
 
 Simply calling &amp;quot;nfc_uri_msg_encode&amp;quot; with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Aug 2016 15:03:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15954/nfc-change-url" /><item><title>RE: nfc change url</title><link>https://devzone.nordicsemi.com/thread/60857?ContentTypeID=1</link><pubDate>Fri, 26 Aug 2016 15:03:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dfba85a-d68a-48f3-9627-0dda50378dfb</guid><dc:creator>Nuno Figueiredo</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Based on the code of Einar I was able to find the solution. It is necessary only to change a simple detail in the code to make it work. We need to pass the reference to the first element of the ndef_msg_buf. I left the code of a function that allows to change dynamically the nfc tag.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void change_nfc_tag()
{

    uint8_t ret_val, err_code;

    ret_val = nfcStopEmulation();
    if (ret_val != NFC_RETVAL_OK)
    {
        APP_ERROR_CHECK((uint32_t) ret_val);
    }
    
    
    /* The new URL */
    char url2[50];
    uint32_t len2 = sizeof(ndef_msg_buf2);
    memset(url2,&amp;#39;0&amp;#39;,sizeof(url3));
    sprintf(url2,&amp;quot;nordicsemi.com&amp;quot;); //you can use format to construct the string. Take care with the size limit (50 in my case)

    /* Encode URI message into buffer */
    err_code = nfc_uri_msg_encode( NFC_URI_HTTP_WWW,
                                   (uint8_t *) url2,
                                   sizeof(url2),
                                   &amp;amp;ndef_msg_buf2[0],
                                   &amp;amp;len2);
                                   
    APP_ERROR_CHECK(err_code);
    /** @snippet [NFC URI usage_1] */

    /* Set created message as the NFC payload */
    ret_val = nfcSetPayload( (char*)ndef_msg_buf2, len2);
    if (ret_val != NFC_RETVAL_OK)
    {
        APP_ERROR_CHECK((uint32_t) ret_val);
    }
    
    /* Start sensing NFC field */
    ret_val = nfcStartEmulation();
    if (ret_val != NFC_RETVAL_OK)
    {
        APP_ERROR_CHECK((uint32_t) ret_val);
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nfc change url</title><link>https://devzone.nordicsemi.com/thread/60856?ContentTypeID=1</link><pubDate>Thu, 25 Aug 2016 10:33:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b3361e0-e557-4b1a-b5a1-e97cefadeaf4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The last option you have suggested should work. I just verified it now by modifying the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/nfc_record_url.html?cp=6_0_0_4_6_2"&gt;URI Message Example&lt;/a&gt;. You can try my modified &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8037.main.c"&gt;main.c&lt;/a&gt; (quick and dirty).&lt;/p&gt;
&lt;p&gt;The main thing, as suggested is to do the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;nfcStopEmulation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nfc_uri_msg_encode&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nfcSetPayload&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nfcStartEmulation&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Remember to use correct size of the new data in the calls to &lt;code&gt;nfc_uri_msg_encode()&lt;/code&gt; and &lt;code&gt;nfcSetPayload()&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nfc change url</title><link>https://devzone.nordicsemi.com/thread/60855?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 11:52:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8112d9a3-4f3a-4626-8729-1e811fa66cd3</guid><dc:creator>Nuno Figueiredo</dc:creator><description>&lt;p&gt;Hi Einar, thanks for your reply, the returned error code is 2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nfc change url</title><link>https://devzone.nordicsemi.com/thread/60854?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 11:15:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb0b072e-b7d7-4dbf-8207-6da4224e130e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;What is the error code is returned from your call to &lt;code&gt;nfcSetPayload()&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>