Skip to content
Shawn A edited this page Feb 3, 2021 · 7 revisions

This is draft outline for NEW API additions

Public Methods

autoConnect()

autoConnect(char const *apName, char const *apPassword = NULL)

auto connect to saved wifi, or custom, and start config portal on failures

startConfigPortal(char const *apName, char const *apPassword = NULL)

manually start the config portal, autoconnect does this automatically on connect failure

returns bool

startConfigPortal()

auto generates apname

returns bool

stopConfigPortal()

manually stop the config portal if started manually, stop immediatly if non blocking, flag abort if blocking

returns bool

startWebPortal()

manually start the web portal, autoconnect does this automatically on connect failure

stopWebPortal()

manually stop the web portal if started manually

process()

Run webserver processing, if setConfigPortalBlocking(false)

returns bool

getConfigPortalSSID()

get the AP name of the config portal, so it can be used in the callback

returns String

getRSSIasQuality(int RSSI)

_get the wifi RSSI as a percentage quality value _

returns int

resetSettings()

erase wifi credentials

reboot()

reboot esp

disconnect()

disconnect wifi, without persistent saving or erasing

returns bool

erase()

erase(bool opt)

erase esp

returns bool

addParameter(WiFiManagerParameter *p)

adds a custom parameter

returns false on failure_

returns bool

WiFiManagerParameter

getParameters()

returns the list of Parameters

getParametersCount()

returns the Parameters Count

returns int

CALLBACKS

setAPCallback( std::function<void(WiFiManager*)> func )

called after AP mode and config portal has started

setWebServerCallback( std::function<void()> func )

called after webserver has started

setConfigResetCallback( std::function<void()> func )

called when settings reset have been triggered

setSaveConfigCallback( std::function<void()> func )

called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) )

setSaveParamsCallback( std::function<void()> func )

called when saving either params-in-wifi or params page

setPreSaveConfigCallback( std::function<void()> func )

called when saving params-in-wifi or params before anything else happens (eg wifi)

setConfigPortalTimeout(unsigned long seconds)

sets timeout before AP,webserver loop ends and exits even if there has been no setup. useful for devices that failed to connect at some point and got stuck in a webserver loop in seconds setConfigPortalTimeout is a new name for setTimeout, ! not used if setConfigPortalBlocking

setConnectTimeout(unsigned long seconds)

sets timeout for which to attempt connecting, useful if you get a lot of failed connects

REPLACES Timeout(unsigned long seconds)

_ConnectRetries(uint8_t numRetries)

sets number of retries for autoconnect, force retry after wait failure exit

setSaveConnectTimeout(unsigned long seconds)

sets timeout for which to attempt connecting on saves, useful if there are bugs in esp waitforconnectloop

setDebugOutput(bool debug)

toggle debug output

setMinimumSignalQuality(int quality = 8)

set min quality percentage to include in scan, defaults to 8% if not specified

setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn)

sets a custom ip /gateway /subnet configuration

setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn)

sets config for a static IP

setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns)

sets config for a static IP with DNS

setBreakAfterConfig(bool shouldBreak)

if this is set, it will exit after config, even if connection is unsuccessful.

setConfigPortalBlocking(bool shouldBlock)

_if this is set, portal will be blocking and wait until save or exit, _ is false user must manually process() to handle config portal, setConfigPortalTimeout is ignored in this mode, user is responsible for closing configportal

setCustomHeadElement(const char* element)

if this is set, customise style

setRemoveDuplicateAPs(bool removeDuplicates)

if this is true, remove duplicated Access Points - defaut true

setRestorePersistent(bool persistent)

setter for ESP wifi.persistent so we can remember it and restore user preference, as WIFi._persistent is protected

setShowStaticFields(bool alwaysShow)

if true, always show static net inputs, IP, subnet, gateway, else only show if set via setSTAStaticIPConfig

setShowDnsFields(bool alwaysShow)

if true, always show static dns, esle only show if set via setSTAStaticIPConfig

setShowPassword(bool show)

toggle showing the saved wifi password in wifi form, could be a security issue.

setCaptivePortalEnable(bool enabled)

if false, disable captive portal redirection

setAPClientCheck(bool enabled)

if false, timeout captive portal even if a STA client connected to softAP (false), suggest disabling if captiveportal is open

setWebPortalClientCheck(bool enabled)

if true, reset timeout when webclient connects (true), suggest disabling if captiveportal is open

setWiFiAutoReconnect(bool enabled)

if true, enable autoreconnecting

setScanDispPerc(bool enabled)

if true, wifiscan will show percentage instead of quality icons, until we have better templating

setEnableConfigPortal(bool enable)

if true (default) then start the config portal from autoConnect if connection failed

setHostname(const char * hostname)

set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266

returns bool

setShowInfoErase(bool enabled)

show erase wifi onfig button on info page, true

setShowInfoUpdate(bool enabled)

show OTA upload button on info page

setWiFiAPChannel(int32_t channel)

set ap channel

WiFiAPHidden(bool hidden)

set ap hidden

CleanConnect(bool enable)

clean connect, always disconnect before connecting

setMenu(std::vector<const char*>& menu)

setMenu(const char* menu[], uint8_t size)

set custom menu items and order, vector or arr _see menutokens for ids

setParamsPage(bool enable)

add params to its own menu page and remove from wifi, NOT TO BE COMBINED WITH setMenu!

getLastConxResult()

get last connection result, includes autoconnect and wifisave

returns uint8_t

getWLStatusString(uint8_t status)

get a status as string

returns String

getModeString(uint8_t mode)

get wifi mode as string

returns String

getWiFiIsSaved()

check if the module has a saved ap to connect to

returns bool

getWiFiPass(bool persistent = true)

helper to get saved password, if persistent get stored, else get current if connected

returns String

getWiFiSSID(bool persistent = true)

helper to get saved ssid, if persistent get stored, else get current if connected

returns String

debugSoftAPConfig()

debug output the softap config

debugPlatformInfo()

debug output platform info and versioning

htmlEntities(String str)

helper for html

returns String

setCountry(String cc)

set the country code for wifi settings, CN

setClass(String str)

set body class (invert), may be used for hacking in alt classes

setDarkMode(bool enable)

set dark mode via invert class

String getDefaultAPName()

get default ap esp uses , esp_chipid etc

setHttpPort(uint16_t port)

set port of webserver, 80

getConfigPortalActive()

check if config portal is active (true)

returns bool

getWebPortalActive()

check if web portal is active (true)

returns bool

l

Clone this wiki locally