<?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>Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82842/disconnection-request-from-peripheral-device</link><description>Hi Everyone, 
 
 sdk : nrf Connect v1.7.0 
 ide : VS code 
 I was trying out central_hr sample on nrf52840 dk. I have simulated hrs server in nrf Connect mobile application. So basically our dk is Central and nrf Connect app is peripheral here. 
 Suppose</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jan 2022 12:36:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82842/disconnection-request-from-peripheral-device" /><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/349521?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 12:36:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa12f377-fccb-4a92-9290-62dfb1c101c9</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Sorry, just to confirm. Here you&amp;#39;re using the nRFConnect mobile app alongside&amp;nbsp;the &amp;quot;BLE sensor&amp;quot; you mentioned earlier as a peripheral device, correct? From this screenshot, the device seem to have disconnected just fine, but you have only enabled &amp;quot;INFO&amp;quot; in the log, so you won&amp;#39;t see a disconnect reason. The servers&amp;nbsp;&amp;quot;Disconnected&amp;quot; message will come a bit before the central/app initiates the disconnection, and the central will write its buffer to the peripheral before disconnecting it seems.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/349428?ContentTypeID=1</link><pubDate>Tue, 25 Jan 2022 08:05:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:810208c4-a27c-42b8-8d70-3649e85f6067</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Simon, though I have disconnected from nrf Connect mobile App, it&amp;#39;s still sending some notification in background. That&amp;#39;s the reason I couldn&amp;#39;t get a disconnect callback.&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Image-2022_2D00_01_2D00_25-at-13.32.19.jpeg" /&gt;&lt;/p&gt;
&lt;p&gt;How to disconnect properly from the app?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/345577?ContentTypeID=1</link><pubDate>Mon, 03 Jan 2022 07:56:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56c67b13-1356-4e69-858a-af0f9103d554</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry, can you upload a screenshot of the log from your nRFConnect app? &amp;quot;Connection terminated by peer&amp;quot; still points to a disconnect occurring, which is expected. It&amp;#39;s just different how the logging is done in the nRFConnect app and your other peripheral.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/344920?ContentTypeID=1</link><pubDate>Thu, 23 Dec 2021 10:49:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08cb1355-9948-4c8b-a72b-01eddc6fd2e7</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I can see that connection parameters updated: 4000ms in mobile app&amp;#39;s log.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried with customer&amp;#39;s ble sensor, pretty much the same central_hrs example, I&amp;#39;ve modified just some service uuids that&amp;#39;s it.&lt;/p&gt;
&lt;p&gt;The sensor would go to sleep immediately after notifying some data.&lt;/p&gt;
&lt;p&gt;Now I got the disconnect callback.&lt;/p&gt;
&lt;p&gt;when I connected customer&amp;#39;s sensor with nrfConnect App then I got...&lt;/p&gt;
&lt;p&gt;&amp;quot; Connection terminated by peer (status 19) &amp;quot; response on log.&lt;/p&gt;
&lt;p&gt;same code different results. I wish to know why I couldn&amp;#39;t do it from mobile app. Some flag setting might be missed. Please help me to know where I went wrong.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* main.c - Application main entry point */

/*
 * Copyright (c) 2015-2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;

#include &amp;lt;bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/hci.h&amp;gt;
#include &amp;lt;bluetooth/conn.h&amp;gt;
#include &amp;lt;bluetooth/uuid.h&amp;gt;
#include &amp;lt;bluetooth/gatt.h&amp;gt;
#include &amp;lt;sys/byteorder.h&amp;gt;

#define BT_UUID_TMU_SERVICE				BT_UUID_DECLARE_16(0xA100) /* TMU characteristic */
#define BT_UUID_TMU_WR_CHRC				BT_UUID_DECLARE_16(0xA101)
#define BT_UUID_TMU_NFY_CHRC			BT_UUID_DECLARE_16(0xA102)

static void start_scan(void);

static struct bt_conn *default_conn;

static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0);
static struct bt_gatt_discover_params discover_params;
static struct bt_gatt_subscribe_params subscribe_params;



static uint8_t notify_func(struct bt_conn *conn,
			   struct bt_gatt_subscribe_params *params,
			   const void *data, uint16_t length)
{
	if (!data) {
		printk(&amp;quot;[UNSUBSCRIBED]\n&amp;quot;);
		params-&amp;gt;value_handle = 0U;
		return BT_GATT_ITER_STOP;
	}

	printk(&amp;quot;[NOTIFICATION] data %p length %u\n&amp;quot;, data, length);

	return BT_GATT_ITER_CONTINUE;
}

