Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Additional Method in ESP Modem: Handling Larger AT Command Responses (IDFGH-13338) #624

Closed
srikanthpalvai opened this issue Jul 26, 2024 · 5 comments

Comments

@srikanthpalvai
Copy link

Is your feature request related to a problem?

When issuing the commands AT+CMGF=0 and AT+CMGL=4, the response results in more data than usual. To handle this, we need an additional method that takes max_len as an argument.

Describe the solution you'd like.

This method allows the user to specify the maximum length of the output buffer, ensuring that larger responses can be handled appropriately.

extern "C" esp_err_t esp_modem_at_raw_ext(esp_modem_dce_t *dce_wrap, const char *cmd, char *p_out, const char *pass, const char *fail, int timeout, size_t max_len)
{
if (dce_wrap == nullptr || dce_wrap->dce == nullptr) {
return ESP_ERR_INVALID_ARG;
}
std::string out;
auto ret = command_response_to_esp_err(dce_wrap->dce->at_raw(cmd, out, pass, fail, timeout));
if ((p_out != NULL) && (!out.empty())) {
strlcpy(p_out, out.c_str(), max_len);
}
return ret;
}

Describe alternatives you've considered.

#define STR_MAX 1024

esp_modem_dce_t *dce_wrap;
char response[ESP_MODEM_C_API_STR_MAX];
esp_err_t ret = esp_modem_at_raw_ext(dce_wrap, "AT+CMGL=4", response, "OK", "ERROR", 1000, STR_MAX );
if (ret == ESP_OK) {
// Process the response
}

Additional context.

No response

@github-actions github-actions bot changed the title Request for Additional Method in ESP Modem: Handling Larger AT Command Responses Request for Additional Method in ESP Modem: Handling Larger AT Command Responses (IDFGH-13338) Jul 26, 2024
@srikanthpalvai
Copy link
Author

@david-cermak
Could you please have a look on it.

@david-cermak
Copy link
Collaborator

Yes, I'll look into it, planning on some maintenance work and the v1.2 release in about two weeks.
Meantime, we're open for ideas/suggestions and PRs are welcome.

@srikanthpalvai
Copy link
Author

Hi @david-cermak

I was not able to create a pull request for esp-modem
but here is the patch file it will help you.
0001-Add-max_len-parameter-to-esp_modem_at_raw_ext-for-bu.patch

@srikanthpalvai
Copy link
Author

srikanthpalvai commented Aug 7, 2024

Hi @david-cermak
I have fixed it with below logic. Added it in the project root CMakeLists.txt

set(ESP_MODEM_C_API_STR_MAX_DEFAULT 512)
target_compile_definitions(__idf_espressif__esp_modem PUBLIC ESP_MODEM_C_API_STR_MAX=${ESP_MODEM_C_API_STR_MAX_DEFAULT})

even though it's better to have specific method to pass the max_length.
where i have provided it the patch file

@david-cermak
Copy link
Collaborator

Fixed in #649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants