Revert minimal module impl

This commit is contained in:
David Cermak
2021-03-28 09:12:58 +02:00
parent 107e66ec01
commit 1ef6141936
2 changed files with 14 additions and 26 deletions

View File

@ -9,11 +9,11 @@
#include <utility> #include <utility>
class NetModule; class NetModule;
typedef DCE_T<MinimalModule> NetDCE; typedef DCE_T<NetModule> NetDCE;
class NetModule: public ModuleIf { class NetModule: public ModuleIf {
public: public:
explicit NetModule(std::shared_ptr<DTE> dte): explicit NetModule(std::shared_ptr<DTE> dte, std::unique_ptr<PdpContext> pdp):
dte(std::move(dte)) {} dte(std::move(dte)) {}
bool setup_data_mode() override bool setup_data_mode() override
@ -61,8 +61,8 @@ public:
// create // create
auto uart_dte = create_uart_dte(&dte_config); auto uart_dte = create_uart_dte(&dte_config);
esp_modem::DCE::Factory f(esp_modem::DCE::Modem::MinModule); esp_modem::DCE::Factory f(esp_modem::DCE::Modem::MinModule);
MinimalModule* module; NetModule* module;
if (!f.build_module_T<MinimalModule>(module, uart_dte, netif)) { if (!f.build_module_T<NetModule>(module, uart_dte, netif)) {
return ESP_OK; return ESP_OK;
} }
esp_modem::DCE::Factory f2(esp_modem::DCE::Modem::SIM7600); esp_modem::DCE::Factory f2(esp_modem::DCE::Modem::SIM7600);

View File

@ -8,9 +8,9 @@
enum class command_result; enum class command_result;
class DTE; class DTE;
class MinimalModule: public ModuleIf { class GenericModule: public ModuleIf {
public: public:
explicit MinimalModule(std::shared_ptr<DTE> dte, std::unique_ptr<PdpContext> pdp): explicit GenericModule(std::shared_ptr<DTE> dte, std::unique_ptr<PdpContext> pdp):
dte(std::move(dte)), pdp(std::move(pdp)) {} dte(std::move(dte)), pdp(std::move(pdp)) {}
bool setup_data_mode() override bool setup_data_mode() override
@ -36,31 +36,20 @@ public:
return true; return true;
} }
template <typename ...T> command_result set_echo(T&&... args) { return esp_modem::dce_commands::set_echo(dte.get(),std::forward<T>(args)...); }
template <typename ...T> command_result set_pdp_context(T&&... args) { return esp_modem::dce_commands::set_pdp_context(dte.get(),std::forward<T>(args)...); } #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) \
template <typename ...T> command_result set_data_mode(T&&... args) { return esp_modem::dce_commands::set_data_mode(dte.get(),std::forward<T>(args)...); } virtual return_type name(__VA_ARGS__);
template <typename ...T> command_result resume_data_mode(T&&... args) { return esp_modem::dce_commands::resume_data_mode(dte.get(),std::forward<T>(args)...); }
template <typename ...T> command_result set_command_mode(T&&... args) { return esp_modem::dce_commands::set_command_mode(dte.get(),std::forward<T>(args)...); } DECLARE_ALL_COMMAND_APIS(virtual return_type name(...); )
template <typename ...T> command_result set_cmux(T&&... args) { return esp_modem::dce_commands::set_cmux(dte.get(),std::forward<T>(args)...); }
#undef ESP_MODEM_DECLARE_DCE_COMMAND
protected: protected:
std::shared_ptr<DTE> dte; std::shared_ptr<DTE> dte;
std::unique_ptr<PdpContext> pdp; std::unique_ptr<PdpContext> pdp;
}; };
class GenericModule: public MinimalModule {
using MinimalModule::MinimalModule;
public:
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) \
virtual return_type name(__VA_ARGS__);
DECLARE_ALL_COMMAND_APIS(virtual return_type name(...);)
#undef ESP_MODEM_DECLARE_DCE_COMMAND
};
// Definitions of other modules // Definitions of other modules
class SIM7600: public GenericModule { class SIM7600: public GenericModule {
using GenericModule::GenericModule; using GenericModule::GenericModule;
@ -75,7 +64,6 @@ public:
}; };
class BG96: public GenericModule { class BG96: public GenericModule {
using GenericModule::GenericModule;
public: public:
command_result get_module_name(std::string& name) override; command_result get_module_name(std::string& name) override;
}; };