|
roo_wifi
API Documentation for roo_wifi
|
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 Network & | currentNetwork () const |
| Returns the current network (may be empty if disconnected). | |
| const Network * | lookupNetwork (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 Network & | otherNetwork (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 |
High-level Wi-Fi controller that manages scanning and connections.
Definition at line 17 of file controller.h.
| 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().
| roo_wifi::Controller::~Controller | ( | ) |
Destroys the controller and detaches listeners.
Definition at line 42 of file controller.cpp.
References roo_wifi::Interface::removeEventListener().
| void roo_wifi::Controller::addListener | ( | Listener * | listener | ) |
Adds a listener for controller events.
Definition at line 54 of file controller.cpp.
| 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().
| 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().
| bool roo_wifi::Controller::connect | ( | const std::string & | ssid, |
| const std::string & | passwd | ||
| ) |
Connects to the specified SSID/password.
Definition at line 157 of file controller.cpp.
References roo_wifi::Interface::connect(), roo_wifi::Store::getDefaultSSID(), roo_wifi::Store::getPassword(), lookupNetwork(), roo_wifi::Controller::Network::open, roo_wifi::Controller::Network::rssi, roo_wifi::Store::setDefaultSSID(), roo_wifi::Store::setPassword(), and roo_wifi::WL_DISCONNECTED.
| 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.
| ConnectionStatus roo_wifi::Controller::currentNetworkStatus | ( | ) | const |
Returns the connection status of the current network.
Definition at line 80 of file controller.cpp.
| void roo_wifi::Controller::disconnect | ( | ) |
Disconnects the current connection.
Definition at line 179 of file controller.cpp.
References roo_wifi::Interface::disconnect().
| 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().
| 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().
|
inline |
Returns true when a connection is in progress.
Definition at line 84 of file controller.h.
|
inline |
Returns true when the interface is enabled.
Definition at line 81 of file controller.h.
|
inline |
Returns true when the current scan has completed.
Definition at line 79 of file controller.h.
References roo_wifi::Interface::scanCompleted().
| 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().
| void roo_wifi::Controller::notifyEnableChanged | ( | ) |
Notifies listeners that enable state changed.
Definition at line 116 of file controller.cpp.
Referenced by begin(), and toggleEnabled().
| 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.
| 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.
| void roo_wifi::Controller::pause | ( | ) |
Temporarily disables periodic refresh and event processing.
Definition at line 127 of file controller.cpp.
Referenced by toggleEnabled().
| void roo_wifi::Controller::removeListener | ( | Listener * | listener | ) |
Removes a previously added listener.
Definition at line 58 of file controller.cpp.
| 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().
| 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().
| 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().
| 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().
|
friend |
Definition at line 138 of file controller.h.