2023-09-14 00:34:04 -04:00
|
|
|
#pragma once
|
|
|
|
#include "Notification.hpp"
|
|
|
|
#include "memory.h"
|
2023-10-22 14:35:49 -04:00
|
|
|
#include "wifiHandlerInterface.h"
|
2023-09-14 00:34:04 -04:00
|
|
|
#include <WiFi.h>
|
|
|
|
|
2023-10-22 14:35:49 -04:00
|
|
|
class wifiHandler : public wifiHandlerInterface {
|
|
|
|
public:
|
|
|
|
static std::shared_ptr<wifiHandler> getInstance();
|
|
|
|
|
|
|
|
// wifiHandlerInterface Implementation
|
|
|
|
void begin() override;
|
|
|
|
void scan() override;
|
|
|
|
void connect(std::string ssid, std::string password) override;
|
|
|
|
wifiStatus GetStatus() override { return mCurrentStatus; };
|
|
|
|
//
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wifiHandler() = default;
|
|
|
|
static std::shared_ptr<wifiHandler> mInstance;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Function to store the credentials when we have had a
|
|
|
|
* successful connection
|
|
|
|
*/
|
|
|
|
void StoreCredentials();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* @brief Handler for incoming arduino wifi events
|
|
|
|
* @param event - a Wifi event
|
|
|
|
*/
|
|
|
|
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t aEventInfo);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Update Internal status and send out a notification
|
|
|
|
*/
|
|
|
|
void UpdateStatus();
|
|
|
|
wifiStatus mCurrentStatus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Variables used to track wifi connection attempts
|
|
|
|
*/
|
|
|
|
bool mIsConnectionAttempt = false;
|
|
|
|
std::string mConnectionAttemptPassword;
|
|
|
|
std::string mConnectionAttemptSSID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Verified Working User and Pass to Wifi network
|
|
|
|
*/
|
|
|
|
std::string mPassword;
|
|
|
|
std::string mSSID;
|
2023-09-14 00:34:04 -04:00
|
|
|
};
|