diff --git a/.github/workflows/modem__build-host-tests.yml b/.github/workflows/modem__build-host-tests.yml index faf8d8c054..832c744c6f 100644 --- a/.github/workflows/modem__build-host-tests.yml +++ b/.github/workflows/modem__build-host-tests.yml @@ -108,11 +108,13 @@ jobs: steps: - name: Checkout esp-protocols uses: actions/checkout@v4 + - name: Compat check shell: bash run: | - apt-get update -y - apt-get install -y astyle + sudo apt-get update -y + sudo apt-get install -y astyle cd components/esp_modem find examples/ -type f -regex '.*/generate/.*\.\(hpp\|cpp\)' -exec ./scripts/generate.sh {} \; ./scripts/generate.sh + git diff --name-only git diff --quiet diff --git a/components/esp_modem/command/include/cxx_include/esp_modem_command_library.hpp b/components/esp_modem/command/include/cxx_include/esp_modem_command_library.hpp index 81a35a4147..7f076f1948 100644 --- a/components/esp_modem/command/include/cxx_include/esp_modem_command_library.hpp +++ b/components/esp_modem/command/include/cxx_include/esp_modem_command_library.hpp @@ -10,10 +10,8 @@ #include "cxx_include/esp_modem_dce_module.hpp" #include "cxx_include/esp_modem_types.hpp" -// --- ESP-MODEM command module starts here --- namespace esp_modem { namespace dce_commands { - /** * @defgroup ESP_MODEM_DCE_COMMAND ESP_MODEM DCE command library * @brief Library of the most useful DCE commands @@ -21,7 +19,6 @@ namespace dce_commands { /** @addtogroup ESP_MODEM_DCE_COMMAND * @{ */ - /** * @brief Generic AT command to be send with pass and fail phrases * @@ -34,51 +31,14 @@ namespace dce_commands { command_result generic_command(CommandableIf *t, const std::string &command, const std::string &pass_phrase, const std::string &fail_phrase, uint32_t timeout_ms); - /** * @brief Declaration of all commands is generated from esp_modem_command_declare.inc */ - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT */ command_result sync(CommandableIf *t ); - /** * @brief Reads the operator name * @param[out] name operator name @@ -86,20 +46,17 @@ command_result sync(CommandableIf *t ); * @return OK, FAIL or TIMEOUT */ command_result get_operator_name(CommandableIf *t, std::string &name, int &act ); - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT */ command_result store_profile(CommandableIf *t ); - /** * @brief Sets the supplied PIN code * @param[in] pin Pin * @return OK, FAIL or TIMEOUT */ command_result set_pin(CommandableIf *t, const std::string &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 @@ -110,7 +67,6 @@ command_result set_pin(CommandableIf *t, const std::string &pin ); * @return OK, FAIL or TIMEOUT */ command_result at_raw(CommandableIf *t, const std::string &cmd, std::string &out, const std::string &pass, const std::string &fail, int timeout ); - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -119,34 +75,29 @@ command_result at_raw(CommandableIf *t, const std::string &cmd, std::string &out * @return OK, FAIL or TIMEOUT */ command_result at(CommandableIf *t, const std::string &cmd, std::string &out, int 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 */ command_result read_pin(CommandableIf *t, bool &pin_ok ); - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) * @return OK, FAIL or TIMEOUT */ command_result set_echo(CommandableIf *t, const bool 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 */ command_result sms_txt_mode(CommandableIf *t, const bool txt ); - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT */ command_result sms_character_set(CommandableIf *t ); - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -154,59 +105,50 @@ command_result sms_character_set(CommandableIf *t ); * @return OK, FAIL or TIMEOUT */ command_result send_sms(CommandableIf *t, const std::string &number, const std::string &message ); - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT */ command_result resume_data_mode(CommandableIf *t ); - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection * @return OK, FAIL or TIMEOUT */ command_result set_pdp_context(CommandableIf *t, PdpContext &pdp ); - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT */ command_result set_command_mode(CommandableIf *t ); - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT */ command_result set_cmux(CommandableIf *t ); - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number * @return OK, FAIL or TIMEOUT */ command_result get_imsi(CommandableIf *t, std::string &imsi ); - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number * @return OK, FAIL or TIMEOUT */ command_result get_imei(CommandableIf *t, std::string &imei ); - /** * @brief Reads the module name * @param[out] name module name * @return OK, FAIL or TIMEOUT */ command_result get_module_name(CommandableIf *t, std::string &name ); - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT */ command_result set_data_mode(CommandableIf *t ); - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -214,7 +156,6 @@ command_result set_data_mode(CommandableIf *t ); * @return OK, FAIL or TIMEOUT */ command_result get_signal_quality(CommandableIf *t, int &rssi, int &ber ); - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -222,13 +163,11 @@ command_result get_signal_quality(CommandableIf *t, int &rssi, int &ber ); * @return OK, FAIL or TIMEOUT */ command_result set_flow_control(CommandableIf *t, int dce_flow, int dte_flow ); - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT */ command_result hang_up(CommandableIf *t ); - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -237,26 +176,22 @@ command_result hang_up(CommandableIf *t ); * @return OK, FAIL or TIMEOUT */ command_result get_battery_status(CommandableIf *t, int &voltage, int &bcs, int &bcl ); - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT */ command_result power_down(CommandableIf *t ); - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT */ command_result reset(CommandableIf *t ); - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE * @return OK, FAIL or TIMEOUT */ command_result set_baud(CommandableIf *t, int baud ); - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -273,49 +208,42 @@ command_result set_baud(CommandableIf *t, int baud ); * @return OK, FAIL or TIMEOUT */ command_result set_operator(CommandableIf *t, int mode, int format, const std::string &oper ); - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach * @return OK, FAIL or TIMEOUT */ command_result set_network_attachment_state(CommandableIf *t, int state ); - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached * @return OK, FAIL or TIMEOUT */ command_result get_network_attachment_state(CommandableIf *t, int &state ); - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ command_result set_radio_state(CommandableIf *t, int state ); - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ command_result get_radio_state(CommandableIf *t, int &state ); - /** * @brief Set network mode * @param[in] mode preferred mode * @return OK, FAIL or TIMEOUT */ command_result set_network_mode(CommandableIf *t, int mode ); - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection * @return OK, FAIL or TIMEOUT */ command_result set_preferred_mode(CommandableIf *t, int mode ); - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -324,30 +252,24 @@ command_result set_preferred_mode(CommandableIf *t, int mode ); * @return OK, FAIL or TIMEOUT */ command_result set_network_bands(CommandableIf *t, const std::string &mode, const int *bands, int size ); - /** * @brief Show network system mode * @param[out] mode current network mode * @return OK, FAIL or TIMEOUT */ command_result get_network_system_mode(CommandableIf *t, int &mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ command_result set_gnss_power_mode(CommandableIf *t, int mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ command_result get_gnss_power_mode(CommandableIf *t, int &mode ); - - - /** * @brief Following commands that are different for some specific modules */ @@ -359,10 +281,8 @@ command_result set_network_bands_sim76xx(CommandableIf *t, const std::string &mo command_result power_down_sim8xx(CommandableIf *t); command_result set_data_mode_alt(CommandableIf *t); command_result set_pdp_context(CommandableIf *t, PdpContext &pdp, uint32_t timeout_ms); - /** * @} */ - } // dce_commands } // esp_modem diff --git a/components/esp_modem/command/include/cxx_include/esp_modem_dce_generic.hpp b/components/esp_modem/command/include/cxx_include/esp_modem_dce_generic.hpp index 57bd3b109a..ea18f71a7b 100644 --- a/components/esp_modem/command/include/cxx_include/esp_modem_dce_generic.hpp +++ b/components/esp_modem/command/include/cxx_include/esp_modem_dce_generic.hpp @@ -6,68 +6,25 @@ #pragma once -// --- ESP-MODEM command module starts here --- 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: - command_result get_operator_name(std::string &name) { return device->get_operator_name(name); } - using DCE_T::DCE_T; - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT @@ -76,7 +33,6 @@ class DCE : public DCE_T { { return device->sync(); } - /** * @brief Reads the operator name * @param[out] name operator name @@ -87,7 +43,6 @@ class DCE : public DCE_T { { return device->get_operator_name(name, act ); } - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT @@ -96,7 +51,6 @@ class DCE : public DCE_T { { return device->store_profile(); } - /** * @brief Sets the supplied PIN code * @param[in] pin Pin @@ -106,7 +60,6 @@ class DCE : public DCE_T { { return device->set_pin(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 @@ -120,7 +73,6 @@ class DCE : public DCE_T { { return device->at_raw(cmd, out, pass, fail, timeout ); } - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -132,7 +84,6 @@ class DCE : public DCE_T { { return device->at(cmd, out, 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 @@ -142,7 +93,6 @@ class DCE : public DCE_T { { return device->read_pin(pin_ok ); } - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) @@ -152,7 +102,6 @@ class DCE : public DCE_T { { return device->set_echo(echo_on ); } - /** * @brief Sets the Txt or Pdu mode for SMS (only txt is supported) * @param[in] txt true if txt mode @@ -162,7 +111,6 @@ class DCE : public DCE_T { { return device->sms_txt_mode(txt ); } - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT @@ -171,7 +119,6 @@ class DCE : public DCE_T { { return device->sms_character_set(); } - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -182,7 +129,6 @@ class DCE : public DCE_T { { return device->send_sms(number, message ); } - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT @@ -191,7 +137,6 @@ class DCE : public DCE_T { { return device->resume_data_mode(); } - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection @@ -201,7 +146,6 @@ class DCE : public DCE_T { { return device->set_pdp_context(pdp ); } - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT @@ -210,7 +154,6 @@ class DCE : public DCE_T { { return device->set_command_mode(); } - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT @@ -219,7 +162,6 @@ class DCE : public DCE_T { { return device->set_cmux(); } - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number @@ -229,7 +171,6 @@ class DCE : public DCE_T { { return device->get_imsi(imsi ); } - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number @@ -239,7 +180,6 @@ class DCE : public DCE_T { { return device->get_imei(imei ); } - /** * @brief Reads the module name * @param[out] name module name @@ -249,7 +189,6 @@ class DCE : public DCE_T { { return device->get_module_name(name ); } - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT @@ -258,7 +197,6 @@ class DCE : public DCE_T { { return device->set_data_mode(); } - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -269,7 +207,6 @@ class DCE : public DCE_T { { return device->get_signal_quality(rssi, ber ); } - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -280,7 +217,6 @@ class DCE : public DCE_T { { return device->set_flow_control(dce_flow, dte_flow ); } - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT @@ -289,7 +225,6 @@ class DCE : public DCE_T { { return device->hang_up(); } - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -301,7 +236,6 @@ class DCE : public DCE_T { { return device->get_battery_status(voltage, bcs, bcl ); } - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT @@ -310,7 +244,6 @@ class DCE : public DCE_T { { return device->power_down(); } - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT @@ -319,7 +252,6 @@ class DCE : public DCE_T { { return device->reset(); } - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE @@ -329,7 +261,6 @@ class DCE : public DCE_T { { return device->set_baud(baud ); } - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -349,7 +280,6 @@ class DCE : public DCE_T { { return device->set_operator(mode, format, oper ); } - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach @@ -359,7 +289,6 @@ class DCE : public DCE_T { { return device->set_network_attachment_state(state ); } - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached @@ -369,7 +298,6 @@ class DCE : public DCE_T { { return device->get_network_attachment_state(state ); } - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... @@ -379,7 +307,6 @@ class DCE : public DCE_T { { return device->set_radio_state(state ); } - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... @@ -389,7 +316,6 @@ class DCE : public DCE_T { { return device->get_radio_state(state ); } - /** * @brief Set network mode * @param[in] mode preferred mode @@ -399,7 +325,6 @@ class DCE : public DCE_T { { return device->set_network_mode(mode ); } - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection @@ -409,7 +334,6 @@ class DCE : public DCE_T { { return device->set_preferred_mode(mode ); } - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -421,7 +345,6 @@ class DCE : public DCE_T { { return device->set_network_bands(mode, bands, size ); } - /** * @brief Show network system mode * @param[out] mode current network mode @@ -431,7 +354,6 @@ class DCE : public DCE_T { { return device->get_network_system_mode(mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -441,7 +363,6 @@ class DCE : public DCE_T { { return device->set_gnss_power_mode(mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -451,13 +372,8 @@ class DCE : public DCE_T { { return device->get_gnss_power_mode(mode ); } - - - }; - /** * @} */ - } // esp_modem diff --git a/components/esp_modem/command/include/cxx_include/esp_modem_dce_module.hpp b/components/esp_modem/command/include/cxx_include/esp_modem_dce_module.hpp index 3558120842..7f8c1b3281 100644 --- a/components/esp_modem/command/include/cxx_include/esp_modem_dce_module.hpp +++ b/components/esp_modem/command/include/cxx_include/esp_modem_dce_module.hpp @@ -14,22 +14,17 @@ #include "esp_modem_dce_config.h" -// --- ESP-MODEM command module starts here --- namespace esp_modem { - /** * @defgroup ESP_MODEM_MODULE * @brief Definition of modules representing specific modem devices */ - /** @addtogroup ESP_MODEM_MODULE * @{ */ - enum class command_result; class DTE; struct PdpContext; - /** * @brief This is a basic building block for custom modules as well as for the supported modules in the esp-modem component * It derives from the ModuleIf. @@ -43,7 +38,6 @@ class GenericModule: public ModuleIf { explicit GenericModule(std::shared_ptr dte, std::unique_ptr pdp): dte(std::move(dte)), pdp(std::move(pdp)) {} explicit GenericModule(std::shared_ptr dte, const esp_modem_dce_config *config); - /** * @brief This is a mandatory method for ModuleIf class, which sets up the device * to be able to connect to the network. This typically consists of setting basic @@ -60,7 +54,6 @@ class GenericModule: public ModuleIf { } return true; } - /** * @brief This is a mandatory method of ModuleIf class, which defines * basic commands for switching between DATA, COMMAND and CMUX modes @@ -91,7 +84,6 @@ class GenericModule: public ModuleIf { } return true; } - /** * @brief Additional method providing runtime configuration of PDP context */ @@ -99,7 +91,6 @@ class GenericModule: public ModuleIf { { pdp = std::move(new_pdp); } - /** * @brief Simplified version of operator name (without the ACT, which is included in the command library) */ @@ -108,55 +99,15 @@ class GenericModule: public ModuleIf { int dummy_act; return get_operator_name(name, dummy_act); } - /** * @brief Common DCE commands generated from the API AT list */ - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - - // DECLARE_ALL_COMMAND_APIS(virtual return_type name(...); ) - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT */ virtual command_result sync(); - /** * @brief Reads the operator name * @param[out] name operator name @@ -164,20 +115,17 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result get_operator_name(std::string &name, int &act ); - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT */ virtual command_result store_profile(); - /** * @brief Sets the supplied PIN code * @param[in] pin Pin * @return OK, FAIL or TIMEOUT */ virtual command_result set_pin(const std::string &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 @@ -188,7 +136,6 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result at_raw(const std::string &cmd, std::string &out, const std::string &pass, const std::string &fail, int timeout ); - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -197,34 +144,29 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result at(const std::string &cmd, std::string &out, int 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 */ virtual command_result read_pin(bool &pin_ok ); - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) * @return OK, FAIL or TIMEOUT */ virtual command_result set_echo(const bool 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 */ virtual command_result sms_txt_mode(const bool txt ); - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT */ virtual command_result sms_character_set(); - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -232,59 +174,50 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result send_sms(const std::string &number, const std::string &message ); - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT */ virtual command_result resume_data_mode(); - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection * @return OK, FAIL or TIMEOUT */ virtual command_result set_pdp_context(PdpContext &pdp ); - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT */ virtual command_result set_command_mode(); - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT */ virtual command_result set_cmux(); - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number * @return OK, FAIL or TIMEOUT */ virtual command_result get_imsi(std::string &imsi ); - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number * @return OK, FAIL or TIMEOUT */ virtual command_result get_imei(std::string &imei ); - /** * @brief Reads the module name * @param[out] name module name * @return OK, FAIL or TIMEOUT */ virtual command_result get_module_name(std::string &name ); - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT */ virtual command_result set_data_mode(); - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -292,7 +225,6 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result get_signal_quality(int &rssi, int &ber ); - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -300,13 +232,11 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result set_flow_control(int dce_flow, int dte_flow ); - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT */ virtual command_result hang_up(); - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -315,26 +245,22 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result get_battery_status(int &voltage, int &bcs, int &bcl ); - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT */ virtual command_result power_down(); - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT */ virtual command_result reset(); - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE * @return OK, FAIL or TIMEOUT */ virtual command_result set_baud(int baud ); - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -351,49 +277,42 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result set_operator(int mode, int format, const std::string &oper ); - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach * @return OK, FAIL or TIMEOUT */ virtual command_result set_network_attachment_state(int state ); - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached * @return OK, FAIL or TIMEOUT */ virtual command_result get_network_attachment_state(int &state ); - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ virtual command_result set_radio_state(int state ); - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ virtual command_result get_radio_state(int &state ); - /** * @brief Set network mode * @param[in] mode preferred mode * @return OK, FAIL or TIMEOUT */ virtual command_result set_network_mode(int mode ); - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection * @return OK, FAIL or TIMEOUT */ virtual command_result set_preferred_mode(int mode ); - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -402,39 +321,29 @@ class GenericModule: public ModuleIf { * @return OK, FAIL or TIMEOUT */ virtual command_result set_network_bands(const std::string &mode, const int *bands, int size ); - /** * @brief Show network system mode * @param[out] mode current network mode * @return OK, FAIL or TIMEOUT */ virtual command_result get_network_system_mode(int &mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ virtual command_result set_gnss_power_mode(int mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ virtual command_result get_gnss_power_mode(int &mode ); - - - - - protected: std::shared_ptr dte; /*!< Generic device needs the DTE as a channel talk to the module using AT commands */ std::unique_ptr pdp; /*!< It also needs a PDP data, const information used for setting up cellular network */ }; - // Definitions of other supported modules with some specific commands overwritten - /** * @brief Specific definition of the SIM7600 module */ @@ -446,7 +355,6 @@ class SIM7600: public GenericModule { command_result set_gnss_power_mode(int mode) override; command_result set_network_bands(const std::string &mode, const int *bands, int size) override; }; - /** * @brief Specific definition of the SIM7070 module */ @@ -455,9 +363,7 @@ class SIM7070: public GenericModule { public: command_result power_down() override; command_result set_data_mode() override; - }; - /** * @brief Specific definition of the SIM7000 module */ @@ -466,7 +372,6 @@ class SIM7000: public GenericModule { public: command_result power_down() override; }; - /** * @brief Specific definition of the SIM800 module */ @@ -475,7 +380,6 @@ class SIM800: public GenericModule { public: command_result power_down() override; }; - /** * @brief Specific definition of the BG96 module */ @@ -484,9 +388,7 @@ class BG96: public GenericModule { public: command_result set_pdp_context(PdpContext &pdp) override; }; - /** * @} */ - } // namespace esp_modem diff --git a/components/esp_modem/command/include/esp_modem_api.h b/components/esp_modem/command/include/esp_modem_api.h index e0a168a931..0a3242169f 100644 --- a/components/esp_modem/command/include/esp_modem_api.h +++ b/components/esp_modem/command/include/esp_modem_api.h @@ -14,55 +14,11 @@ extern "C" { #endif -// --- ESP-MODEM command module starts here --- - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name - - - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_sync(esp_modem_dce_t *dce ); - /** * @brief Reads the operator name * @param[out] name operator name @@ -70,20 +26,17 @@ esp_err_t esp_modem_sync(esp_modem_dce_t *dce ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_operator_name(esp_modem_dce_t *dce, char *name, int *act ); - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_store_profile(esp_modem_dce_t *dce ); - /** * @brief Sets the supplied PIN code * @param[in] pin Pin * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_pin(esp_modem_dce_t *dce, const char *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 @@ -94,7 +47,6 @@ esp_err_t esp_modem_set_pin(esp_modem_dce_t *dce, const char *pin ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_at_raw(esp_modem_dce_t *dce, const char *cmd, char *out, const char *pass, const char *fail, int timeout ); - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -103,34 +55,29 @@ esp_err_t esp_modem_at_raw(esp_modem_dce_t *dce, const char *cmd, char *out, con * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_at(esp_modem_dce_t *dce, const char *cmd, char *out, int 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_err_t esp_modem_read_pin(esp_modem_dce_t *dce, bool *pin_ok ); - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_echo(esp_modem_dce_t *dce, const bool 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_err_t esp_modem_sms_txt_mode(esp_modem_dce_t *dce, const bool txt ); - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_sms_character_set(esp_modem_dce_t *dce ); - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -138,59 +85,50 @@ esp_err_t esp_modem_sms_character_set(esp_modem_dce_t *dce ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_send_sms(esp_modem_dce_t *dce, const char *number, const char *message ); - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_resume_data_mode(esp_modem_dce_t *dce ); - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_pdp_context(esp_modem_dce_t *dce, esp_modem_PdpContext_t *pdp ); - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_command_mode(esp_modem_dce_t *dce ); - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_cmux(esp_modem_dce_t *dce ); - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_imsi(esp_modem_dce_t *dce, char *imsi ); - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_imei(esp_modem_dce_t *dce, char *imei ); - /** * @brief Reads the module name * @param[out] name module name * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_module_name(esp_modem_dce_t *dce, char *name ); - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_data_mode(esp_modem_dce_t *dce ); - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -198,7 +136,6 @@ esp_err_t esp_modem_set_data_mode(esp_modem_dce_t *dce ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_signal_quality(esp_modem_dce_t *dce, int *rssi, int *ber ); - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -206,13 +143,11 @@ esp_err_t esp_modem_get_signal_quality(esp_modem_dce_t *dce, int *rssi, int *ber * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_flow_control(esp_modem_dce_t *dce, int dce_flow, int dte_flow ); - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_hang_up(esp_modem_dce_t *dce ); - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -221,26 +156,22 @@ esp_err_t esp_modem_hang_up(esp_modem_dce_t *dce ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_battery_status(esp_modem_dce_t *dce, int *voltage, int *bcs, int *bcl ); - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_power_down(esp_modem_dce_t *dce ); - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_reset(esp_modem_dce_t *dce ); - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_baud(esp_modem_dce_t *dce, int baud ); - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -257,49 +188,42 @@ esp_err_t esp_modem_set_baud(esp_modem_dce_t *dce, int baud ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_operator(esp_modem_dce_t *dce, int mode, int format, const char *oper ); - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_network_attachment_state(esp_modem_dce_t *dce, int state ); - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_network_attachment_state(esp_modem_dce_t *dce, int *state ); - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_radio_state(esp_modem_dce_t *dce, int state ); - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_radio_state(esp_modem_dce_t *dce, int *state ); - /** * @brief Set network mode * @param[in] mode preferred mode * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_network_mode(esp_modem_dce_t *dce, int mode ); - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_preferred_mode(esp_modem_dce_t *dce, int mode ); - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -308,29 +232,24 @@ esp_err_t esp_modem_set_preferred_mode(esp_modem_dce_t *dce, int mode ); * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_network_bands(esp_modem_dce_t *dce, const char *mode, const int *bands, int size ); - /** * @brief Show network system mode * @param[out] mode current network mode * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_network_system_mode(esp_modem_dce_t *dce, int *mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_set_gnss_power_mode(esp_modem_dce_t *dce, int mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ esp_err_t esp_modem_get_gnss_power_mode(esp_modem_dce_t *dce, int *mode ); - - // --- ESP-MODEM command module ends here --- #ifdef __cplusplus diff --git a/components/esp_modem/command/src/esp_modem_modules.cpp b/components/esp_modem/command/src/esp_modem_modules.cpp index 3b06d498ce..55454d1b8b 100644 --- a/components/esp_modem/command/src/esp_modem_modules.cpp +++ b/components/esp_modem/command/src/esp_modem_modules.cpp @@ -8,50 +8,9 @@ #include "cxx_include/esp_modem_dce_module.hpp" #include "cxx_include/esp_modem_dte.hpp" -// --- ESP-MODEM command module starts here --- namespace esp_modem { - GenericModule::GenericModule(std::shared_ptr dte, const dce_config *config) : dte(std::move(dte)), pdp(std::make_unique(config->apn)) {} - - - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT @@ -60,7 +19,6 @@ command_result GenericModule::sync() { return esp_modem::dce_commands::sync(dte.get() ); } - /** * @brief Reads the operator name * @param[out] name operator name @@ -71,7 +29,6 @@ command_result GenericModule::get_operator_name(std::string &name, int &act ) { return esp_modem::dce_commands::get_operator_name(dte.get(), name, act ); } - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT @@ -80,7 +37,6 @@ command_result GenericModule::store_profile() { return esp_modem::dce_commands::store_profile(dte.get() ); } - /** * @brief Sets the supplied PIN code * @param[in] pin Pin @@ -90,7 +46,6 @@ command_result GenericModule::set_pin(const std::string &pin ) { return esp_modem::dce_commands::set_pin(dte.get(), 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 @@ -104,7 +59,6 @@ command_result GenericModule::at_raw(const std::string &cmd, std::string &out, c { return esp_modem::dce_commands::at_raw(dte.get(), cmd, out, pass, fail, timeout ); } - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -116,7 +70,6 @@ command_result GenericModule::at(const std::string &cmd, std::string &out, int t { return esp_modem::dce_commands::at(dte.get(), cmd, out, 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 @@ -126,7 +79,6 @@ command_result GenericModule::read_pin(bool &pin_ok ) { return esp_modem::dce_commands::read_pin(dte.get(), pin_ok ); } - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) @@ -136,7 +88,6 @@ command_result GenericModule::set_echo(const bool echo_on ) { return esp_modem::dce_commands::set_echo(dte.get(), echo_on ); } - /** * @brief Sets the Txt or Pdu mode for SMS (only txt is supported) * @param[in] txt true if txt mode @@ -146,7 +97,6 @@ command_result GenericModule::sms_txt_mode(const bool txt ) { return esp_modem::dce_commands::sms_txt_mode(dte.get(), txt ); } - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT @@ -155,7 +105,6 @@ command_result GenericModule::sms_character_set() { return esp_modem::dce_commands::sms_character_set(dte.get() ); } - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -166,7 +115,6 @@ command_result GenericModule::send_sms(const std::string &number, const std::str { return esp_modem::dce_commands::send_sms(dte.get(), number, message ); } - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT @@ -175,7 +123,6 @@ command_result GenericModule::resume_data_mode() { return esp_modem::dce_commands::resume_data_mode(dte.get() ); } - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection @@ -185,7 +132,6 @@ command_result GenericModule::set_pdp_context(PdpContext &pdp ) { return esp_modem::dce_commands::set_pdp_context(dte.get(), pdp ); } - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT @@ -194,7 +140,6 @@ command_result GenericModule::set_command_mode() { return esp_modem::dce_commands::set_command_mode(dte.get() ); } - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT @@ -203,7 +148,6 @@ command_result GenericModule::set_cmux() { return esp_modem::dce_commands::set_cmux(dte.get() ); } - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number @@ -213,7 +157,6 @@ command_result GenericModule::get_imsi(std::string &imsi ) { return esp_modem::dce_commands::get_imsi(dte.get(), imsi ); } - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number @@ -223,7 +166,6 @@ command_result GenericModule::get_imei(std::string &imei ) { return esp_modem::dce_commands::get_imei(dte.get(), imei ); } - /** * @brief Reads the module name * @param[out] name module name @@ -233,7 +175,6 @@ command_result GenericModule::get_module_name(std::string &name ) { return esp_modem::dce_commands::get_module_name(dte.get(), name ); } - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT @@ -242,7 +183,6 @@ command_result GenericModule::set_data_mode() { return esp_modem::dce_commands::set_data_mode(dte.get() ); } - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -253,7 +193,6 @@ command_result GenericModule::get_signal_quality(int &rssi, int &ber ) { return esp_modem::dce_commands::get_signal_quality(dte.get(), rssi, ber ); } - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -264,7 +203,6 @@ command_result GenericModule::set_flow_control(int dce_flow, int dte_flow ) { return esp_modem::dce_commands::set_flow_control(dte.get(), dce_flow, dte_flow ); } - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT @@ -273,7 +211,6 @@ command_result GenericModule::hang_up() { return esp_modem::dce_commands::hang_up(dte.get() ); } - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -285,7 +222,6 @@ command_result GenericModule::get_battery_status(int &voltage, int &bcs, int &bc { return esp_modem::dce_commands::get_battery_status(dte.get(), voltage, bcs, bcl ); } - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT @@ -294,7 +230,6 @@ command_result GenericModule::power_down() { return esp_modem::dce_commands::power_down(dte.get() ); } - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT @@ -303,7 +238,6 @@ command_result GenericModule::reset() { return esp_modem::dce_commands::reset(dte.get() ); } - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE @@ -313,7 +247,6 @@ command_result GenericModule::set_baud(int baud ) { return esp_modem::dce_commands::set_baud(dte.get(), baud ); } - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -333,7 +266,6 @@ command_result GenericModule::set_operator(int mode, int format, const std::stri { return esp_modem::dce_commands::set_operator(dte.get(), mode, format, oper ); } - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach @@ -343,7 +275,6 @@ command_result GenericModule::set_network_attachment_state(int state ) { return esp_modem::dce_commands::set_network_attachment_state(dte.get(), state ); } - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached @@ -353,7 +284,6 @@ command_result GenericModule::get_network_attachment_state(int &state ) { return esp_modem::dce_commands::get_network_attachment_state(dte.get(), state ); } - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... @@ -363,7 +293,6 @@ command_result GenericModule::set_radio_state(int state ) { return esp_modem::dce_commands::set_radio_state(dte.get(), state ); } - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... @@ -373,7 +302,6 @@ command_result GenericModule::get_radio_state(int &state ) { return esp_modem::dce_commands::get_radio_state(dte.get(), state ); } - /** * @brief Set network mode * @param[in] mode preferred mode @@ -383,7 +311,6 @@ command_result GenericModule::set_network_mode(int mode ) { return esp_modem::dce_commands::set_network_mode(dte.get(), mode ); } - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection @@ -393,7 +320,6 @@ command_result GenericModule::set_preferred_mode(int mode ) { return esp_modem::dce_commands::set_preferred_mode(dte.get(), mode ); } - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -405,7 +331,6 @@ command_result GenericModule::set_network_bands(const std::string &mode, const i { return esp_modem::dce_commands::set_network_bands(dte.get(), mode, bands, size ); } - /** * @brief Show network system mode * @param[out] mode current network mode @@ -415,7 +340,6 @@ command_result GenericModule::get_network_system_mode(int &mode ) { return esp_modem::dce_commands::get_network_system_mode(dte.get(), mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -425,7 +349,6 @@ command_result GenericModule::set_gnss_power_mode(int mode ) { return esp_modem::dce_commands::set_gnss_power_mode(dte.get(), mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -435,21 +358,12 @@ command_result GenericModule::get_gnss_power_mode(int &mode ) { return esp_modem::dce_commands::get_gnss_power_mode(dte.get(), mode ); } - - - // Usage examples: // Zero arguments - // Helper to apply the correct macro to each parameter - // // Repeat all declarations and forward to the AT commands defined in esp_modem::dce_commands:: namespace // - - - - // // Handle specific commands for specific supported modems // @@ -457,45 +371,36 @@ command_result SIM7600::get_battery_status(int &voltage, int &bcs, int &bcl) { return dce_commands::get_battery_status_sim7xxx(dte.get(), voltage, bcs, bcl); } - command_result SIM7600::set_network_bands(const std::string &mode, const int *bands, int size) { return dce_commands::set_network_bands_sim76xx(dte.get(), mode, bands, size); } - command_result SIM7600::set_gnss_power_mode(int mode) { return dce_commands::set_gnss_power_mode_sim76xx(dte.get(), mode); } - command_result SIM7600::power_down() { return dce_commands::power_down_sim76xx(dte.get()); } - command_result SIM7070::power_down() { return dce_commands::power_down_sim70xx(dte.get()); } - command_result SIM7070::set_data_mode() { return dce_commands::set_data_mode_alt(dte.get()); } - command_result SIM7000::power_down() { return dce_commands::power_down_sim70xx(dte.get()); } - command_result SIM800::power_down() { return dce_commands::power_down_sim8xx(dte.get()); } - command_result BG96::set_pdp_context(esp_modem::PdpContext &pdp) { return dce_commands::set_pdp_context(dte.get(), pdp, 300); } - } diff --git a/components/esp_modem/examples/modem_console/main/command/my_module_dce.cpp b/components/esp_modem/examples/modem_console/main/command/my_module_dce.cpp index 4a7be8e975..069e8b0228 100644 --- a/components/esp_modem/examples/modem_console/main/command/my_module_dce.cpp +++ b/components/esp_modem/examples/modem_console/main/command/my_module_dce.cpp @@ -18,56 +18,14 @@ //#include "generate/esp_modem_command_declare.inc" #include "my_module_dce.hpp" -// --- ESP-MODEM command module starts here --- using namespace esp_modem; - // // Define preprocessor's forwarding to dce_commands definitions // - - - - // // Repeat all declarations and forward to the AT commands defined in esp_modem::dce_commands:: namespace // - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - //DECLARE_ALL_COMMAND_APIS(return_type name(...) ) - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT @@ -76,7 +34,6 @@ command_result Shiny::DCE::sync() { return esp_modem::dce_commands::sync(this ); } - /** * @brief Reads the operator name * @param[out] name operator name @@ -87,7 +44,6 @@ command_result Shiny::DCE::get_operator_name(std::string &name, int &act ) { return esp_modem::dce_commands::get_operator_name(this, name, act ); } - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT @@ -96,7 +52,6 @@ command_result Shiny::DCE::store_profile() { return esp_modem::dce_commands::store_profile(this ); } - /** * @brief Sets the supplied PIN code * @param[in] pin Pin @@ -106,7 +61,6 @@ command_result Shiny::DCE::set_pin(const std::string &pin ) { return esp_modem::dce_commands::set_pin(this, 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 @@ -120,7 +74,6 @@ command_result Shiny::DCE::at_raw(const std::string &cmd, std::string &out, cons { return esp_modem::dce_commands::at_raw(this, cmd, out, pass, fail, timeout ); } - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -132,7 +85,6 @@ command_result Shiny::DCE::at(const std::string &cmd, std::string &out, int time { return esp_modem::dce_commands::at(this, cmd, out, 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 @@ -142,7 +94,6 @@ command_result Shiny::DCE::read_pin(bool &pin_ok ) { return esp_modem::dce_commands::read_pin(this, pin_ok ); } - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) @@ -152,7 +103,6 @@ command_result Shiny::DCE::set_echo(const bool echo_on ) { return esp_modem::dce_commands::set_echo(this, echo_on ); } - /** * @brief Sets the Txt or Pdu mode for SMS (only txt is supported) * @param[in] txt true if txt mode @@ -162,7 +112,6 @@ command_result Shiny::DCE::sms_txt_mode(const bool txt ) { return esp_modem::dce_commands::sms_txt_mode(this, txt ); } - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT @@ -171,7 +120,6 @@ command_result Shiny::DCE::sms_character_set() { return esp_modem::dce_commands::sms_character_set(this ); } - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -182,7 +130,6 @@ command_result Shiny::DCE::send_sms(const std::string &number, const std::string { return esp_modem::dce_commands::send_sms(this, number, message ); } - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT @@ -191,7 +138,6 @@ command_result Shiny::DCE::resume_data_mode() { return esp_modem::dce_commands::resume_data_mode(this ); } - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection @@ -201,7 +147,6 @@ command_result Shiny::DCE::set_pdp_context(PdpContext &pdp ) { return esp_modem::dce_commands::set_pdp_context(this, pdp ); } - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT @@ -210,7 +155,6 @@ command_result Shiny::DCE::set_command_mode() { return esp_modem::dce_commands::set_command_mode(this ); } - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT @@ -219,7 +163,6 @@ command_result Shiny::DCE::set_cmux() { return esp_modem::dce_commands::set_cmux(this ); } - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number @@ -229,7 +172,6 @@ command_result Shiny::DCE::get_imsi(std::string &imsi ) { return esp_modem::dce_commands::get_imsi(this, imsi ); } - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number @@ -239,7 +181,6 @@ command_result Shiny::DCE::get_imei(std::string &imei ) { return esp_modem::dce_commands::get_imei(this, imei ); } - /** * @brief Reads the module name * @param[out] name module name @@ -249,7 +190,6 @@ command_result Shiny::DCE::get_module_name(std::string &name ) { return esp_modem::dce_commands::get_module_name(this, name ); } - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT @@ -258,7 +198,6 @@ command_result Shiny::DCE::set_data_mode() { return esp_modem::dce_commands::set_data_mode(this ); } - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -269,7 +208,6 @@ command_result Shiny::DCE::get_signal_quality(int &rssi, int &ber ) { return esp_modem::dce_commands::get_signal_quality(this, rssi, ber ); } - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -280,7 +218,6 @@ command_result Shiny::DCE::set_flow_control(int dce_flow, int dte_flow ) { return esp_modem::dce_commands::set_flow_control(this, dce_flow, dte_flow ); } - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT @@ -289,7 +226,6 @@ command_result Shiny::DCE::hang_up() { return esp_modem::dce_commands::hang_up(this ); } - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -301,7 +237,6 @@ command_result Shiny::DCE::get_battery_status(int &voltage, int &bcs, int &bcl ) { return esp_modem::dce_commands::get_battery_status(this, voltage, bcs, bcl ); } - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT @@ -310,7 +245,6 @@ command_result Shiny::DCE::power_down() { return esp_modem::dce_commands::power_down(this ); } - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT @@ -319,7 +253,6 @@ command_result Shiny::DCE::reset() { return esp_modem::dce_commands::reset(this ); } - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE @@ -329,7 +262,6 @@ command_result Shiny::DCE::set_baud(int baud ) { return esp_modem::dce_commands::set_baud(this, baud ); } - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -349,7 +281,6 @@ command_result Shiny::DCE::set_operator(int mode, int format, const std::string { return esp_modem::dce_commands::set_operator(this, mode, format, oper ); } - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach @@ -359,7 +290,6 @@ command_result Shiny::DCE::set_network_attachment_state(int state ) { return esp_modem::dce_commands::set_network_attachment_state(this, state ); } - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached @@ -369,7 +299,6 @@ command_result Shiny::DCE::get_network_attachment_state(int &state ) { return esp_modem::dce_commands::get_network_attachment_state(this, state ); } - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... @@ -379,7 +308,6 @@ command_result Shiny::DCE::set_radio_state(int state ) { return esp_modem::dce_commands::set_radio_state(this, state ); } - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... @@ -389,7 +317,6 @@ command_result Shiny::DCE::get_radio_state(int &state ) { return esp_modem::dce_commands::get_radio_state(this, state ); } - /** * @brief Set network mode * @param[in] mode preferred mode @@ -399,7 +326,6 @@ command_result Shiny::DCE::set_network_mode(int mode ) { return esp_modem::dce_commands::set_network_mode(this, mode ); } - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection @@ -409,7 +335,6 @@ command_result Shiny::DCE::set_preferred_mode(int mode ) { return esp_modem::dce_commands::set_preferred_mode(this, mode ); } - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -421,7 +346,6 @@ command_result Shiny::DCE::set_network_bands(const std::string &mode, const int { return esp_modem::dce_commands::set_network_bands(this, mode, bands, size ); } - /** * @brief Show network system mode * @param[out] mode current network mode @@ -431,7 +355,6 @@ command_result Shiny::DCE::get_network_system_mode(int &mode ) { return esp_modem::dce_commands::get_network_system_mode(this, mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -441,7 +364,6 @@ command_result Shiny::DCE::set_gnss_power_mode(int mode ) { return esp_modem::dce_commands::set_gnss_power_mode(this, mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -451,16 +373,12 @@ command_result Shiny::DCE::get_gnss_power_mode(int &mode ) { return esp_modem::dce_commands::get_gnss_power_mode(this, mode ); } - - - std::unique_ptr create_shiny_dce(const esp_modem::dce_config *config, std::shared_ptr dte, esp_netif_t *netif) { return Shiny::Factory::create(config, std::move(dte), netif); } - /** * @brief Definition of the command API, which makes the Shiny::DCE "command-able class" * @param cmd Command to send @@ -488,7 +406,6 @@ command_result Shiny::DCE::command(const std::string &cmd, got_line_cb got_line, } return esp_modem::command_result::TIMEOUT; } - /** * @brief Handle received data * diff --git a/components/esp_modem/examples/modem_console/main/command/my_module_dce.hpp b/components/esp_modem/examples/modem_console/main/command/my_module_dce.hpp index f32d6cc841..91ee34852d 100644 --- a/components/esp_modem/examples/modem_console/main/command/my_module_dce.hpp +++ b/components/esp_modem/examples/modem_console/main/command/my_module_dce.hpp @@ -16,7 +16,6 @@ #include "cxx_include/esp_modem_dce_factory.hpp" #include "cxx_include/esp_modem_dce_module.hpp" -// --- ESP-MODEM command module starts here --- /** * @brief Definition of a custom DCE uses GenericModule and all its methods * but could override command processing. Here, for demonstration purposes only, @@ -26,75 +25,31 @@ * to be processed using "our" `command()` method (with custom URC handler). */ namespace Shiny { - using namespace esp_modem; - class DCE : public esp_modem::DCE_T, public CommandableIf { public: using DCE_T::DCE_T; - command_result command(const std::string &cmd, got_line_cb got_line, uint32_t time_ms) override { return command(cmd, got_line, time_ms, '\n'); } - command_result command(const std::string &cmd, got_line_cb got_line, uint32_t time_ms, const char separator) override; - int write(uint8_t *data, size_t len) override { return dte->write(data, len); } - void on_read(got_line_cb on_data) override { return dte->on_read(on_data); } - - - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - // DECLARE_ALL_COMMAND_APIS(forwards name(...)) - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT */ esp_modem::command_result sync(); - /** * @brief Reads the operator name * @param[out] name operator name @@ -102,20 +57,17 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_operator_name(std::string &name, int &act ); - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT */ esp_modem::command_result store_profile(); - /** * @brief Sets the supplied PIN code * @param[in] pin Pin * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_pin(const std::string &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 @@ -126,7 +78,6 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result at_raw(const std::string &cmd, std::string &out, const std::string &pass, const std::string &fail, int timeout ); - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -135,34 +86,29 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result at(const std::string &cmd, std::string &out, int 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::command_result read_pin(bool &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::command_result set_echo(const bool 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::command_result sms_txt_mode(const bool txt ); - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT */ esp_modem::command_result sms_character_set(); - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -170,59 +116,50 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result send_sms(const std::string &number, const std::string &message ); - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT */ esp_modem::command_result resume_data_mode(); - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_pdp_context(PdpContext &pdp ); - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_command_mode(); - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_cmux(); - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_imsi(std::string &imsi ); - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_imei(std::string &imei ); - /** * @brief Reads the module name * @param[out] name module name * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_module_name(std::string &name ); - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_data_mode(); - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -230,7 +167,6 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_signal_quality(int &rssi, int &ber ); - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -238,13 +174,11 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_flow_control(int dce_flow, int dte_flow ); - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT */ esp_modem::command_result hang_up(); - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -253,26 +187,22 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_battery_status(int &voltage, int &bcs, int &bcl ); - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT */ esp_modem::command_result power_down(); - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT */ esp_modem::command_result reset(); - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_baud(int baud ); - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -289,49 +219,42 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_operator(int mode, int format, const std::string &oper ); - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_network_attachment_state(int state ); - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_network_attachment_state(int &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::command_result set_radio_state(int state ); - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_radio_state(int &state ); - /** * @brief Set network mode * @param[in] mode preferred mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_network_mode(int mode ); - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_preferred_mode(int mode ); - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -340,30 +263,24 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_network_bands(const std::string &mode, const int *bands, int size ); - /** * @brief Show network system mode * @param[out] mode current network mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_network_system_mode(int &mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_gnss_power_mode(int mode ); - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_gnss_power_mode(int &mode ); - - - void set_on_read(esp_modem::got_line_cb on_read_cb) { if (on_read_cb == nullptr) { @@ -379,31 +296,23 @@ class DCE : public esp_modem::DCE_T, public CommandableIf { }); handling_urc = true; } - private: got_line_cb handle_urc{nullptr}; got_line_cb handle_cmd{nullptr}; SignalGroup signal; bool handling_urc {false}; - command_result handle_data(uint8_t *data, size_t len); - }; - class Factory: public ::esp_modem::dce_factory::Factory { public: - static std::unique_ptr create(const esp_modem::dce_config *config, std::shared_ptr dte, esp_netif_t *netif) { return build_generic_DCE>(config, std::move(dte), netif); } - }; - } // namespace Shiny - /** * @brief Helper create method which employs the DCE factory for creating DCE objects templated by a custom module * @return unique pointer of the resultant DCE diff --git a/components/esp_modem/examples/modem_tcp_client/main/command/sock_commands.hpp b/components/esp_modem/examples/modem_tcp_client/main/command/sock_commands.hpp index 6c34e7430b..e61022d76e 100644 --- a/components/esp_modem/examples/modem_tcp_client/main/command/sock_commands.hpp +++ b/components/esp_modem/examples/modem_tcp_client/main/command/sock_commands.hpp @@ -13,53 +13,16 @@ namespace sock_commands { -// --- ESP-MODEM command module starts here --- - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - /** * @brief Opens network in AT command mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result net_open(esp_modem::CommandableIf *t ); - /** * @brief Closes network in AT command mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result net_close(esp_modem::CommandableIf *t ); - /** * @brief Opens a TCP connection * @param[in] host Host name or IP address to connect to @@ -68,26 +31,21 @@ esp_modem::command_result net_close(esp_modem::CommandableIf *t ); * @return OK, FAIL or TIMEOUT */ esp_modem::command_result tcp_open(esp_modem::CommandableIf *t, const std::string &host, int port, int timeout ); - /** * @brief Closes opened TCP socket * @return OK, FAIL or TIMEOUT */ esp_modem::command_result tcp_close(esp_modem::CommandableIf *t ); - /** * @brief Gets modem IP address * @param[out] addr String representation of modem's IP * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_ip(esp_modem::CommandableIf *t, std::string &addr ); - /** * @brief Sets Rx mode * @param[in] mode 0=auto, 1=manual * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_rx_mode(esp_modem::CommandableIf *t, int mode ); - - } diff --git a/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.cpp b/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.cpp index 6373c69847..6a1f2bf23c 100644 --- a/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.cpp +++ b/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.cpp @@ -305,41 +305,6 @@ std::unique_ptr create(const esp_modem::dce_config *config, std::shared_ptr } -// --- ESP-MODEM command module starts here --- - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - /** * @brief Opens network in AT command mode * @return OK, FAIL or TIMEOUT @@ -348,7 +313,6 @@ esp_modem::command_result DCE::net_open() { return sock_commands::net_open(dte.get() ); } - /** * @brief Closes network in AT command mode * @return OK, FAIL or TIMEOUT @@ -357,7 +321,6 @@ esp_modem::command_result DCE::net_close() { return sock_commands::net_close(dte.get() ); } - /** * @brief Opens a TCP connection * @param[in] host Host name or IP address to connect to @@ -369,7 +332,6 @@ esp_modem::command_result DCE::tcp_open(const std::string &host, int port, int t { return sock_commands::tcp_open(dte.get(), host, port, timeout ); } - /** * @brief Closes opened TCP socket * @return OK, FAIL or TIMEOUT @@ -378,7 +340,6 @@ esp_modem::command_result DCE::tcp_close() { return sock_commands::tcp_close(dte.get() ); } - /** * @brief Gets modem IP address * @param[out] addr String representation of modem's IP @@ -388,7 +349,6 @@ esp_modem::command_result DCE::get_ip(std::string &addr ) { return sock_commands::get_ip(dte.get(), addr ); } - /** * @brief Sets Rx mode * @param[in] mode 0=auto, 1=manual @@ -398,6 +358,4 @@ esp_modem::command_result DCE::set_rx_mode(int mode ) { return sock_commands::set_rx_mode(dte.get(), mode ); } - - } // namespace sock_dce diff --git a/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.hpp b/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.hpp index 869a244157..4469e50cd7 100644 --- a/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.hpp +++ b/components/esp_modem/examples/modem_tcp_client/main/command/sock_dce.hpp @@ -101,53 +101,16 @@ class DCE : public ::esp_modem::GenericModule { using esp_modem::GenericModule::GenericModule; public: -// --- ESP-MODEM command module starts here --- - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - /** * @brief Opens network in AT command mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result net_open(); - /** * @brief Closes network in AT command mode * @return OK, FAIL or TIMEOUT */ esp_modem::command_result net_close(); - /** * @brief Opens a TCP connection * @param[in] host Host name or IP address to connect to @@ -156,40 +119,31 @@ class DCE : public ::esp_modem::GenericModule { * @return OK, FAIL or TIMEOUT */ esp_modem::command_result tcp_open(const std::string &host, int port, int timeout ); - /** * @brief Closes opened TCP socket * @return OK, FAIL or TIMEOUT */ esp_modem::command_result tcp_close(); - /** * @brief Gets modem IP address * @param[out] addr String representation of modem's IP * @return OK, FAIL or TIMEOUT */ esp_modem::command_result get_ip(std::string &addr ); - /** * @brief Sets Rx mode * @param[in] mode 0=auto, 1=manual * @return OK, FAIL or TIMEOUT */ esp_modem::command_result set_rx_mode(int mode ); - - bool init(); bool connect(std::string host, int port); - void start_listening(int port); - bool perform_sock(); - void set_idle() { signal.set(IDLE); } - bool wait_to_idle(uint32_t ms) { if (!signal.wait(IDLE, ms)) { @@ -202,7 +156,6 @@ class DCE : public ::esp_modem::GenericModule { } return true; } - int sync_recv(char *buffer, int len, int timeout_ms) { if (!wait_to_idle(timeout_ms)) { @@ -224,7 +177,6 @@ class DCE : public ::esp_modem::GenericModule { set_idle(); return ret; } - int sync_send(const char *buffer, size_t len, int timeout_ms) { int len_to_send = std::min(len, at.get_buf_len()); @@ -245,7 +197,6 @@ class DCE : public ::esp_modem::GenericModule { set_idle(); return len_to_send; } - int wait_to_read(uint32_t ms) { if (at.has_data() > 0) { @@ -272,17 +223,13 @@ class DCE : public ::esp_modem::GenericModule { } return -1; } - private: esp_modem::SignalGroup signal; - void close_sock(); bool accept_sock(); bool sock_to_at(); bool at_to_sock(); - void perform_at(uint8_t *data, size_t len); - status state{status::IDLE}; static constexpr uint8_t IDLE = 1; Responder at{sock, data_ready_fd, dte}; @@ -290,7 +237,5 @@ class DCE : public ::esp_modem::GenericModule { int listen_sock {-1}; int data_ready_fd {-1}; }; - std::unique_ptr create(const esp_modem::dce_config *config, std::shared_ptr dte); - } diff --git a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/command/SIM7070_gnss.hpp b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/command/SIM7070_gnss.hpp index 65cb48828f..10e836110f 100644 --- a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/command/SIM7070_gnss.hpp +++ b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/command/SIM7070_gnss.hpp @@ -38,41 +38,6 @@ class DCE_gnss : public esp_modem::DCE_T { using DCE_T::DCE_T; -// --- ESP-MODEM command module starts here --- - -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name - -// Utility to count arguments (works for up to two parameters here) - - - /** * @brief Sends the initial AT sequence to sync up with the device * @return OK, FAIL or TIMEOUT @@ -81,7 +46,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->sync(); } - /** * @brief Reads the operator name * @param[out] name operator name @@ -92,7 +56,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_operator_name(name, act ); } - /** * @brief Stores current user profile * @return OK, FAIL or TIMEOUT @@ -101,7 +64,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->store_profile(); } - /** * @brief Sets the supplied PIN code * @param[in] pin Pin @@ -111,7 +73,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_pin(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 @@ -125,7 +86,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->at_raw(cmd, out, pass, fail, timeout ); } - /** * @brief Execute the supplied AT command * @param[in] cmd AT command @@ -137,7 +97,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->at(cmd, out, 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 @@ -147,7 +106,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->read_pin(pin_ok ); } - /** * @brief Sets echo mode * @param[in] echo_on true if echo mode on (repeats the commands) @@ -157,7 +115,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_echo(echo_on ); } - /** * @brief Sets the Txt or Pdu mode for SMS (only txt is supported) * @param[in] txt true if txt mode @@ -167,7 +124,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->sms_txt_mode(txt ); } - /** * @brief Sets the default (GSM) character set * @return OK, FAIL or TIMEOUT @@ -176,7 +132,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->sms_character_set(); } - /** * @brief Sends SMS message in txt mode * @param[in] number Phone number to send the message to @@ -187,7 +142,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->send_sms(number, message ); } - /** * @brief Resumes data mode (Switches back to the data mode, which was temporarily suspended) * @return OK, FAIL or TIMEOUT @@ -196,7 +150,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->resume_data_mode(); } - /** * @brief Sets php context * @param[in] p1 PdP context struct to setup modem cellular connection @@ -206,7 +159,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_pdp_context(pdp ); } - /** * @brief Switches to the command mode * @return OK, FAIL or TIMEOUT @@ -215,7 +167,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_command_mode(); } - /** * @brief Switches to the CMUX mode * @return OK, FAIL or TIMEOUT @@ -224,7 +175,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_cmux(); } - /** * @brief Reads the IMSI number * @param[out] imsi Module's IMSI number @@ -234,7 +184,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_imsi(imsi ); } - /** * @brief Reads the IMEI number * @param[out] imei Module's IMEI number @@ -244,7 +193,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_imei(imei ); } - /** * @brief Reads the module name * @param[out] name module name @@ -254,7 +202,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_module_name(name ); } - /** * @brief Sets the modem to data mode * @return OK, FAIL or TIMEOUT @@ -263,7 +210,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_data_mode(); } - /** * @brief Get Signal quality * @param[out] rssi signal strength indication @@ -274,7 +220,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_signal_quality(rssi, ber ); } - /** * @brief Sets HW control flow * @param[in] dce_flow 0=none, 2=RTS hw flow control of DCE @@ -285,7 +230,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_flow_control(dce_flow, dte_flow ); } - /** * @brief Hangs up current data call * @return OK, FAIL or TIMEOUT @@ -294,7 +238,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->hang_up(); } - /** * @brief Get voltage levels of modem power up circuitry * @param[out] voltage Current status in mV @@ -306,7 +249,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_battery_status(voltage, bcs, bcl ); } - /** * @brief Power down the module * @return OK, FAIL or TIMEOUT @@ -315,7 +257,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->power_down(); } - /** * @brief Reset the module * @return OK, FAIL or TIMEOUT @@ -324,7 +265,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->reset(); } - /** * @brief Configures the baudrate * @param[in] baud Desired baud rate of the DTE @@ -334,7 +274,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_baud(baud ); } - /** * @brief Force an attempt to connect to a specific operator * @param[in] mode mode of attempt @@ -354,7 +293,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_operator(mode, format, oper ); } - /** * @brief Attach or detach from the GPRS service * @param[in] state 1-attach 0-detach @@ -364,7 +302,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_network_attachment_state(state ); } - /** * @brief Get network attachment state * @param[out] state 1-attached 0-detached @@ -374,7 +311,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_network_attachment_state(state ); } - /** * @brief What mode the radio should be set to * @param[in] state state 1-full 0-minimum ... @@ -384,7 +320,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_radio_state(state ); } - /** * @brief Get current radio state * @param[out] state 1-full 0-minimum ... @@ -394,7 +329,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_radio_state(state ); } - /** * @brief Set network mode * @param[in] mode preferred mode @@ -404,7 +338,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_network_mode(mode ); } - /** * @brief Preferred network mode (CAT-M and/or NB-IoT) * @param[in] mode preferred selection @@ -414,7 +347,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_preferred_mode(mode ); } - /** * @brief Set network bands for CAT-M or NB-IoT * @param[in] mode CAT-M or NB-IoT @@ -426,7 +358,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_network_bands(mode, bands, size ); } - /** * @brief Show network system mode * @param[out] mode current network mode @@ -436,7 +367,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_network_system_mode(mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -446,7 +376,6 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->set_gnss_power_mode(mode ); } - /** * @brief GNSS power control * @param[out] mode power mode (0 - off, 1 - on) @@ -456,18 +385,12 @@ class DCE_gnss : public esp_modem::DCE_T { { return device->get_gnss_power_mode(mode ); } - - - esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps); - esp_modem::command_result get_operator_name(std::string &name) { return device->get_operator_name(name); } }; - - /** * @brief Helper create method which employs the customized DCE factory for building DCE_gnss objects * @return unique pointer of the specific DCE diff --git a/components/esp_modem/generate/include/esp_modem_command_declare_helper.inc b/components/esp_modem/generate/include/esp_modem_command_declare_helper.inc index a8fab511bf..dbd6c0fe84 100644 --- a/components/esp_modem/generate/include/esp_modem_command_declare_helper.inc +++ b/components/esp_modem/generate/include/esp_modem_command_declare_helper.inc @@ -1,34 +1,5 @@ #pragma once -// -//#define INT_IN(name) int name -//#ifdef __cplusplus -//#define STRING_IN(name) const std::string& name -//#define STRING_OUT(name) std::string& name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool& name -//#define INT_OUT(name) int& name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) struct_name& name -//#else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name -//#endif -// -//#define FORWARD_INT_IN(name) name -//#define FORWARD_STRING_IN(name) name -//#define FORWARD_STRING_OUT(name) name -//#define FORWARD_BOOL_IN(name) name -//#define FORWARD_BOOL_OUT(name) name -//#define FORWARD_INT_OUT(name) name -//#define FORWARD_INTEGER_LIST_IN(name) name -//#define FORWARD_STRUCT_OUT(struct_name, name) name -// Utility to count arguments (works for up to two parameters here) #define ESP_MODEM_GET_MACRO(_0, _1, _2, _3, _4, _5, _6, ESP_MODEM_MACRO_NAME, ...) ESP_MODEM_MACRO_NAME #define ESP_MODEM_COMMAND_PARAMS(...) ESP_MODEM_GET_MACRO(_0, ##__VA_ARGS__, ESP_MODEM_HELPER6, ESP_MODEM_HELPER5, ESP_MODEM_HELPER4, ESP_MODEM_HELPER3, ESP_MODEM_HELPER2, ESP_MODEM_HELPER1, ESP_MODEM_HELPER0)(PARAM_, ESP_MODEM_NO_COMMA, ESP_MODEM_NO_COMMA, ##__VA_ARGS__) #define ESP_MODEM_COMMAND_PARAMS_AFTER(...) ESP_MODEM_GET_MACRO(_0, ##__VA_ARGS__, ESP_MODEM_HELPER6, ESP_MODEM_HELPER5, ESP_MODEM_HELPER4, ESP_MODEM_HELPER3, ESP_MODEM_HELPER2, ESP_MODEM_HELPER1, ESP_MODEM_HELPER0)(PARAM_, ESP_MODEM_COMMA, ESP_MODEM_NO_COMMA, ##__VA_ARGS__) @@ -45,14 +16,6 @@ #define PARAM_STRUCT_OUT(struct_name, name) struct_name& name #define PARAM_INT_LIST_IN(name) const int* name #else -//#define STRING_IN(name) const char* name -//#define STRING_OUT(name) char* name -//#define BOOL_IN(name) const bool name -//#define BOOL_OUT(name) bool* name -//#define INT_OUT(name) int* name -//#define INTEGER_LIST_IN(name) const int* name -//#define STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name - #define PARAM_STR_OUT(name) char* name #define PARAM_STR_IN(name) const char* name #define PARAM_INT_OUT(name) int* name @@ -61,8 +24,8 @@ #define PARAM_BOOL_OUT(name) bool* name #define PARAM_STRUCT_OUT(struct_name, name) esp_modem_ ## struct_name ## _t* name #define PARAM_INT_LIST_IN(name) const int* name - #endif + #define FORWARD_STR_OUT(name) name #define FORWARD_STR_IN(name) name #define FORWARD_INT_OUT(name) name diff --git a/components/esp_modem/scripts/generate.sh b/components/esp_modem/scripts/generate.sh index f6f9d8266a..9b87832caa 100755 --- a/components/esp_modem/scripts/generate.sh +++ b/components/esp_modem/scripts/generate.sh @@ -40,11 +40,13 @@ for file in "${files[@]}"; do echo "Processing $in_file" # Process the header and includes -- just paste the content (without expanding) - sed -n '1,/ESP-MODEM command module starts here/p' "$in_file" > "$out_file" + sed -n '1,/ESP-MODEM command module starts here/{/ESP-MODEM command module starts here/d;p}' "$in_file" > "$out_file" # Determine whether to use clang or clang++ based on file extension if [[ $file == *.cpp || $file == *.hpp ]]; then compiler="clang++ -E -P -CC -xc++" + elif [[ $file == *.rst ]]; then + compiler="clang -E -P -xc" else compiler="clang -E -P -CC -xc" fi diff --git a/docs/esp_modem/Doxyfile b/docs/esp_modem/Doxyfile index 6fe470f93f..a516cb848f 100644 --- a/docs/esp_modem/Doxyfile +++ b/docs/esp_modem/Doxyfile @@ -829,8 +829,8 @@ INPUT = \ $(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_terminal.hpp \ $(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_cmux.hpp \ $(PROJECT_PATH)/../components/esp_modem/include/cxx_include/esp_modem_dce.hpp \ - $(PROJECT_PATH)/../docs/esp_modem/en/esp_modem_api_commands.h \ - $(PROJECT_PATH)/../docs/esp_modem/en/esp_modem_dce.hpp + $(PROJECT_PATH)/../docs/esp_modem/command/dce.h \ + $(PROJECT_PATH)/../docs/esp_modem/command/dce.hpp # The last two are generated diff --git a/docs/esp_modem/en/cxx_api_docs.rst b/docs/esp_modem/en/cxx_api_docs.rst index 94fdb94e13..53be3c17a4 100644 --- a/docs/esp_modem/en/cxx_api_docs.rst +++ b/docs/esp_modem/en/cxx_api_docs.rst @@ -33,7 +33,7 @@ Mode switching commands Modem commands -------------- -.. include:: cxx_api_links.rst +.. include:: ../command/dce.rst .. _cpp_destroy: diff --git a/docs/esp_modem/generate/dce.h b/docs/esp_modem/generate/dce.h new file mode 100644 index 0000000000..63fd8ebbb0 --- /dev/null +++ b/docs/esp_modem/generate/dce.h @@ -0,0 +1,6 @@ + +// --- ESP-MODEM command module starts here --- +#include "esp_modem_command_declare_helper.inc" +#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) return_type esp_modem_ ## name (ESP_MODEM_COMMAND_PARAMS(__VA_ARGS__)); + +#include "esp_modem_command_declare.inc" diff --git a/docs/esp_modem/generate/dce.hpp b/docs/esp_modem/generate/dce.hpp new file mode 100644 index 0000000000..5ee2289028 --- /dev/null +++ b/docs/esp_modem/generate/dce.hpp @@ -0,0 +1,16 @@ + +// --- ESP-MODEM command module starts here --- +class esp_modem::DCE : public DCE_T { +public: + using DCE_T::DCE_T; + +#include "esp_modem_command_declare_helper.inc" +#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) \ + return_type name(ESP_MODEM_COMMAND_PARAMS(__VA_ARGS__)); + + +#include "esp_modem_command_declare.inc" + +#undef ESP_MODEM_DECLARE_DCE_COMMAND + +}; diff --git a/docs/esp_modem/generate/dce.rst b/docs/esp_modem/generate/dce.rst new file mode 100644 index 0000000000..4db92dd5c2 --- /dev/null +++ b/docs/esp_modem/generate/dce.rst @@ -0,0 +1,6 @@ + +// --- ESP-MODEM command module starts here --- + +#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, ...) - :cpp:func:`esp_modem::DCE::name` + +#include "esp_modem_command_declare.inc" diff --git a/docs/esp_modem/generate_docs b/docs/esp_modem/generate_docs index 2ca746653c..174acad4bb 100755 --- a/docs/esp_modem/generate_docs +++ b/docs/esp_modem/generate_docs @@ -3,15 +3,14 @@ # Cleanup the generated html rm -rf html docs -# Generate C++ API header of the DCE -cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang++ -E -P -CC -xc++ -I../../components/esp_modem/include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > en/esp_modem_dce.hpp +pushd `pwd` -# Generate C API header of the modem_api.h -cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang -E -P -CC -xc -I../../components/esp_modem/include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > en/esp_modem_api_commands.h +cd ../../components/esp_modem/scripts +./generate.sh ../../docs/esp_modem/generate/dce.rst +./generate.sh ../../docs/esp_modem/generate/dce.hpp +./generate.sh ../../docs/esp_modem/generate/dce.h - -# RST with links to C++ API -cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang -E -P -xc -I../../components/esp_modem/include -DGENERATE_DOCS -DGENERATE_RST_LINKS - | sed 's/NL/\n/g' > en/cxx_api_links.rst +popd build-docs --target esp32 --language en