Zephyr Project API
3.7.0
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
>
30
#include <
zephyr/mgmt/mcumgr/transport/smp.h
>
31
32
#include <zcbor_common.h>
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
37
39
enum
smp_mcumgr_version_t
{
41
SMP_MCUMGR_VERSION_1
= 0,
42
44
SMP_MCUMGR_VERSION_2
,
45
};
46
47
struct
cbor_nb_reader
{
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
55
struct
cbor_nb_writer
{
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
71
struct
net_buf
*
smp_packet_alloc
(
void
);
72
78
void
smp_packet_free
(
struct
net_buf
*nb);
79
83
struct
smp_streamer
{
84
struct
smp_transport
*
smpt
;
85
struct
cbor_nb_reader
*
reader
;
86
struct
cbor_nb_writer
*
writer
;
87
88
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
89
const
char
*rc_rsn;
90
#endif
91
};
92
107
int
smp_process_request_packet
(
struct
smp_streamer
*streamer,
void
*req);
108
122
bool
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)
138
typedef
int (*smp_translate_error_fn)(
uint16_t
err);
139
#endif
140
141
#ifdef __cplusplus
142
}
143
#endif
144
145
#endif
/* H_SMP_ */
ret
static ZTEST_BMEM int ret
Definition
main.c:16
smp_add_cmd_err
bool smp_add_cmd_err(zcbor_state_t *zse, uint16_t group, uint16_t ret)
Appends an "err" response.
smp_process_request_packet
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_version_t
SMP MCUmgr protocol version, part of the SMP header.
Definition
smp.h:39
SMP_MCUMGR_VERSION_2
@ SMP_MCUMGR_VERSION_2
Version 2: adds more detailed error reporting capabilities.
Definition
smp.h:44
SMP_MCUMGR_VERSION_1
@ SMP_MCUMGR_VERSION_1
Version 1: the original protocol.
Definition
smp.h:41
smp_add_cmd_ret
bool smp_add_cmd_ret(zcbor_state_t *zse, uint16_t group, uint16_t ret)
Definition
smp.h:125
smp_packet_alloc
struct net_buf * smp_packet_alloc(void)
Allocates a net_buf for holding an mcumgr request or response.
smp_packet_free
void smp_packet_free(struct net_buf *nb)
Frees an mcumgr net_buf.
smp.h
buf.h
Buffer management.
uint16_t
__UINT16_TYPE__ uint16_t
Definition
stdint.h:89
cbor_nb_reader
Definition
smp.h:47
cbor_nb_reader::nb
struct net_buf * nb
Definition
smp.h:48
cbor_nb_reader::zs
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS+2]
Definition
smp.h:52
cbor_nb_writer
Definition
smp.h:55
cbor_nb_writer::zs
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS+2]
Definition
smp.h:57
cbor_nb_writer::nb
struct net_buf * nb
Definition
smp.h:56
net_buf
Network buffer representation.
Definition
buf.h:1004
smp_streamer
Decodes, encodes, and transmits SMP packets.
Definition
smp.h:83
smp_streamer::writer
struct cbor_nb_writer * writer
Definition
smp.h:86
smp_streamer::smpt
struct smp_transport * smpt
Definition
smp.h:84
smp_streamer::reader
struct cbor_nb_reader * reader
Definition
smp.h:85
smp_transport
SMP transport object for sending SMP responses.
Definition
smp.h:118
include
zephyr
mgmt
mcumgr
smp
smp.h
Generated on Sun Sep 15 2024 17:01:30 for Zephyr Project API by
1.9.8