diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-13 20:34:47 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-05-13 20:34:47 +0200 |
commit | 7cdad7abace13f834f19219ef91f57698a2429df (patch) | |
tree | ca1a193ec6472b005f9975d065d9178a9104fed7 /minion/src | |
parent | 51682e6475d477ced2427c131ff7e975b7cbe4b9 (diff) |
refactor(minion): rename ResponseStatus to WiFiModuleResponseStatus
Diffstat (limited to 'minion/src')
-rw-r--r-- | minion/src/wifi_module.cpp | 27 | ||||
-rw-r--r-- | minion/src/wifi_module.hpp | 4 |
2 files changed, 17 insertions, 14 deletions
diff --git a/minion/src/wifi_module.cpp b/minion/src/wifi_module.cpp index 8895722..d56e51e 100644 --- a/minion/src/wifi_module.cpp +++ b/minion/src/wifi_module.cpp @@ -29,8 +29,8 @@ void WiFiModule::reset() noexcept const auto response_status = _read(2000U, response); Serial.println( - response_status == ResponseStatus::OK ? "Reset wifi module" - : "Failed to reset wifi module" + response_status == WiFiModuleResponseStatus::OK ? "Reset wifi module" + : "Failed to reset wifi module" ); } @@ -64,7 +64,7 @@ auto WiFiModule::connect_to_wifi(const char *ssid, const char *password) noexcep const auto response_status = _read(20000U, response); - return response_status == ResponseStatus::OK; + return response_status == WiFiModuleResponseStatus::OK; } void WiFiModule::set_wifi_mode(WifiMode wifi_mode) noexcept @@ -125,7 +125,9 @@ void WiFiModule::set_echo_enabled(bool is_enabled) noexcept const auto response_status = _read(1500U, response); - Serial.print(response_status == ResponseStatus::OK ? "Turned " : "Failed to turn "); + Serial.print( + response_status == WiFiModuleResponseStatus::OK ? "Turned " : "Failed to turn " + ); Serial.print(is_enabled ? "on" : "off"); Serial.println(" AT commands echo"); } @@ -164,7 +166,7 @@ auto WiFiModule::test() noexcept -> bool const auto response_status = _read(5000U, response); - if (response_status == ResponseStatus::TIMEOUT) + if (response_status == WiFiModuleResponseStatus::TIMEOUT) { return false; } @@ -195,7 +197,7 @@ auto WiFiModule::get_local_ip(char *local_ip_out) noexcept -> const char * const auto response_status = _read(10000U, buf); - if (response_status != ResponseStatus::OK) + if (response_status != WiFiModuleResponseStatus::OK) { free(buf); @@ -312,7 +314,7 @@ auto WiFiModule::close_connection(size_t connection_id) noexcept -> bool const auto response_status = _read(4000U, response); - if (response_status == ResponseStatus::OK) + if (response_status == WiFiModuleResponseStatus::OK) { Serial.print("Closed connection to "); Serial.println(connection_id); @@ -422,12 +424,13 @@ HTTPRequestMethod WiFiModule::_read_request_method(size_t &request_data_length) return request_method; } -auto WiFiModule::_read(uint64_t timeout, char *response_out) noexcept -> ResponseStatus +auto WiFiModule::_read(uint64_t timeout, char *response_out) noexcept + -> WiFiModuleResponseStatus { const auto start_time = millis(); bool has_end = false; - auto status = ResponseStatus::TIMEOUT; + auto status = WiFiModuleResponseStatus::TIMEOUT; while (!has_end && (start_time + timeout) > millis()) { @@ -439,19 +442,19 @@ auto WiFiModule::_read(uint64_t timeout, char *response_out) noexcept -> Respons if (util::str_ends_with(response_out, "OK")) { - status = ResponseStatus::OK; + status = WiFiModuleResponseStatus::OK; has_end = true; } if (util::str_ends_with(response_out, "ERROR")) { - status = ResponseStatus::ERROR; + status = WiFiModuleResponseStatus::ERROR; has_end = true; } if (util::str_ends_with(response_out, "FAIL")) { - status = ResponseStatus::FAIL; + status = WiFiModuleResponseStatus::FAIL; has_end = true; } } diff --git a/minion/src/wifi_module.hpp b/minion/src/wifi_module.hpp index 55abdfc..b7310bb 100644 --- a/minion/src/wifi_module.hpp +++ b/minion/src/wifi_module.hpp @@ -26,7 +26,7 @@ enum WifiMode SoftAPAndStation = 3 }; -enum ResponseStatus +enum WiFiModuleResponseStatus { OK, FAIL, @@ -124,7 +124,7 @@ private: * @returns The response status. * */ - auto _read(uint64_t timeout, char *response_out) noexcept -> ResponseStatus; + auto _read(uint64_t timeout, char *response_out) noexcept -> WiFiModuleResponseStatus; void _read_to(char *buffer_out, size_t length, char stop_char, uint64_t timeout) noexcept; |