<?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>BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119485/ble-not-connecting-after-disconnect</link><description>I have a problem with connecting to my device after i disconnect from it. I have tried ubond function, it does not work. This is my disconnect function: 
 I have a service with 2 characteristics and one configuration 
 
 BT_GATT_CCC ( rx_ccc_cfg_changed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Mar 2025 13:34:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119485/ble-not-connecting-after-disconnect" /><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525992?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 13:34:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77cb5d02-8b93-4db2-baea-c807710f87ab</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;Wow i missed that somehow and thank you for noticing it.&lt;br /&gt;&lt;br /&gt;i now what in main there is a endless loop since i cut out most of my code so only BLE related code is being sent in zip file.&lt;br /&gt;&lt;br /&gt;Thank you again for you help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525982?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 13:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d768b81-3e9c-4695-8e2d-1425554ac1be</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for sharing the code. The issue was that you were increasing the reference count for the connection object with &amp;#39;2&amp;#39; in your connected callback, but you only released one of them in your disconnected callback. The advertiser does not resume until the reference count is 0. Solution is to only call&amp;nbsp;bt_conn_ref() once.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You also had an endless loop in main() in the code you provided me. This will block other threads such as the logger thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525913?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:55:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c5294c5-a7d2-416b-bb86-e108aa6a70f9</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;ill make some changes and upload it to a private ticket.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525909?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:45:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:403845f5-6e4d-4b8a-bc12-5a081a15cf69</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Can you upload a minimal version of your project here or in a private ticket so I can reproduce the problem and debug the problem on my end?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525901?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a9b148-5b13-4083-aa2b-4be05e29a6d9</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;i still doesnt work after i removed it.&lt;br /&gt;&lt;br /&gt;i accidentaly put it closed, maybe for someone it works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525896?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:06:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c40b2550-3e27-449c-b7ad-414eef20e676</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;When the connectable advertiser was started with bt_le_adv_start(), the bt host will automatically try to resume advertising on disconnect as you don&amp;#39;t have the BT_LE_ADV_OPT_ONE_TIME flag set.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1741165555890v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Removing the call to&amp;nbsp; advertising_stop(); and advertising_start(); in&amp;nbsp;disconnected() should fix the issue you are seeing with the advetiser not starting after disconnect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525895?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c421f9b-51a5-479f-a637-bdbe6a25f0d6</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Declaring advertising parameters
static struct bt_le_adv_param adv_param = 
{
	.options = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_IDENTITY, 	/* Connectable advertising and use identity address */
	.interval_max = BT_GAP_ADV_FAST_INT_MAX_1,							/* 0x30 units, 48 units, 30ms */
	.interval_min = BT_GAP_ADV_FAST_INT_MIN_1,							/* 0x60 units, 96 units, 60ms */
	.peer = NULL														/* Set to NULL for undirected advertising */
};

// Declaring the advertising data
struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA(BT_DATA_NAME_COMPLETE, ble_dev_name, 16),
};

// Declaring the scanning data
struct bt_data sd[] = {
	BT_DATA(BT_DATA_UUID128_ALL, uuid_128, sizeof(uuid_128)),
	BT_DATA(BT_DATA_MANUFACTURER_DATA, manufacturer_data, sizeof(manufacturer_data))
};

/*
	@brief Function for starting advertising.
*/
void advertising_start(void)
{
	if(ble_status == BLE_IDLE){
		int err = bt_le_adv_start(&amp;amp;adv_param, ad, ARRAY_SIZE(ad), sd,
					ARRAY_SIZE(sd));
		
		if (err) {
			LOG_ERR(&amp;quot;Advertising failed to start (err %d)&amp;quot;, err);
		}
		ble_status = BLE_ADV;
	}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525890?ContentTypeID=1</link><pubDate>Wed, 05 Mar 2025 09:00:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a81f3047-5f10-49d5-83a9-1a83cbfcb0ce</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;This indicates that the advertiser is not re-started on disconnect. Please also post your implementation of&amp;nbsp;advertising_start().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525739?ContentTypeID=1</link><pubDate>Tue, 04 Mar 2025 13:45:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:332b3a53-b66d-4bca-ac56-6e36843fcd03</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;no, i cannot discover my device on application.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525731?ContentTypeID=1</link><pubDate>Tue, 04 Mar 2025 13:24:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:001b2177-cc50-49ac-b226-7eafb07c7c1b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Does the device start connectable advertising again after the disconnect?&amp;nbsp; In other words,&amp;nbsp;if you restart scanning in the nRF Connect app after the disconnect, can you still&amp;nbsp;discover your device?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE not connecting after disconnect</title><link>https://devzone.nordicsemi.com/thread/525536?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2025 14:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20c4b6f5-cfc5-4966-85c8-276ded078529</guid><dc:creator>Zugislav</dc:creator><description>&lt;p&gt;Also security is not enabled, I do not use any security regarding it.&lt;br /&gt;&lt;br /&gt;Also this is part of prj.conf file:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;# Configure your preferred connection parameters
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y //this also added to try all

CONFIG_BT_MAX_PAIRED=1&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="line"&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt; err= &lt;/span&gt;&lt;span&gt;bt_unpair&lt;/span&gt;&lt;span&gt;(BT_ID_DEFAULT,BT_ADDR_LE_ANY); this is unpair function not unbond as i mentioned above.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>