roo_wifi
API Documentation for roo_wifi
Loading...
Searching...
No Matches
roo_wifi::Controller Class Reference

High-level Wi-Fi controller that manages scanning and connections. More...

#include <controller.h>

Data Structures

class  Listener
 Listener for controller events. More...
 
struct  Network
 Summary of a scanned network. More...
 

Public Member Functions

 Controller (Store &store, Interface &interface, roo_scheduler::Scheduler &scheduler)
 Creates a controller using the provided store, interface, and scheduler.
 
 ~Controller ()
 Destroys the controller and detaches listeners.
 
void begin ()
 Initializes the controller and registers for interface events.
 
void addListener (Listener *listener)
 Adds a listener for controller events.
 
void removeListener (Listener *listener)
 Removes a previously added listener.
 
int otherScannedNetworksCount () const
 Returns the number of non-current networks in the scan list.
 
const NetworkcurrentNetwork () const
 Returns the current network (may be empty if disconnected).
 
const NetworklookupNetwork (const std::string &ssid) const
 Returns a network by SSID, or nullptr if not found.
 
ConnectionStatus currentNetworkStatus () const
 Returns the connection status of the current network.
 
const NetworkotherNetwork (int idx) const
 Returns the ith non-current network in the scan list.
 
bool startScan ()
 Starts a scan. Returns false if a scan could not be started.
 
bool isScanCompleted () const
 Returns true when the current scan has completed.
 
bool isEnabled () const
 Returns true when the interface is enabled.
 
bool isConnecting () const
 Returns true when a connection is in progress.
 
void toggleEnabled ()
 Toggles the enabled/disabled state and persists it in the store.
 
void notifyEnableChanged ()
 Notifies listeners that enable state changed.
 
bool getStoredPassword (const std::string &ssid, std::string &passwd) const
 Looks up a stored password for the given SSID.
 
void pause ()
 Temporarily disables periodic refresh and event processing.
 
void resume ()
 Resumes periodic refresh and event processing.
 
void setPassword (const std::string &ssid, const std::string &passwd)
 Stores a password for the given SSID.
 
bool connect ()
 Connects using stored SSID/password values.
 
bool connect (const std::string &ssid, const std::string &passwd)
 Connects to the specified SSID/password.
 
void disconnect ()
 Disconnects the current connection.
 
void forget (const std::string &ssid)
 Forgets the password and SSID association.
 

Friends

class WifiListener
 

Detailed Description

High-level Wi-Fi controller that manages scanning and connections.

Definition at line 17 of file controller.h.

Constructor & Destructor Documentation

◆ Controller()

roo_wifi::Controller::Controller ( Store store,
Interface interface,
roo_scheduler::Scheduler &  scheduler 
)

Creates a controller using the provided store, interface, and scheduler.

Definition at line 26 of file controller.cpp.

References startScan().

◆ ~Controller()

roo_wifi::Controller::~Controller ( )

Destroys the controller and detaches listeners.

Definition at line 42 of file controller.cpp.

References roo_wifi::Interface::removeEventListener().

Member Function Documentation

◆ addListener()

void roo_wifi::Controller::addListener ( Listener listener)

Adds a listener for controller events.

Definition at line 54 of file controller.cpp.

◆ begin()

void roo_wifi::Controller::begin ( )

Initializes the controller and registers for interface events.

Definition at line 44 of file controller.cpp.

References roo_wifi::Interface::addEventListener(), connect(), roo_wifi::Store::getDefaultSSID(), roo_wifi::Store::getIsInterfaceEnabled(), and notifyEnableChanged().

◆ connect() [1/2]

bool roo_wifi::Controller::connect ( )

Connects using stored SSID/password values.

Definition at line 150 of file controller.cpp.

References connect(), roo_wifi::Store::getDefaultSSID(), and roo_wifi::Store::getPassword().

Referenced by begin(), and connect().

◆ connect() [2/2]

bool roo_wifi::Controller::connect ( const std::string &  ssid,
const std::string &  passwd 
)

◆ currentNetwork()

const Controller::Network & roo_wifi::Controller::currentNetwork ( ) const

