Skip to content

Fix 10 second delay in WiFiClient read methods when no data is available to read #458

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libraries/WiFiS3/src/Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_

sized_read_size = atoi(data_res.c_str());
data_res.clear();
if (sized_read_size == 0) {
state = at_parse_state_t::Res;
}
Copy link
Contributor

@andreagilardoni andreagilardoni Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the state transition at line 297 and keep the state change next to each other. This will improve the readability.

Suggested change
if (sized_read_size == 0) {
state = at_parse_state_t::Res;
}
if (sized_read_size != 0) {
state = at_parse_state_t::Sized;
} else {
state = at_parse_state_t::Res;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good suggestion - I have added another commit to address.

} else if(c == '\r') {
state = at_parse_state_t::ResWaitLF;
} else if(c == '\n') {
Expand Down
Loading