|
1 | 1 | /*
|
2 |
| - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD |
3 | 3 | *
|
4 | 4 | * SPDX-License-Identifier: Unlicense OR CC0-1.0
|
5 | 5 | */
|
|
17 | 17 | #include "cxx_include/esp_modem_dce_module.hpp"
|
18 | 18 |
|
19 | 19 | /**
|
20 |
| - * @brief Definition of a custom modem which inherits from the GenericModule, uses all its methods |
21 |
| - * and could override any of them. Here, for demonstration purposes only, we redefine just `get_module_name()` |
| 20 | + * @brief Definition of a custom DCE uses GenericModule and all its methods |
| 21 | + * but could override command processing. Here, for demonstration purposes only, |
| 22 | + * we "inject" URC handler to the actual command processing. |
| 23 | + * This is possible since we inherit from `CommandableIf` and redefine `command()` method. |
| 24 | + * Then we're able to use declare all common methods from the command library |
| 25 | + * to be processed using "our" `command()` method (with custom URC handler). |
22 | 26 | */
|
23 |
| -class MyShinyModem: public esp_modem::GenericModule { |
24 |
| - using GenericModule::GenericModule; |
25 |
| -public: |
26 |
| - esp_modem::command_result get_module_name(std::string &name) override |
27 |
| - { |
28 |
| - name = "Custom Shiny Module"; |
29 |
| - return esp_modem::command_result::OK; |
30 |
| - } |
31 |
| -}; |
32 |
| - |
33 | 27 | namespace Shiny {
|
34 | 28 |
|
35 | 29 | using namespace esp_modem;
|
36 | 30 |
|
37 |
| -class DCE : public esp_modem::DCE_T<MyShinyModem>, public CommandableIf { |
| 31 | +class DCE : public esp_modem::DCE_T<GenericModule>, public CommandableIf { |
38 | 32 | public:
|
39 |
| - using DCE_T<MyShinyModem>::DCE_T; |
| 33 | + using DCE_T<GenericModule>::DCE_T; |
40 | 34 |
|
41 | 35 | command_result
|
42 | 36 | command(const std::string &cmd, got_line_cb got_line, uint32_t time_ms) override
|
@@ -97,7 +91,7 @@ class Factory: public ::esp_modem::dce_factory::Factory {
|
97 | 91 | std::shared_ptr<esp_modem::DTE> dte,
|
98 | 92 | esp_netif_t *netif)
|
99 | 93 | {
|
100 |
| - return build_generic_DCE<MyShinyModem, DCE, std::unique_ptr<DCE>>(config, std::move(dte), netif); |
| 94 | + return build_generic_DCE<GenericModule, DCE, std::unique_ptr<DCE>>(config, std::move(dte), netif); |
101 | 95 | }
|
102 | 96 |
|
103 | 97 | };
|
|
0 commit comments