From 0dadda86decd191e4b2ad1184b790fd33175674e Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Mon, 14 Nov 2016 21:13:38 +1100 Subject: [PATCH] wifi_get/set_sleep_type: add source code implementations plus fixes. (#218) * wifi_set_sleep_type returns a bool success flag. * wifi_get_sleep_type seemed useless, just returning an argument. Added an implementation using sdk_pm_get_sleep_type. --- include/espressif/esp_system.h | 4 ++-- open_esplibs/libmain/user_interface.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/espressif/esp_system.h b/include/espressif/esp_system.h index abeb26a..c7185d4 100644 --- a/include/espressif/esp_system.h +++ b/include/espressif/esp_system.h @@ -37,8 +37,8 @@ enum sdk_sleep_type { WIFI_SLEEP_LIGHT = 1, WIFI_SLEEP_MODEM = 2, }; -void sdk_wifi_set_sleep_type(enum sdk_sleep_type); -enum sdk_sleep_type sdk_wifi_get_sleep_type(enum sdk_sleep_type); +bool sdk_wifi_set_sleep_type(enum sdk_sleep_type); +enum sdk_sleep_type sdk_wifi_get_sleep_type(void); void sdk_system_restore(void); void sdk_system_restart(void); diff --git a/open_esplibs/libmain/user_interface.c b/open_esplibs/libmain/user_interface.c index c13273c..ad9dca0 100644 --- a/open_esplibs/libmain/user_interface.c +++ b/open_esplibs/libmain/user_interface.c @@ -591,4 +591,16 @@ void sdk_system_uart_de_swap() DPORT.PERI_IO &= ~DPORT_PERI_IO_SWAP_UART0_PINS; } +enum sdk_sleep_type sdk_wifi_get_sleep_type() +{ + return sdk_pm_get_sleep_type(); +} + +bool sdk_wifi_set_sleep_type(enum sdk_sleep_type type) +{ + if (type > WIFI_SLEEP_MODEM) return false; + sdk_pm_set_sleep_type_from_upper(type); + return true; +} + #endif /* OPEN_LIBMAIN_USER_INTERFACE */