Zephyr Project API  3.3.0
A Scalable Open Source RTOS
MCUmgr callback API

MCUmgr callback API. More...

Modules

 MCUmgr fs_mgmt callback API
 MCUmgr fs_mgmt callback API.
 
 MCUmgr img_mgmt callback API
 MCUmgr img_mgmt callback API.
 

Data Structures

struct  mgmt_callback
 
struct  mgmt_evt_op_cmd_arg
 

Macros

#define MGMT_EVT_GET_GROUP(event)   ((event >> 16) & MGMT_EVT_OP_ID_ALL)
 
#define MGMT_EVT_GET_ID(event)   (event & MGMT_EVT_OP_ID_ALL)
 

Typedefs

typedef int32_t(* mgmt_cb) (uint32_t event, int32_t rc, bool *abort_more, void *data, size_t data_size)
 Function to be called on MGMT notification/event. More...
 

Enumerations

enum  mgmt_cb_groups {
  MGMT_EVT_GRP_ALL = 0 , MGMT_EVT_GRP_SMP , MGMT_EVT_GRP_OS , MGMT_EVT_GRP_IMG ,
  MGMT_EVT_GRP_FS , MGMT_EVT_GRP_USER_CUSTOM_START = MGMT_GROUP_ID_PERUSER
}
 
enum  smp_all_events { MGMT_EVT_OP_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_ALL) }
 
enum  smp_group_events { MGMT_EVT_OP_CMD_RECV = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 0) , MGMT_EVT_OP_CMD_STATUS = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 1) , MGMT_EVT_OP_CMD_DONE = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 2) , MGMT_EVT_OP_CMD_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_SMP) }
 
enum  fs_mgmt_group_events { MGMT_EVT_OP_FS_MGMT_FILE_ACCESS = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_FS, 0) , MGMT_EVT_OP_FS_MGMT_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_FS) }
 
enum  img_mgmt_group_events {
  MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 0) , MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 1) , MGMT_EVT_OP_IMG_MGMT_DFU_STARTED = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 2) , MGMT_EVT_OP_IMG_MGMT_DFU_PENDING = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 3) ,
  MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_IMG, 4) , MGMT_EVT_OP_IMG_MGMT_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_IMG)
}
 
enum  os_mgmt_group_events { MGMT_EVT_OP_OS_MGMT_RESET = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_OS, 0) , MGMT_EVT_OP_OS_MGMT_INFO_CHECK = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_OS, 1) , MGMT_EVT_OP_OS_MGMT_INFO_APPEND = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_OS, 2) , MGMT_EVT_OP_OS_MGMT_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_OS) }
 

Functions

int32_t mgmt_callback_notify (uint32_t event, void *data, size_t data_size)
 This function is called to notify registered callbacks about mcumgr notifications/events. More...
 
void mgmt_callback_register (struct mgmt_callback *callback)
 Register event callback function. More...
 
void mgmt_callback_unregister (struct mgmt_callback *callback)
 Unregister event callback function. More...
 

Detailed Description

MCUmgr callback API.

Macro Definition Documentation

◆ MGMT_EVT_GET_GROUP

#define MGMT_EVT_GET_GROUP (   event)    ((event >> 16) & MGMT_EVT_OP_ID_ALL)

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

Get group from event.

◆ MGMT_EVT_GET_ID

#define MGMT_EVT_GET_ID (   event)    (event & MGMT_EVT_OP_ID_ALL)

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

Get event ID from event.

Typedef Documentation

◆ mgmt_cb

mgmt_cb

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

Function to be called on MGMT notification/event.

This callback function is used to notify an application or system about a mcumgr mgmt event.

Parameters
eventmcumgr_op_t.
rcmcumgr_err_t of the previous handler calls, if it is an error then it will be the first error that was returned by a handler (i.e. this handler is being called for a notification only, the return code will be ignored).
abort_moreSet to true to abort further processing by additional handlers.
dataOptional event argument.
data_sizeSize of optional event argument (0 if no data is provided).
Returns
mcumgr_err_t of the status to return to the calling code (only checked when failed is false).

Enumeration Type Documentation

◆ fs_mgmt_group_events

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event opcodes for filesystem management group.

Enumerator
MGMT_EVT_OP_FS_MGMT_FILE_ACCESS 

Callback when a file has been accessed, data is fs_mgmt_file_access().

MGMT_EVT_OP_FS_MGMT_ALL 

Used to enable all fs_mgmt_group events.

◆ img_mgmt_group_events

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event opcodes for image management group.

Enumerator
MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK 

Callback when a client sends a file upload chunk, data is img_mgmt_upload_check().

MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED 

Callback when a DFU operation is stopped.

MGMT_EVT_OP_IMG_MGMT_DFU_STARTED 

Callback when a DFU operation is started.

MGMT_EVT_OP_IMG_MGMT_DFU_PENDING 

Callback when a DFU operation has finished being transferred.

MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED 

Callback when an image has been confirmed.

MGMT_EVT_OP_IMG_MGMT_ALL 

Used to enable all img_mgmt_group events.

◆ mgmt_cb_groups

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event callback group IDs. Note that this is not a 1:1 mapping with mcumgr_group_t values.

Enumerator
MGMT_EVT_GRP_ALL 
MGMT_EVT_GRP_SMP 
MGMT_EVT_GRP_OS 
MGMT_EVT_GRP_IMG 
MGMT_EVT_GRP_FS 
MGMT_EVT_GRP_USER_CUSTOM_START 

◆ os_mgmt_group_events

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event opcodes for operating system management group.

Enumerator
MGMT_EVT_OP_OS_MGMT_RESET 

Callback when a reset command has been received.

MGMT_EVT_OP_OS_MGMT_INFO_CHECK 

Callback when an info command is processed, data is os_mgmt_info_check.

MGMT_EVT_OP_OS_MGMT_INFO_APPEND 

Callback when an info command needs to output data, data is os_mgmt_info_append.

MGMT_EVT_OP_OS_MGMT_ALL 

Used to enable all os_mgmt_group events.

◆ smp_all_events

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event opcodes for all command processing.

Enumerator
MGMT_EVT_OP_ALL 

Used to enable all events.

◆ smp_group_events

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

MGMT event opcodes for base SMP command processing.

Enumerator
MGMT_EVT_OP_CMD_RECV 

Callback when a command is received, data is mgmt_evt_op_cmd_arg().

MGMT_EVT_OP_CMD_STATUS 

Callback when a a status is updated, data is mgmt_evt_op_cmd_arg().

MGMT_EVT_OP_CMD_DONE 

Callback when a command has been processed, data is mgmt_evt_op_cmd_arg().

MGMT_EVT_OP_CMD_ALL 

Used to enable all smp_group events.

Function Documentation

◆ mgmt_callback_notify()

int32_t mgmt_callback_notify ( uint32_t  event,
void *  data,
size_t  data_size 
)

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

This function is called to notify registered callbacks about mcumgr notifications/events.

Parameters
eventmcumgr_op_t.
dataOptional event argument.
data_sizeSize of optional event argument (0 if none).
Returns
mcumgr_err_t either MGMT_ERR_EOK if all handlers returned it, or the error code of the first handler that returned an error.

◆ mgmt_callback_register()

void mgmt_callback_register ( struct mgmt_callback callback)

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

Register event callback function.

Parameters
callbackCallback struct.

◆ mgmt_callback_unregister()

void mgmt_callback_unregister ( struct mgmt_callback callback)

#include <include/zephyr/mgmt/mcumgr/mgmt/callbacks.h>

Unregister event callback function.

Parameters
callbackCallback struct.