LCOV - code coverage report
Current view: top level - zephyr/mgmt/mcumgr/transport - smp_shell.h Coverage Total Hit
Test: new.info Lines: 50.0 % 10 5
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2019 Nordic Semiconductor ASA
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /** @file
       8              :  * @brief Shell transport for the mcumgr SMP protocol.
       9              :  * @ingroup mcumgr_transport_shell
      10              :  */
      11              : 
      12              : #ifndef ZEPHYR_INCLUDE_MGMT_SMP_SHELL_H_
      13              : #define ZEPHYR_INCLUDE_MGMT_SMP_SHELL_H_
      14              : 
      15              : /**
      16              :  * @brief This allows to use the MCUmgr SMP protocol over Zephyr shell.
      17              :  * @defgroup mcumgr_transport_shell Shell transport
      18              :  * @ingroup mcumgr_transport
      19              :  * @{
      20              :  */
      21              : 
      22              : #include <zephyr/kernel.h>
      23              : #include <zephyr/types.h>
      24              : 
      25              : #ifdef __cplusplus
      26              : extern "C" {
      27              : #endif
      28              : 
      29            0 : #define SMP_SHELL_RX_BUF_SIZE   127
      30              : 
      31              : /** @brief Data used by SMP shell */
      32            1 : struct smp_shell_data {
      33            0 :         struct net_buf_pool *buf_pool;
      34            0 :         struct k_fifo buf_ready;
      35            0 :         struct net_buf *buf;
      36            0 :         atomic_t esc_state;
      37              : };
      38              : 
      39              : /**
      40              :  * @brief Attempt to process received bytes as part of an SMP frame.
      41              :  *
      42              :  * Called to scan buffer from the beginning and consume all bytes that are
      43              :  * part of SMP frame until frame or buffer ends.
      44              :  *
      45              :  * @param data SMP shell transfer data.
      46              :  * @param bytes Buffer with bytes to process
      47              :  * @param size Number of bytes to process
      48              :  *
      49              :  * @return number of bytes consumed by the SMP
      50              :  */
      51            1 : size_t smp_shell_rx_bytes(struct smp_shell_data *data, const uint8_t *bytes,
      52              :                           size_t size);
      53              : 
      54              : /**
      55              :  * @brief Processes SMP data and executes command if full frame was received.
      56              :  *
      57              :  * This function should be called from thread context.
      58              :  *
      59              :  * @param data SMP shell transfer data.
      60              :  */
      61            1 : void smp_shell_process(struct smp_shell_data *data);
      62              : 
      63              : /**
      64              :  * @brief Initializes SMP transport over shell.
      65              :  *
      66              :  * This function should be called before feeding SMP transport with received
      67              :  * data.
      68              :  *
      69              :  * @return 0 on success
      70              :  */
      71            1 : int smp_shell_init(void);
      72              : 
      73              : #ifdef __cplusplus
      74              : }
      75              : #endif
      76              : 
      77              : /**
      78              :  * @}
      79              :  */
      80              : 
      81              : #endif
        

Generated by: LCOV version 2.0-1