mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-16 03:52:13 +02:00
feat(modem): Add factory method for simple creation of custom DCEs
This allows calling directly: auto dce = dce_factory::Factory::create_unique_dce_from<SIM7600>(&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...); }
This commit is contained in:
@ -236,6 +236,14 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T_Module>
|
||||
static std::unique_ptr<DCE> create_unique_dce_from(const esp_modem::dce_config *config,
|
||||
std::shared_ptr<esp_modem::DTE> dte,
|
||||
esp_netif_t *netif)
|
||||
{
|
||||
return build_generic_DCE<T_Module, DCE, std::unique_ptr<DCE>>(config, std::move(dte), netif);
|
||||
}
|
||||
|
||||
private:
|
||||
ModemType m;
|
||||
|
||||
|
Reference in New Issue
Block a user