TinyWifiDongle 0.1.0
Header-only USB WiFi dongle for Arduino
Loading...
Searching...
No Matches
TinyWifiDongleSetup Class Reference

Finds out which WiFi network to join: from flash, or from the user through a setup page. More...

#include <TinyWifiDongleSetup.h>

Public Member Functions

 TinyWifiDongleSetup (const char *setupNetwork="TinyWifiDongle-Setup", const char *setupPassword=nullptr)
 The setup network is called setupNetwork; setupPassword (at least 8 characters) protects it, nullptr leaves it open.
void setForgetWindow (uint32_t ms)
 How long, after a start, the BOOT button (ESP32) or BOOTSEL button (Pico) forgets the saved network; 0 switches the button off. Default 3000.
void setJoinTimeout (uint32_t ms)
 How long a start may take to join the network before the saved network is forgotten and the setup opens again; 0 = never. Default 60000.
void begin ()
 Loads the saved network, or opens the setup and blocks until the user has entered one.
const char * ssid () const
 Name of the network to join; valid after begin().
const char * password () const
 Password of the network to join, nullptr for an open network; valid after begin().
void forget ()
 Removes the saved network; the next start opens the setup.
void update (bool connected)
 Call regularly with TinyWifiDongle::isWifiConnected(). If the board has not joined the network within the join timeout of a start, the saved network is forgotten and the board restarts, so that the setup opens again.

Detailed Description

Finds out which WiFi network to join: from flash, or from the user through a setup page.

begin() uses the network saved in flash. If there is none, the board opens its own WiFi network (the "setup network"); a phone or laptop that joins it is led to a page on which the user picks a network and enters the password. The choice is saved in flash, so the next start needs no setup.

The setup page needs the board to have an IP address, which the bridge of TinyWifiDongle never has. So the setup runs first and the dongle takes over the WiFi chip afterwards; the USB adapter does not exist while the setup runs.

void setup() {
wifiSetup.begin();
dongle.begin(wifiSetup.ssid(), wifiSetup.password());
}
void loop() {
bool connected = dongle.isWifiConnected();
wifiSetup.update(connected);
delay(connected ? 1000 : 100);
}
TinyWifiDongleSetup(const char *setupNetwork="TinyWifiDongle-Setup", const char *setupPassword=nullptr)
The setup network is called setupNetwork; setupPassword (at least 8 characters) protects it,...
void update(bool connected)
Call regularly with TinyWifiDongle::isWifiConnected(). If the board has not joined the network within...
void begin()
Loads the saved network, or opens the setup and blocks until the user has entered one.
const char * ssid() const
Name of the network to join; valid after begin().
const char * password() const
Password of the network to join, nullptr for an open network; valid after begin().
Shares the microcontroller's WiFi connection with a USB host.
bool isWifiConnected()
True when the MCU is associated with the WiFi access point.
bool begin(const char *ssid, const char *password=nullptr)
Join ssid and expose the connection over USB.

Definition at line 41 of file TinyWifiDongleSetup.h.

Constructor & Destructor Documentation

◆ TinyWifiDongleSetup()

TinyWifiDongleSetup::TinyWifiDongleSetup ( const char * setupNetwork = "TinyWifiDongle-Setup",
const char * setupPassword = nullptr )
inlineexplicit

The setup network is called setupNetwork; setupPassword (at least 8 characters) protects it, nullptr leaves it open.

Definition at line 44 of file TinyWifiDongleSetup.h.

Member Function Documentation

◆ begin()

void TinyWifiDongleSetup::begin ( )
inline

Loads the saved network, or opens the setup and blocks until the user has entered one.

Definition at line 54 of file TinyWifiDongleSetup.h.

◆ forget()

void TinyWifiDongleSetup::forget ( )
inline

Removes the saved network; the next start opens the setup.

Definition at line 78 of file TinyWifiDongleSetup.h.

◆ password()

const char * TinyWifiDongleSetup::password ( ) const
inline

Password of the network to join, nullptr for an open network; valid after begin().

Definition at line 75 of file TinyWifiDongleSetup.h.

◆ setForgetWindow()

void TinyWifiDongleSetup::setForgetWindow ( uint32_t ms)
inline

How long, after a start, the BOOT button (ESP32) or BOOTSEL button (Pico) forgets the saved network; 0 switches the button off. Default 3000.

Definition at line 48 of file TinyWifiDongleSetup.h.

◆ setJoinTimeout()

void TinyWifiDongleSetup::setJoinTimeout ( uint32_t ms)
inline

How long a start may take to join the network before the saved network is forgotten and the setup opens again; 0 = never. Default 60000.

Definition at line 51 of file TinyWifiDongleSetup.h.

◆ ssid()

const char * TinyWifiDongleSetup::ssid ( ) const
inline

Name of the network to join; valid after begin().

Definition at line 72 of file TinyWifiDongleSetup.h.

◆ update()

void TinyWifiDongleSetup::update ( bool connected)
inline

Call regularly with TinyWifiDongle::isWifiConnected(). If the board has not joined the network within the join timeout of a start, the saved network is forgotten and the board restarts, so that the setup opens again.

Definition at line 81 of file TinyWifiDongleSetup.h.


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