<?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>Sending large extended adverts</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102088/sending-large-extended-adverts</link><description>What config flags are required to send large (e.g. 1000 byte) extended adverts using the nrf connect SDK (using a nrf52840)? 
 I am trying to send large adverts but am having issues calling `bt_le_ext_adv_set_data` 
 and get EIO responses that I have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Jul 2023 11:51:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102088/sending-large-extended-adverts" /><item><title>RE: Sending large extended adverts</title><link>https://devzone.nordicsemi.com/thread/437655?ContentTypeID=1</link><pubDate>Fri, 21 Jul 2023 11:51:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1aecaa07-0924-4768-b7db-3de2689fec78</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Kyle,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You would need to us chained advertising.&amp;nbsp;&lt;br /&gt;Please take a look at my example here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/88164/advertising-1650-bytes-of-host-advertising-data-in-an-auxiliary-segment-using-advertising-extensions/370439"&gt;RE: Advertising 1650 bytes of Host advertising data in an Auxiliary segment using Advertising Extensions&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending large extended adverts</title><link>https://devzone.nordicsemi.com/thread/437481?ContentTypeID=1</link><pubDate>Thu, 20 Jul 2023 13:11:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d6fe5de-bc31-4002-a807-70d716a3268a</guid><dc:creator>saty9pd</dc:creator><description>&lt;p&gt;kconfig flags:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT_LL_SW_SPLIT=y

CONFIG_BT_EXT_ADV=y

CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=1650
CONFIG_BT_CTLR_ADV_DATA_CHAIN=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;example code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;

LOG_MODULE_REGISTER(reproduction, CONFIG_EDGE_LIVE_DATA_LOG_LEVEL);

static struct bt_le_ext_adv *adv;
static struct bt_data adv_data[7]; // 255 * 7 &amp;gt; 1650
static struct bt_le_adv_param adv_params;

//Fills adv_data array with bytes and returns how many entries used
static int fill_adv_data(const unsigned char *bytes, int len)
{
  __ASSERT(len &amp;lt;= 1650, &amp;quot;Too much data to fit in advertising packet&amp;quot;);

  int ad_num = 0;
  while (len &amp;gt; 0) {
    adv_data[ad_num].type = BT_DATA_MANUFACTURER_DATA;
    adv_data[ad_num].data_len = MIN(len, 255);
    adv_data[ad_num].data = &amp;amp;bytes[ad_num*255];

    len -= 255;
    ad_num += 1;
  }
  return ad_num;
}

static int send_advert(const unsigned char *bytes, unsigned int len, unsigned char num_repetitions) {
  int ad_count = fill_adv_data(bytes, len);

  adv_params.interval_min = 1250;
  adv_params.interval_max = 1260;
  int err = bt_le_ext_adv_update_param(adv, &amp;amp;adv_params);
  if (err) {
    LOG_ERR(&amp;quot;Failed to change advertising set params (%i)&amp;quot;, err);
  }

  err = bt_le_ext_adv_set_data(adv, adv_data, ad_count, NULL, 0);
  if (err) {
    LOG_ERR(&amp;quot;Failed to change advertising set data (%i)&amp;quot;, err);
    return -1;
  } else {
    LOG_HEXDUMP_INF(bytes, len, &amp;quot;Advertising set data set to&amp;quot;);
  }

  struct bt_le_ext_adv_start_param param = {
      .num_events = num_repetitions*10,
  };

  err = bt_le_ext_adv_start(adv, &amp;amp;param);
  if (err) {
    LOG_ERR(&amp;quot;Failed to start advertising set (%i)&amp;quot;, err);
    return -1;
  } else {
    LOG_INF(&amp;quot;Advertising set started for %i repetitions, size %i bytes&amp;quot;, num_repetitions, len);
  }

  return 0;
}

static uint8_t example_data[1000];

int example(void)
{
  adv_params.id = BT_ID_DEFAULT;
  adv_params.sid = 1;
  adv_params.secondary_max_skip = 0;
  adv_params.options = BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_USE_IDENTITY;
  adv_params.interval_min = 1250;
  adv_params.interval_max = 1250 + 10;
  adv_params.peer = NULL;

  int err = bt_le_ext_adv_create(&amp;amp;adv_params, NULL, &amp;amp;adv);
  if (err) {
    LOG_ERR(&amp;quot;Failed to create advertising set, err %d&amp;quot;, err);
    return err;
  }

  return send_advert(example_data, 1000, 1);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Log output:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.2.99-ncs2 ***

[00:00:00.454,833] &amp;lt;inf&amp;gt; bluetooth: Bluetooth initialized
[00:00:00.455,963] &amp;lt;err&amp;gt; bt_hci_core: opcode 0x2037 status 0x45
[00:00:00.455,963] &amp;lt;err&amp;gt; reproduction: Failed to change advertising set data (-5)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>