Zephyr API Documentation 3.7.99
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
194
223
234
245
267
274
277
278 union {
281
283 int err;
284
287 };
288};
289
298
315enum mgmt_cb_return mgmt_callback_notify(uint32_t event, void *data, size_t data_size,
316 int32_t *err_rc, uint16_t *err_group);
317
324
331
336#ifdef __cplusplus
337}
338#endif
339
340#endif /* H_MCUMGR_CALLBACKS_ */
settings_mgmt_group_events
MGMT event opcodes for settings management group.
Definition callbacks.h:227
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:198
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:238
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:229
@ MGMT_EVT_OP_SETTINGS_MGMT_ALL
Used to enable all settings_mgmt_group events.
Definition callbacks.h:232
@ 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:209
@ MGMT_EVT_OP_OS_MGMT_DATETIME_SET
Callback when a datetime set command has been received, data is struct rtc_time().
Definition callbacks.h:212
@ MGMT_EVT_OP_OS_MGMT_INFO_CHECK
Callback when an info command is processed, data is os_mgmt_info_check.
Definition callbacks.h:203
@ 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:218
@ MGMT_EVT_OP_OS_MGMT_RESET
Callback when a reset command has been received, data is os_mgmt_reset_data.
Definition callbacks.h:200
@ 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:206
@ MGMT_EVT_OP_OS_MGMT_ALL
Used to enable all os_mgmt_group events.
Definition callbacks.h:221
@ 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:192
@ 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_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:243
@ MGMT_EVT_OP_ENUM_MGMT_DETAILS
Callback when fetching details on supported command groups.
Definition callbacks.h:240
@ 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:249
uint32_t event_id
MGMT_EVT_[...] Event ID for handler to be called on.
Definition callbacks.h:265
sys_snode_t node
Entry list node.
Definition callbacks.h:251
mgmt_cb callback
Callback that will be called.
Definition callbacks.h:254
Arguments for MGMT_EVT_OP_CMD_RECV, MGMT_EVT_OP_CMD_STATUS and MGMT_EVT_OP_CMD_DONE.
Definition callbacks.h:271
uint16_t group
mcumgr_group_t
Definition callbacks.h:273
int status
img_mgmt_id_upload_t, used in MGMT_EVT_OP_CMD_STATUS
Definition callbacks.h:286
int err
mcumgr_err_t, used in MGMT_EVT_OP_CMD_DONE
Definition callbacks.h:283
uint8_t id
Message ID within group.
Definition callbacks.h:276
uint8_t op
mcumgr_op_t used in MGMT_EVT_OP_CMD_RECV
Definition callbacks.h:280