1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00
esp8266/doc/esp8266wifi/generic-class.rst
2018-08-29 01:39:09 -04:00

3.4 KiB

orphan

Generic Class

Methods and properties described in this section are specific to ESP8266. They are not covered in Arduino WiFi library documentation. Before they are fully documented please refer to information below.

onEvent

void  onEvent (WiFiEventCb cb, WiFiEvent_t event=WIFI_EVENT_ANY) __attribute__((deprecated))

To see how to use onEvent please check example sketch WiFiClientEvents.ino available inside examples folder of the ESP8266WiFi library.

WiFiEventHandler

WiFiEventHandler  onStationModeConnected (std::function< void(const WiFiEventStationModeConnected &)>)
WiFiEventHandler  onStationModeDisconnected (std::function< void(const WiFiEventStationModeDisconnected &)>)
WiFiEventHandler  onStationModeAuthModeChanged (std::function< void(const WiFiEventStationModeAuthModeChanged &)>)
WiFiEventHandler  onStationModeGotIP (std::function< void(const WiFiEventStationModeGotIP &)>)
WiFiEventHandler  onStationModeDHCPTimeout (std::function< void(void)>)
WiFiEventHandler  onSoftAPModeStationConnected (std::function< void(const WiFiEventSoftAPModeStationConnected &)>)
WiFiEventHandler  onSoftAPModeStationDisconnected (std::function< void(const WiFiEventSoftAPModeStationDisconnected &)>)

To see a sample application with WiFiEventHandler, please check separate section with examples ➡️ dedicated specifically to the Generic Class..

persistent

WiFi.persistent(persistent)

ESP8266 is able to reconnect to the last used Wi-Fi network or establishes the same Access Point upon power up or reset. By default, these settings are written to specific sectors of flash memory every time they are changed in WiFi.begin(ssid, passphrase) or WiFi.softAP(ssid, passphrase, channel), and when WiFi.disconnect or WiFi.softAPdisconnect is invoked. Frequently calling these functions could cause wear on the flash memory (see issue #1054).

Once WiFi.persistent(false) is called, WiFi.begin, WiFi.disconnect, WiFi.softAP, or WiFi.softAPdisconnect only changes the current in-memory Wi-Fi settings, and does not affect the Wi-Fi settings stored in flash memory.

mode

WiFi.mode(m)
WiFi.getMode()
  • WiFi.mode(m): set mode to WIFI_AP, WIFI_STA, WIFI_AP_STA or WIFI_OFF
  • WiFi.getMode(): return current Wi-Fi mode (one out of four modes above)

Other Function Calls

int32_t  channel (void)
bool  setSleepMode (WiFiSleepType_t type)
WiFiSleepType_t  getSleepMode ()
bool  setPhyMode (WiFiPhyMode_t mode)
WiFiPhyMode_t  getPhyMode ()
void  setOutputPower (float dBm)
WiFiMode_t  getMode ()
bool  enableSTA (bool enable)
bool  enableAP (bool enable)
bool  forceSleepBegin (uint32 sleepUs=0)
bool  forceSleepWake ()
int  hostByName (const char *aHostname, IPAddress &aResult)

Documentation for the above functions is not yet prepared.

For code samples please refer to separate section with examples dedicated specifically to the Generic Class.