static uint8_t discover_func(struct bt_conn *conn,
			     const struct bt_gatt_attr *attr,
			     struct bt_gatt_discover_params *params)
{
	int err;

	if (!attr) {
		printk(&amp;quot;Discover complete\n&amp;quot;);
		(void)memset(params, 0, sizeof(*params));
		return BT_GATT_ITER_STOP;
	}

	printk(&amp;quot;[ATTRIBUTE] handle %u\n&amp;quot;, attr-&amp;gt;handle);
	#if 0
	if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_TMU_SERVICE)) {
		memcpy(&amp;amp;uuid, BT_UUID_TMU_WR_CHRC, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.start_handle = attr-&amp;gt;handle + 1;
		discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC;

		err = bt_gatt_discover(conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed (err %d)\n&amp;quot;, err);
		}
	}else if(!bt_uuid_cmp(discover_params.uuid, BT_UUID_TMU_WR_CHRC)) {
		memcpy(&amp;amp;uuid, BT_UUID_TMU_NFY_CHRC, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.start_handle = attr-&amp;gt;handle + 1;
		discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC;

		err = bt_gatt_discover(conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed (err %d)\n&amp;quot;, err);
		}
	}else if(!bt_uuid_cmp(discover_params.uuid, BT_UUID_TMU_NFY_CHRC)) {
		memcpy(&amp;amp;uuid, BT_UUID_GATT_CCC, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.start_handle = attr-&amp;gt;handle + 2;
		discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
		subscribe_params.value_handle = bt_gatt_attr_value_handle(attr);

		err = bt_gatt_discover(conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed (err %d)\n&amp;quot;, err);
		}
	}else {
		subscribe_params.notify = notify_func;
		subscribe_params.value = BT_GATT_CCC_NOTIFY;
		subscribe_params.ccc_handle = attr-&amp;gt;handle;

		err = bt_gatt_subscribe(conn, &amp;amp;subscribe_params);
		if (err &amp;amp;&amp;amp; err != -EALREADY) {
			printk(&amp;quot;Subscribe failed (err %d)\n&amp;quot;, err);
		} else {
			printk(&amp;quot;[SUBSCRIBED]\n&amp;quot;);
		}
		return BT_GATT_ITER_STOP;
	}
	#endif
#if 1
	if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_HRS)) {
		memcpy(&amp;amp;uuid, BT_UUID_HRS_MEASUREMENT, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.start_handle = attr-&amp;gt;handle + 1;
		discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC;

		err = bt_gatt_discover(conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed (err %d)\n&amp;quot;, err);
		}
	} else if (!bt_uuid_cmp(discover_params.uuid,
				BT_UUID_HRS_MEASUREMENT)) {
		memcpy(&amp;amp;uuid, BT_UUID_GATT_CCC, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.start_handle = attr-&amp;gt;handle + 2;
		discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
		subscribe_params.value_handle = bt_gatt_attr_value_handle(attr);

		err = bt_gatt_discover(conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed (err %d)\n&amp;quot;, err);
		}
	} else {
		subscribe_params.notify = notify_func;
		subscribe_params.value = BT_GATT_CCC_NOTIFY;
		subscribe_params.ccc_handle = attr-&amp;gt;handle;

		err = bt_gatt_subscribe(conn, &amp;amp;subscribe_params);
		if (err &amp;amp;&amp;amp; err != -EALREADY) {
			printk(&amp;quot;Subscribe failed (err %d)\n&amp;quot;, err);
		} else {
			printk(&amp;quot;[SUBSCRIBED]\n&amp;quot;);
		}

		return BT_GATT_ITER_STOP;
	}
#endif
	return BT_GATT_ITER_STOP;
}

