Skip to content

Commit 7cddc8c

Browse files
authored
Merge pull request #834 from david-cermak/fix/modem_build_new_gcc
[modem]: Fix to use compatible iterator types for std::search in new gcc
2 parents a8631ee + fac2edb commit 7cddc8c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

components/esp_modem/examples/modem_tcp_client/main/sock_commands_bg96.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -18,14 +18,14 @@ using namespace esp_modem;
1818

1919
command_result net_open(CommandableIf *t)
2020
{
21-
ESP_LOGV(TAG, "%s", __func__ );
21+
ESP_LOGV(TAG, "%s", __func__);
2222
std::string out;
2323
auto ret = dce_commands::generic_get_string(t, "AT+QISTATE?\r", out, 1000);
2424
if (ret != command_result::OK) {
2525
return ret;
2626
}
2727
if (out.find("+QISTATE: 0") != std::string::npos) {
28-
ESP_LOGV(TAG, "%s", out.data() );
28+
ESP_LOGV(TAG, "%s", out.data());
2929
ESP_LOGD(TAG, "Already there");
3030
return command_result::FAIL;
3131
} else if (out.empty()) {
@@ -36,47 +36,47 @@ command_result net_open(CommandableIf *t)
3636

3737
command_result net_close(CommandableIf *t)
3838
{
39-
ESP_LOGV(TAG, "%s", __func__ );
39+
ESP_LOGV(TAG, "%s", __func__);
4040
dce_commands::generic_command(t, "AT+QICLOSE=0\r", "OK", "ERROR", 10000);
4141
esp_modem::Task::Delay(1000);
4242
return dce_commands::generic_command(t, "AT+QIDEACT=1\r", "OK", "ERROR", 40000);
4343
}
4444

4545
command_result tcp_open(CommandableIf *t, const std::string &host, int port, int timeout)
4646
{
47-
ESP_LOGV(TAG, "%s", __func__ );
47+
ESP_LOGV(TAG, "%s", __func__);
4848
std::string ip_open = R"(AT+QIOPEN=1,0,"TCP",")" + host + "\"," + std::to_string(port) + "\r";
4949
auto ret = dce_commands::generic_command(t, ip_open, "+QIOPEN: 0,0", "ERROR", timeout);
5050
if (ret != command_result::OK) {
51-
ESP_LOGE(TAG, "%s Failed", __func__ );
51+
ESP_LOGE(TAG, "%s Failed", __func__);
5252
return ret;
5353
}
5454
return command_result::OK;
5555
}
5656

5757
command_result tcp_close(CommandableIf *t)
5858
{
59-
ESP_LOGV(TAG, "%s", __func__ );
59+
ESP_LOGV(TAG, "%s", __func__);
6060
return dce_commands::generic_command(t, "AT+QICLOSE=0\r", "OK", "ERROR", 10000);
6161
}
6262

6363
command_result tcp_send(CommandableIf *t, uint8_t *data, size_t len)
6464
{
65-
ESP_LOGV(TAG, "%s", __func__ );
65+
ESP_LOGV(TAG, "%s", __func__);
6666
assert(0); // Remove when fix done
6767
return command_result::FAIL;
6868
}
6969

7070
command_result tcp_recv(CommandableIf *t, uint8_t *data, size_t len, size_t &out_len)
7171
{
72-
ESP_LOGV(TAG, "%s", __func__ );
72+
ESP_LOGV(TAG, "%s", __func__);
7373
assert(0); // Remove when fix done
7474
return command_result::FAIL;
7575
}
7676

7777
command_result get_ip(CommandableIf *t, std::string &ip)
7878
{
79-
ESP_LOGV(TAG, "%s", __func__ );
79+
ESP_LOGV(TAG, "%s", __func__);
8080
std::string out;
8181
auto ret = dce_commands::generic_get_string(t, "AT+QIACT?\r", out, 5000);
8282
if (ret != command_result::OK) {
@@ -130,12 +130,15 @@ Responder::ret Responder::recv(uint8_t *data, size_t len)
130130
auto *recv_data = (char *)data;
131131
if (data_to_recv == 0) {
132132
const std::string_view head = "+QIRD: ";
133-
auto head_pos = std::search(recv_data, recv_data + len, head.begin(), head.end());
134-
if (head_pos == recv_data + len) {
133+
const std::string_view recv_data_view = std::string_view(recv_data, len);
134+
auto head_pos_found = recv_data_view.find(head);
135+
if (head_pos_found == std::string_view::npos) {
135136
return ret::FAIL;
136137
}
137138

139+
auto *head_pos = recv_data + head_pos_found;
138140
auto next_nl = (char *)memchr(head_pos + head.size(), '\n', MIN_MESSAGE);
141+
139142
if (next_nl == nullptr) {
140143
return ret::FAIL;
141144
}

components/esp_modem/examples/pppos_client/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ menu "Example Configuration"
185185

186186
config EXAMPLE_MQTT_BROKER_URI
187187
string "MQTT Broker URL"
188-
default "mqtt://mqtt.eclipseprojects.io"
188+
default "mqtt://test.mosquitto.org"
189189
help
190190
URL of the mqtt broker which this example connects to.
191191

components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ CONFIG_COMPILER_CXX_EXCEPTIONS=y
1616
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
1717
CONFIG_EXAMPLE_CLOSE_CMUX_AT_END=y
1818
CONFIG_EXAMPLE_MQTT_TEST_TOPIC="/ci/esp-modem/pppos-client"
19-
CONFIG_BROKER_URI="mqtt://mqtt.eclipseprojects.io"
19+
CONFIG_BROKER_URI="mqtt://test.mosquitto.org"

0 commit comments

Comments
 (0)