Skip to content

Cellular: AT information response to return false on empty prefix #10084

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
merged 1 commit into from
Mar 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ TEST_F(TestATHandler, test_ATHandler_info_resp)
filehandle_stub_table = NULL;

ATHandler at(&fh1, que, 0, ",");
EXPECT_TRUE(at.info_resp());
EXPECT_TRUE(!at.info_resp());

at.resp_start();
EXPECT_TRUE(!at.info_resp());
Expand Down
6 changes: 3 additions & 3 deletions features/cellular/framework/AT/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ void ATHandler::resp(const char *prefix, bool check_urc)
return;
}

if (prefix && match(prefix, strlen(prefix))) {
if (prefix && strlen(prefix) && match(prefix, strlen(prefix))) {
_prefix_matched = true;
return;
}
Expand All @@ -853,14 +853,14 @@ void ATHandler::resp(const char *prefix, bool check_urc)
// If no match found, look for CRLF and consume everything up to and including CRLF
if (mem_str(_recv_buff, _recv_len, CRLF, CRLF_LENGTH)) {
// If no prefix, return on CRLF - means data to read
if (!prefix) {
if (!prefix || (prefix && !strlen(prefix))) {
return;
}
consume_to_tag(CRLF, true);
} else {
// If no prefix, no CRLF and no more chance to match for OK, ERROR or URC(since max resp length is already in buffer)
// return so data could be read
if (!prefix && ((_recv_len - _recv_pos) >= _max_resp_length)) {
if ((!prefix || (prefix && !strlen(prefix))) && ((_recv_len - _recv_pos) >= _max_resp_length)) {
return;
}
if (!fill_buffer()) {
Expand Down
3 changes: 2 additions & 1 deletion features/cellular/framework/AT/ATHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ class ATHandler {
* If needed, it ends the scope of a previous information response.
* Sets the information response scope if new prefix is found and response scope if prefix is not found.
*
* @return true if new information response is found, false otherwise
* @return true if prefix defined for information response is not empty string and is found,
* false otherwise.
*/
bool info_resp();

Expand Down