Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
smp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2021 mcumgr authors
3 * Copyright (c) 2023 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
26#ifndef H_SMP_
27#define H_SMP_
28
29#include <zephyr/net_buf.h>
31
32#include <zcbor_common.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
46
48 struct net_buf *nb;
49 /* CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2 translates to minimal
50 * zcbor backup states.
51 */
52 zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2];
53};
54
56 struct net_buf *nb;
57 zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS + 2];
58
59#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
60 uint16_t error_group;
61 uint16_t error_ret;
62#endif
63};
64
72
78void smp_packet_free(struct net_buf *nb);
79
87
88#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
89 const char *rc_rsn;
90#endif
91};
92
107int smp_process_request_packet(struct smp_streamer *streamer, void *req);
108
122bool smp_add_cmd_err(zcbor_state_t *zse, uint16_t group, uint16_t ret);
123
125__deprecated inline bool smp_add_cmd_ret(zcbor_state_t *zse, uint16_t group, uint16_t ret)
126{
127 return smp_add_cmd_err(zse, group, ret);
128}
129
130#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
138typedef int (*smp_translate_error_fn)(uint16_t err);
139#endif
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif /* H_SMP_ */
bool smp_add_cmd_err(zcbor_state_t *zse, uint16_t group, uint16_t ret)
Appends an "err" response.
int smp_process_request_packet(struct smp_streamer *streamer, void *req)
Processes a single SMP request packet and sends all corresponding responses.
smp_mcumgr_version_t
SMP MCUmgr protocol version, part of the SMP header.
Definition smp.h:39
@ SMP_MCUMGR_VERSION_2
Version 2: adds more detailed error reporting capabilities.
Definition smp.h:44
@ SMP_MCUMGR_VERSION_1
Version 1: the original protocol.
Definition smp.h:41
bool smp_add_cmd_ret(zcbor_state_t *zse, uint16_t group, uint16_t ret)
Definition smp.h:125
struct net_buf * smp_packet_alloc(void)
Allocates a net_buf for holding an mcumgr request or response.
void smp_packet_free(struct net_buf *nb)
Frees an mcumgr net_buf.
Buffer management.
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Definition smp.h:47
struct net_buf * nb
Definition smp.h:48
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS+2]
Definition smp.h:52
Definition smp.h:55
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS+2]
Definition smp.h:57
struct net_buf * nb
Definition smp.h:56
Group structure.
Definition grp.h:18
Network buffer representation.
Definition net_buf.h:1006
Decodes, encodes, and transmits SMP packets.
Definition smp.h:83
struct cbor_nb_writer * writer
Definition smp.h:86
struct smp_transport * smpt
Definition smp.h:84
struct cbor_nb_reader * reader
Definition smp.h:85
SMP transport object for sending SMP responses.
Definition smp.h:118