Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

This allows to use the MCUmgr SMP protocol over serial. More...

Files

file  serial.h
 Header file for the MCUmgr serial transport API.

Data Structures

struct  mcumgr_serial_rx_ctxt
 Maintains state for an incoming mcumgr request packet. More...

Macros

#define MCUMGR_SERIAL_HDR_PKT   0x0609
 Serial packet header.
#define MCUMGR_SERIAL_HDR_FRAG   0x0414
 Serial fragment header.
#define MCUMGR_SERIAL_MAX_FRAME   127
 Maximum frame size.
#define MCUMGR_SERIAL_HDR_PKT_1   (MCUMGR_SERIAL_HDR_PKT >> 8)
 First byte of packet header.
#define MCUMGR_SERIAL_HDR_PKT_2   (MCUMGR_SERIAL_HDR_PKT & 0xff)
 Second byte of packet header.
#define MCUMGR_SERIAL_HDR_FRAG_1   (MCUMGR_SERIAL_HDR_FRAG >> 8)
 First byte of fragment header.
#define MCUMGR_SERIAL_HDR_FRAG_2   (MCUMGR_SERIAL_HDR_FRAG & 0xff)
 Second byte of fragment header.

Typedefs

typedef int(* mcumgr_serial_tx_cb) (const void *data, int len)
 Transmits a chunk of raw response data.

Functions

struct net_bufmcumgr_serial_process_frag (struct mcumgr_serial_rx_ctxt *rx_ctxt, const uint8_t *frag, int frag_len)
 Processes an mcumgr request fragment received over a serial transport.
int mcumgr_serial_tx_pkt (const uint8_t *data, int len, mcumgr_serial_tx_cb cb)
 Encodes and transmits an mcumgr packet over serial.

Detailed Description

This allows to use the MCUmgr SMP protocol over serial.

Macro Definition Documentation

◆ MCUMGR_SERIAL_HDR_FRAG

#define MCUMGR_SERIAL_HDR_FRAG   0x0414

#include <serial.h>

Serial fragment header.

◆ MCUMGR_SERIAL_HDR_FRAG_1

#define MCUMGR_SERIAL_HDR_FRAG_1   (MCUMGR_SERIAL_HDR_FRAG >> 8)

#include <serial.h>

First byte of fragment header.

◆ MCUMGR_SERIAL_HDR_FRAG_2

#define MCUMGR_SERIAL_HDR_FRAG_2   (MCUMGR_SERIAL_HDR_FRAG & 0xff)

#include <serial.h>

Second byte of fragment header.

◆ MCUMGR_SERIAL_HDR_PKT

#define MCUMGR_SERIAL_HDR_PKT   0x0609

#include <serial.h>

Serial packet header.

◆ MCUMGR_SERIAL_HDR_PKT_1

#define MCUMGR_SERIAL_HDR_PKT_1   (MCUMGR_SERIAL_HDR_PKT >> 8)

#include <serial.h>

First byte of packet header.

◆ MCUMGR_SERIAL_HDR_PKT_2

#define MCUMGR_SERIAL_HDR_PKT_2   (MCUMGR_SERIAL_HDR_PKT & 0xff)

#include <serial.h>

Second byte of packet header.

◆ MCUMGR_SERIAL_MAX_FRAME

#define MCUMGR_SERIAL_MAX_FRAME   127

#include <serial.h>

Maximum frame size.

Typedef Documentation

◆ mcumgr_serial_tx_cb

typedef int(* mcumgr_serial_tx_cb) (const void *data, int len)

#include <serial.h>

Transmits a chunk of raw response data.

Parameters
dataThe data to transmit.
lenThe number of bytes to transmit.
Returns
0 on success; negative error code on failure.

Function Documentation

◆ mcumgr_serial_process_frag()

struct net_buf * mcumgr_serial_process_frag ( struct mcumgr_serial_rx_ctxt * rx_ctxt,
const uint8_t * frag,
int frag_len )

#include <serial.h>

Processes an mcumgr request fragment received over a serial transport.

Processes an mcumgr request fragment received over a serial transport. If the fragment is the end of a valid mcumgr request, this function returns a net_buf containing the decoded request. It is the caller's responsibility to free the net_buf after it has been processed.

Parameters
rx_ctxtThe receive context associated with the serial transport being used.
fragThe incoming fragment to process.
frag_lenThe length of the fragment, in bytes.
Returns
A net_buf containing the decoded request if a complete and valid request has been received. NULL if the packet is incomplete or invalid.

◆ mcumgr_serial_tx_pkt()

int mcumgr_serial_tx_pkt ( const uint8_t * data,
int len,
mcumgr_serial_tx_cb cb )

#include <serial.h>

Encodes and transmits an mcumgr packet over serial.

Parameters
dataThe mcumgr packet data to send.
lenThe length of the unencoded mcumgr packet.
cbA callback used to transmit raw bytes.
Returns
0 on success; negative error code on failure.