Zephyr is not able to advertise and keep central connections after "bt_conn: Unable to allocate TX context"

Hi everyone.

I catch a terrible issue

When I use nrf52840 and NUS Android app and had for a short time a bad rssi (because of long distance between Android and SoC) and received a debug message "bt_conn: Unable to allocate TX context" then all central connections became broken and I can not return it in normal mode until Hardware Reset.

I found the source of this message

This is "conn.c" file from "subsys/host" folder

How could I return a normal state of BLE connections and advertising

int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf,
		    bt_conn_tx_cb_t cb, void *user_data)
{
	struct bt_conn_tx *tx;

	BT_DBG("conn handle %u buf len %u cb %p user_data %p", conn->handle,
	       buf->len, cb, user_data);

	if (conn->state != BT_CONN_CONNECTED) {
		BT_ERR("not connected!");
		return -ENOTCONN;
	}

	if (cb) {
		tx = conn_tx_alloc();
		if (!tx) {
			BT_ERR("Unable to allocate TX context");
			return -ENOBUFS;
		}

here is debug messages

[00:15:21.844,329] <inf> nrf52: Connected App 4D:CC:1E:97:84:CB (random)
[00:15:21.844,390] <inf> nrf52: MTU (5): 36
[00:15:21.844,421] <inf> nrf52: Exchange pending...
[00:15:22.019,622] <inf> nrf52: MTU exchange 5 successful (272)
[00:15:22.382,873] <err> bt_conn: Unable to allocate TX context
[00:15:22.845,733] <inf> nrf52: le_param_updated <5> 4D:CC:1E:97:84:CB (random)
[00:15:22.845,764] <inf> nrf52: bt_conn_get_info interval 6 latency 0 timeout 500
[00:15:23.156,982] <inf> nrf52: le_param_updated <5> 4D:CC:1E:97:84:CB (random)
[00:15:23.157,012] <inf> nrf52: bt_conn_get_info interval 39 latency 0 timeout 500
[00:15:25.258,758] <inf> nrf52: 
                                 54 04 00 58 00 58 7c 26                          |T..X.X|&         
[00:15:25.382,904] <err> bt_conn: Unable to allocate TX context
[00:15:26.184,967] <inf> nrf52: 
                                 54 04 00 b0 00 58 fc 12                          |T....X..         
[00:15:26.383,148] <err> bt_conn: Unable to allocate TX context
[00:15:27.159,942] <inf> nrf52: 
                                 54 04 00 00 00 58 fd f5                          |T....X..         
[00:15:30.389,648] <inf> nrf52: titac 93
[00:15:33.383,087] <wrn> nrf52: Failed to send (err -12)
[00:15:33.383,575] <err> nrf52: disconnect 10 adr 6 - F2:08:3F:30:F5:E3 (random)
[00:15:38.388,275] <wrn> nrf52: Failed to send (err -12)
[00:15:38.388,763] <err> nrf52: disconnect 16 adr 7 - F4:09:5E:B7:4B:1A (random)
[00:15:40.389,709] <inf> nrf52: titac 94
[00:15:43.393,341] <wrn> nrf52: Failed to send (err -12)
[00:15:43.393,798] <err> nrf52: disconnect 3 adr 8 - DC:9D:05:72:99:CE (random)
[00:15:48.398,101] <wrn> nrf52: Failed to send (err -12)
[00:15:48.398,590] <err> nrf52: disconnect 1 adr 9 - C2:9C:DD:0E:68:04 (random)
[00:15:50.389,801] <inf> nrf52: titac 95
[00:15:53.402,496] <wrn> nrf52: Failed to send (err -12)
[00:15:53.402,984] <err> nrf52: disconnect 7 adr 10 - FA:A7:8B:C0:F7:29 (random)
[00:15:58.406,738] <wrn> nrf52: Failed to send (err -12)
[00:15:58.407,196] <err> nrf52: disconnect 15 adr 11 - E4:6E:07:8E:BF:22 (random)
[00:16:00.389,892] <inf> nrf52: titac 96
[00:16:03.410,552] <wrn> nrf52: Failed to send (err -12)
[00:16:03.411,041] <err> nrf52: disconnect 2 adr 12 - DE:8D:42:C6:23:F6 (random)
[00:16:09.381,195] <wrn> nrf52: Failed to send (err -12)
[00:16:09.381,652] <err> nrf52: disconnect 5 adr 14 - F3:8E:04:C7:97:EB (random)
[00:16:10.389,953] <inf> nrf52: titac 97
[00:16:14.384,429] <wrn> nrf52: Failed to send (err -12)
[00:16:14.384,887] <err> nrf52: disconnect 9 adr 15 - DE:AA:DC:58:F1:A7 (random)
[00:16:16.380,493] <wrn> nrf52: Failed to send (err -120)
[00:16:16.380,920] <err> nrf52: disconnect 6 adr 0 - ED:E1:2B:01:BF:D2 (random)
[00:16:20.390,014] <inf> nrf52: titac 98
[00:16:22.380,401] <wrn> nrf52: Failed to send (err -12)
[00:16:22.380,798] <err> nrf52: disconnect 11 adr 1 - DE:F3:51:86:CF:62 (random)
[00:16:27.383,117] <wrn> nrf52: Failed to send (err -12)
[00:16:27.383,514] <err> nrf52: disconnect 13 adr 2 - EE:E1:6A:AC:E2:58 (random)
[00:16:27.385,467] <wrn> nrf52: Failed to send (err -120)
[00:16:27.385,864] <err> nrf52: disconnect 4 adr 3 - F7:FC:40:94:27:40 (random)
[00:16:28.379,852] <wrn> nrf52: Failed to send (err -120)
[00:16:28.380,249] <err> nrf52: disconnect 14 adr 4 - DD:31:A1:B5:C6:5E (random)
[00:16:30.379,760] <wrn> nrf52: Failed to send (err -128)
[00:16:30.380,065] <err> nrf52: disconnect 10 adr 6 - F2:08:3F:30:F5:E3 (random)
[00:16:30.390,075] <inf> nrf52: titac 99

Related