Zephyr Project API  3.3.0
A Scalable Open Source RTOS
MCUmgr transport SMP API

MCUmgr transport SMP API. More...

Data Structures

struct  smp_transport
 SMP transport object for sending SMP responses. More...
 
struct  zephyr_smp_transport
 

Typedefs

typedef int(* smp_transport_out_fn) (struct net_buf *nb)
 SMP transmit callback for transport. More...
 
typedef int zephyr_smp_transport_out_fn(struct net_buf *nb)
 
typedef uint16_t(* smp_transport_get_mtu_fn) (const struct net_buf *nb)
 SMP MTU query callback for transport. More...
 
typedef uint16_t zephyr_smp_transport_get_mtu_fn(const struct net_buf *nb)
 
typedef int(* smp_transport_ud_copy_fn) (struct net_buf *dst, const struct net_buf *src)
 SMP copy user_data callback. More...
 
typedef int zephyr_smp_transport_ud_copy_fn(struct net_buf *dst, const struct net_buf *src)
 
typedef void(* smp_transport_ud_free_fn) (void *ud)
 SMP free user_data callback. More...
 
typedef void zephyr_smp_transport_ud_free_fn(void *ud)
 
typedef bool(* smp_transport_query_valid_check_fn) (struct net_buf *nb, void *arg)
 Function for checking if queued data is still valid. More...
 

Functions

void smp_transport_init (struct smp_transport *smpt, smp_transport_out_fn output_func, smp_transport_get_mtu_fn get_mtu_func, smp_transport_ud_copy_fn ud_copy_func, smp_transport_ud_free_fn ud_free_func, smp_transport_query_valid_check_fn query_valid_check_func)
 Initializes a Zephyr SMP transport object. More...
 
static void zephyr_smp_transport_init (struct zephyr_smp_transport *smpt, zephyr_smp_transport_out_fn *output_func, zephyr_smp_transport_get_mtu_fn *get_mtu_func, zephyr_smp_transport_ud_copy_fn *ud_copy_func, zephyr_smp_transport_ud_free_fn *ud_free_func)
 
void smp_rx_remove_invalid (struct smp_transport *zst, void *arg)
 Used to remove queued requests for an SMP transport that are no longer valid. A smp_transport_query_valid_check_fn() function must be registered for this to function. If the smp_transport_query_valid_check_fn() function returns false during a callback, the queried command will classed as invalid and dropped. More...
 
void smp_rx_clear (struct smp_transport *zst)
 Used to clear pending queued requests for an SMP transport. More...
 

Detailed Description

MCUmgr transport SMP API.

Typedef Documentation

◆ smp_transport_get_mtu_fn

smp_transport_get_mtu_fn

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

SMP MTU query callback for transport.

The supplied net_buf should contain a request received from the peer whose MTU is being queried. This function takes a net_buf parameter because some transports store connection-specific information in the net_buf user header (e.g., the BLE transport stores the peer address).

Parameters
nbContains a request from the relevant peer.
Returns
The transport's MTU; 0 if transmission is currently not possible.

◆ smp_transport_out_fn

smp_transport_out_fn

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

SMP transmit callback for transport.

The supplied net_buf is always consumed, regardless of return code.

Parameters
nbThe net_buf to transmit.
Returns
0 on success, mcumgr_err_t code on failure.

◆ smp_transport_query_valid_check_fn

smp_transport_query_valid_check_fn

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

Function for checking if queued data is still valid.

This function is used to check if queued SMP data is still valid e.g. on a remote device disconnecting, this is triggered when smp_rx_remove_invalid() is called.

Parameters
nbnet buf containing queued request.
argArgument provided when calling smp_rx_remove_invalid() function.
Returns
false if data is no longer valid/should be freed, true otherwise.

◆ smp_transport_ud_copy_fn

smp_transport_ud_copy_fn

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

SMP copy user_data callback.

The supplied src net_buf should contain a user_data that cannot be copied using regular memcpy function (e.g., the BLE transport net_buf user_data stores the connection reference that has to be incremented when is going to be used by another buffer).

Parameters
dstSource buffer user_data pointer.
srcDestination buffer user_data pointer.
Returns
0 on success, mcumgr_err_t code on failure.

◆ smp_transport_ud_free_fn

smp_transport_ud_free_fn

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

SMP free user_data callback.

This function frees net_buf user data, because some transports store connection-specific information in the net_buf user data (e.g., the BLE transport stores the connection reference that has to be decreased).

Parameters
udContains a user_data pointer to be freed.

◆ zephyr_smp_transport_get_mtu_fn

typedef uint16_t zephyr_smp_transport_get_mtu_fn(const struct net_buf *nb)

◆ zephyr_smp_transport_out_fn

typedef int zephyr_smp_transport_out_fn(struct net_buf *nb)

◆ zephyr_smp_transport_ud_copy_fn

typedef int zephyr_smp_transport_ud_copy_fn(struct net_buf *dst, const struct net_buf *src)

◆ zephyr_smp_transport_ud_free_fn

typedef void zephyr_smp_transport_ud_free_fn(void *ud)

Function Documentation

◆ smp_rx_clear()

void smp_rx_clear ( struct smp_transport zst)

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

Used to clear pending queued requests for an SMP transport.

Parameters
zstThe transport to use.

◆ smp_rx_remove_invalid()

void smp_rx_remove_invalid ( struct smp_transport zst,
void *  arg 
)

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

Used to remove queued requests for an SMP transport that are no longer valid. A smp_transport_query_valid_check_fn() function must be registered for this to function. If the smp_transport_query_valid_check_fn() function returns false during a callback, the queried command will classed as invalid and dropped.

Parameters
zstThe transport to use.
argArgument provided to callback smp_transport_query_valid_check_fn() function.

◆ smp_transport_init()

void smp_transport_init ( struct smp_transport smpt,
smp_transport_out_fn  output_func,
smp_transport_get_mtu_fn  get_mtu_func,
smp_transport_ud_copy_fn  ud_copy_func,
smp_transport_ud_free_fn  ud_free_func,
smp_transport_query_valid_check_fn  query_valid_check_func 
)

#include <include/zephyr/mgmt/mcumgr/transport/smp.h>

Initializes a Zephyr SMP transport object.

Parameters
smptThe transport to construct.
output_funcThe transport's send function.
get_mtu_funcThe transport's get-MTU function.
ud_copy_funcThe transport buffer user_data copy function.
ud_free_funcThe transport buffer user_data free function.
query_valid_check_funcThe transport's check function for if a query is valid.

◆ zephyr_smp_transport_init()

static void zephyr_smp_transport_init ( struct zephyr_smp_transport smpt,
zephyr_smp_transport_out_fn output_func,
zephyr_smp_transport_get_mtu_fn get_mtu_func,
zephyr_smp_transport_ud_copy_fn ud_copy_func,
zephyr_smp_transport_ud_free_fn ud_free_func 
)
inlinestatic