<?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>Connection MTU update fails on ncs v3.2.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/126199/connection-mtu-update-fails-on-ncs-v3-2-0</link><description>Hello, 
 I hope you are well. 
 I have a code inside the connection connected callback that sets the MTU to the maximum, which is working fine on ncs v3.0.2 but generates the following error on v3.2.0: 
 
 I am using: 
 
 With the configuration: 
 
 And</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Dec 2025 09:40:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/126199/connection-mtu-update-fails-on-ncs-v3-2-0" /><item><title>RE: Connection MTU update fails on ncs v3.2.0</title><link>https://devzone.nordicsemi.com/thread/557506?ContentTypeID=1</link><pubDate>Mon, 22 Dec 2025 09:40:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6c7a1c8-6bcf-46b9-9dd4-74e32bdd5d81</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have forwarded internally, due to holidays many key personnel is away, so maybe there will no feedback until beginning of January.&lt;/p&gt;
&lt;p&gt;Something you can try for now is to move the&amp;nbsp;call to&amp;nbsp;&lt;span&gt;bt_conn_le_data_len_update() in a work queue or in main. For instance call&amp;nbsp;&lt;/span&gt;k_work_submit() from connected callback.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection MTU update fails on ncs v3.2.0</title><link>https://devzone.nordicsemi.com/thread/557377?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 21:46:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5194def-6738-4d51-8ce6-c4275bd5b6f4</guid><dc:creator>ael-mess</dc:creator><description>&lt;p&gt;Hello Kenneth,&lt;/p&gt;
&lt;p&gt;Thank you for your reply.&lt;/p&gt;
&lt;p&gt;I initialise the BLE peripheral from the main thread and run&amp;nbsp;&lt;span&gt;bt_conn_le_data_len_update() in the connected callback as follows (bt_conn_le_data_len_update() also produces the same error):&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/conn.h&amp;gt;
#include &amp;lt;zephyr/bluetooth/gatt.h&amp;gt;
#include &amp;lt;zephyr/settings/settings.h&amp;gt;

#include &amp;lt;zephyr/logging/log.h&amp;gt;

#define DEVICE_NAME     &amp;quot;tPeripheral&amp;quot;
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

static struct bt_conn_cb              conn_callbacks;
static struct bt_conn   *             conn;
static uint8_t                        mtu;
static struct bt_gatt_exchange_params exchange_params;

static const struct bt_le_adv_param *c_adv_param = BT_LE_ADV_PARAM(
    BT_LE_ADV_OPT_CONN | BT_LE_ADV_OPT_ANONYMOUS, BT_GAP_ADV_SLOW_INT_MIN, BT_GAP_ADV_SLOW_INT_MAX, NULL);

static const struct bt_data c_adv_data[] = {
    BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};

static void exchange_func(struct bt_conn *p_conn, uint8_t p_err, struct bt_gatt_exchange_params *p_params) {
    if (p_err) {
        printk(&amp;quot;MTU exhange failed, err: 0x%x\n&amp;quot;, p_err);
    } else {
        mtu = bt_gatt_get_mtu(p_conn);
        printk(&amp;quot;MTU updated, conn: %p, mtu: %u\n&amp;quot;, (void *)p_conn, mtu);
    }
}

static void on_connect(struct bt_conn *p_conn, uint8_t p_err) {
    if (p_err) {
        printk(&amp;quot;Connection failed, err: 0x%x\n&amp;quot;, p_err);
        return;
    }

    if (bt_le_adv_stop() != 0) {
        printk(&amp;quot;Advertising stop failed\n&amp;quot;);
    }

    conn = p_conn;
    mtu  = bt_gatt_get_mtu(p_conn);

    printk(&amp;quot;Connection, conn: %p, mtu: %u\n&amp;quot;, (void *)p_conn, mtu);

    const struct bt_conn_le_phy_param preferred_phy = {
        .options     = BT_CONN_LE_PHY_OPT_NONE,
        .pref_rx_phy = BT_GAP_LE_PHY_2M,
        .pref_tx_phy = BT_GAP_LE_PHY_2M,
    };
    if (bt_conn_le_phy_update(conn, &amp;amp;preferred_phy) != 0) {
        printk(&amp;quot;PHY update failed\n&amp;quot;);
    }

    struct bt_conn_le_data_len_param data_len = {
        .tx_max_len  = BT_GAP_DATA_LEN_MAX,
        .tx_max_time = BT_GAP_DATA_TIME_MAX,
    };
    if (bt_conn_le_data_len_update(conn, &amp;amp;data_len) != 0) {
        printk(&amp;quot;Data Length update failed\n&amp;quot;);
    }

    exchange_params.func = exchange_func;
    if (bt_gatt_exchange_mtu(conn, &amp;amp;exchange_params) != 0) {
        printk(&amp;quot;MTU update failed\n&amp;quot;);
    }
}

static void on_disconnect(struct bt_conn *p_conn, uint8_t p_reason) {
    printk(&amp;quot;Disconnection, conn: %p, reason: 0x%x\n&amp;quot;, (void *)p_conn, p_reason);
    conn = NULL;
    mtu  = 23;
}

static void on_recycled(void) {
    int err = bt_le_adv_start(c_adv_param, c_adv_data, ARRAY_SIZE(c_adv_data), NULL, 0);
    if (err != 0) {
        printk(&amp;quot;Advertising start failed %d\n&amp;quot;, err);
    }
}

int main(void) {
    int err;

    conn = NULL;
    mtu  = 23;

    conn_callbacks.connected    = on_connect;
    conn_callbacks.disconnected = on_disconnect;
    conn_callbacks.recycled     = on_recycled;

    err = bt_conn_cb_register(&amp;amp;conn_callbacks);
    if (err != 0) {
        printk(&amp;quot;Connection manager: failed to register callbacks %d\n&amp;quot;, err);
        return err;
    }

    err = bt_enable(NULL);
    if (err != 0) {
        printk(&amp;quot;Connection manager: failed to enable bluetooth %d\n&amp;quot;, err);
        return err;
    }

    if (IS_ENABLED(CONFIG_SETTINGS)) {
        settings_load();
    }

    /* err = drv_bles_init(void); my service */
    if (err != 0) {
        printk(&amp;quot;Connection manager: failed to Initialize bles driver %d\n&amp;quot;, err);
        return err;
    }

    err = bt_le_adv_start(c_adv_param, c_adv_data, ARRAY_SIZE(c_adv_data), NULL, 0);
    if (err != 0) {
        printk(&amp;quot;Connection manager: failed to start advertising %d\n&amp;quot;, err);
        return err;
    }

    for (;;) {
        k_sleep(K_MSEC(500));
    }

    return 0;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And the error&amp;nbsp;&lt;/span&gt;happens when I connect using my custom app or nRF Connect app.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection MTU update fails on ncs v3.2.0</title><link>https://devzone.nordicsemi.com/thread/557321?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 12:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:326c2ab9-6dc5-4187-8c35-c094cd82e8ad</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am a little bit out of ideas, do you have any example project I can run here to recreate this on a DK? Do calling&amp;nbsp;bt_conn_le_data_len_update() from a deferred work queue work?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>