Fix DeepSleep bootloop disable

Fix DeepSleep bootloop disable (#6890)
This commit is contained in:
Theo Arends 2019-11-10 12:05:09 +01:00
parent becea45707
commit c7a74b82d0
3 changed files with 17 additions and 15 deletions

View File

@ -625,7 +625,7 @@ void SettingsDefaultSet2(void)
// Settings.flag.stop_flash_rotate = 0; // Settings.flag.stop_flash_rotate = 0;
Settings.save_data = SAVE_DATA; Settings.save_data = SAVE_DATA;
Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY; Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY;
Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; // SetOption36
Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW; Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW;
Settings.sleep = APP_SLEEP; Settings.sleep = APP_SLEEP;
if (Settings.sleep < 50) { if (Settings.sleep < 50) {
@ -1007,7 +1007,7 @@ void SettingsDelta(void)
for (uint32_t i = 1; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } for (uint32_t i = 1; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; }
} }
if (Settings.version < 0x0604010D) { if (Settings.version < 0x0604010D) {
Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; // SetOption36
} }
if (Settings.version < 0x06040110) { if (Settings.version < 0x06040110) {
ModuleDefault(WEMOS); ModuleDefault(WEMOS);

View File

@ -1538,7 +1538,7 @@ void setup(void)
#endif #endif
#endif // USE_EMULATION #endif // USE_EMULATION
if (Settings.param[P_BOOT_LOOP_OFFSET]) { if (Settings.param[P_BOOT_LOOP_OFFSET]) { // SetOption36
// Disable functionality as possible cause of fast restart within BOOT_LOOP_TIME seconds (Exception, WDT or restarts) // Disable functionality as possible cause of fast restart within BOOT_LOOP_TIME seconds (Exception, WDT or restarts)
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET]) { // Restart twice if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET]) { // Restart twice
Settings.flag3.user_esp8285_enable = 0; // SetOption51 - Enable ESP8285 user GPIO's - Disable ESP8285 Generic GPIOs interfering with flash SPI Settings.flag3.user_esp8285_enable = 0; // SetOption51 - Enable ESP8285 user GPIO's - Disable ESP8285 Generic GPIOs interfering with flash SPI

View File

@ -58,16 +58,18 @@ bool DeepSleepEnabled(void)
void DeepSleepInit(void) void DeepSleepInit(void)
{ {
// Go back to sleep after 60 minutes if requested deepsleep has not been reached if (DeepSleepEnabled()) {
if (DeepSleepEnabled() && (RtcSettings.ultradeepsleep > MAX_DEEPSLEEP_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) { RtcReboot.fast_reboot_count = 0;
RtcSettings.ultradeepsleep = RtcSettings.ultradeepsleep - MAX_DEEPSLEEP_CYCLE; RtcRebootSave();
RtcReboot.fast_reboot_count = 0; if ((RtcSettings.ultradeepsleep > MAX_DEEPSLEEP_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) {
RtcRebootSave(); // Go back to sleep after 60 minutes if requested deepsleep has not been reached
AddLog_P2(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); RtcSettings.ultradeepsleep = RtcSettings.ultradeepsleep - MAX_DEEPSLEEP_CYCLE;
RtcSettingsSave(); AddLog_P2(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep);
ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (MAX_DEEPSLEEP_CYCLE < RtcSettings.ultradeepsleep ? MAX_DEEPSLEEP_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT); RtcSettingsSave();
yield(); ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (MAX_DEEPSLEEP_CYCLE < RtcSettings.ultradeepsleep ? MAX_DEEPSLEEP_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT);
// Sleeping yield();
// Sleeping
}
} }
// Stay awake // Stay awake
RtcSettings.ultradeepsleep = 0; RtcSettings.ultradeepsleep = 0;
@ -137,8 +139,8 @@ void DeepSleepCheck(void)
void CmndDeepsleepTime(void) void CmndDeepsleepTime(void)
{ {
// if ((XdrvMailbox.payload == 0) || ((XdrvMailbox.payload > 10) && (XdrvMailbox.payload < 4294967295))) { if ((XdrvMailbox.payload == 0) ||
if ((XdrvMailbox.payload == 0) || ((XdrvMailbox.payload > 10) && (XdrvMailbox.payload < (24 * 60 * 60)))) { // Allow max 24 hours sleep ((XdrvMailbox.payload > 10) && (XdrvMailbox.payload < (10 * 366 * 24 * 60 * 60)))) { // Allow max 10 years sleep
Settings.deepsleep = XdrvMailbox.payload; Settings.deepsleep = XdrvMailbox.payload;
RtcSettings.nextwakeup = 0; RtcSettings.nextwakeup = 0;
tele_period = Settings.tele_period -1; // Initiate start DeepSleep on next finish of forced TelePeriod tele_period = Settings.tele_period -1; // Initiate start DeepSleep on next finish of forced TelePeriod