Skip to content

Commit

Permalink
Fix merge & CI, add example "modem_tcp_client" into CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathandreyer authored and david-cermak committed Jan 23, 2023
1 parent 13bbf7e commit 4d2bd34
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 11 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion components/esp_modem/examples/modem_console/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -359,6 +360,7 @@ extern "C" void app_main(void)
}
return 0;
});
#endif

const struct SetApn {
SetApn(): apn(STR1, nullptr, nullptr, "<apn>", "APN (Access Point Name)") {}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 "../..")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_mqtt_event_id_t>(ESP_EVENT_ANY_ID), mqtt_event_handler, NULL);
esp_mqtt_client_start(mqtt_client);
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion components/esp_modem/src/esp_modem_command_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions components/esp_modem/src/esp_modem_dte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4d2bd34

Please sign in to comment.