summaryrefslogtreecommitdiff
path: root/minion/src/wifi_module.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'minion/src/wifi_module.hpp')
-rw-r--r--minion/src/wifi_module.hpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/minion/src/wifi_module.hpp b/minion/src/wifi_module.hpp
index 3621229..5de898e 100644
--- a/minion/src/wifi_module.hpp
+++ b/minion/src/wifi_module.hpp
@@ -8,6 +8,9 @@ constexpr auto MAX_NETWORK_MODULE_RESPONSE_LENGTH = 128U;
constexpr auto ASCII_TO_CHAR = 48U;
+constexpr auto TIMEOUT_SHORT = 1500U;
+constexpr auto TIMEOUT_LONG = 4000U;
+
enum WifiMode
{
Station = 1,
@@ -23,14 +26,20 @@ enum ResponseStatus
TIMEOUT
};
+struct WiFiModuleOptions
+{
+ uint8_t receive_pin;
+ uint8_t transmit_pin;
+};
+
class WiFiModule
{
public:
- WiFiModule(uint8_t receive_pin, uint8_t transmit_pin) noexcept;
+ explicit WiFiModule(const WiFiModuleOptions &options) noexcept;
void begin(size_t baudrate) noexcept;
- int get_available() noexcept;
+ auto get_available() noexcept -> int;
void reset() noexcept;
@@ -42,7 +51,7 @@ public:
*
* @returns Whether or not it succeeded.
*/
- bool connect(const char *ssid, const char *password) noexcept;
+ auto connect(const char *ssid, const char *password) noexcept -> bool;
void set_wifi_mode(WifiMode wifi_mode) noexcept;
@@ -57,7 +66,7 @@ public:
*
* @returns Whether or not the test succeeded.
*/
- bool test() noexcept;
+ auto test() noexcept -> bool;
/**
* Gets local IP address of the wifi module.
@@ -66,9 +75,9 @@ public:
*
* @returns A pointer to the local IP output buffer.
*/
- const char *get_local_ip(char *local_ip_out) noexcept;
+ auto get_local_ip(char *local_ip_out) noexcept -> const char *;
- bool has_incoming_request() noexcept;
+ auto has_incoming_request() noexcept -> bool;
/**
* Reads a incoming HTTP request.
@@ -77,11 +86,11 @@ public:
*
* @returns The connection ID.
*/
- size_t read_incoming_request(char *raw_request_out) noexcept;
+ auto read_incoming_request(char *raw_request_out) noexcept -> size_t;
- bool close_connection(size_t connection_id) noexcept;
+ auto close_connection(size_t connection_id) noexcept -> bool;
- bool send(size_t connection_id, const char *data);
+ auto send(size_t connection_id, const char *data) noexcept -> bool;
private:
SoftwareSerial _serial;
@@ -93,7 +102,7 @@ private:
*
* @returns Whether or not it succeeded.
*/
- bool _send_serial(const char *command) noexcept;
+ auto _send_serial(const char *command) noexcept -> bool;
/**
* Reads from the wifi module until it responds with a status.
@@ -104,7 +113,7 @@ private:
* @returns The response status.
*
*/
- ResponseStatus _read(uint64_t timeout, char *response_out) noexcept;
+ auto _read(uint64_t timeout, char *response_out) noexcept -> ResponseStatus;
- char _read_byte() noexcept;
+ auto _read_byte() noexcept -> char;
};