From fe3dba6cad0256a37023e16f2ac01932132a8998 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Wed, 6 Apr 2016 16:03:14 +0200 Subject: [PATCH] Add CONFIG_ENABLE_POWER_SAVE Enable light sleep Switch off internal LED Disable mDNS --- WifiControlSensor/WifiControlSensor.ino | 6 +++++- WifiControlSensor/config_device.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index ca6c48d..16bbdd1 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -103,6 +103,7 @@ void WifiSetup(int bootmode, int forceSetup, char *confSsid, char *confPassword, SKETCH_DEBUG_PRINTLN(""); SKETCH_DEBUG_PRINTLN("WiFi connected"); +#ifndef CONFIG_ENABLE_POWER_SAVE if (!MDNS.begin(confHost)) { SKETCH_DEBUG_PRINTLN("Error setting up MDNS responder!"); while (1) { @@ -110,6 +111,7 @@ void WifiSetup(int bootmode, int forceSetup, char *confSsid, char *confPassword, } } SKETCH_DEBUG_PRINTLN("mDNS responder started"); +#endif myIP = WiFi.localIP(); } @@ -222,8 +224,10 @@ void setup() { SKETCH_DEBUG_PRINTLN("BMP180 init success"); WebSetupServer(mode); } -#ifdef CONFIG_ENABLE_LIGHT_SLEEP +#ifdef CONFIG_ENABLE_POWER_SAVE wifi_set_sleep_type(LIGHT_SLEEP_T); + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, HIGH); //Active at low level #endif } diff --git a/WifiControlSensor/config_device.h b/WifiControlSensor/config_device.h index 1fd9978..cbf78af 100644 --- a/WifiControlSensor/config_device.h +++ b/WifiControlSensor/config_device.h @@ -13,7 +13,9 @@ #define CONFIG_BMP180_SCL 14 // Enable light sleep to save some power (http://bbs.espressif.com/viewtopic.php?f=6&t=133&p=485&hilit=sleep+modem#p485) -//#define CONFIG_ENABLE_LIGHT_SLEEP +// Switch off internal LED +// Disable mDNS +//#define CONFIG_ENABLE_POWER_SAVE /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */