summaryrefslogtreecommitdiff
path: root/minion/src/wifi_module.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-05-30 13:11:38 +0200
committerHampusM <hampus@hampusmat.com>2022-05-30 13:11:38 +0200
commitec20c707ea677c9b2c8e585b78c9837a2f6e7372 (patch)
tree6499124c7f7cd1d3da12afb60ab9f65f7782d228 /minion/src/wifi_module.cpp
parentd95ce9a08977b82fe6f331f110c218044b9f41cb (diff)
refactor(minion): make reading wifi module more reliable
Diffstat (limited to 'minion/src/wifi_module.cpp')
-rw-r--r--minion/src/wifi_module.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/minion/src/wifi_module.cpp b/minion/src/wifi_module.cpp
index 5174168..953e9fa 100644
--- a/minion/src/wifi_module.cpp
+++ b/minion/src/wifi_module.cpp
@@ -498,22 +498,29 @@ auto WiFiModule::_read(uint64_t timeout, char *response_out) noexcept
{
char character = _read_byte();
+ if (has_end)
+ {
+ continue;
+ }
+
+ const auto end_pos = index + 1U;
+
response_out[index] = character;
- response_out[index + 1] = '\0';
+ response_out[end_pos] = '\0';
- if (util::str_ends_with(response_out, "OK"))
+ if (util::str_ends_with(response_out, end_pos, "OK"))
{
status = WiFiModuleResponseStatus::OK;
has_end = true;
}
- if (util::str_ends_with(response_out, "ERROR"))
+ if (util::str_ends_with(response_out, end_pos, "ERROR"))
{
status = WiFiModuleResponseStatus::ERROR;
has_end = true;
}
- if (util::str_ends_with(response_out, "FAIL"))
+ if (util::str_ends_with(response_out, end_pos, "FAIL"))
{
status = WiFiModuleResponseStatus::FAIL;
has_end = true;