<?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>Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81405/error-when-trying-to-enable-extended-advertising-on-code-based-on-nus-example</link><description>Hi, 
 I&amp;#39;m working on an nRF5340 project using nRF Connect SDK v1.7.0 with VS Code. I started my project with the NUS example. 
 I&amp;#39;ve been able to customize the standard/legacy advertising packets as required by my customer with no problem using bt_le_adv_start</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Dec 2021 22:26:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81405/error-when-trying-to-enable-extended-advertising-on-code-based-on-nus-example" /><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/341758?ContentTypeID=1</link><pubDate>Thu, 02 Dec 2021 22:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99c8ef6b-b425-4fcd-8eb2-78c2d6d2e0ef</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I finally got somewhere with this - Instead of always using &amp;quot;Debug&amp;quot; I tried &amp;quot;Erase and Flash&amp;quot; from the actions menu and now the example works (both after Erase and Flash and now that I just debug it. Maybe I had some old stuff in the network core or somewhere that was cleaned out by that action?&lt;/p&gt;
&lt;p&gt;Glad to have it going!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/339944?ContentTypeID=1</link><pubDate>Mon, 22 Nov 2021 06:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eba80b0d-6e21-490a-97a1-b22e6cbaef14</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="Aryan"]I tried to use your code in hr_coded example and adding settings or&amp;nbsp;BT_LE_EXT_ADV_NCONN_NAME in bt_le_ext_adv_create passes normally. Not sure what else is different in your setup but i cannot find anything that is relevant to this issue to be different than your code snippet and this hr_coded exampe&amp;nbsp;&amp;nbsp;[/quote]
&lt;p&gt;I tried hr_coded example with changes to the create function to match yours and the error code returned was 0.&amp;nbsp;&lt;/p&gt;
[quote user="Glen M"]Maybe the return code doesn&amp;#39;t matter and it&amp;#39;ll end up working anyway if I just let it run?[/quote]
&lt;p&gt;That odes not sound right, error codes other than 0 shows failure and letting it run anyway to expect it to work is very risky.&lt;/p&gt;
&lt;p&gt;Have you tried the hr_coded example with minor changes to the arguments to&amp;nbsp;&lt;span&gt;bt_le_ext_adv_create and run it in the debugger, set a breakpoint at this function and see what error code you get? If this example works for you, then we need to take a closer look at your setup.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/339833?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 13:27:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49692db7-2f86-4571-9541-829b329dbc60</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;Yes CONFIG_BT_EXT_ADV is y. I&amp;#39;m not sure what to try next either as we&amp;#39;re running the same HR CODED example using the same hardware and tools and getting different results.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How are you verifying that it works - is it just working, or are you looking at the return codes? Maybe the return code doesn&amp;#39;t matter and it&amp;#39;ll end up working anyway if I just let it run?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/339774?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 09:16:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3b9483f-89c9-4dec-8106-ae8cd3ca7d72</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;sorry for the late reply Glen,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I need to get your full setup, obviously there is some difference between your and my setup.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you set CONFIG_BT_EXT_ADV=y in your config? Not sure what else is different.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338860?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 23:07:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c56faab-4d08-4c08-a8c9-83d108c6d098</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I upgraded to all the latest stuff and I get the same thing... at line 83 of main.c in the create_advertising_coded function I get -5 back from&amp;nbsp;bt_le_ext_adv_create().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338855?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 20:19:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55077f6e-602d-4099-8662-fcc86e47f002</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I just tried it and I get the same error from&amp;nbsp;bt_le_ext_adv_create. I&amp;#39;m using VSCode with SDK 1.7.0. The newer SDK isn&amp;#39;t supposed to have any relevant changes but I guess I could upgrade and see what happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338736?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 10:04:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c2833b7-9c99-4b0e-ad1f-af15a6ae1f4a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;i used 5340 DK, so not sure why you are seeing any difference.&amp;nbsp; Have you run the hr_coded example (unedited) on your eval board? does it run normally?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338607?ContentTypeID=1</link><pubDate>Thu, 11 Nov 2021 14:27:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:155a4618-030a-4417-9427-8d7f22a2cb8a</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;Will your example work on my nRF5340 eval board where I could debug it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338544?ContentTypeID=1</link><pubDate>Thu, 11 Nov 2021 11:45:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e72a301-5336-49e2-a08c-34877990af4e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I tried to use your code in hr_coded example and adding settings or&amp;nbsp;BT_LE_EXT_ADV_NCONN_NAME in bt_le_ext_adv_create passes normally. Not sure what else is different in your setup but i cannot find anything that is relevant to this issue to be different than your code snippet and this hr_coded exampe&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338265?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 22:40:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47c06f10-a237-4960-b8e9-d84a36956854</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;If I call&amp;nbsp;bt_le_ext_adv_create after settings_load the error is -5 (-EIO), if I call it before settings_load the return code is -11 (-EAGAIN)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338238?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 15:20:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b0737c8-d403-40f0-a30f-cab2a04455d6</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;Thanks Susheel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/338225?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 14:43:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96e82de2-0e90-4278-b6d0-202ac89c53cb</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;sorry Glen, I did not manage to test this as i am OoO due to sick child. I will test this as soon as i am back to office. Since this is an public ticket, hopefully someone chimes in some knowledge before i can test.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/337747?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 15:12:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ea5f168-5466-46d4-b6ad-137026b56d5b</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;Here&amp;#39;s a trimmed down version with the problem section. Most of this is from the peripheral_uart (NUS) example that I used as a starting point, I just added the&amp;nbsp;bt_le_ext_adv_create stuff.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
static void connected(struct bt_conn *conn, uint8_t err);
static void disconnected(struct bt_conn *conn, uint8_t reason);
#ifdef CONFIG_BT_NUS_SECURITY_ENABLED
static void security_changed(struct bt_conn *conn, bt_security_t level,enum bt_security_err err);
#endif
#if defined(CONFIG_BT_NUS_SECURITY_ENABLED)
static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey);
static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey);
static void auth_cancel(struct bt_conn *conn);
static void pairing_confirm(struct bt_conn *conn);
static void pairing_complete(struct bt_conn *conn, bool bonded);
static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason);
#endif
static void bt_receive_cb(struct bt_conn *conn, const uint8_t *const data, uint16_t len);
void error(void);

