Executing Shell commands from Mcumgr

nRF Connect SDK 2.6.1 + nRF52832

I can't get the execution of shell commands from mcumgr over SMP to work.

Here is my prj.conf:

CONFIG_LOG=y

CONFIG_USE_SEGGER_RTT=n
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=n
CONFIG_UART_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_UART=y

CONFIG_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_LOG_BACKEND=n

CONFIG_MCUMGR=y
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_MCUMGR_TRANSPORT_SHELL=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y

CONFIG_GPIO=y

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Test"

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

I registered some custom shell commands with SHELL_CMD_REGISTER which I can successfully execute from UART.

On the other hand, I can connect to my device from a Linux PC with mcumgr via BLE (i.e. SMP) and do FOTA or execute echo commands successfully.

However, when trying to execute mcumgr -c <my_conn> shell exec <my_cmd>,  I get status=8 in mcumgr.

I found out that the problem on the nRF side is in smp.c -> smp_handle_single_payload() -> mgmt_find_handler() which always returns NULL.

If I print out the contents of net_buf *req passed to smp_process_request_packet(), I can see that it contains my command name in the req->data field correctly.

Any hint? Or some sample code for executing shell commands over SMP?

Related