NRF52840 + Nus Shell + BT disconnected by timeout

Describe 
Need to repeat disconnect/connect cycle after BT timeout.
Problem is when using UART over BT with Nus Shell when connection is terminated by timeout (for example when device went out of range of BT) so disconnect reason is 8.

To Reproduce
shell_bt_nus example https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/shell_bt_nus/src

  • I connect by BT to device, all is ok,
  • I go away with conneceted phone so it is out of BT range
  • Device is disconnected with code 8 (timeout)
  • After new BT connection I see that it recives data but nus shell does not process them

Expected behavior
After disconnect by timeout (code 8) software should behave same as manual disconnect (code 19).

Impact
Nus shell does not process messagges (to start need to repeat disconnect/connect)

Logs and console output

<inf>  ble: Connected
<inf> shell_bt_nus: Write req:11 accept:0
<inf> shell_bt_nus: Failed to send 20 bytes (-22 error)
<inf> shell_bt_nus: NUS notification has been enabled
<inf> shell_bt_nus: Received 8 bytes.
<inf> shell_bt_nus: Received 8 bytes.
<inf> shell_bt_nus: Received 8 bytes.
<inf> shell_bt_nus: Received 8 bytes.
<inf> shell_bt_nus: Received 8 bytes.
<inf> shell_bt_nus: RX ring buffer fill. Dropping 8 bytes.`

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	LOG_INF("Disconnected (reason %u)", reason);
	shell_bt_nus_disable();
	if (current_conn) {
		bt_conn_unref(current_conn);
		current_conn = NULL;
	}
}

Environment (please complete the following information):
-- CMake version: 3.25.2
-- Found Python3: C:/Users/user/zephyrproject/.venv/Scripts/python.exe (found suitable exact version "3.10.11") found components: Interpreter
-- Zephyr version: 3.3.0-rc3 (C:/Users/user/zephyrproject/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Found host-tools: zephyr 0.15.2 (C:/Users/user/zephyr-sdk-0.15.2)
-- Found toolchain: zephyr 0.15.2 (C:/Users/user/zephyr-sdk-0.15.2)

Additional context
To "fix" this I need to disconnect and connect again, now everything is ok
When use "normal" disconnect (code 19) this problem doesn not occurs - after connection nus shell process bt commands.

Related