"Unable to allocate TX context" at the beginning of a stream

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:

[00:00:16.970,672] <err> bt_conn: Unable to allocate TX context
[00:00:16.970,672] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -105
[00:00:16.972,656] <err> bt_conn: Unable to allocate TX context
[00:00:16.972,686] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -105
[00:00:16.973,663] <err> bt_conn: Unable to allocate TX context
[00:00:16.973,663] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -105
[00:00:16.975,860] <err> bt_conn: Unable to allocate TX context
[00:00:16.975,860] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -105
[00:00:16.983,093] <err> bt_conn: Unable to allocate TX context
[00:00:16.983,123] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -105
[00:00:21.978,057] <wrn> bt_att: Not connected
[00:00:21.978,088] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -128
[00:00:21.978,302] <wrn> bt_att: Not connected
[00:00:21.978,302] <wrn> ble_bsp: Failed to send data over BLE connection. bt_nus_send return value = -22

After those few drops, it works fine.

My question is, is there any concrete explanation to why this is the case?

Additional info:

  • NRF Connect SDK: v1.8.0 and v1.9.1 were used, there was no difference between them
  • nrf52840 dongle is used to communicate with nrf5340 dev board, where the dongle is central and nrf5340dk is a nus peripheral
  • PC is running Windows 10, communicating via Blatann library
  • nrf5340's antenna is a few centimeters away from nrf52840 USB dongle

Connection parameters:

  • 7.5ms Conn interval
  • 1ms Slave latency
  • 247 MTU
  • 251 DLE
  • 2M PHY
  • After you establish a connection, then central and peripheral will start to negotiate the Connection parameters outlined above.

    You should wait until this negotiation is finished before starting to send data. Note this can take upwards of 2-3 seconds.

    Until such time, hold off on making calls to bt_nus_send()

  • After you establish a connection, then central and peripheral will start to negotiate the Connection parameters outlined above.

    You should wait until this negotiation is finished before starting to send data. Note this can take upwards of 2-3 seconds.

    Until such time, hold off on making calls to bt_nus_send()

  • That is not the case, on my central I await all of the connection paramater updates before proceeding with stream initiation.

    To further test it out, I put a 5s delay in my central after negotiating the connection paramaters and the results are the same.

  • Hi, 

    Connection parameters:

    • 7.5ms Conn interval
    • 1ms Slave latency
    • 247 MTU
    • 251 DLE
    • 2M PHY

    Could you share the prj.conf?

    You also could refer to this setting https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bluetooth/throughput/prj.conf. 

    Regards,
    Amanda

  • Hi Amanda,

    This is our prj.conf

    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

    And this is our hci_rpmsg.conf

    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
    

Related