mirror of https://github.com/arendst/Tasmota.git
Fix check deepsleep for valid values in Settings (#6961)
This commit is contained in:
parent
6ec4373761
commit
5743486d2a
|
@ -2,6 +2,7 @@
|
|||
* 7.0.0.5 20191118
|
||||
* Fix boot loop regression
|
||||
* Add command TempOffset -12.6 .. 12.6 to set global temperature sensor offset (#6958)
|
||||
* Fix check deepsleep for valid values in Settings (#6961)
|
||||
*
|
||||
* 7.0.0.4 20191108
|
||||
* Add command WifiPower 0 .. 20.5 to set Wifi Output Power which will be default set to 17dBm
|
||||
|
|
|
@ -42,6 +42,8 @@ const char kDeepsleepCommands[] PROGMEM = D_PRFX_DEEPSLEEP "|"
|
|||
void (* const DeepsleepCommand[])(void) PROGMEM = {
|
||||
&CmndDeepsleepTime };
|
||||
|
||||
const uint32_t MAX_DEEPSLEEP = 10 * 366 * 24 * 60 * 60; // Allow max 10 years sleep
|
||||
|
||||
uint32_t deepsleep_sleeptime = 0;
|
||||
uint8_t deepsleep_flag = 0;
|
||||
|
||||
|
@ -61,6 +63,10 @@ bool DeepSleepEnabled(void)
|
|||
|
||||
void DeepSleepReInit(void)
|
||||
{
|
||||
// do a sanity check on deepsleep value
|
||||
if ((0xFFFFFFFF == Settings.deepsleep) || (Settings.deepsleep > MAX_DEEPSLEEP)) {
|
||||
Settings.deepsleep = 0; // issue #6961
|
||||
}
|
||||
if ((ResetReason() == REASON_DEEP_SLEEP_AWAKE) && DeepSleepEnabled()) {
|
||||
if ((RtcSettings.ultradeepsleep > MAX_DEEPSLEEP_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) {
|
||||
// Go back to sleep after 60 minutes if requested deepsleep has not been reached
|
||||
|
@ -164,7 +170,7 @@ void DeepSleepEverySecond(void)
|
|||
void CmndDeepsleepTime(void)
|
||||
{
|
||||
if ((0 == XdrvMailbox.payload) ||
|
||||
((XdrvMailbox.payload > 10) && (XdrvMailbox.payload < (10 * 366 * 24 * 60 * 60)))) { // Allow max 10 years sleep
|
||||
((XdrvMailbox.payload > 10) && (XdrvMailbox.payload < MAX_DEEPSLEEP))) {
|
||||
Settings.deepsleep = XdrvMailbox.payload;
|
||||
RtcSettings.nextwakeup = 0;
|
||||
deepsleep_flag = (0 == XdrvMailbox.payload) ? 0 : 4;
|
||||
|
|
Loading…
Reference in New Issue