| 
    Doxygen with github
    
   | 
 
A component that manages the WiFi connection. More...
#include <ksWifiConnector.h>
 Inheritance diagram for ksf::comps::ksWifiConnector:Public Member Functions | |
| virtual std::size_t | getInstanceType () const | 
| Retrieves type ID of the object.   | |
| virtual bool | isA (const std::size_t id) const | 
| Checks whether object is of given type.   | |
| ksWifiConnector (const char *hostname, bool savePower=true) | |
| Constructs WiFi connector component.   | |
| virtual | ~ksWifiConnector () | 
| Destructos 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.   | |
  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 | |
| virtual | ~ksRtti ()=default | 
| Destructor.  | |
| 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 std::size_t | getClassType () | 
  Static Public Member Functions inherited from ksf::ksComponent | |
| static std::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 | ||
| 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.  | ||
| } | __attribute__ ((packed)) bitflags | |
| void | setupMacAddress () | |
| Internal method that generates MAC address for the device.   | ||
Protected Attributes | |
| misc::ksSimpleTimer | wifiTimeoutTimer | 
| Wifi timer - long timeout in case of issues.  | |
| misc::ksSimpleTimer | wifiReconnectTimer | 
| Wifi timer - reconnection timeout.  | |
| misc::ksSimpleTimer | wifiIpCheckTimer | 
| Wifi timer - IP check interval.  | |
  Protected Attributes inherited from ksf::ksComponent | |
| ksComponentState::TYPE | componentState { ksComponentState::NotInitialized } | 
| Holds current state of the component.  | |
A component that manages the WiFi connection.
This component handles WiFi connectivity and automatically reconnects in case of disconnection.
Key functionalities include:
| 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::evt::ksEvent< Params >::broadcast(), ksf::misc::ksSimpleTimer::hasTimePassed(), isConnected(), ksf::misc::ksSimpleTimer::restart(), ksf::misc::ksSimpleTimer::triggered(), 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().