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

            Line data    Source code
       1            1 : /*
       2              :  * Copyright Runtime.io 2018. All rights reserved.
       3              :  * Copyright Laird Connectivity 2021-2022. All rights reserved.
       4              :  *
       5              :  * SPDX-License-Identifier: Apache-2.0
       6              :  */
       7              : 
       8              : /** @file
       9              :  * @brief Dummy transport for the mcumgr SMP protocol for unit testing.
      10              :  * @ingroup mcumgr_transport_dummy
      11              :  */
      12              : #ifndef ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_
      13              : #define ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_
      14              : 
      15              : /**
      16              :  * @brief This allows to use the MCUmgr SMP protocol over a dummy transport, usually for testing
      17              :  *        purposes.
      18              :  * @defgroup mcumgr_transport_dummy Dummy transport
      19              :  * @ingroup mcumgr_transport
      20              :  * @{
      21              :  */
      22              : 
      23              : #include <zephyr/kernel.h>
      24              : #include <zephyr/net_buf.h>
      25              : #include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
      26              : #include <zephyr/mgmt/mcumgr/transport/serial.h>
      27              : 
      28              : #ifdef __cplusplus
      29              : extern "C" {
      30              : #endif
      31              : 
      32              : /**
      33              :  * @brief Clears internal dummy SMP state and resets semaphore
      34              :  */
      35            1 : void smp_dummy_clear_state(void);
      36              : 
      37              : /**
      38              :  * @brief Adds SMPC data to the internal buffer to be processed
      39              :  *
      40              :  * @param data Input data buffer
      41              :  * @param data_size Size of data (in bytes)
      42              :  */
      43            1 : void dummy_mcumgr_add_data(uint8_t *data, uint16_t data_size);
      44              : 
      45              : /**
      46              :  * @brief Processes a single line (fragment) coming from the mcumgr response to
      47              :  *        be used in tests
      48              :  *
      49              :  * @retval net buffer of processed data
      50              :  */
      51            1 : struct net_buf *smp_dummy_get_outgoing(void);
      52              : 
      53              : /**
      54              :  * @brief Waits for a period of time for outgoing SMPC data to be ready and
      55              :  *        returns either when a full message is ready or when the timeout has
      56              :  *        elapsed.
      57              :  *
      58              :  * @param wait_time_s Time to wait for data (in seconds)
      59              :  *
      60              :  * @retval true on message received successfully, false on timeout
      61              :  */
      62            1 : bool smp_dummy_wait_for_data(uint32_t wait_time_s);
      63              : 
      64              : /**
      65              :  * @brief Calls dummy_mcumgr_add_data with the internal SMPC receive buffer.
      66              :  */
      67            1 : void smp_dummy_add_data(void);
      68              : 
      69              : /**
      70              :  * @brief Gets current send buffer position
      71              :  *
      72              :  * @retval Current send buffer position (in bytes)
      73              :  */
      74            1 : uint16_t smp_dummy_get_send_pos(void);
      75              : 
      76              : /**
      77              :  * @brief Gets current receive buffer position
      78              :  *
      79              :  * @retval Current receive buffer position (in bytes)
      80              :  */
      81            1 : uint16_t smp_dummy_get_receive_pos(void);
      82              : 
      83              : /**
      84              :  * @brief Converts input data to go out through the internal SMPC buffer.
      85              :  *
      86              :  * @param data Input data buffer
      87              :  * @param len Size of data (in bytes)
      88              :  *
      89              :  * @retval 0 on success, negative on error.
      90              :  */
      91            1 : int smp_dummy_tx_pkt(const uint8_t *data, int len);
      92              : 
      93              : /**
      94              :  * @brief Enabled the dummy SMP module (will process sent/received data)
      95              :  */
      96            1 : void smp_dummy_enable(void);
      97              : 
      98              : /**
      99              :  * @brief Disables the dummy SMP module (will not process sent/received data)
     100              :  */
     101            1 : void smp_dummy_disable(void);
     102              : 
     103              : /**
     104              :  * @brief Returns status on if the dummy SMP system is active
     105              :  *
     106              :  * @retval true if dummy SMP is enabled, false otherwise
     107              :  */
     108            1 : bool smp_dummy_get_status(void);
     109              : 
     110              : #ifdef __cplusplus
     111              : }
     112              : #endif
     113              : 
     114              : /**
     115              :  * @}
     116              :  */
     117              : 
     118              : #endif /* ZEPHYR_INCLUDE_MGMT_MCUMGR_TRANSPORT_DUMMY_H_ */
        

Generated by: LCOV version 2.0-1