Returns the current network (may be empty if disconnected).

Definition at line 68 of file controller.cpp.

◆ currentNetworkStatus()

ConnectionStatus roo_wifi::Controller::currentNetworkStatus ( ) const

Returns the connection status of the current network.

Definition at line 80 of file controller.cpp.

◆ disconnect()

void roo_wifi::Controller::disconnect ( )

Disconnects the current connection.

Definition at line 179 of file controller.cpp.

References roo_wifi::Interface::disconnect().

◆ forget()

void roo_wifi::Controller::forget ( const std::string &  ssid)

Forgets the password and SSID association.

Definition at line 184 of file controller.cpp.

References roo_wifi::Store::clearDefaultSSID(), roo_wifi::Store::clearPassword(), and roo_wifi::Store::getDefaultSSID().

◆ getStoredPassword()

bool roo_wifi::Controller::getStoredPassword ( const std::string &  ssid,
std::string &  passwd 
) const

Looks up a stored password for the given SSID.

Definition at line 122 of file controller.cpp.

References roo_wifi::Store::getPassword().

◆ isConnecting()

bool roo_wifi::Controller::isConnecting ( ) const
inline

Returns true when a connection is in progress.

Definition at line 84 of file controller.h.

◆ isEnabled()

bool roo_wifi::Controller::isEnabled ( ) const
inline

Returns true when the interface is enabled.

Definition at line 81 of file controller.h.

◆ isScanCompleted()

bool roo_wifi::Controller::isScanCompleted ( ) const
inline

Returns true when the current scan has completed.

Definition at line 79 of file controller.h.

References roo_wifi::Interface::scanCompleted().

◆ lookupNetwork()

const Controller::Network * roo_wifi::Controller::lookupNetwork ( const std::string &  ssid) const

Returns a network by SSID, or nullptr if not found.

Definition at line 72 of file controller.cpp.

Referenced by connect().

◆ notifyEnableChanged()

void roo_wifi::Controller::notifyEnableChanged ( )

Notifies listeners that enable state changed.

Definition at line 116 of file controller.cpp.

Referenced by begin(), and toggleEnabled().

◆ otherNetwork()

const Controller::Network & roo_wifi::Controller::otherNetwork ( int  idx) const

Returns the ith non-current network in the scan list.

Definition at line 84 of file controller.cpp.

◆ otherScannedNetworksCount()

int roo_wifi::Controller::otherScannedNetworksCount ( ) const

Returns the number of non-current networks in the scan list.

Definition at line 62 of file controller.cpp.

◆ pause()

void roo_wifi::Controller::pause ( )

Temporarily disables periodic refresh and event processing.

Definition at line 127 of file controller.cpp.

Referenced by toggleEnabled().

◆ removeListener()

void roo_wifi::Controller::removeListener ( Listener listener)

Removes a previously added listener.

Definition at line 58 of file controller.cpp.

◆ resume()

void roo_wifi::Controller::resume ( )

Resumes periodic refresh and event processing.

Definition at line 129 of file controller.cpp.

References roo_wifi::Interface::scanCompleted(), and startScan().

Referenced by toggleEnabled().

◆ setPassword()

void roo_wifi::Controller::setPassword ( const std::string &  ssid,
const std::string &  passwd 
)

Stores a password for the given SSID.

Definition at line 145 of file controller.cpp.

References roo_wifi::Store::setPassword().

◆ startScan()

bool roo_wifi::Controller::startScan ( )

Starts a scan. Returns false if a scan could not be started.

Definition at line 91 of file controller.cpp.

References roo_wifi::Interface::startScan().

Referenced by Controller(), and resume().

◆ toggleEnabled()

void roo_wifi::Controller::toggleEnabled ( )

Toggles the enabled/disabled state and persists it in the store.

Definition at line 101 of file controller.cpp.

References roo_wifi::Interface::disconnect(), notifyEnableChanged(), pause(), resume(), and roo_wifi::Store::setIsInterfaceEnabled().

Friends And Related Symbol Documentation

◆ WifiListener

friend class WifiListener
friend

Definition at line 138 of file controller.h.


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