FabGL2 2.0.0
ESP32 Display Controller and Graphics Library for ESP-IDF
Loading...
Searching...
No Matches
WiFiConnection Class Reference

WiFi connection helper class. More...

#include <netutils.h>

Public Member Functions

WiFiConnectionState connect (char const *ssid, char const *password, int waitConnectionTimeOutMS=10000)
 Tries to connect to a WiFi network.
void disconnect ()
 Disconnects from the WiFi network.
esp_ip4_addr_t const & gateway ()
 Returns the gateway address.
esp_ip4_addr_t const & IP ()
 Returns the IP address.
char const * IPString ()
 Returns the current IP address as a dotted string.
esp_ip4_addr_t const & netmask ()
 Returns the netmask.
int RSSI ()
 Returns the RSSI (signal strength in dBm) of the connected access point, or 0 if not connected.
char const * SSID ()
 Returns the SSID of the network.
WiFiConnectionState state ()
 Returns the connection state.

Static Public Member Functions

static WiFiConnection * instance ()
 Returns the global (last) connection object, if any.

Detailed Description

WiFi connection helper class.

WiFiConnection establishes and maintains a connection with a WiFi network.

Example:

auto nc = fabgl::WiFiConnection();
if (nc.connect("MySSID", "MyPassword")) {
  Term.printf("Connected. IP:%d.%d.%d.%d NMASK:%d.%d.%d.%d GATEW:%d.%d.%d.%d\r\n", IP2STR(&nc.IP()), IP2STR(&nc.netmask()), IP2STR(&nc.gateway()));

  // ...use the network (e.g. with fabgl::HTTPRequest)

  // now disconnect
  nc.disconnect();
}

Definition at line 163 of file netutils.h.


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