blob: b1bc1dbb65d8a7a3d2dd882c1dc129ffa7067620 [file] [log] [blame]
/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/** @file
* @brief Shell transport for the mcumgr SMP protocol.
*/
#ifndef ZEPHYR_INCLUDE_MGMT_SMP_SHELL_H_
#define ZEPHYR_INCLUDE_MGMT_SMP_SHELL_H_
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Data used by SMP shell */
struct smp_shell_data {
char mcumgr_buff[128];
bool cmd_rdy;
atomic_t esc_state;
uint32_t cur;
};
/**
* @brief Attempt to process received bytes as part of an SMP frame.
*
* Called to scan buffer from the beginning and consume all bytes that are
* part of SMP frame until frame or buffer ends.
*
* @param data SMP shell transfer data.
* @param bytes Buffer with bytes to process
* @param size Number of bytes to process
*
* @return number of bytes consumed by the SMP
*/
size_t smp_shell_rx_bytes(struct smp_shell_data *data, const uint8_t *bytes,
size_t size);
/**
* @brief Processes SMP data and executes command if full frame was received.
*
* This function should be called from thread context.
*
* @param data SMP shell transfer data.
*/
void smp_shell_process(struct smp_shell_data *data);
/**
* @brief Initializes SMP transport over shell.
*
* This function should be called before feeding SMP transport with received
* data.
*
* @return 0 on success
*/
int smp_shell_init(void);
#ifdef __cplusplus
}
#endif
#endif