mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
Experimental: add new WiFi (pseudo) modes: WIFI_SHUTDOWN & WIFI_RESUME (#6356)
* add new WiFimodes: WIFI_SHUTDOWN & WIFI_RESUME with example * restore WiFi.onWiFiModeChange()
This commit is contained in:
@ -42,6 +42,8 @@ typedef std::shared_ptr<WiFiEventHandlerOpaque> WiFiEventHandler;
|
||||
|
||||
typedef void (*WiFiEventCb)(WiFiEvent_t);
|
||||
|
||||
struct WiFiState;
|
||||
|
||||
class ESP8266WiFiGenericClass {
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
// -------------------------------------- Generic WiFi function ---------------------------------
|
||||
@ -62,7 +64,7 @@ class ESP8266WiFiGenericClass {
|
||||
WiFiEventHandler onSoftAPModeStationConnected(std::function<void(const WiFiEventSoftAPModeStationConnected&)>);
|
||||
WiFiEventHandler onSoftAPModeStationDisconnected(std::function<void(const WiFiEventSoftAPModeStationDisconnected&)>);
|
||||
WiFiEventHandler onSoftAPModeProbeRequestReceived(std::function<void(const WiFiEventSoftAPModeProbeRequestReceived&)>);
|
||||
// WiFiEventHandler onWiFiModeChange(std::function<void(const WiFiEventModeChange&)>);
|
||||
WiFiEventHandler onWiFiModeChange(std::function<void(const WiFiEventModeChange&)>);
|
||||
|
||||
int32_t channel(void);
|
||||
|
||||
@ -79,7 +81,7 @@ class ESP8266WiFiGenericClass {
|
||||
|
||||
void persistent(bool persistent);
|
||||
|
||||
bool mode(WiFiMode_t);
|
||||
bool mode(WiFiMode_t, WiFiState* state = nullptr);
|
||||
WiFiMode_t getMode();
|
||||
|
||||
bool enableSTA(bool enable);
|
||||
@ -88,6 +90,8 @@ class ESP8266WiFiGenericClass {
|
||||
bool forceSleepBegin(uint32 sleepUs = 0);
|
||||
bool forceSleepWake();
|
||||
|
||||
static uint32_t shutdownCRC (const WiFiState* state);
|
||||
static bool shutdownValidCRC (const WiFiState* state);
|
||||
static void preinitWiFiOff (); //meant to be called in user-defined preinit()
|
||||
|
||||
protected:
|
||||
@ -96,17 +100,22 @@ class ESP8266WiFiGenericClass {
|
||||
|
||||
static void _eventCallback(void *event);
|
||||
|
||||
// called by WiFi.mode(SHUTDOWN/RESTORE, state)
|
||||
// - sleepUs is WiFi.forceSleepBegin() parameter, 0 = forever
|
||||
// - saveState is the user's state to hold configuration on restore
|
||||
bool shutdown (uint32 sleepUs = 0, WiFiState* stateSave = nullptr);
|
||||
bool resumeFromShutdown (WiFiState* savedState = nullptr);
|
||||
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
// ------------------------------------ Generic Network function --------------------------------
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
|
||||
int hostByName(const char* aHostname, IPAddress& aResult);
|
||||
int hostByName(const char* aHostname, IPAddress& aResult, uint32_t timeout_ms);
|
||||
bool getPersistent();
|
||||
protected:
|
||||
|
||||
protected:
|
||||
friend class ESP8266WiFiSTAClass;
|
||||
friend class ESP8266WiFiScanClass;
|
||||
friend class ESP8266WiFiAPClass;
|
||||
|
Reference in New Issue
Block a user