esp-modem: c++ dce added

This commit is contained in:
David Cermak
2021-02-26 20:23:29 +01:00
parent 86b8cfd6f5
commit 7807770d50
7 changed files with 164 additions and 12 deletions

View File

@ -9,7 +9,7 @@
#include <utility>
#include "esp_err.h"
#include "terminal_objects.hpp"
#include "ppp_netif.hpp"
enum class terminal_error {
@ -62,10 +62,14 @@ typedef std::function<bool(uint8_t *data, size_t len)> got_line_cb;
class dte {
public:
explicit dte(std::unique_ptr<terminal> terminal);
explicit dte(std::unique_ptr<terminal> t);
~dte() = default;
// void set_line_cb(got_line f) { on_line_cb = std::move(f); }
int write(uint8_t *data, size_t len) { return term->write(data, len); }
int read(uint8_t *data, size_t len) { return term->read(data, len); }
void start() { term->start(); }
void data_mode_closed() { term->stop(); }
void set_mode(dte_mode m) { term->start(); mode = m; }
bool send_command(const std::string& command, got_line_cb got_line, uint32_t time_ms);
@ -81,6 +85,14 @@ private:
};
class dce {
public:
explicit dce(std::shared_ptr<dte> d, esp_netif_t * netif);
private:
std::shared_ptr<dte> _dte;
ppp ppp_netif;
};
#endif //SIMPLE_CXX_CLIENT_ESP_MODEM_DTE_HPP

View File

@ -0,0 +1,30 @@
//
// Created by david on 2/26/21.
//
#ifndef SIMPLE_CXX_CLIENT_PPP_NETIF_HPP
#define SIMPLE_CXX_CLIENT_PPP_NETIF_HPP
#include "esp_netif.h"
class dte;
//struct ppp_netif_driver;
struct ppp_netif_driver {
esp_netif_driver_base_t base;
dte *e;
};
class ppp {
public:
explicit ppp(std::shared_ptr<dte> e, esp_netif_t *netif);
private:
esp_netif_t *netif;
std::shared_ptr<dte> _dte;
struct ppp_netif_driver driver;
};
#endif //SIMPLE_CXX_CLIENT_PPP_NETIF_HPP

View File

@ -12,6 +12,9 @@ std::unique_ptr<terminal> create_uart_terminal(const struct dte_config *config);
class dte;
std::unique_ptr<dte> create_dte(const struct dte_config *config);
std::shared_ptr<dte> create_dte(const struct dte_config *config);
std::unique_ptr<dce> create_dce(const std::shared_ptr<dte>& e, esp_netif_t *netif);
#endif //SIMPLE_CXX_CLIENT_UART_TERMINAL_HPP