From 0529ac97653bc535c5c1db832d258f661d69309c Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 16 May 2022 13:49:54 +0200 Subject: refactor(minion): improve network code readability --- minion/src/wifi_module.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'minion/src/wifi_module.hpp') diff --git a/minion/src/wifi_module.hpp b/minion/src/wifi_module.hpp index 6adaf05..51e90f0 100644 --- a/minion/src/wifi_module.hpp +++ b/minion/src/wifi_module.hpp @@ -14,6 +14,11 @@ constexpr auto REQUEST_METHOD_STR_MAX_LENGTH = 10U; constexpr auto REQUEST_PATH_MAX_LENGTH = 64U; constexpr auto REQUEST_HTTP_VERSION_MAX_LENGTH = 10U; +constexpr auto WIFI_CONNECT_COMMAND_BASE_LENGTH = 7U; +constexpr auto CREATE_TCP_SERVER_COMMAND_BASE_LENGTH = 8U; +constexpr auto CLOSE_CONNECTION_COMMAND_BASE_LENGTH = 51U; +constexpr auto SEND_RESPONSE_COMMAND_BASE_LENGTH = 51U; + constexpr auto ASCII_TO_CHAR = 48U; constexpr auto TIMEOUT_SHORT = 1500U; @@ -23,6 +28,8 @@ constexpr auto TIMEOUT_LONG = 10000U; constexpr auto RESPONSE_HTTP_VERSION = "HTTP/1.1"; constexpr auto RESPONSE_STATUS_CODE_LENGTH = 3U; +constexpr auto NUMBER_BASE = 10U; + enum WifiMode { Station = 1, @@ -116,11 +123,11 @@ private: */ auto _send_serial(const char *command) noexcept -> bool; - int8_t _read_connection_id() noexcept; + auto _read_connection_id() noexcept -> int8_t; - size_t _read_request_data_length() noexcept; + auto _read_request_data_length() noexcept -> size_t; - HTTPRequestMethod _read_request_method(size_t &request_data_length) noexcept; + auto _read_request_method(size_t &request_data_length) noexcept -> HTTPRequestMethod; /** * Reads from the wifi module until it responds with a status. -- cgit v1.2.3-18-g5258