Skip to content

Commit

Permalink
feat(modem): Add factory method for simple creation of custom DCEs
Browse files Browse the repository at this point in the history
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...);
}
  • Loading branch information
david-cermak committed Aug 17, 2023
1 parent a4af848 commit db9f3f3
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ class Factory {
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;

Expand Down

0 comments on commit db9f3f3

Please sign in to comment.