Skip to content

Commit 0998f3d

Browse files
committed
fix(modem): Fixed incorrect dial command format
ATD command is used to switch generic device to the data mode by dialing GPRS_SRC. The generic version of the command was incorrect `ATD*99##` (containing extra trailing # char, which is accepted by most devices). Command has been fixed, but the extra #'s been kept for devices that we cannot test (to be fixed in IDFGH-9470). Closes #433
1 parent 577de67 commit 0998f3d

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

components/esp_modem/include/cxx_include/esp_modem_command_library.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ command_result power_down_sim76xx(CommandableIf *t);
5454
command_result power_down_sim70xx(CommandableIf *t);
5555
command_result set_network_bands_sim76xx(CommandableIf *t, const std::string &mode, const int *bands, int size);
5656
command_result power_down_sim8xx(CommandableIf *t);
57-
command_result set_data_mode_sim8xx(CommandableIf *t);
57+
command_result set_data_mode_alt(CommandableIf *t);
5858
command_result set_pdp_context(CommandableIf *t, PdpContext &pdp, uint32_t timeout_ms);
5959

6060
/**

components/esp_modem/include/cxx_include/esp_modem_dce_module.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class SIM7070: public GenericModule {
144144
using GenericModule::GenericModule;
145145
public:
146146
command_result power_down() override;
147+
command_result set_data_mode() override;
148+
147149
};
148150

149151
/**
@@ -162,7 +164,6 @@ class SIM800: public GenericModule {
162164
using GenericModule::GenericModule;
163165
public:
164166
command_result power_down() override;
165-
command_result set_data_mode() override;
166167
};
167168

168169
/**

components/esp_modem/src/esp_modem_command_library.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ command_result set_pdp_context(CommandableIf *t, PdpContext &pdp)
277277
command_result set_data_mode(CommandableIf *t)
278278
{
279279
ESP_LOGV(TAG, "%s", __func__ );
280-
return generic_command(t, "ATD*99##\r", "CONNECT", "ERROR", 5000);
280+
return generic_command(t, "ATD*99#\r", "CONNECT", "ERROR", 5000);
281281
}
282282

283-
command_result set_data_mode_sim8xx(CommandableIf *t)
283+
command_result set_data_mode_alt(CommandableIf *t)
284284
{
285285
ESP_LOGV(TAG, "%s", __func__ );
286-
return generic_command(t, "ATD*99#\r", "CONNECT", "ERROR", 5000);
286+
return generic_command(t, "ATD*99##\r", "CONNECT", "ERROR", 5000);
287287
}
288288

289289
command_result resume_data_mode(CommandableIf *t)

components/esp_modem/src/esp_modem_modules.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -67,6 +67,11 @@ command_result SIM7070::power_down()
6767
return dce_commands::power_down_sim70xx(dte.get());
6868
}
6969

70+
command_result SIM7070::set_data_mode()
71+
{
72+
return dce_commands::set_data_mode_alt(dte.get());
73+
}
74+
7075
command_result SIM7000::power_down()
7176
{
7277
return dce_commands::power_down_sim70xx(dte.get());
@@ -77,11 +82,6 @@ command_result SIM800::power_down()
7782
return dce_commands::power_down_sim8xx(dte.get());
7883
}
7984

80-
command_result SIM800::set_data_mode()
81-
{
82-
return dce_commands::set_data_mode_sim8xx(dte.get());
83-
}
84-
8585
command_result BG96::set_pdp_context(esp_modem::PdpContext &pdp)
8686
{
8787
return dce_commands::set_pdp_context(dte.get(), pdp, 300);

components/esp_modem/test/host_test/main/LoopbackTerm.cpp

Lines changed: 5 additions & 2 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-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -36,7 +36,7 @@ int LoopbackTerm::write(uint8_t *data, size_t len)
3636
} else if (command == "ATO\r") {
3737
response = "ERROR\r\n";
3838
} else if (command.find("ATD") != std::string::npos) {
39-
response = "CONNECT\r\n";
39+
response = "CONNECT\n";
4040
} else if (command.find("AT+CSQ\r") != std::string::npos) {
4141
response = "+CSQ: 123,456\n\r\nOK\r\n";
4242
} else if (command.find("AT+CGMM\r") != std::string::npos) {
@@ -74,6 +74,9 @@ int LoopbackTerm::write(uint8_t *data, size_t len)
7474
}
7575
if (len > 2 && data[0] == 0xf9) { // Simple CMUX responder
7676
// turn the request into a reply -> implements CMUX loopback
77+
// Note: This simple CMUX responder only updates CMUX headers and replaces payload.
78+
// It means that all responses (that we test) must be shorter or equal to the requests
79+
// For example ATD (dial command): sizeof("ATD*99#") >= sizeof("CONNECT");
7780
if (data[2] == 0x3f || data[2] == 0x53) { // SABM command
7881
data[2] = 0x73;
7982
} else if (data[2] == 0xef) { // Generic request

0 commit comments

Comments
 (0)