<?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>NRF52840: NCS 2.5.0 -&amp;gt; NCS 2.7.0 BLE advertising stops on disconnect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114174/nrf52840-ncs-2-5-0---ncs-2-7-0-ble-advertising-stops-on-disconnect</link><description>I have a custom board that is in production but is running NCS 2.5.0. I am interested in migrating to 2.7.0 however I am running into a few issues. When I pair to the device with our phone app then disconnect, the device stops advertising (See log snippet</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Aug 2024 14:14:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114174/nrf52840-ncs-2-5-0---ncs-2-7-0-ble-advertising-stops-on-disconnect" /><item><title>RE: NRF52840: NCS 2.5.0 -&gt; NCS 2.7.0 BLE advertising stops on disconnect</title><link>https://devzone.nordicsemi.com/thread/500239?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 14:14:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4aca8e9-f6a0-47f0-8de3-3319fd9f1d30</guid><dc:creator>sheldon_b</dc:creator><description>&lt;p&gt;I decided to set &lt;span&gt;CONFIG_BT_MAX_CONN&amp;nbsp;to 2 and it worked as you described. I might try the work approach later, but for now I don&amp;#39;t want to deal with any potential race conditions between the disconnection and work.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840: NCS 2.5.0 -&gt; NCS 2.7.0 BLE advertising stops on disconnect</title><link>https://devzone.nordicsemi.com/thread/499731?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 11:50:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37c1d771-3988-4c3d-a10d-4aa2148167b4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;The disconnect probably is not complete if you do start to advertise in the disconnect callback with&amp;nbsp;CONFIG_BT_MAX_CONN set to 1. This is because you cannot do a connectable advertising while the controller is not fully finished with the disconnect procedure. Which means, you cannot do another connectable advertising while in another connection with max_conn = 1;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Either change&amp;nbsp;CONFIG_BT_MAX_CONN to 2, to allow this overlap of roles or&lt;/li&gt;
&lt;li&gt;Create a worker thread to start the advertising after the disconnect callback has exited like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static K_WORK_DEFINE(start_advertising_worker, start_advertising_coded);

static void start_advertising_coded(struct k_work *work)
{
	int err;

	err = bt_le_ext_adv_start(adv, NULL);
	if (err) {
		printk(&amp;quot;Failed to start advertising set (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Advertiser %p set started\n&amp;quot;, adv);
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	printk(&amp;quot;Disconnected (reason 0x%02x)\n&amp;quot;, reason);

	k_work_submit(&amp;amp;start_advertising_worker);

}&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Where disconnected() is the callback for disconnected which is configured as below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;BT_CONN_CB_DEFINE(conn_callbacks) = {
	.connected = connected,
	.disconnected = disconnected,
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>