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