Hi!
And I use the Zephyr SHELL to configure the device (nrf52832) from the terminal on the android tablet.
A problem with using a shell with nus ble transport. When you first connect, keystrokes are sent to the device, but nothing comes in response. If you disconnect and reconnect, sometimes the terminal starts working as it should.
--- first log output --
[00:00:15.241,027] <inf> ble: connected: Connected 0x20001f38-0x20001f38
[00:00:15.241,485] <inf> bt_nus: bt_nus_init: NUS init success
[00:00:16.463,226] <dbg> bt_nus: nus_ccc_cfg_changed: Notification has been turned on
[00:00:17.400,726] <dbg> bt_nus: on_receive: Received data, handle 0, conn 0x20001f38
[00:00:19.150,756] <dbg> bt_nus: on_receive: Received data, handle 0, conn 0x20001f38
[00:00:19.850,799] <dbg> bt_nus: on_receive: Received data, handle 0, conn 0x20001f38
--- log output --
[00:02:20.700,256] <inf> ble: connected: Connected 0x20002000-0x20002000
[00:02:21.898,895] <dbg> bt_nus: nus_ccc_cfg_changed: Notification has been turned on
[00:02:22.043,823] <dbg> bt_nus: on_receive: Received data, handle 0, conn 0x20002000
[00:02:22.143,676] <dbg> bt_nus: on_sent: Data send, conn 0x20002000
[00:02:23.843,597] <dbg> bt_nus: on_receive: Received data, handle 0, conn 0x20002000
[00:02:23.943,450] <dbg> bt_nus: on_sent: Data send, conn 0x20002000
-----------------------------------
In function enable conn is NULL :
--- subsys/shell/shell_bt_nus.c ---
static int enable(const struct shell_transport *transport, bool blocking_tx)
if (blocking_tx) {
/* transport cannot work in blocking mode, shut down */
bt_nus->ctrl_blk->conn = NULL;
-----------------------------------------------------
Workaround (subsys/shell/shell_bt_nus.c):
static void rx_callback(struct bt_conn *conn, const uint8_t *const data, uint16_t len)
{
const struct shell_bt_nus *bt_nus =
(const struct shell_bt_nus *)shell_transport_bt_nus.ctx;
uint32_t done = ring_buf_put(bt_nus->rx_ringbuf, data, len);
bt_nus->ctrl_blk->conn = conn; // <--- added by me
-------------------------------------------------------
In this case, everything works fine.
How to solve this problem correctly.
=====================
ncs -- v2.4.1
The test code is based on the example "nrf/samples/bluetooth/shell_bt_nus".
--- prj.conf --
CONFIG_SHELL=y
CONFIG_SHELL_CMDS=y
CONFIG_BT_NUS_LOG_LEVEL_DBG=y
# # Enable the BT NUS shell
CONFIG_SHELL_BT_NUS=y
#CONFIG_SHELL_BT_NUS_LOG_LEVEL_DBG=y