Browse Source

WiFi light sleep enabled, power saving delay in main loop

fastled
Xose Pérez 7 years ago
parent
commit
54341d4b54
3 changed files with 14 additions and 6 deletions
  1. +2
    -0
      code/espurna/config/general.h
  2. +8
    -6
      code/espurna/espurna.ino
  3. +4
    -0
      code/espurna/wifi.ino

+ 2
- 0
code/espurna/config/general.h View File

@ -9,6 +9,7 @@
#define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI)
#define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
#define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250]
//------------------------------------------------------------------------------
// TELNET
@ -266,6 +267,7 @@ PROGMEM const char* const custom_reset_string[] = {
#define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
#define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
#define WIFI_AP_MODE AP_MODE_ALONE
#define WIFI_SLEEP_ENABLED 1 // Enable WiFi light sleep
// Optional hardcoded configuration (up to 2 different networks)
//#define WIFI1_SSID "..."


+ 8
- 6
code/espurna/espurna.ino View File

@ -241,6 +241,7 @@ void setup() {
if (!systemCheck()) return;
#endif
// Init webserver required before any module that uses API
#if WEB_SUPPORT
webSetup();
#endif
@ -256,7 +257,6 @@ void setup() {
#ifdef ITEAD_SONOFF_RFBRIDGE
rfbSetup();
#endif
#if POWER_PROVIDER != POWER_PROVIDER_NONE
powerSetup();
#endif
@ -311,26 +311,23 @@ void loop() {
wifiLoop();
otaLoop();
// Do not run the next services if system is flagged stable
#if SYSTEM_CHECK_ENABLED
systemCheckLoop();
// Do not run the next services if system is flagged stable
if (!systemCheck()) return;
#endif
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
lightLoop();
#endif
buttonLoop();
relayLoop();
buttonLoop();
ledLoop();
mqttLoop();
#ifdef ITEAD_SONOFF_RFBRIDGE
rfbLoop();
#endif
#if POWER_PROVIDER != POWER_PROVIDER_NONE
powerLoop();
#endif
@ -362,4 +359,9 @@ void loop() {
irLoop();
#endif
// Power saving delay
#if LOOP_DELAY_TIME
delay(LOOP_DELAY_TIME);
#endif
}

+ 4
- 0
code/espurna/wifi.ino View File

@ -174,6 +174,10 @@ void wifiInject() {
void wifiSetup() {
#if WIFI_SLEEP_ENABLED
wifi_set_sleep_type(LIGHT_SLEEP_T);
#endif
wifiInject();
wifiConfigure();


Loading…
Cancel
Save