Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,39 @@ class ESP8266WiFiGenericClass {
uint8_t channel(void);

bool setSleepMode(WiFiSleepType_t type, uint8_t listenInterval = 0);
/**
* Set modem sleep mode (ESP32 compatibility)
* @param enable true to enable
* @return true if succeeded
*/
bool setSleep(bool enable)
{
if (enable)
{
return setSleepMode(WIFI_MODEM_SLEEP);
}
else
{
return setSleepMode(WIFI_NONE_SLEEP);
}
}
/**
* Set sleep mode (ESP32 compatibility)
* @param mode wifi_ps_type_t
* @return true if succeeded
*/
bool setSleep(wifi_ps_type_t mode)
{
return setSleepMode((WiFiSleepType_t)mode);
}
/**
* Get current sleep state (ESP32 compatibility)
* @return true if modem sleep is enabled
*/
bool getSleep()
{
return getSleepMode() == WIFI_MODEM_SLEEP;
}

WiFiSleepType_t getSleepMode();
uint8_t getListenInterval ();
Expand Down
7 changes: 7 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiType.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ typedef enum WiFiSleepType
WIFI_NONE_SLEEP = 0, WIFI_LIGHT_SLEEP = 1, WIFI_MODEM_SLEEP = 2
} WiFiSleepType_t;

// ESP32 compatibility
typedef enum wifi_ps_type
{
WIFI_PS_NONE = WIFI_NONE_SLEEP,
WIFI_PS_MIN_MODEM = WIFI_MODEM_SLEEP,
WIFI_PS_MAX_MODEM = WIFI_LIGHT_SLEEP,
} wifi_ps_type_t;

typedef enum WiFiEvent
{
Expand Down