fix(esp_modem): Implement movable unique_buffer to bundle data, size, ptr

Also improves and fixes tests
This commit is contained in:
David Cermak
2022-06-10 18:04:10 +02:00
parent f3ff98bb82
commit 66e6d4cbf8
10 changed files with 176 additions and 87 deletions

View File

@ -15,18 +15,20 @@
#pragma once
#include <memory>
#include <utility>
#include <cstddef>
#include <cstdint>
#include <utility>
#include "cxx_include/esp_modem_primitives.hpp"
#include "cxx_include/esp_modem_terminal.hpp"
#include "cxx_include/esp_modem_cmux.hpp"
#include "cxx_include/esp_modem_types.hpp"
#include "cxx_include/esp_modem_buffer.hpp"
struct esp_modem_dte_config;
namespace esp_modem {
class CMux;
/**
* @defgroup ESP_MODEM_DTE
* @brief Definition of DTE and related classes
@ -104,19 +106,17 @@ protected:
private:
static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */
[[nodiscard]] bool setup_cmux(); /*!< Internal setup of CMUX mode */
[[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode */
[[nodiscard]] bool setup_cmux(); /*!< Internal setup of CMUX mode */
[[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode */
Lock internal_lock{}; /*!< Locks DTE operations */
size_t buffer_size; /*!< Size of available DTE buffer */
size_t consumed; /*!< Indication of already processed portion in DTE buffer */
std::unique_ptr<uint8_t[]> buffer; /*!< DTE buffer */
Lock internal_lock{}; /*!< Locks DTE operations */
unique_buffer buffer; /*!< DTE buffer */
std::shared_ptr<CMux> cmux_term; /*!< Primary terminal for this DTE */
std::shared_ptr<Terminal> command_term; /*!< Reference to the terminal used for sending commands */
std::shared_ptr<Terminal> data_term; /*!< Secondary terminal for this DTE */
modem_mode mode; /*!< DTE operation mode */
modem_mode mode; /*!< DTE operation mode */
SignalGroup signal; /*!< Event group used to signal request-response operations */
std::function<bool(uint8_t *data, size_t len)> on_data; /*!< on data callback for current terminal */
std::function<bool(uint8_t *data, size_t len)> on_data; /*!< on data callback for current terminal */
};
/**