static bool eir_found(struct bt_data *data, void *user_data)
{
	 bt_addr_le_t *addr = user_data;
	int i;
uint8_t array[20] = {0};
	printk(&amp;quot;[AD]: %u data_len %u\n&amp;quot;, data-&amp;gt;type, data-&amp;gt;data_len);

	switch (data-&amp;gt;type) {
	case BT_DATA_UUID16_SOME:
	case BT_DATA_UUID16_ALL:
		if (data-&amp;gt;data_len % sizeof(uint16_t) != 0U) {
			printk(&amp;quot;AD malformed\n&amp;quot;);
			return true;
		}

		for (i = 0; i &amp;lt; data-&amp;gt;data_len; i += sizeof(uint16_t)) {
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			uint16_t u16;
			int err;

			memcpy(&amp;amp;u16, &amp;amp;data-&amp;gt;data[i], sizeof(u16));
			uuid = BT_UUID_DECLARE_16(sys_le16_to_cpu(u16));
			if (bt_uuid_cmp(uuid, BT_UUID_HRS)) {
				continue;
			}

			err = bt_le_scan_stop();
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				continue;
			}

			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				// bt_start_scan();
			}

			return false;
		}
	break;
	case BT_DATA_NAME_COMPLETE:
			
	memcpy(array, data-&amp;gt;data,data-&amp;gt;data_len);
	printk(&amp;quot;Complete local Name: %s\r\n&amp;quot;,array);
	if(strcmp(array,&amp;quot;TMU&amp;quot;) == 0)
	{
	int err = bt_le_scan_stop();
	printk(&amp;quot;BLE SCAN STOP\r\n&amp;quot;);
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				// continue;
			}
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				// bt_start_scan();
			}
			return false;
	}
		break;
	}

	return true;                   
	#if 0
	bt_addr_le_t *addr = user_data;
	int i;
	uint8_t array[20] = {0};

	printk(&amp;quot;[AD]: %u data_len %u\n&amp;quot;, data-&amp;gt;type, data-&amp;gt;data_len);

	switch (data-&amp;gt;type) {
	case BT_DATA_UUID16_SOME:
	case BT_DATA_UUID16_ALL:
		if (data-&amp;gt;data_len % sizeof(uint16_t) != 0U) {
			printk(&amp;quot;AD malformed\n&amp;quot;);
			return true;
		}

		for (i = 0; i &amp;lt; data-&amp;gt;data_len; i += sizeof(uint16_t)) {
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			uint16_t u16;
			int err;

			memcpy(&amp;amp;u16, &amp;amp;data-&amp;gt;data[i], sizeof(u16));
			uuid = BT_UUID_DECLARE_16(sys_le16_to_cpu(u16));
			if (bt_uuid_cmp(uuid, BT_UUID_HRS)) {
				continue;
			}

			err = bt_le_scan_stop();
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				continue;
			}

			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				start_scan();
			}

			return false;
		}
		break;
	case BT_DATA_NAME_COMPLETE:
			
	memcpy(array, data-&amp;gt;data,data-&amp;gt;data_len);
	printk(&amp;quot;Complete local Name: %s\r\n&amp;quot;,array);
	if(strcmp(array,&amp;quot;Viswa&amp;#39;s A52&amp;quot;) == 0)
	{
	int err = bt_le_scan_stop();
	printk(&amp;quot;BLE SCAN STOP\r\n&amp;quot;);
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				// continue;
			}
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				// bt_start_scan();

			}
	}
		break;
	}

	return true;
	#endif
}

