diff --git a/src/MQTTManager.cpp b/src/MQTTManager.cpp index e8533137..86d5e9dd 100644 --- a/src/MQTTManager.cpp +++ b/src/MQTTManager.cpp @@ -297,7 +297,7 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length) if (doc.containsKey("sleep")) { DisplayManager.setPower(false); - PowerManager.sleep(doc["sleep"].as()); + PowerManager.sleep(doc["sleep"].as()); } delete[] payloadCopy; diff --git a/src/PowerManager.cpp b/src/PowerManager.cpp index 85210406..867a86f2 100644 --- a/src/PowerManager.cpp +++ b/src/PowerManager.cpp @@ -2,7 +2,7 @@ #include #include "Globals.h" -#define uS_TO_S_FACTOR 1000000 +#define uS_TO_S_FACTOR 1000000L // The getter for the instantiated singleton instance PowerManager_ &PowerManager_::getInstance() @@ -32,12 +32,12 @@ void PowerManager_::sleepParser(const char *json) if (doc.containsKey("sleep")) { - uint32_t seconds = doc["sleep"].as(); + uint64_t seconds = doc["sleep"].as(); sleep(seconds); } } -void PowerManager_::sleep(uint32_t seconds) +void PowerManager_::sleep(uint64_t seconds) { esp_sleep_enable_timer_wakeup(seconds * uS_TO_S_FACTOR); Serial.print("Going to sleep...\n"); diff --git a/src/PowerManager.h b/src/PowerManager.h index 52bd0d83..b9f9979c 100644 --- a/src/PowerManager.h +++ b/src/PowerManager.h @@ -11,7 +11,7 @@ class PowerManager_ static PowerManager_ &getInstance(); void setup(); void sleepParser(const char*); - void sleep(uint32_t); + void sleep(uint64_t); }; extern PowerManager_ &PowerManager;