Zephyr API Documentation  3.6.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 __cplusplus
31extern "C" {
32#endif
33
43#define MGMT_EVT_OP_ID_ALL 0xffff
44
46#define MGMT_DEF_EVT_OP_ID(group, event_id) ((group << 16) | BIT(event_id))
47
49#define MGMT_DEF_EVT_OP_ALL(group) ((group << 16) | MGMT_EVT_OP_ID_ALL)
53#define MGMT_EVT_GET_GROUP(event) ((event >> 16) & MGMT_EVT_OP_ID_ALL)
54
56#define MGMT_EVT_GET_ID(event) (event & MGMT_EVT_OP_ID_ALL)
57
64
67
73};
74
75/* Deprecated after Zephyr 3.4, use MGMT_CB_ERROR_ERR instead */
76#define MGMT_CB_ERROR_RET __DEPRECATED_MACRO MGMT_CB_ERROR_ERR
77
107typedef enum mgmt_cb_return (*mgmt_cb)(uint32_t event, enum mgmt_cb_return prev_status,
108 int32_t *rc, uint16_t *group, bool *abort_more, void *data,
109 size_t data_size);
110
121
123};
124
130 MGMT_EVT_OP_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_ALL),
131};
132
138 MGMT_EVT_OP_CMD_RECV = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 0),
139
141 MGMT_EVT_OP_CMD_STATUS = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 1),
142
144 MGMT_EVT_OP_CMD_DONE = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_SMP, 2),
145
147 MGMT_EVT_OP_CMD_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_SMP),
148};
149
156
159};
160
167
170
173
176
179
182
185
188};
189
196
199
202
205
208
211};
212
219
222};
223
230
233
244};
245
252
255
256 union {
259
261 int err;
262
265 };
266};
267
276
293enum mgmt_cb_return mgmt_callback_notify(uint32_t event, void *data, size_t data_size,
294 int32_t *err_rc, uint16_t *err_group);
295
302
309
314#ifdef __cplusplus
315}
316#endif
317
318#endif /* H_MCUMGR_CALLBACKS_ */
settings_mgmt_group_events
MGMT event opcodes for settings management group.
Definition: callbacks.h:216
mgmt_cb_return
MGMT event callback return value.
Definition: callbacks.h:61
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:193
fs_mgmt_group_events
MGMT event opcodes for filesystem management group.
Definition: callbacks.h:153
img_mgmt_group_events
MGMT event opcodes for image management group.
Definition: callbacks.h:164
mgmt_cb_groups
MGMT event callback group IDs.
Definition: callbacks.h:114
smp_group_events
MGMT event opcodes for base SMP command processing.
Definition: callbacks.h:136
smp_all_events
MGMT event opcodes for all command processing.
Definition: callbacks.h:128
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:107
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:218
@ MGMT_EVT_OP_SETTINGS_MGMT_ALL
Used to enable all settings_mgmt_group events.
Definition: callbacks.h:221
@ MGMT_CB_ERROR_RC
SMP protocol error and err_rc contains the mcumgr_err_t error code.
Definition: callbacks.h:66
@ MGMT_CB_OK
No error.
Definition: callbacks.h:63
@ 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:72
@ MGMT_EVT_OP_OS_MGMT_DATETIME_GET
Callback when a datetime get command has been received.
Definition: callbacks.h:204
@ MGMT_EVT_OP_OS_MGMT_DATETIME_SET
Callback when a datetime set command has been received, data is struct rtc_time().
Definition: callbacks.h:207
@ MGMT_EVT_OP_OS_MGMT_INFO_CHECK
Callback when an info command is processed, data is os_mgmt_info_check.
Definition: callbacks.h:198
@ MGMT_EVT_OP_OS_MGMT_RESET
Callback when a reset command has been received, data is os_mgmt_reset_data.
Definition: callbacks.h:195
@ 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:201
@ MGMT_EVT_OP_OS_MGMT_ALL
Used to enable all os_mgmt_group events.
Definition: callbacks.h:210
@ MGMT_EVT_OP_FS_MGMT_FILE_ACCESS
Callback when a file has been accessed, data is fs_mgmt_file_access().
Definition: callbacks.h:155
@ MGMT_EVT_OP_FS_MGMT_ALL
Used to enable all fs_mgmt_group events.
Definition: callbacks.h:158
@ MGMT_EVT_OP_IMG_MGMT_ALL
Used to enable all img_mgmt_group events.
Definition: callbacks.h:187
@ 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:166
@ MGMT_EVT_OP_IMG_MGMT_DFU_PENDING
Callback when a DFU operation has finished being transferred.
Definition: callbacks.h:175
@ MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED
Callback when an image has been confirmed.
Definition: callbacks.h:178
@ MGMT_EVT_OP_IMG_MGMT_DFU_CHUNK_WRITE_COMPLETE
Callback when an image write command has finished writing to flash.
Definition: callbacks.h:181
@ MGMT_EVT_OP_IMG_MGMT_IMAGE_SLOT_STATE
Callback when an image slot's state is encoded for a response.
Definition: callbacks.h:184
@ MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED
Callback when a DFU operation is stopped.
Definition: callbacks.h:169
@ MGMT_EVT_OP_IMG_MGMT_DFU_STARTED
Callback when a DFU operation is started.
Definition: callbacks.h:172
@ MGMT_EVT_GRP_ALL
Definition: callbacks.h:115
@ MGMT_EVT_GRP_SMP
Definition: callbacks.h:116
@ MGMT_EVT_GRP_OS
Definition: callbacks.h:117
@ MGMT_EVT_GRP_SETTINGS
Definition: callbacks.h:120
@ MGMT_EVT_GRP_FS
Definition: callbacks.h:119
@ MGMT_EVT_GRP_USER_CUSTOM_START
Definition: callbacks.h:122
@ MGMT_EVT_GRP_IMG
Definition: callbacks.h:118
@ MGMT_EVT_OP_CMD_RECV
Callback when a command is received, data is mgmt_evt_op_cmd_arg().
Definition: callbacks.h:138
@ MGMT_EVT_OP_CMD_ALL
Used to enable all smp_group events.
Definition: callbacks.h:147
@ MGMT_EVT_OP_CMD_DONE
Callback when a command has been processed, data is mgmt_evt_op_cmd_arg().
Definition: callbacks.h:144
@ MGMT_EVT_OP_CMD_STATUS
Callback when a a status is updated, data is mgmt_evt_op_cmd_arg().
Definition: callbacks.h:141
@ MGMT_EVT_OP_ALL
Used to enable all events.
Definition: callbacks.h:130
@ MGMT_GROUP_ID_PERUSER
User groups defined from 64 onwards.
Definition: mgmt_defines.h:81
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
MGMT callback struct.
Definition: callbacks.h:227
uint32_t event_id
MGMT_EVT_[...] Event ID for handler to be called on.
Definition: callbacks.h:243
sys_snode_t node
Entry list node.
Definition: callbacks.h:229
mgmt_cb callback
Callback that will be called.
Definition: callbacks.h:232
Arguments for MGMT_EVT_OP_CMD_RECV, MGMT_EVT_OP_CMD_STATUS and MGMT_EVT_OP_CMD_DONE.
Definition: callbacks.h:249
uint16_t group
mcumgr_group_t
Definition: callbacks.h:251
int status
img_mgmt_id_upload_t, used in MGMT_EVT_OP_CMD_STATUS
Definition: callbacks.h:264
int err
mcumgr_err_t, used in MGMT_EVT_OP_CMD_DONE
Definition: callbacks.h:261
uint8_t id
Message ID within group.
Definition: callbacks.h:254
uint8_t op
mcumgr_op_t used in MGMT_EVT_OP_CMD_RECV
Definition: callbacks.h:258