Doxygen with github
|
A component that manages WiFi connection. More...
#include <ksWifiConnector.h>
Public Member Functions | |
virtual const size_t | getInstanceType () const |
Retrieves type ID of the object. | |
virtual bool | isA (const size_t id) const |
Checks whether object is of given type. | |
ksWifiConnector (const char *hostname, bool savePower=true) | |
Constructs WiFi connector component. | |
bool | init (ksApplication *app) override |
Initializes WiFi connector component. | |
bool | loop (ksApplication *app) override |
Handles WiFi connector component loop logic. | |
bool | isConnected () const |
Returns whether WiFi is connected or not. | |
virtual | ~ksWifiConnector () |
Destructos WiFi connector component. | |
Public Member Functions inherited from ksf::ksComponent | |
virtual bool | postInit (ksApplication *app) |
Method called after component initialization, used to setup references to other components. | |
Public Member Functions inherited from ksf::ksRtti | |
template<typename TType > | |
TType * | as () |
Tries to cast object to the type provided as a template parameter. | |
template<typename TType > | |
const TType * | as () const |
Tries to cast object to the type provided as a template parameter (const version). | |
Static Public Member Functions | |
static const size_t | getClassType () |
Static Public Member Functions inherited from ksf::ksComponent | |
static const size_t | getClassType () |
Public Attributes | |
std::shared_ptr< ksf::evt::ksEvent<> > | onConnected {std::make_shared<ksf::evt::ksEvent<>>()} |
std::shared_ptr< ksf::evt::ksEvent<> > | onDisconnected {std::make_shared<ksf::evt::ksEvent<>>()} |
Protected Member Functions | |
void | setupMacAddress () |
Internal method that generates MAC address for the device. | |
void | wifiConnectedInternal () |
Internal method called on WiFi connection. | |
void | wifiDisconnectedInternal () |
Internal method called on WiFi disconnection. | |
Protected Attributes | ||
ksSimpleTimer | wifiTimeoutTimer { 120000UL } | |
Wifi timer - long timeout in case of issues. | ||
ksSimpleTimer | wifiReconnectTimer { 5000UL } | |
Wifi timer - reconnection timeout. | ||
ksSimpleTimer | wifiIpCheckTimer { 1000UL } | |
Wifi timer - IP check interval. | ||
struct { | ||
bool wasConnected: 1 | ||
True if connected in previous loop. | ||
bool savePower: 1 | ||
True to save power. | ||
bool gotIpAddress: 1 | ||
True if IP address is set. | ||
} | bitflags = {false, true, false} | |
Protected Attributes inherited from ksf::ksComponent | ||
ksComponentState::TYPE | componentState { ksComponentState::NotInitialized } | |
A component that manages WiFi connection.
This component handles WiFi connection, reconnecting automatically in case of disconnection.
There are many things that this component manages:
ksf::comps::ksWifiConnector::ksWifiConnector | ( | const char * | hostname, |
bool | savePower = true ) |
Constructs WiFi connector component.
hostname | Hostname of the device, used also by mDNS service. |
savePower | If set, will put the device in modem sleep mode. This is useful to reduce power consumption, but increases reaction time. |
References savePower, and setupMacAddress().
|
inlinevirtual |
|
overridevirtual |
Initializes WiFi connector component.
app | Pointer to the parent ksApplication. |
Reimplemented from ksf::ksComponent.
|
inlinevirtual |
Checks whether object is of given type.
id | Type ID to check against. |
Reimplemented from ksf::ksComponent.
bool ksf::comps::ksWifiConnector::isConnected | ( | ) | const |
Returns whether WiFi is connected or not.
Referenced by loop().
|
overridevirtual |
Handles WiFi connector component loop logic.
app | Pointer to the parent ksApplication. |
Reimplemented from ksf::ksComponent.
References ksf::ksSimpleTimer::hasTimePassed(), isConnected(), ksf::ksSimpleTimer::restart(), ksf::ksSimpleTimer::triggered(), wifiConnectedInternal(), wifiDisconnectedInternal(), wifiIpCheckTimer, wifiReconnectTimer, and wifiTimeoutTimer.
|
protected |
Internal method that generates MAC address for the device.
This MAC is generated by using original ChipID / MAC, but starts with 0xFA 0xF1 and then there are four Chip ID bytes. 0xFA 0xF1 works like prefix / signature to help identyfying devices in router properties / Wireshark (debugging) etc.
Referenced by ksWifiConnector().