diff --git a/esp_modem/examples/ap_to_pppos/main/NetworkDCE.cpp b/esp_modem/examples/ap_to_pppos/main/NetworkDCE.cpp index d6a4130f1..edd9c0dbd 100644 --- a/esp_modem/examples/ap_to_pppos/main/NetworkDCE.cpp +++ b/esp_modem/examples/ap_to_pppos/main/NetworkDCE.cpp @@ -9,11 +9,11 @@ #include class NetModule; -typedef DCE_T NetDCE; +typedef DCE_T NetDCE; class NetModule: public ModuleIf { public: - explicit NetModule(std::shared_ptr dte): + explicit NetModule(std::shared_ptr dte, std::unique_ptr pdp): dte(std::move(dte)) {} bool setup_data_mode() override @@ -61,8 +61,8 @@ public: // create auto uart_dte = create_uart_dte(&dte_config); esp_modem::DCE::Factory f(esp_modem::DCE::Modem::MinModule); - MinimalModule* module; - if (!f.build_module_T(module, uart_dte, netif)) { + NetModule* module; + if (!f.build_module_T(module, uart_dte, netif)) { return ESP_OK; } esp_modem::DCE::Factory f2(esp_modem::DCE::Modem::SIM7600); diff --git a/esp_modem/include/cxx_include/esp_modem_dce_module.hpp b/esp_modem/include/cxx_include/esp_modem_dce_module.hpp index 351193a7d..7b1ee8ad8 100644 --- a/esp_modem/include/cxx_include/esp_modem_dce_module.hpp +++ b/esp_modem/include/cxx_include/esp_modem_dce_module.hpp @@ -8,9 +8,9 @@ enum class command_result; class DTE; -class MinimalModule: public ModuleIf { +class GenericModule: public ModuleIf { public: - explicit MinimalModule(std::shared_ptr dte, std::unique_ptr pdp): + explicit GenericModule(std::shared_ptr dte, std::unique_ptr pdp): dte(std::move(dte)), pdp(std::move(pdp)) {} bool setup_data_mode() override @@ -36,31 +36,20 @@ public: return true; } - template command_result set_echo(T&&... args) { return esp_modem::dce_commands::set_echo(dte.get(),std::forward(args)...); } - template command_result set_pdp_context(T&&... args) { return esp_modem::dce_commands::set_pdp_context(dte.get(),std::forward(args)...); } - template command_result set_data_mode(T&&... args) { return esp_modem::dce_commands::set_data_mode(dte.get(),std::forward(args)...); } - template command_result resume_data_mode(T&&... args) { return esp_modem::dce_commands::resume_data_mode(dte.get(),std::forward(args)...); } - template command_result set_command_mode(T&&... args) { return esp_modem::dce_commands::set_command_mode(dte.get(),std::forward(args)...); } - template command_result set_cmux(T&&... args) { return esp_modem::dce_commands::set_cmux(dte.get(),std::forward(args)...); } + +#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 + protected: std::shared_ptr dte; std::unique_ptr 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 class SIM7600: public GenericModule { using GenericModule::GenericModule; @@ -75,7 +64,6 @@ public: }; class BG96: public GenericModule { - using GenericModule::GenericModule; public: command_result get_module_name(std::string& name) override; };