<?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>Changing Eddystone beacon frame type and data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60080/changing-eddystone-beacon-frame-type-and-data</link><description>Hi all, 
 Based on the EddystoneBeacon example (ble_app_eddystone), I try and change the advertising slot contents runtime from main.c on a button press. I read similar questions here in the Devzone, and as expected this pointed me to the usage of es_slot_on_write</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Apr 2020 12:57:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60080/changing-eddystone-beacon-frame-type-and-data" /><item><title>RE: Changing Eddystone beacon frame type and data</title><link>https://devzone.nordicsemi.com/thread/244217?ContentTypeID=1</link><pubDate>Fri, 10 Apr 2020 12:57:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8dee217-ad5d-4b5d-86a2-f2c011c479e7</guid><dc:creator>Slay</dc:creator><description>&lt;p&gt;OK, I think I have figured it out myself:&lt;/p&gt;
&lt;p&gt;Looking at the code for configure_slot in es_slot.c, it starts copying the data at&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    uint8_t * p_data_after_ranging_data = ((uint8_t *)(&amp;amp;m_reg.slots[slot_no].adv_frame.frame) +
                                           RANGING_DATA_INDEX + RANGING_DATA_LENGTH);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is 2 bytes from the frame-start. And the actual copying is done like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case ES_FRAME_TYPE_URL:
            memcpy(p_data_after_ranging_data, &amp;amp;p_frame_data[1], length - 1);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which means that my TestData is one byte too long and should not include the Tx-Power. If I leave this byte out and pass a length of 19, no Fatal error occurs and the data is sent as should be. So apparently the es_slot_on-write does require a little different frame format as one (or at least I) would expect. For completeness the final (working) code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static const uint8_t TestDataUid[19] = {
	APP_ES_UID_FRAME_TYPE,
	0x33, 0x33, 0x44, 0x44, 0x55, 0x55, 0x44, 0x44, 0x33, 0x33,		//10-byte UID namespace
	0x07, 0x07, 0x07, 0x07, 0x07, 0x07,								//6-byte UID ID
	0x00, 0x00
};

static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
{
    if (button_action == APP_BUTTON_PUSH &amp;amp;&amp;amp; pin_no == BUTTON_1) {
//        nrf_ble_es_on_start_connectable_advertising();
		es_slot_on_write(0, 19, TestDataUid);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope this could help someone else. Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>