diff --git a/doc/releases/release-notes-3.5.rst b/doc/releases/release-notes-3.5.rst index 00e23f6d30b..0fd4fb94a95 100644 --- a/doc/releases/release-notes-3.5.rst +++ b/doc/releases/release-notes-3.5.rst @@ -328,6 +328,9 @@ Libraries / Subsystems * Added :kconfig:option:`CONFIG_MCUMGR_GRP_IMG_ALLOW_ERASE_PENDING` that allows to erase slots pending for next boot, that are not revert slots. + * Added ``user_data`` as an optional field to :c:struct:`mgmt_handler` when + :kconfig:option:`CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA` is enabled. + * File systems * Added support for ext2 file system. diff --git a/include/zephyr/mgmt/mcumgr/mgmt/mgmt.h b/include/zephyr/mgmt/mcumgr/mgmt/mgmt.h index e681ea2b939..ec09bb03467 100644 --- a/include/zephyr/mgmt/mcumgr/mgmt/mgmt.h +++ b/include/zephyr/mgmt/mcumgr/mgmt/mgmt.h @@ -71,6 +71,9 @@ typedef int (*mgmt_handler_fn)(struct smp_streamer *ctxt); struct mgmt_handler { mgmt_handler_fn mh_read; mgmt_handler_fn mh_write; +#if IS_ENABLED(CONFIG_MCUMGR_MGMT_HANDLER_USER_DATA) + void *user_data; +#endif }; /** diff --git a/subsys/mgmt/mcumgr/mgmt/Kconfig b/subsys/mgmt/mcumgr/mgmt/Kconfig index d1701627860..a0c889f0c5e 100644 --- a/subsys/mgmt/mcumgr/mgmt/Kconfig +++ b/subsys/mgmt/mcumgr/mgmt/Kconfig @@ -25,3 +25,9 @@ config MCUMGR_MGMT_NOTIFICATION_HOOKS or decline the current operation, by returning false this will signal to the calling function that the request should be denied, for informal-only notifications or acceptable, true must be returned by all the registered notification handlers. + +config MCUMGR_MGMT_HANDLER_USER_DATA + bool "MCUmgr mgmt handler user data support" + help + This will add an extra field to the struct mgmt_handler that will allow a user + to pass user_data when the defined handler is called.