diff --git a/components/esp_modem/idf_component.yml b/components/esp_modem/idf_component.yml index bce3f7785..bdff44e37 100644 --- a/components/esp_modem/idf_component.yml +++ b/components/esp_modem/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.1.22" +version: "0.1.23" description: esp modem url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem dependencies: diff --git a/components/esp_modem/include/esp_private/c_api_wrapper.hpp b/components/esp_modem/include/esp_private/c_api_wrapper.hpp new file mode 100644 index 000000000..4568c0533 --- /dev/null +++ b/components/esp_modem/include/esp_private/c_api_wrapper.hpp @@ -0,0 +1,45 @@ +// Copyright 2022 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "cxx_include/esp_modem_dce_factory.hpp" +#include "esp_modem_c_api_types.h" + +using namespace esp_modem; + +struct esp_modem_dce_wrap { // need to mimic the polymorphic dispatch as CPP uses templated dispatch + enum class modem_wrap_dte_type { UART, VFS, USB } dte_type; + dce_factory::ModemType modem_type; + DCE *dce; +}; + +inline dce_factory::ModemType convert_modem_enum(esp_modem_dce_device_t module) +{ + switch (module) { + case ESP_MODEM_DCE_SIM7600: + return esp_modem::dce_factory::ModemType::SIM7600; + case ESP_MODEM_DCE_SIM7070: + return esp_modem::dce_factory::ModemType::SIM7070; + case ESP_MODEM_DCE_SIM7000: + return esp_modem::dce_factory::ModemType::SIM7000; + case ESP_MODEM_DCE_BG96: + return esp_modem::dce_factory::ModemType::BG96; + case ESP_MODEM_DCE_SIM800: + return esp_modem::dce_factory::ModemType::SIM800; + default: + case ESP_MODEM_DCE_GENETIC: + return esp_modem::dce_factory::ModemType::GenericModule; + } +} diff --git a/components/esp_modem/src/esp_modem_c_api.cpp b/components/esp_modem/src/esp_modem_c_api.cpp index 27473fb5d..0bdae7e4b 100644 --- a/components/esp_modem/src/esp_modem_c_api.cpp +++ b/components/esp_modem/src/esp_modem_c_api.cpp @@ -21,6 +21,7 @@ #include "esp_modem_c_api_types.h" #include "esp_modem_config.h" #include "exception_stub.hpp" +#include "esp_private/c_api_wrapper.hpp" #include "cstring" #ifndef ESP_MODEM_C_API_STR_MAX @@ -35,12 +36,6 @@ size_t strlcpy(char *dest, const char *src, size_t len); // C API definitions using namespace esp_modem; -struct esp_modem_dce_wrap { // need to mimic the polymorphic dispatch as CPP uses templated dispatch - enum class modem_wrap_dte_type { UART, } dte_type; - dce_factory::ModemType modem_type; - DCE *dce; -}; - static inline esp_err_t command_response_to_esp_err(command_result res) { switch (res) { @@ -54,25 +49,6 @@ static inline esp_err_t command_response_to_esp_err(command_result res) return ESP_ERR_INVALID_ARG; } -static inline dce_factory::ModemType convert_modem_enum(esp_modem_dce_device_t module) -{ - switch (module) { - case ESP_MODEM_DCE_SIM7600: - return esp_modem::dce_factory::ModemType::SIM7600; - case ESP_MODEM_DCE_SIM7070: - return esp_modem::dce_factory::ModemType::SIM7070; - case ESP_MODEM_DCE_SIM7000: - return esp_modem::dce_factory::ModemType::SIM7000; - case ESP_MODEM_DCE_BG96: - return esp_modem::dce_factory::ModemType::BG96; - case ESP_MODEM_DCE_SIM800: - return esp_modem::dce_factory::ModemType::SIM800; - default: - case ESP_MODEM_DCE_GENETIC: - return esp_modem::dce_factory::ModemType::GenericModule; - } -} - extern "C" esp_modem_dce_t *esp_modem_new_dev(esp_modem_dce_device_t module, const esp_modem_dte_config_t *dte_config, const esp_modem_dce_config_t *dce_config, esp_netif_t *netif) { auto dce_wrap = new (std::nothrow) esp_modem_dce_wrap;