<?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>Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81860/set-mtu-size-in-zephyr</link><description>Hello, 
 I ran the throughput example ,but I found that setting the MTU size actually requires calling the bt_gatt_exchange_mtu function, which is different from sdk16.0 . 
 In sdk16.0 or other versions, I can set the MTU size by calling nrf_ble_gatt_att_mtu_periph_set</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Nov 2021 12:09:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81860/set-mtu-size-in-zephyr" /><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/341062?ContentTypeID=1</link><pubDate>Mon, 29 Nov 2021 12:09:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f141eb5-8f48-4162-a0e7-619c8b130153</guid><dc:creator>haakonsh</dc:creator><description>[quote user="haakonsh"]You can&amp;#39;t set it before a connection as&amp;nbsp;the MTU exchange&amp;nbsp;is a negotiation between the Central and Peripheral (where the Central ultimately decides what value to use). You&amp;#39;ll have to initiate such an exchange for each established connection.&amp;nbsp;[/quote]
&lt;p&gt;The MTU that you&amp;#39;ve set in the configs will be applied when calling&amp;nbsp;bt_gatt_exchange_mtu() with an empty exchange_params.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/340817?ContentTypeID=1</link><pubDate>Fri, 26 Nov 2021 03:58:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b725a8ee-fc32-4c5e-924c-4cb44030898d</guid><dc:creator>Palmer Huang</dc:creator><description>&lt;p&gt;Yes, my output is also like this.&lt;/p&gt;
&lt;p&gt;So, why is the MTU_SIZE obtained in discovery_complete() 23 instead of 247? I obviously set 247 in prj.conf&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/340755?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 13:56:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6630132-bbe2-4a58-a89c-2e9bcc53132e</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey again Grey,&lt;/p&gt;
&lt;p&gt;I added the bt_gatt_get_mtu functions to the exchange and discovery complete functions:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void exchange_func(struct bt_conn *conn, uint8_t att_err,
			  struct bt_gatt_exchange_params *params)
{
	struct bt_conn_info info = {0};
	int err;

	printk(&amp;quot;MTU exchange %s\n&amp;quot;, att_err == 0 ? &amp;quot;successful&amp;quot; : &amp;quot;failed&amp;quot;);
	printk(&amp;quot;MTU size is: %d\n&amp;quot;, bt_gatt_get_mtu(conn));

	err = bt_conn_get_info(conn, &amp;amp;info);
	if (err) {
		printk(&amp;quot;Failed to get connection info %d\n&amp;quot;, err);
		return;
	}

	if (info.role == BT_CONN_ROLE_MASTER) {
		instruction_print();
		test_ready = true;
	}
}

static void discovery_complete(struct bt_gatt_dm *dm,
			       void *context)
{
	int err;
	struct bt_throughput *throughput = context;

	printk(&amp;quot;Service discovery completed\n&amp;quot;);

	bt_gatt_dm_data_print(dm);
	bt_throughput_handles_assign(dm, throughput);
	bt_gatt_dm_data_release(dm);

	exchange_params.func = exchange_func;

	printk(&amp;quot;MTU size is: %d\n&amp;quot;, bt_gatt_get_mtu(default_conn));

	err = bt_gatt_exchange_mtu(default_conn, &amp;amp;exchange_params);
	if (err) {
		printk(&amp;quot;MTU exchange failed (err %d)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;MTU exchange pending\n&amp;quot;);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;div&gt;This was my output:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Connected as master&lt;br /&gt;Conn. interval is 320 units&lt;br /&gt;Service discovery completed&lt;br /&gt;MTU size is: 23&lt;br /&gt;MTU exchange pending&lt;br /&gt;MTU exchange successful&lt;br /&gt;MTU size is: 247&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I&amp;#39;m on NCS 1.7.1 btw.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/340436?ContentTypeID=1</link><pubDate>Wed, 24 Nov 2021 01:37:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ed92fc4-e356-4519-8f20-c1c81cade31d</guid><dc:creator>Palmer Huang</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;span&gt;haakonsh&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The demo I ran was provided by Nordic(&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/throughput/README.html"&gt;throughput example&lt;/a&gt;). I didn&amp;rsquo;t change the code much. I only called get_mtu_size() in the connected() and exchange_func() functions.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/340117?ContentTypeID=1</link><pubDate>Mon, 22 Nov 2021 14:09:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d97ce38f-931a-440f-9d89-aebe1239623d</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey Gray,&lt;/p&gt;
&lt;p&gt;You configs looks good.&lt;/p&gt;
&lt;p&gt;We need more information however. I suggest you start by enabling debug logs for the BT stack and share that. A sniffer trace would also help.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/339938?ContentTypeID=1</link><pubDate>Mon, 22 Nov 2021 03:16:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:402a9a5a-fc23-47d2-9836-ec2718c80813</guid><dc:creator>Palmer Huang</dc:creator><description>&lt;p&gt;Hi,&lt;span&gt;haakonsh&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;My doubt is why the C&lt;span&gt;entral does not choose to set MTU_SIZE?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After connecting, I called bt_gatt_get_mtu() and the read size was 23 instead of the set size.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/samples/bluetooth/throughput/prj.conf"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/samples/bluetooth/throughput/prj.conf&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_RX_BUFFERS=2
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/339790?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 10:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e349bef5-f0a1-4015-b53d-9b63620a29bc</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;You can&amp;#39;t set it before a connection as&amp;nbsp;the MTU exchange&amp;nbsp;is a negotiation between the Central and Peripheral (where the Central ultimately decides what value to use). You&amp;#39;ll have to initiate such an exchange for each established connection.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/339725?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 01:14:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02b6ab33-4d15-4fdb-9d3d-db742e49db58</guid><dc:creator>Palmer Huang</dc:creator><description>&lt;p&gt;Hello, haakonsh&lt;/p&gt;
&lt;p&gt;Sorry, my description is not clear enough.&lt;br /&gt;What I mean is how to set the MTU before the connection, without calling &lt;span&gt;bt_gatt_exchange_mtu()&lt;/span&gt; to set it after the connection.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Gray&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set MTU size  in Zephyr</title><link>https://devzone.nordicsemi.com/thread/339602?ContentTypeID=1</link><pubDate>Thu, 18 Nov 2021 10:49:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56052ce8-7262-4854-8241-fb24a2ef2383</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;What do you mean by automatically?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>