From db9f3f3bbc1d065f05acb095a361a6148f5464c2 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 27 Jun 2023 14:01:11 +0200 Subject: [PATCH] feat(modem): Add factory method for simple creation of custom DCEs This allows calling directly: auto dce = dce_factory::Factory::create_unique_dce_from(&dce_config, uart_dte, esp_netif); instead of: auto dce = create_SIM7600_dce(&dce_config, uart_dte, esp_netif); Which is very useful when adding a custom module, so we won't need to update factory layers and add the new device to enums, etc. To add a new module, you just: 1) Define the module class NewModule: public GenericModule { }; 2) Implement the specific commands: command_result do_work_new_module(CommandableIf *t, params) {} 3) Connect 1) and 2) command_result NewModule::do_work_new_module(params...) { return dce_commands::do_work_new_module(dte.get(), params...); } --- .../include/cxx_include/esp_modem_dce_factory.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce_factory.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce_factory.hpp index a9aeead6590..5bcb39070c9 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dce_factory.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dce_factory.hpp @@ -236,6 +236,14 @@ class Factory { return nullptr; } + template + static std::unique_ptr create_unique_dce_from(const esp_modem::dce_config *config, + std::shared_ptr dte, + esp_netif_t *netif) + { + return build_generic_DCE>(config, std::move(dte), netif); + } + private: ModemType m;