Skip to content
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 @@ -1052,6 +1052,27 @@ TEST_F(TestATHandler, test_ATHandler_consume_to_stop_tag)

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

at.clear_error();
char table1[] = "\r\n\r\r\r\nOOK\r\n";
at.flush();
filehandle_stub_table = table1;
filehandle_stub_table_pos = 0;
mbed_poll_stub::revents_value = POLLIN;
mbed_poll_stub::int_value = 1;
char buf1[6];
at.resp_start();
EXPECT_TRUE(at.consume_to_stop_tag());

at.clear_error();
char table2[] = "OKOK\r\n";
at.flush();
filehandle_stub_table = table2;
filehandle_stub_table_pos = 0;
mbed_poll_stub::revents_value = POLLIN;
mbed_poll_stub::int_value = 1;
char buf2[6];
EXPECT_TRUE(at.consume_to_stop_tag());
}

TEST_F(TestATHandler, test_ATHandler_set_debug)
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 @@ -926,16 +926,16 @@ bool ATHandler::consume_to_tag(const char *tag, bool consume_tag)
int c = get_char();
if (c == -1) {
break;
} else if (c == tag[match_pos]) {
// compares c against tag at current position and if this match fails
// compares c against tag[0] and also resets match_pos to 0
} else if (c == tag[match_pos] || ((match_pos = 1) && (c == tag[--match_pos]))) {
match_pos++;
if (match_pos == strlen(tag)) {
if (!consume_tag) {
_recv_pos -= strlen(tag);
}
return true;
}
} else if (match_pos) {
match_pos = 0;
}
}
tr_debug("consume_to_tag not found");
Expand Down