Automatic Curtain  MVP
Software repository for an automatic curtain using stepper motor, TMC2209 and ESP32
Connectivity Class Reference

#include <connectivity.h>

Collaboration diagram for Connectivity:

Public Member Functions

 Connectivity (std::shared_ptr< Logging > &logging, CONFIG_SET::DEVICE_CRED *device_cred)
 Fetches the LED pin from config, setups pin mode, setup WS2812 RGBLED, initializes logger. More...
 
 ~Connectivity ()
 Destroy the Connectivity object. More...
 
void StartOTA ()
 Set the up Arduino OTA. More...
 
void StartEnsureConnectivity (const CONFIG_SET::DEVICE_CRED device_cred)
 Start ensuring connectivity. More...
 
int GetSecLostConnection ()
 Return number of seconds of lost connection. More...
 
void HandleOTA ()
 Regular call function for syncing OTA requests. More...
 
void StopOTA ()
 Disable OTA. More...
 
bool IsConnected ()
 Checks if the device is connected to the WiFi. More...
 
void StartWebpage ()
 Creates a server and starts hosting webpage. More...
 
void StopWebpage ()
 Stops webpage server. More...
 
void StopWiFi ()
 disconnects WiFi More...
 
std::tuple< bool, CONFIG_SET::DEVICE_CREDGetWebpageSubmission ()
 Get the latest submission. More...
 

Private Member Functions

void StartHotspot ()
 Starts wifi hotspot, basically start wifi in soft access point mode. More...
 
void StopHotspot ()
 Stops wifi hotspot. More...
 
void EnsureConnectivity ()
 Check if the device is connected, if not, try to connect it. More...
 
void StopEnsuringConnectivity ()
 Check if the device is connected, if not, try to connect it. More...
 

Private Attributes

std::shared_ptr< Logginglogger_
 
std::unique_ptr< AsyncWebServer > webpage_server_ {nullptr}
 
bool ota_enabled_ = false
 
bool webpage_enabled_ = false
 
bool hotspot_enabled_ = false
 
bool keep_handler_running_ = false
 
bool is_new_submission_available_ = false
 
CONFIG_SET::time_var time_last_connected_
 
CONFIG_SET::DEVICE_CRED webpage_submitted_device_cred_
 
CONFIG_SET::DEVICE_CRED device_cred_
 
std::unique_ptr< std::thread > ensure_conn_thread_ {nullptr}
 
std::mutex webpage_submission_mutex_
 

Constructor & Destructor Documentation

◆ Connectivity()

Connectivity::Connectivity ( std::shared_ptr< Logging > &  logging,
CONFIG_SET::DEVICE_CRED device_cred 
)

Fetches the LED pin from config, setups pin mode, setup WS2812 RGBLED, initializes logger.

◆ ~Connectivity()

Connectivity::~Connectivity ( )

Destroy the Connectivity object.

Here is the call graph for this function:

Member Function Documentation

◆ EnsureConnectivity()

void Connectivity::EnsureConnectivity ( )
private

Check if the device is connected, if not, try to connect it.

Returns
true : wifi is connected
false : failed to connect, device is no longer connected, despite of trying
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSecLostConnection()

int Connectivity::GetSecLostConnection ( )

Return number of seconds of lost connection.

◆ GetWebpageSubmission()

std::tuple< bool, CONFIG_SET::DEVICE_CRED > Connectivity::GetWebpageSubmission ( )

Get the latest submission.

Returns
std::tuple<bool, CONFIG_SET::DEVICE_CRED>: bool returning if there is a new submission available, device_cred: new submission

◆ HandleOTA()

void Connectivity::HandleOTA ( )

Regular call function for syncing OTA requests.

◆ IsConnected()

bool Connectivity::IsConnected ( )

Checks if the device is connected to the WiFi.

Returns
true : if connected
false : otherwise
Here is the caller graph for this function:

◆ StartEnsureConnectivity()

void Connectivity::StartEnsureConnectivity ( const CONFIG_SET::DEVICE_CRED  device_cred)

Start ensuring connectivity.

Here is the call graph for this function:

◆ StartHotspot()

void Connectivity::StartHotspot ( )
private

Starts wifi hotspot, basically start wifi in soft access point mode.

Here is the caller graph for this function:

◆ StartOTA()

void Connectivity::StartOTA ( )

Set the up Arduino OTA.

Here is the call graph for this function:

◆ StartWebpage()

void Connectivity::StartWebpage ( )

Creates a server and starts hosting webpage.

Here is the call graph for this function:

◆ StopEnsuringConnectivity()

void Connectivity::StopEnsuringConnectivity ( )
private

Check if the device is connected, if not, try to connect it.

Returns
true : wifi is connected
false : failed to connect, device is no longer connected, despite of trying
Here is the caller graph for this function:

◆ StopHotspot()

void Connectivity::StopHotspot ( )
private

Stops wifi hotspot.

Here is the caller graph for this function:

◆ StopOTA()

void Connectivity::StopOTA ( )

Disable OTA.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopWebpage()

void Connectivity::StopWebpage ( )

Stops webpage server.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopWiFi()

void Connectivity::StopWiFi ( )

disconnects WiFi

Here is the caller graph for this function:

Member Data Documentation

◆ device_cred_

CONFIG_SET::DEVICE_CRED Connectivity::device_cred_
private

◆ ensure_conn_thread_

std::unique_ptr<std::thread> Connectivity::ensure_conn_thread_ {nullptr}
private

◆ hotspot_enabled_

bool Connectivity::hotspot_enabled_ = false
private

◆ is_new_submission_available_

bool Connectivity::is_new_submission_available_ = false
private

◆ keep_handler_running_

bool Connectivity::keep_handler_running_ = false
private

◆ logger_

std::shared_ptr<Logging> Connectivity::logger_
private

◆ ota_enabled_

bool Connectivity::ota_enabled_ = false
private

◆ time_last_connected_

CONFIG_SET::time_var Connectivity::time_last_connected_
private

◆ webpage_enabled_

bool Connectivity::webpage_enabled_ = false
private

◆ webpage_server_

std::unique_ptr<AsyncWebServer> Connectivity::webpage_server_ {nullptr}
private

◆ webpage_submission_mutex_

std::mutex Connectivity::webpage_submission_mutex_
private

◆ webpage_submitted_device_cred_

CONFIG_SET::DEVICE_CRED Connectivity::webpage_submitted_device_cred_
private

The documentation for this class was generated from the following files: