diff --git a/components/esp_modem/examples/modem_console/main/my_module_dce.cpp b/components/esp_modem/examples/modem_console/main/my_module_dce.cpp index 3d35722b5f..61a71d6793 100644 --- a/components/esp_modem/examples/modem_console/main/my_module_dce.cpp +++ b/components/esp_modem/examples/modem_console/main/my_module_dce.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -15,7 +15,7 @@ #include #include "cxx_include/esp_modem_api.hpp" #include "cxx_include/esp_modem_dce_module.hpp" -#include "generate/esp_modem_command_declare.inc" +//#include "generate/esp_modem_command_declare.inc" #include "my_module_dce.hpp" using namespace esp_modem; @@ -45,7 +45,8 @@ using namespace esp_modem; #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, arg_nr, ...) \ return_type Shiny::DCE::name(__VA_ARGS__) { return esp_modem::dce_commands::name(this ARGS(arg_nr) ); } -DECLARE_ALL_COMMAND_APIS(return_type name(...) ) +//DECLARE_ALL_COMMAND_APIS(return_type name(...) ) +#include "generate/esp_modem_command_declare.inc" #undef ESP_MODEM_DECLARE_DCE_COMMAND diff --git a/components/esp_modem/examples/modem_console/main/my_module_dce.hpp b/components/esp_modem/examples/modem_console/main/my_module_dce.hpp index fe9fb4450e..b017913508 100644 --- a/components/esp_modem/examples/modem_console/main/my_module_dce.hpp +++ b/components/esp_modem/examples/modem_console/main/my_module_dce.hpp @@ -54,7 +54,8 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, num, ...) \ esp_modem::return_type name(__VA_ARGS__); - DECLARE_ALL_COMMAND_APIS(forwards name(...)) +// DECLARE_ALL_COMMAND_APIS(forwards name(...)) +#include "generate/esp_modem_command_declare.inc" #undef ESP_MODEM_DECLARE_DCE_COMMAND diff --git a/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp b/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp index d0e133eebe..52ea1ec0b9 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,7 @@ #include "esp_modem_dte.hpp" #include "esp_modem_dce_module.hpp" #include "esp_modem_types.hpp" -#include "generate/esp_modem_command_declare.inc" +//#include "generate/esp_modem_command_declare.inc" namespace esp_modem { namespace dce_commands { @@ -41,7 +41,8 @@ command_result generic_command(CommandableIf *t, const std::string &command, #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, num, ...) \ return_type name(CommandableIf *t, ## __VA_ARGS__); -DECLARE_ALL_COMMAND_APIS(declare name(Commandable *p, ...);) +// DECLARE_ALL_COMMAND_APIS(declare name(Commandable *p, ...);) +#include "generate/esp_modem_command_declare.inc" #undef ESP_MODEM_DECLARE_DCE_COMMAND diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce.hpp index 3db3fd86dd..3a82e2ddd6 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dce.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dce.hpp @@ -1,134 +1,10 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include -#include "cxx_include/esp_modem_netif.hpp" -#include "cxx_include/esp_modem_dce_module.hpp" - -namespace esp_modem { - -/** - * @defgroup ESP_MODEM_DCE - * @brief Definition of DCE abstraction - */ -/** @addtogroup ESP_MODEM_DCE - * @{ - */ - - -/** - * @brief Helper class responsible for switching modes of the DCE's - */ -class DCE_Mode { -public: - DCE_Mode(): mode(modem_mode::UNDEF) {} - ~DCE_Mode() = default; - bool set(DTE *dte, ModuleIf *module, Netif &netif, modem_mode m); - modem_mode get(); - -private: - bool set_unsafe(DTE *dte, ModuleIf *module, Netif &netif, modem_mode m); - modem_mode mode; - -}; - -/** - * @brief General DCE class templated on a specific module. It is responsible for all the necessary transactions - * related to switching modes and consequent synergy with aggregated objects of DTE, Netif and a specific Module - */ -template -class DCE_T { - static_assert(std::is_base_of::value, "DCE must be instantiated with Module class only"); -public: - explicit DCE_T(const std::shared_ptr &dte, std::shared_ptr dev, esp_netif_t *netif): - dte(dte), device(std::move(dev)), netif(dte, netif) - { } - - ~DCE_T() = default; - - /** - * @brief Set data mode! - */ - void set_data() - { - set_mode(modem_mode::DATA_MODE); - } - - void exit_data() - { - set_mode(modem_mode::COMMAND_MODE); - } - - void set_cmux() - { - set_mode(modem_mode::CMUX_MODE); - } - - SpecificModule *get_module() - { - return device.get(); - } - - command_result command(const std::string &command, got_line_cb got_line, uint32_t time_ms) - { - return dte->command(command, std::move(got_line), time_ms); - } - - bool set_mode(modem_mode m) - { - return mode.set(dte.get(), device.get(), netif, m); - } - - bool recover() - { - return dte->recover(); - } - -#ifdef CONFIG_ESP_MODEM_URC_HANDLER - void set_urc(got_line_cb on_read_cb) - { - dte->set_urc_cb(on_read_cb); - } -#endif - -protected: - std::shared_ptr dte; - std::shared_ptr device; - Netif netif; - DCE_Mode mode; -}; - -/** - * @brief Common abstraction of the modem DCE, specialized by the GenericModule which is a parent class for the supported - * devices and most common modems, as well. - */ -class DCE : public DCE_T { -public: - - using DCE_T::DCE_T; -#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, num, ...) \ - template \ - return_type name(Agrs&&... args) \ - { \ - return device->name(std::forward(args)...); \ - } - - DECLARE_ALL_COMMAND_APIS(forwards name(...) - { - device->name(...); - } ) - -#undef ESP_MODEM_DECLARE_DCE_COMMAND - -}; - -/** - * @} - */ - -} // esp_modem +#include "cxx_include/esp_modem_dce_template.hpp" +#include "cxx_include/esp_modem_dce_generic.hpp" diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce_generic.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce_generic.hpp new file mode 100644 index 0000000000..229bd18298 --- /dev/null +++ b/components/esp_modem/include/cxx_include/esp_modem_dce_generic.hpp @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +//#include +//#include "cxx_include/esp_modem_netif.hpp" +//#include "cxx_include/esp_modem_dce_module.hpp" +//#include "cxx_include/esp_modem_dce_template.hpp" +//#include "esp_modem_dce_template.hpp" + + +namespace esp_modem { + +/** + * @defgroup ESP_MODEM_DCE + * @brief Definition of DCE abstraction + */ + +/** @addtogroup ESP_MODEM_DCE + * @{ + */ + +/** + * @brief Common abstraction of the modem DCE, specialized by the GenericModule which is a parent class for the supported + * devices and most common modems, as well. + */ +class DCE : public DCE_T { +public: + + using DCE_T::DCE_T; +#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, num, ...) \ + template \ + return_type name(Agrs&&... args) \ + { \ + return device->name(std::forward(args)...); \ + } +#include "generate/esp_modem_command_declare.inc" +// DECLARE_ALL_COMMAND_APIS(forwards name(...) +// { +// device->name(...); +// } ) + +#undef ESP_MODEM_DECLARE_DCE_COMMAND + +}; + +/** + * @} + */ + +} // esp_modem diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp index 6ae36e63ec..cbc03dd7c3 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,7 +8,7 @@ #include #include -#include "generate/esp_modem_command_declare.inc" +//#include "generate/esp_modem_command_declare.inc" #include "cxx_include/esp_modem_command_library.hpp" #include "cxx_include/esp_modem_types.hpp" #include "esp_modem_dce_config.h" @@ -113,7 +113,10 @@ class GenericModule: public ModuleIf { #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, num, ...) \ virtual return_type name(__VA_ARGS__); - DECLARE_ALL_COMMAND_APIS(virtual return_type name(...); ) +// DECLARE_ALL_COMMAND_APIS(virtual return_type name(...); ) + +#include "generate/esp_modem_command_declare.inc" + #undef ESP_MODEM_DECLARE_DCE_COMMAND diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce_template.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce_template.hpp new file mode 100644 index 0000000000..be3a887c32 --- /dev/null +++ b/components/esp_modem/include/cxx_include/esp_modem_dce_template.hpp @@ -0,0 +1,110 @@ +/* + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "cxx_include/esp_modem_netif.hpp" +#include "cxx_include/esp_modem_dce_module.hpp" + +namespace esp_modem { + +/** + * @defgroup ESP_MODEM_DCE + * @brief Definition of DCE abstraction + */ +/** @addtogroup ESP_MODEM_DCE + * @{ + */ + + +/** + * @brief Helper class responsible for switching modes of the DCE's + */ +class DCE_Mode { +public: + DCE_Mode(): mode(modem_mode::UNDEF) {} + ~DCE_Mode() = default; + bool set(DTE *dte, ModuleIf *module, Netif &netif, modem_mode m); + modem_mode get(); + +private: + bool set_unsafe(DTE *dte, ModuleIf *module, Netif &netif, modem_mode m); + modem_mode mode; + +}; + +/** + * @brief General DCE class templated on a specific module. It is responsible for all the necessary transactions + * related to switching modes and consequent synergy with aggregated objects of DTE, Netif and a specific Module + */ +template +class DCE_T { + static_assert(std::is_base_of::value, "DCE must be instantiated with Module class only"); +public: + explicit DCE_T(const std::shared_ptr &dte, std::shared_ptr dev, esp_netif_t *netif): + dte(dte), device(std::move(dev)), netif(dte, netif) + { } + + ~DCE_T() = default; + + /** + * @brief Set data mode! + */ + void set_data() + { + set_mode(modem_mode::DATA_MODE); + } + + void exit_data() + { + set_mode(modem_mode::COMMAND_MODE); + } + + void set_cmux() + { + set_mode(modem_mode::CMUX_MODE); + } + + SpecificModule *get_module() + { + return device.get(); + } + + command_result command(const std::string &command, got_line_cb got_line, uint32_t time_ms) + { + return dte->command(command, std::move(got_line), time_ms); + } + + bool set_mode(modem_mode m) + { + return mode.set(dte.get(), device.get(), netif, m); + } + + bool recover() + { + return dte->recover(); + } + +#ifdef CONFIG_ESP_MODEM_URC_HANDLER + void set_urc(got_line_cb on_read_cb) + { + dte->set_urc_cb(on_read_cb); + } +#endif + +protected: + std::shared_ptr dte; + std::shared_ptr device; + Netif netif; + DCE_Mode mode; +}; + +/** + * @} + */ + +} // esp_modem diff --git a/components/esp_modem/include/esp_modem_api.h b/components/esp_modem/include/esp_modem_api.h index fdc27ab8a9..f914fad466 100644 --- a/components/esp_modem/include/esp_modem_api.h +++ b/components/esp_modem/include/esp_modem_api.h @@ -7,7 +7,7 @@ #pragma once #include "esp_err.h" -#include "generate/esp_modem_command_declare.inc" +//#include "generate/esp_modem_command_declare.inc" #include "esp_modem_c_api_types.h" #ifdef __cplusplus diff --git a/components/esp_modem/include/generate/esp_modem_command_declare.inc b/components/esp_modem/include/generate/esp_modem_command_declare.inc index 0f7b122f35..69fa6de882 100644 --- a/components/esp_modem/include/generate/esp_modem_command_declare.inc +++ b/components/esp_modem/include/generate/esp_modem_command_declare.inc @@ -4,46 +4,45 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#pragma once +//#pragma once #include "generate/esp_modem_command_declare_helper.inc" -#define DECLARE_ALL_COMMAND_APIS(...) \ /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(sync, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(sync, command_result, 0) + /** * @brief Reads the operator name * @param[out] name operator name * @param[out] act access technology * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_operator_name, command_result, 2, STRING_OUT(p1, name), INT_OUT(p2, act)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_operator_name, command_result, 2, STRING_OUT(p1, name), INT_OUT(p2, act)) + /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(store_profile, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(store_profile, command_result, 0) + /** * @brief Sets the supplied PIN code * @param[in] pin Pin * @return OK, FAIL or TIMEOUT - */\ -ESP_MODEM_DECLARE_DCE_COMMAND(set_pin, command_result, 1, STRING_IN(p1, pin)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_pin, command_result, 1, STRING_IN(p1, pin)) + /** * @brief Execute the supplied AT command in raw mode (doesn't append '\r' to command, returns everything) * @param[in] cmd String command that's send to DTE @@ -52,155 +51,155 @@ ESP_MODEM_DECLARE_DCE_COMMAND(set_pin, command_result, 1, STRING_IN(p1, pin)) \ * @param[in] fail Pattern in response for the API to return FAIL * @param[in] timeout AT command timeout in milliseconds * @return OK, FAIL or TIMEOUT - */\ -ESP_MODEM_DECLARE_DCE_COMMAND(at_raw, command_result, 5, STRING_IN(p1, cmd), STRING_OUT(p2, out), STRING_IN(p3, pass), STRING_IN(p4, fail), INT_IN(p5, timeout)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(at_raw, command_result, 5, STRING_IN(p1, cmd), STRING_OUT(p2, out), STRING_IN(p3, pass), STRING_IN(p4, fail), INT_IN(p5, timeout)) + /** * @brief Execute the supplied AT command * @param[in] cmd AT command * @param[out] out Command output string * @param[in] timeout AT command timeout in milliseconds * @return OK, FAIL or TIMEOUT - */\ -ESP_MODEM_DECLARE_DCE_COMMAND(at, command_result, 3, STRING_IN(p1, cmd), STRING_OUT(p2, out), INT_IN(p3, timeout)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(at, command_result, 3, STRING_IN(p1, cmd), STRING_OUT(p2, out), INT_IN(p3, timeout)) + /** * @brief Checks if the SIM needs a PIN * @param[out] pin_ok true if the SIM card doesn't need a PIN to unlock * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(read_pin, command_result, 1, BOOL_OUT(p1, pin_ok)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(read_pin, command_result, 1, BOOL_OUT(p1, pin_ok)) + /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_echo, command_result, 1, BOOL_IN(p1, echo_on)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_echo, command_result, 1, BOOL_IN(p1, echo_on)) + /** * @brief Sets the Txt or Pdu mode for SMS (only txt is supported) * @param[in] txt true if txt mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(sms_txt_mode, command_result, 1, BOOL_IN(p1, txt)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(sms_txt_mode, command_result, 1, BOOL_IN(p1, txt)) + /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(sms_character_set, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(sms_character_set, command_result, 0) + /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to * @param[in] message Text message to be sent * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(send_sms, command_result, 2, STRING_IN(p1, number), STRING_IN(p2, message)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(send_sms, command_result, 2, STRING_IN(p1, number), STRING_IN(p2, message)) + /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(resume_data_mode, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(resume_data_mode, command_result, 0) + /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_pdp_context, command_result, 1, STRUCT_OUT(PdpContext, p1)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_pdp_context, command_result, 1, STRUCT_OUT(PdpContext, p1)) + /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_command_mode, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_command_mode, command_result, 0) + /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_cmux, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_cmux, command_result, 0) + /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_imsi, command_result, 1, STRING_OUT(p1, imsi)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_imsi, command_result, 1, STRING_OUT(p1, imsi)) + /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_imei, command_result, 1, STRING_OUT(p1, imei)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_imei, command_result, 1, STRING_OUT(p1, imei)) + /** * @brief Reads the module name * @param[out] name module name * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_module_name, command_result, 1, STRING_OUT(p1, name)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_module_name, command_result, 1, STRING_OUT(p1, name)) + /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_data_mode, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_data_mode, command_result, 0) + /** * @brief Get Signal quality * @param[out] rssi signal strength indication * @param[out] ber channel bit error rate * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_signal_quality, command_result, 2, INT_OUT(p1, rssi), INT_OUT(p2, ber)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_signal_quality, command_result, 2, INT_OUT(p1, rssi), INT_OUT(p2, ber)) + /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE * @param[in] dte_flow 0=none, 2=CTS hw flow control of DTE * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_flow_control, command_result, 2, INT_IN(p1, dce_flow), INT_IN(p2, dte_flow)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_flow_control, command_result, 2, INT_IN(p1, dce_flow), INT_IN(p2, dte_flow)) + /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(hang_up, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(hang_up, command_result, 0) + /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV * @param[out] bcs charge status (-1-Not available, 0-Not charging, 1-Charging, 2-Charging done) * @param[out] bcl 1-100% battery capacity, -1-Not available * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_battery_status, command_result, 3, INT_OUT(p1, voltage), INT_OUT(p2, bcs), INT_OUT(p3, bcl)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_battery_status, command_result, 3, INT_OUT(p1, voltage), INT_OUT(p2, bcs), INT_OUT(p3, bcl)) + /** * @brief Power down the module * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(power_down, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(power_down, command_result, 0) + /** * @brief Reset the module * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(reset, command_result, 0) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(reset, command_result, 0) + /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_baud, command_result, 1, INT_IN(p1, baud)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_baud, command_result, 1, INT_IN(p1, baud)) + /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -215,81 +214,81 @@ ESP_MODEM_DECLARE_DCE_COMMAND(set_baud, command_result, 1, INT_IN(p1, baud)) \ * format=2 - numeric * @param[in] oper the operator to connect to * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_operator, command_result, 3, INT_IN(p1, mode), INT_IN(p2, format), STRING_IN(p3, oper)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_operator, command_result, 3, INT_IN(p1, mode), INT_IN(p2, format), STRING_IN(p3, oper)) + /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_network_attachment_state, command_result, 1, INT_IN(p1, state)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_network_attachment_state, command_result, 1, INT_IN(p1, state)) + /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_network_attachment_state, command_result, 1, INT_OUT(p1, state)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_network_attachment_state, command_result, 1, INT_OUT(p1, state)) + /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_radio_state, command_result, 1, INT_IN(p1, state)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_radio_state, command_result, 1, INT_IN(p1, state)) + /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_radio_state, command_result, 1, INT_OUT(p1, state)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_radio_state, command_result, 1, INT_OUT(p1, state)) + /** * @brief Set network mode * @param[in] mode preferred mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_network_mode, command_result, 1, INT_IN(p1, mode)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_network_mode, command_result, 1, INT_IN(p1, mode)) + /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_preferred_mode, command_result, 1, INT_IN(p1, mode)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_preferred_mode, command_result, 1, INT_IN(p1, mode)) + /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT * @param[in] bands bitmap in hex representing bands * @param[in] size size of teh bands bitmap * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_network_bands, command_result, 3, STRING_IN(p1, mode), INTEGER_LIST_IN(p2, bands), INT_IN(p3, size)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_network_bands, command_result, 3, STRING_IN(p1, mode), INTEGER_LIST_IN(p2, bands), INT_IN(p3, size)) + /** * @brief Show network system mode * @param[out] mode current network mode * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_network_system_mode, command_result, 1, INT_OUT(p1, mode)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_network_system_mode, command_result, 1, INT_OUT(p1, mode)) + /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(set_gnss_power_mode, command_result, 1, INT_IN(p1, mode)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(set_gnss_power_mode, command_result, 1, INT_IN(p1, mode)) + /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT - */ \ -ESP_MODEM_DECLARE_DCE_COMMAND(get_gnss_power_mode, command_result, 1, INT_OUT(p1, mode)) \ - \ + */ +ESP_MODEM_DECLARE_DCE_COMMAND(get_gnss_power_mode, command_result, 1, INT_OUT(p1, mode)) + #ifdef GENERATE_DOCS diff --git a/components/esp_modem/src/esp_modem_modules.cpp b/components/esp_modem/src/esp_modem_modules.cpp index 5634034946..5b6dd29cb7 100644 --- a/components/esp_modem/src/esp_modem_modules.cpp +++ b/components/esp_modem/src/esp_modem_modules.cpp @@ -6,7 +6,8 @@ #include "cxx_include/esp_modem_api.hpp" #include "cxx_include/esp_modem_dce_module.hpp" -#include "generate/esp_modem_command_declare.inc" +#include "cxx_include/esp_modem_dte.hpp" +//#include "generate/esp_modem_command_declare.inc" namespace esp_modem { @@ -35,7 +36,9 @@ GenericModule::GenericModule(std::shared_ptr dte, const dce_config *config) #define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, arg_nr, ...) \ return_type GenericModule::name(__VA_ARGS__) { return esp_modem::dce_commands::name(dte.get() ARGS(arg_nr) ); } -DECLARE_ALL_COMMAND_APIS(return_type name(...) ) +//DECLARE_ALL_COMMAND_APIS(return_type name(...) ) +#include "generate/esp_modem_command_declare.inc" + #undef ESP_MODEM_DECLARE_DCE_COMMAND