From 4d2bd341be0edbbf2d7f02d06db97a43775e493c Mon Sep 17 00:00:00 2001 From: Jonathan Dreyer Date: Mon, 23 Jan 2023 10:08:02 +0100 Subject: [PATCH] Fix merge & CI, add example "modem_tcp_client" into CI --- .github/workflows/target-test.yml | 8 +++++++- .../esp_modem/examples/modem_console/CMakeLists.txt | 3 ++- .../examples/modem_console/main/Kconfig.projbuild | 2 +- .../examples/modem_console/main/modem_console_main.cpp | 2 ++ .../esp_modem/examples/modem_tcp_client/CMakeLists.txt | 3 ++- .../examples/modem_tcp_client/main/modem_client.cpp | 5 +++++ .../examples/simple_cmux_client/CMakeLists.txt | 3 ++- components/esp_modem/src/esp_modem_command_library.cpp | 2 +- components/esp_modem/src/esp_modem_dte.cpp | 10 +++++----- 9 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/target-test.yml b/.github/workflows/target-test.yml index adc64de0eec..b6fa2f37a7e 100644 --- a/.github/workflows/target-test.yml +++ b/.github/workflows/target-test.yml @@ -7,11 +7,17 @@ jobs: strategy: matrix: idf_ver: ["latest", "release-v4.1", "release-v4.2", "release-v4.3", "release-v4.4", "release-v5.0"] - example: ["pppos_client", "modem_console", "ap_to_pppos", "simple_cmux_client"] + example: ["pppos_client", "modem_console", "modem_tcp_client", "ap_to_pppos", "simple_cmux_client"] idf_target: ["esp32"] exclude: - idf_ver: "release-v4.1" example: modem_console + - idf_ver: "release-v4.1" + example: modem_tcp_client + - idf_ver: "release-v4.2" + example: modem_tcp_client + - idf_ver: "release-v4.3" + example: modem_tcp_client - idf_ver: "release-v4.1" example: ap_to_pppos - idf_ver: "release-v4.1" diff --git a/components/esp_modem/examples/modem_console/CMakeLists.txt b/components/esp_modem/examples/modem_console/CMakeLists.txt index 12e4daf0a72..eaf4959a8be 100644 --- a/components/esp_modem/examples/modem_console/CMakeLists.txt +++ b/components/esp_modem/examples/modem_console/CMakeLists.txt @@ -1,6 +1,7 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) +set(CMAKE_CXX_STANDARD 17) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(modem-console) diff --git a/components/esp_modem/examples/modem_console/main/Kconfig.projbuild b/components/esp_modem/examples/modem_console/main/Kconfig.projbuild index 1415229f1b3..e31c9cf85f2 100644 --- a/components/esp_modem/examples/modem_console/main/Kconfig.projbuild +++ b/components/esp_modem/examples/modem_console/main/Kconfig.projbuild @@ -18,7 +18,7 @@ menu "Example Configuration" choice EXAMPLE_MODEM_DEVICE depends on EXAMPLE_SERIAL_CONFIG_UART prompt "Choose supported modem device (DCE)" - default EXAMPLE_MODEM_DEVICE_BG96 + default EXAMPLE_MODEM_DEVICE_SHINY help Select modem device connected to the ESP DTE. config EXAMPLE_MODEM_DEVICE_SHINY diff --git a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp index f2c7a0bc791..ebe4790bbbe 100644 --- a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp +++ b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp @@ -348,6 +348,7 @@ extern "C" void app_main(void) ESP_LOGI(TAG, "Resetting the module..."); CHECK_ERR(dce->reset(), ESP_LOGI(TAG, "OK")); }); +#if CONFIG_EXAMPLE_MODEM_DEVICE_SHINY == 1 const ConsoleCommand HandleURC("urc", "toggle urc handling", no_args, [&](ConsoleCommand * c) { static int cnt = 0; if (++cnt % 2) { @@ -359,6 +360,7 @@ extern "C" void app_main(void) } return 0; }); +#endif const struct SetApn { SetApn(): apn(STR1, nullptr, nullptr, "", "APN (Access Point Name)") {} diff --git a/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt b/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt index b907780de10..2901da17299 100644 --- a/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt +++ b/components/esp_modem/examples/modem_tcp_client/CMakeLists.txt @@ -1,6 +1,7 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) +set(CMAKE_CXX_STANDARD 17) set(EXTRA_COMPONENT_DIRS "../..") diff --git a/components/esp_modem/examples/modem_tcp_client/main/modem_client.cpp b/components/esp_modem/examples/modem_tcp_client/main/modem_client.cpp index fa1a69e7612..842c6ea43d3 100644 --- a/components/esp_modem/examples/modem_tcp_client/main/modem_client.cpp +++ b/components/esp_modem/examples/modem_tcp_client/main/modem_client.cpp @@ -115,8 +115,13 @@ extern "C" void app_main(void) dce->init(1883); esp_mqtt_client_config_t mqtt_config = {}; +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) mqtt_config.broker.address.uri = "mqtt://127.0.0.1"; mqtt_config.session.message_retransmit_timeout = 10000; +#else + mqtt_config.uri = "mqtt://127.0.0.1"; + mqtt_config.message_retransmit_timeout = 10000; +#endif esp_mqtt_client_handle_t mqtt_client = esp_mqtt_client_init(&mqtt_config); esp_mqtt_client_register_event(mqtt_client, static_cast(ESP_EVENT_ANY_ID), mqtt_event_handler, NULL); esp_mqtt_client_start(mqtt_client); diff --git a/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt b/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt index 6547c14501a..52ed43441ad 100644 --- a/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt +++ b/components/esp_modem/examples/simple_cmux_client/CMakeLists.txt @@ -1,6 +1,7 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) +set(CMAKE_CXX_STANDARD 17) set(EXTRA_COMPONENT_DIRS "../.." $ENV{IDF_PATH}/examples/cxx/experimental/experimental_cpp_component) diff --git a/components/esp_modem/src/esp_modem_command_library.cpp b/components/esp_modem/src/esp_modem_command_library.cpp index 3947d70ed74..4470e3062f6 100644 --- a/components/esp_modem/src/esp_modem_command_library.cpp +++ b/components/esp_modem/src/esp_modem_command_library.cpp @@ -51,7 +51,7 @@ command_result generic_command(CommandableIf *t, const std::string &command, return generic_command(t, command, pass, fail, timeout_ms); } -static command_result generic_get_string(CommandableIf *t, const std::string &command, std::string_view &output, uint32_t timeout_ms = 500) +command_result generic_get_string(CommandableIf *t, const std::string &command, std::string_view &output, uint32_t timeout_ms) { ESP_LOGV(TAG, "%s", __func__ ); return t->command(command, [&](uint8_t *data, size_t len) { diff --git a/components/esp_modem/src/esp_modem_dte.cpp b/components/esp_modem/src/esp_modem_dte.cpp index f51ca69c2bb..a1d9bde2fa3 100644 --- a/components/esp_modem/src/esp_modem_dte.cpp +++ b/components/esp_modem/src/esp_modem_dte.cpp @@ -194,25 +194,25 @@ int DTE::write(uint8_t *data, size_t len) int DTE::write_cmd(uint8_t *data, size_t len) { - return command_term->write(data, len); + return primary_term->write(data, len); } void DTE::on_read(got_line_cb on_read_cb) { if (on_read_cb == nullptr) { - command_term->set_read_cb(nullptr); + primary_term->set_read_cb(nullptr); internal_lock.unlock(); return; } internal_lock.lock(); - command_term->set_read_cb([this, on_read_cb](uint8_t *data, size_t len) { + primary_term->set_read_cb([this, on_read_cb](uint8_t *data, size_t len) { if (!data) { data = buffer.get(); - len = command_term->read(data, buffer.size); + len = primary_term->read(data, buffer.size); } auto res = on_read_cb(data, len); if (res == command_result::OK || res == command_result::FAIL) { - command_term->set_read_cb(nullptr); + primary_term->set_read_cb(nullptr); internal_lock.unlock(); return true; }