Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
callbacks.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022-2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef H_MCUMGR_CALLBACKS_
8#define H_MCUMGR_CALLBACKS_
9
10#include <inttypes.h>
11#include <zephyr/sys/slist.h>
13
14#ifdef CONFIG_MCUMGR_GRP_FS
16#endif
17
18#ifdef CONFIG_MCUMGR_GRP_IMG
20#endif
21
22#ifdef CONFIG_MCUMGR_GRP_OS
24#endif
25
26#ifdef CONFIG_MCUMGR_GRP_SETTINGS
28#endif
29
30#ifdef CONFIG_MCUMGR_GRP_ENUM
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
47#define MGMT_EVT_OP_ID_ALL 0xffff
48
50#define MGMT_DEF_EVT_OP_ID(group, event_id) ((group << 16) | BIT(event_id))
51
53#define MGMT_DEF_EVT_OP_ALL(group) ((group << 16) | MGMT_EVT_OP_ID_ALL)
57#define MGMT_EVT_GET_GROUP(event) ((event >> 16) & MGMT_EVT_OP_ID_ALL)
58
60#define MGMT_EVT_GET_ID(event) (event & MGMT_EVT_OP_ID_ALL)
61
78
79/* Deprecated after Zephyr 3.4, use MGMT_CB_ERROR_ERR instead */
80#define MGMT_CB_ERROR_RET __DEPRECATED_MACRO MGMT_CB_ERROR_ERR
81
111typedef enum mgmt_cb_return (*mgmt_cb)(uint32_t event, enum mgmt_cb_return prev_status,
112 int32_t *rc, uint16_t *group, bool *abort_more, void *data,
113 size_t data_size);
114
129
135 MGMT_EVT_OP_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_ALL),
136};
137
143 MGMT_EVT_OP_CMD_RECV = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 0),
144
146 MGMT_EVT_OP_CMD_STATUS = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 1),
147
149 MGMT_EVT_OP_CMD_DONE = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 2),
150
152 MGMT_EVT_OP_CMD_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_SMP),
153};
154
165
200
229
240
251
273
280
283
284 union {
287
289 int err;
290
293 };
294};
295
304
321enum mgmt_cb_return mgmt_callback_notify(uint32_t event, void *data, size_t data_size,
322 int32_t *err_rc, uint16_t *err_group);
323
330
337
342#ifdef __cplusplus
343}
344#endif
345
346#endif /* H_MCUMGR_CALLBACKS_ */
settings_mgmt_group_events
MGMT event opcodes for settings management group.
Definition callbacks.h:233
mgmt_cb_return
MGMT event callback return value.
Definition callbacks.h:65
void mgmt_callback_unregister(struct mgmt_callback *callback)
Unregister event callback function.
os_mgmt_group_events
MGMT event opcodes for operating system management group.
Definition callbacks.h:204
fs_mgmt_group_events
MGMT event opcodes for filesystem management group.
Definition callbacks.h:158
img_mgmt_group_events
MGMT event opcodes for image management group.
Definition callbacks.h:169
mgmt_cb_groups
MGMT event callback group IDs.
Definition callbacks.h:118
smp_group_events
MGMT event opcodes for base SMP command processing.
Definition callbacks.h:141
enum_mgmt_group_events
MGMT event opcodes for enumeration management group.
Definition callbacks.h:244
smp_all_events
MGMT event opcodes for all command processing.
Definition callbacks.h:133
void mgmt_callback_register(struct mgmt_callback *callback)
Register event callback function.
uint8_t mgmt_evt_get_index(uint32_t event)
Get event ID index from event.
enum mgmt_cb_return(* mgmt_cb)(uint32_t event, enum mgmt_cb_return prev_status, int32_t *rc, uint16_t *group, bool *abort_more, void *data, size_t data_size)
Function to be called on MGMT notification/event.
Definition callbacks.h:111
enum mgmt_cb_return mgmt_callback_notify(uint32_t event, void *data, size_t data_size, int32_t *err_rc, uint16_t *err_group)
This function is called to notify registered callbacks about mcumgr notifications/events.
@ MGMT_EVT_OP_SETTINGS_MGMT_ACCESS
Callback when a setting is read/written/deleted.
Definition callbacks.h:235
@ MGMT_EVT_OP_SETTINGS_MGMT_ALL
Used to enable all settings_mgmt_group events.
Definition callbacks.h:238
@ MGMT_CB_ERROR_RC
SMP protocol error and err_rc contains the mcumgr_err_t error code.
Definition callbacks.h:70
@ MGMT_CB_OK
No error.
Definition callbacks.h:67
@ MGMT_CB_ERROR_ERR
Group (application-level) error and err_group contains the group ID that caused the error and err_rc ...
Definition callbacks.h:76
@ MGMT_EVT_OP_OS_MGMT_DATETIME_GET
Callback when a datetime get command has been received.
Definition callbacks.h:215
@ MGMT_EVT_OP_OS_MGMT_DATETIME_SET
Callback when a datetime set command has been received, data is struct rtc_time().
Definition callbacks.h:218
@ MGMT_EVT_OP_OS_MGMT_INFO_CHECK
Callback when an info command is processed, data is os_mgmt_info_check.
Definition callbacks.h:209
@ MGMT_EVT_OP_OS_MGMT_BOOTLOADER_INFO
Callback when a bootloader info command has been received, data is os_mgmt_bootloader_info_data.
Definition callbacks.h:224
@ MGMT_EVT_OP_OS_MGMT_RESET
Callback when a reset command has been received, data is os_mgmt_reset_data.
Definition callbacks.h:206
@ MGMT_EVT_OP_OS_MGMT_INFO_APPEND
Callback when an info command needs to output data, data is os_mgmt_info_append.
Definition callbacks.h:212
@ MGMT_EVT_OP_OS_MGMT_ALL
Used to enable all os_mgmt_group events.
Definition callbacks.h:227
@ MGMT_EVT_OP_FS_MGMT_FILE_ACCESS
Callback when a file has been accessed, data is fs_mgmt_file_access().
Definition callbacks.h:160
@ MGMT_EVT_OP_FS_MGMT_ALL
Used to enable all fs_mgmt_group events.
Definition callbacks.h:163
@ MGMT_EVT_OP_IMG_MGMT_ALL
Used to enable all img_mgmt_group events.
Definition callbacks.h:198
@ MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK
Callback when a client sends a file upload chunk, data is img_mgmt_upload_check().
Definition callbacks.h:171
@ MGMT_EVT_OP_IMG_MGMT_DFU_PENDING
Callback when a DFU operation has finished being transferred.
Definition callbacks.h:180
@ MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED
Callback when an image has been confirmed.
Definition callbacks.h:183
@ MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK_WRITE_COMPLETE
Callback when an image write command has finished writing to flash.
Definition callbacks.h:186
@ MGMT_EVT_OP_IMG_MGMT_IMAGE_SLOT_STATE
Callback when an image slot's state is encoded for a response.
Definition callbacks.h:189
@ MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_SLOT
Callback when an slot list command outputs fields for a slot of an image.
Definition callbacks.h:195
@ MGMT_EVT_OP_IMG_MGMT_SLOT_INFO_IMAGE
Callback when an slot list command outputs fields for an image.
Definition callbacks.h:192
@ MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED
Callback when a DFU operation is stopped.
Definition callbacks.h:174
@ MGMT_EVT_OP_IMG_MGMT_DFU_STARTED
Callback when a DFU operation is started.
Definition callbacks.h:177
@ MGMT_EVT_GRP_ALL
Definition callbacks.h:119
@ MGMT_EVT_GRP_SMP
Definition callbacks.h:120
@ MGMT_EVT_GRP_OS
Definition callbacks.h:121
@ MGMT_EVT_GRP_SETTINGS
Definition callbacks.h:124
@ MGMT_EVT_GRP_FS
Definition callbacks.h:123
@ MGMT_EVT_GRP_USER_CUSTOM_START
Definition callbacks.h:127
@ MGMT_EVT_GRP_ENUM
Definition callbacks.h:125
@ MGMT_EVT_GRP_IMG
Definition callbacks.h:122
@ MGMT_EVT_OP_CMD_RECV
Callback when a command is received, data is mgmt_evt_op_cmd_arg().
Definition callbacks.h:143
@ MGMT_EVT_OP_CMD_ALL
Used to enable all smp_group events.
Definition callbacks.h:152
@ MGMT_EVT_OP_CMD_DONE
Callback when a command has been processed, data is mgmt_evt_op_cmd_arg().
Definition callbacks.h:149
@ MGMT_EVT_OP_CMD_STATUS
Callback when a status is updated, data is mgmt_evt_op_cmd_arg().
Definition callbacks.h:146
@ MGMT_EVT_OP_ENUM_MGMT_ALL
Used to enable all enum_mgmt_group events.
Definition callbacks.h:249
@ MGMT_EVT_OP_ENUM_MGMT_DETAILS
Callback when fetching details on supported command groups.
Definition callbacks.h:246
@ MGMT_EVT_OP_ALL
Used to enable all events.
Definition callbacks.h:135
@ MGMT_GROUP_ID_PERUSER
User groups defined from 64 onwards.
Definition mgmt_defines.h:84
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Group structure.
Definition grp.h:18
MGMT callback struct.
Definition callbacks.h:255
uint32_t event_id
MGMT_EVT_[...] Event ID for handler to be called on.
Definition callbacks.h:271
sys_snode_t node
Entry list node.
Definition callbacks.h:257
mgmt_cb callback
Callback that will be called.
Definition callbacks.h:260
Arguments for MGMT_EVT_OP_CMD_RECV, MGMT_EVT_OP_CMD_STATUS and MGMT_EVT_OP_CMD_DONE.
Definition callbacks.h:277
uint16_t group
mcumgr_group_t
Definition callbacks.h:279
int status
img_mgmt_id_upload_t, used in MGMT_EVT_OP_CMD_STATUS
Definition callbacks.h:292
int err
mcumgr_err_t, used in MGMT_EVT_OP_CMD_DONE
Definition callbacks.h:289
uint8_t id
Message ID within group.
Definition callbacks.h:282
uint8_t op
mcumgr_op_t used in MGMT_EVT_OP_CMD_RECV
Definition callbacks.h:286