static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
			 struct net_buf_simple *ad)
{
	char dev[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(addr, dev, sizeof(dev));
	// printk(&amp;quot;[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i\n&amp;quot;,
	    //    dev, type, ad-&amp;gt;len, rssi);

	/* We&amp;#39;re only interested in connectable events */
	if (type == BT_GAP_ADV_TYPE_ADV_IND ||
	    type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) {
		bt_data_parse(ad, eir_found, (void *)addr);
	}
}

static void start_scan(void)
{
	int err;

	/* Use active scanning and disable duplicate filtering to handle any
	 * devices that might update their advertising data at runtime. */
	struct bt_le_scan_param scan_param = {
		.type       = BT_LE_SCAN_TYPE_ACTIVE,
		.options    = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
		.interval   = BT_GAP_SCAN_FAST_INTERVAL,
		.window     = BT_GAP_SCAN_FAST_WINDOW,
	};

	err = bt_le_scan_start(&amp;amp;scan_param, device_found);
	if (err) {
		printk(&amp;quot;Scanning failed to start (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Scanning successfully started\n&amp;quot;);
}

static void connected(struct bt_conn *conn, uint8_t conn_err)
{
	char addr[BT_ADDR_LE_STR_LEN];
	int err;

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	if (conn_err) {
		printk(&amp;quot;Failed to connect to %s (%u)\n&amp;quot;, addr, conn_err);

		bt_conn_unref(default_conn);
		default_conn = NULL;

		start_scan();
		return;
	}

	printk(&amp;quot;Connected: %s\n&amp;quot;, addr);

	if (conn == default_conn) {
		memcpy(&amp;amp;uuid, BT_UUID_HRS, sizeof(uuid));
		discover_params.uuid = &amp;amp;uuid.uuid;
		discover_params.func = discover_func;
		discover_params.start_handle = BT_ATT_FIRST_ATTTRIBUTE_HANDLE;
		discover_params.end_handle = BT_ATT_LAST_ATTTRIBUTE_HANDLE;
		discover_params.type = BT_GATT_DISCOVER_PRIMARY;

		err = bt_gatt_discover(default_conn, &amp;amp;discover_params);
		if (err) {
			printk(&amp;quot;Discover failed(err %d)\n&amp;quot;, err);
			return;
		}
	}
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	printk(&amp;quot;Disconnected: %s (reason 0x%02x)\n&amp;quot;, addr, reason);

	if (default_conn != conn) {
		return;
	}

	bt_conn_unref(default_conn);
	default_conn = NULL;

	start_scan();
}

static struct bt_conn_cb conn_callbacks = {
	.connected = connected,
	.disconnected = disconnected,
};

void main(void)
{
	int err;
	err = bt_enable(NULL);

	if (err) {
		printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Bluetooth initialized\n&amp;quot;);

	bt_conn_cb_register(&amp;amp;conn_callbacks);

	start_scan();
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Config File.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=n
CONFIG_BT_GATT_CLIENT=y
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/344486?ContentTypeID=1</link><pubDate>Tue, 21 Dec 2021 07:18:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb83847d-2b2c-4d7f-bfb5-1b614de7e2b6</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Please note that this timeout you set is a connection supervision timeout, and will be trigged after 4 seconds of&amp;nbsp;&lt;strong&gt;inactivity&amp;nbsp;&lt;/strong&gt;in the connection. Are you sure that the application is inactive for 4 seconds, or else the connection timeout won&amp;#39;t be trigged.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you&amp;#39;re using a phone (and nRFConnect) as a peripheral you should be able to see logging information in nRFConnect where I believe the conn sup. timeout should be printed upon a connection. Can you confirm that it is set to 4 seconds?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/344278?ContentTypeID=1</link><pubDate>Mon, 20 Dec 2021 09:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62b47212-1f49-4d09-a960-ade11f96e311</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks for clearing my doubt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We include some connection timeout timer before creating a connection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;/**&amp;nbsp;Default&amp;nbsp;LE&amp;nbsp;connection&amp;nbsp;parameters:&lt;br /&gt;&amp;nbsp;*&amp;nbsp;Connection&amp;nbsp;Interval:&amp;nbsp;30-50&amp;nbsp;ms&lt;br /&gt;&amp;nbsp;*&amp;nbsp;Latency:&amp;nbsp;0&lt;br /&gt;&amp;nbsp;*&amp;nbsp;Timeout:&amp;nbsp;4&amp;nbsp;s&lt;br /&gt;&amp;nbsp;*/&lt;br /&gt;#define&amp;nbsp;BT_LE_CONN_PARAM_DEFAULT&amp;nbsp;BT_LE_CONN_PARAM(BT_GAP_INIT_CONN_INT_MIN,&amp;nbsp;\&lt;br /&gt;&amp;nbsp;BT_GAP_INIT_CONN_INT_MAX,&amp;nbsp;\&lt;br /&gt;&amp;nbsp;0,&amp;nbsp;400)Code&lt;/p&gt;
&lt;p&gt;After a timeout the bluetooth stack should trigger a callback isn&amp;#39;t it, then why it&amp;#39;s not triggering....I&amp;#39;m still getting used to rtos and Nordic, I couldn&amp;#39;t debug it myself. I request you once to try with any development board and let me know if it happens the same with you.&lt;/p&gt;
&lt;p&gt;I thought of adding the timer myself and monitor the connection, then what&amp;#39;s the point in giving a timeout before a connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/344266?ContentTypeID=1</link><pubDate>Mon, 20 Dec 2021 08:57:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04409c87-48a5-44a0-962e-c14009b4fb86</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Just to be clear. You want to trigger the disconnect on the peripheral side, is that so? That is indeed possible as well. You can check out the&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/bluetooth/connection_mgmt.html"&gt; Connection Management API &lt;/a&gt;that the Zephyr Bluetooth stack uses to manage connections and disconnections for both roles. Here you see that the bt_conn_disconnect call can be called to disconnect from a remote device. Both the central and peripheral can use this call.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/344131?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 11:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0843ccd9-b732-4cf6-bc62-4f7ce0da7f48</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;yeah, I&amp;#39;ve waited for 10minutes long, &lt;pre class="ui-code" data-mode="text"&gt;/******** My change to central_hr sample code ****************/

static bool eir_found(struct bt_data *data, void *user_data)
{
	bt_addr_le_t *addr = user_data;
	int i;
    uint8_t array[20] = {0};
	printk(&amp;quot;[AD]: %u data_len %u\n&amp;quot;, data-&amp;gt;type, data-&amp;gt;data_len);

	switch (data-&amp;gt;type) {
	case BT_DATA_UUID16_SOME:
	case BT_DATA_UUID16_ALL:
		if (data-&amp;gt;data_len % sizeof(uint16_t) != 0U) {
			printk(&amp;quot;AD malformed\n&amp;quot;);
			return true;
		}

		for (i = 0; i &amp;lt; data-&amp;gt;data_len; i += sizeof(uint16_t)) {
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			uint16_t u16;
			int err;

			memcpy(&amp;amp;u16, &amp;amp;data-&amp;gt;data[i], sizeof(u16));
			uuid = BT_UUID_DECLARE_16(sys_le16_to_cpu(u16));
			if (bt_uuid_cmp(uuid, BT_UUID_HRS)) {
				continue;
			}

			err = bt_le_scan_stop();
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				continue;
			}

			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				// bt_start_scan();
			}

			return false;
		}
	break;
	case BT_DATA_NAME_COMPLETE:
			
	memcpy(array, data-&amp;gt;data,data-&amp;gt;data_len);
	printk(&amp;quot;Complete local Name: %s\r\n&amp;quot;,array);
	if(strcmp(array,&amp;quot;Viswa&amp;#39;s A52&amp;quot;) == 0)
	{
	int err = bt_le_scan_stop();
	printk(&amp;quot;BLE SCAN STOP\r\n&amp;quot;);
			if (err) {
				printk(&amp;quot;Stop LE scan failed (err %d)\n&amp;quot;, err);
				// continue;
			}
			struct bt_le_conn_param *param;
			struct bt_uuid *uuid;
			param = BT_LE_CONN_PARAM_DEFAULT;
			err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
						param, &amp;amp;default_conn);
			if (err) {
				printk(&amp;quot;Create conn failed (err %d)\n&amp;quot;, err);
				// bt_start_scan();
			}
			return false;
	}
		break;
	}

	return true;                   
	
}

&lt;/pre&gt;but in my case I couldn&amp;#39;t see the callback triggered. the only change i did is to start connection based on &amp;quot;complete local name 0x09 flag&amp;quot; from advertising parameters into existing central_hr&amp;nbsp; sample code.&lt;/p&gt;
&lt;p&gt;I have commented the discovery of services part too. Now the client simply connects. I have registered disconnect callbacks so i expect, it should be triggered.&lt;/p&gt;
&lt;p&gt;please clarify my doubt below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Can we disconnect from peripheral side in a ble connection?&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disconnection request from peripheral device.</title><link>https://devzone.nordicsemi.com/thread/343946?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 14:01:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d18e4e5f-00fd-4a04-8593-0dc517c06215</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Most of the central applications in the nRFConnect SDK (NCS) handle disconnections with a disconnected event similar to this, so you should get a &amp;quot;Disconnected&amp;quot; logging message:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	int err;
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	printk(&amp;quot;Disconnected: %s (reason 0x%02x)\n&amp;quot;, addr, reason);

	if (default_conn != conn) {
		return;
	}

	bt_conn_unref(default_conn);
	default_conn = NULL;

	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
	if (err) {
		printk(&amp;quot;Scanning failed to start (err %d)\n&amp;quot;, err);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Generally I think most central applications have a button assigned to disconnect from peripherals, alternatively they&amp;#39;ll disconnect automatically when the connection supervision timeout is exceeded.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>