//== Global Variables ========================================================

static K_SEM_DEFINE(ble_init_ok, 0, 1);

static const struct bt_data m_scan_response_data[] = 
{
   BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
};

static struct bt_conn *current_conn;
static struct bt_conn *auth_conn;

static struct bt_conn_cb conn_callbacks = 
{
   .connected    = connected,
   .disconnected = disconnected,
   #ifdef CONFIG_BT_NUS_SECURITY_ENABLED
      .security_changed = security_changed,
   #endif
};

#if defined(CONFIG_BT_NUS_SECURITY_ENABLED)
static struct bt_conn_auth_cb conn_auth_callbacks = 
{
   .passkey_display = auth_passkey_display,
   .passkey_confirm = auth_passkey_confirm,
   .cancel = auth_cancel,
   .pairing_confirm = pairing_confirm,
   .pairing_complete = pairing_complete,
   .pairing_failed = pairing_failed
};
#else
static struct bt_conn_auth_cb conn_auth_callbacks;
#endif

static struct bt_nus_cb nus_cb = 
{
   .received = bt_receive_cb,
};

static struct bt_le_ext_adv *m_extended_advertising_set;
static struct bt_le_ext_adv_start_param ext_adv_start_param = {
	.timeout = 0,
	.num_events = 0,
};

//============================================================================

//----------------------------------------------------------------------------
// Name  : bluetooth_init
// Desc  : Configure Bluetooth services and start advertising
// Ins   : none
// Outs  : none
//----------------------------------------------------------------------------
void bluetooth_init(void)
{
   int err = 0;

   bt_conn_cb_register(&amp;amp;conn_callbacks);

   if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED)) 
   {
      bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
   }

   err = bt_enable(NULL);
   if (err) 
   {
      error();
   }

   printk(&amp;quot;Bluetooth initialized&amp;quot;);

   k_sem_give(&amp;amp;ble_init_ok);

   if (IS_ENABLED(CONFIG_SETTINGS)) 
   {
      settings_load();
   }

   err = bt_le_ext_adv_create(BT_LE_EXT_ADV_NCONN_NAME, NULL, &amp;amp;m_extended_advertising_set);  
   if (err) 
   {
      error();
   }

   err = bt_nus_init(&amp;amp;nus_cb);
   if (err) 
   {
      LOG_ERR(&amp;quot;Failed to initialize UART service (err: %d)&amp;quot;, err);
      return;
   }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error when trying to enable extended advertising on code based on NUS example</title><link>https://devzone.nordicsemi.com/thread/337722?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 14:04:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c61fa09a-fe40-41c8-a480-556c692f8a2f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;can you show some code snippets on the details of arguments to&amp;nbsp;&lt;span&gt;bt_le_ext_adv_create&amp;nbsp;I can try to replicate that on my end. That error looks like a missing feature but cannot confirm it before I can see it.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>