<?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>&amp;quot;Unable to allocate TX context&amp;quot; at the beginning of a stream</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87041/unable-to-allocate-tx-context-at-the-beginning-of-a-stream</link><description>Hi, 
 
 In my system I have a timer that ticks at 1kHz frequency, collects some data and sends it over BLE via bt_nus_send. It works fine, but in the beginning of the stream for the first few messages I get the following in the debug log: 
 
 After those</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Apr 2022 17:07:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87041/unable-to-allocate-tx-context-at-the-beginning-of-a-stream" /><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363693?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 17:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c18331a5-7e18-4a3b-b084-6c405d4c2fb8</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;OK, understood now.&lt;/p&gt;
&lt;p&gt;Can you show a bit of code leading up to the bt_nus_send() area ?&lt;/p&gt;
&lt;p&gt;Can you&amp;nbsp;show the Peripheral logs showing connection negotiation, including the&amp;nbsp;receiving the &amp;quot;go ahead&amp;quot; command from the Central, to a short time after the error logs you posted above?&lt;/p&gt;
&lt;p&gt;Helpful if Peripheral outputs logs upon reception/confirmation of the above connection negotiations.&lt;/p&gt;
&lt;p&gt;If you are using security/encryption, you may need to wait for that to complete also.&lt;/p&gt;
&lt;p&gt;In Peripheral code, you should have callbacks for&amp;nbsp;security_changed(),&amp;nbsp;le_param_updated(),&amp;nbsp;le_phy_updated(),&amp;nbsp;le_data_length_updated()&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t get a callback working for MTU update ( see atu_mtu_notification_callback() ), but you can print it out right after receiving your&amp;nbsp;&lt;span&gt;&amp;quot;go ahead&amp;quot; command from the Central. See&amp;nbsp;bt_gatt_get_mtu(current_conn)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363690?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 16:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bae2f9a-f007-48ef-abae-42b0d2476de0</guid><dc:creator>Branislav</dc:creator><description>&lt;p&gt;The peripheral is streaming the data, but it wont initiate the stream until central tells it to, and central is configured to send that command only after connection parameters are negotiated (+ some additional time)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363688?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 16:39:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a3b0408-6ba7-4eb6-932e-e8a72be9e44c</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;Hmmm ... who is streaming the data ... the central or the peripheral ?&amp;nbsp; If the peripheral, then the waiting for end of connection negotiations should occur on the peripheral.&lt;/p&gt;
&lt;p&gt;peripheral uses&amp;nbsp;&lt;span&gt;bt_nus_send(), whereas central uses bt_nus_client_send() ... so from your logs&amp;nbsp;it seems that your Peripheral is streaming the data.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Do you have code on the peripheral side to ensure that you do not call&amp;nbsp;bt_nus_send() until all negotiations are complete ?&amp;nbsp;It would be helpful to paste some code to review.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363594?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 12:52:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f008ef73-e9c1-4ec3-8676-6e1d754194de</guid><dc:creator>Branislav</dc:creator><description>&lt;p&gt;Hi Amanda,&lt;/p&gt;
&lt;p&gt;This is our prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

CONFIG_BT_NUS=y

CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

CONFIG_DK_LIBRARY=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=y

CONFIG_ASSERT=y

CONFIG_PWM=y
CONFIG_LED=y
CONFIG_LED_PWM=y
CONFIG_NRFX_PWM0=y
CONFIG_NRFX_PWM1=y
CONFIG_NRFX_PWM2=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y

CONFIG_BT_DEVICE_NAME_DYNAMIC=y

CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_ATT_PREPARE_COUNT=50
CONFIG_BT_L2CAP_TX_BUF_COUNT=20
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_BUF_ACL_TX_COUNT=20
CONFIG_BT_BUF_ACL_TX_SIZE=251

CONFIG_NRFX_SPIM1=y
CONFIG_NRFX_SPIS2=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this is our hci_rpmsg.conf&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_RPMSG_SERVICE=y
CONFIG_RPMSG_SERVICE_MODE_REMOTE=y

CONFIG_HEAP_MEM_POOL_SIZE=8192

CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_HCI_RAW_RESERVE=1
CONFIG_BT_BUF_CMD_TX_COUNT=64

CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=502

CONFIG_SPEED_OPTIMIZATIONS=y
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363591?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 12:48:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67897c92-9d50-4650-9444-995eff11be35</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;Connection parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;7.5ms Conn interval&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;1ms Slave latency&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;247 MTU&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;251 DLE&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;2M PHY&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;Could you share the prj.conf?&lt;/p&gt;
&lt;p&gt;You also could refer to this setting&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bluetooth/throughput/prj.conf"&gt;https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bluetooth/throughput/prj.conf.&amp;nbsp;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363509?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 09:56:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4239f3d-4b0d-47fc-92c5-e0a3d3a4f107</guid><dc:creator>Branislav</dc:creator><description>&lt;p&gt;That is not the case, on my central I await all of the connection paramater updates&amp;nbsp;before proceeding with stream initiation.&lt;br /&gt;&lt;br /&gt;To further test it out, I put a 5s delay in my central after negotiating the connection paramaters and the results are the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363398?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2022 23:24:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d667294-a4bc-45f5-893b-1ac3c0a58921</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;After you establish a connection, then central and peripheral will start to negotiate the Connection parameters outlined above.&lt;/p&gt;
&lt;p&gt;You should wait until this negotiation is finished before starting to send data. Note this can take upwards of 2-3 seconds.&lt;/p&gt;
&lt;p&gt;Until such time, hold off on making calls to&amp;nbsp;&lt;span&gt;bt_nus_send()&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Unable to allocate TX context" at the beginning of a stream</title><link>https://devzone.nordicsemi.com/thread/363397?ContentTypeID=1</link><pubDate>Mon, 18 Apr 2022 23:23:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad1a893a-9c60-49c0-918a-1ee102cd7c29</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;After you establish a connection, then central and peripheral will start to negotiate the Connection parameters outlined above.&lt;/p&gt;
&lt;p&gt;You should wait until this negotiation is finished before starting to send data. Note this can take upwards of 2-3 seconds.&lt;/p&gt;
&lt;p&gt;Until such time, hold off on making calls to&amp;nbsp;&lt;span&gt;bt_nus_send()&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>