diff --git a/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp b/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp index 6e3729e13..9b732fe50 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_command_library.hpp @@ -55,6 +55,7 @@ command_result power_down_sim70xx(CommandableIf *t); command_result set_network_bands_sim76xx(CommandableIf *t, const std::string &mode, const int *bands, int size); command_result power_down_sim8xx(CommandableIf *t); command_result set_data_mode_sim8xx(CommandableIf *t); +command_result set_pdp_context(CommandableIf *t, PdpContext &pdp, uint32_t timeout_ms); /** * @} diff --git a/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp b/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp index 3c6669b37..cc08c537d 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp @@ -170,6 +170,8 @@ public: */ class BG96: public GenericModule { using GenericModule::GenericModule; +public: + command_result set_pdp_context(PdpContext &pdp) override; }; /** diff --git a/components/esp_modem/src/esp_modem_command_library.cpp b/components/esp_modem/src/esp_modem_command_library.cpp index 3947d70ed..976869e51 100644 --- a/components/esp_modem/src/esp_modem_command_library.cpp +++ b/components/esp_modem/src/esp_modem_command_library.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -261,12 +261,17 @@ command_result set_echo(CommandableIf *t, bool on) return generic_command_common(t, "ATE0\r"); } -command_result set_pdp_context(CommandableIf *t, PdpContext &pdp) +command_result set_pdp_context(CommandableIf *t, PdpContext &pdp, uint32_t timeout_ms) { ESP_LOGV(TAG, "%s", __func__ ); std::string pdp_command = "AT+CGDCONT=" + std::to_string(pdp.context_id) + ",\"" + pdp.protocol_type + "\",\"" + pdp.apn + "\"\r"; - return generic_command_common(t, pdp_command, 150000); + return generic_command_common(t, pdp_command, timeout_ms); +} + +command_result set_pdp_context(CommandableIf *t, PdpContext &pdp) +{ + return set_pdp_context(t, pdp, 1000); } command_result set_data_mode(CommandableIf *t) diff --git a/components/esp_modem/src/esp_modem_modules.cpp b/components/esp_modem/src/esp_modem_modules.cpp index a1d0fc48c..a3c6801e3 100644 --- a/components/esp_modem/src/esp_modem_modules.cpp +++ b/components/esp_modem/src/esp_modem_modules.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -82,4 +82,9 @@ command_result SIM800::set_data_mode() return dce_commands::set_data_mode_sim8xx(dte.get()); } +command_result BG96::set_pdp_context(esp_modem::PdpContext &pdp) +{ + return dce_commands::set_pdp_context(dte.get(), pdp, 300); +} + }