From 32c1e2d13c9b6fc28a7a5fd80e0a5d1fdb614b03 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 19 Feb 2019 10:48:19 +0100 Subject: [PATCH] Tuning uptime and add utctime Tuning uptime and add utctime --- sonoff/sonoff.ino | 5 +---- sonoff/support_rtc.ino | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 058631a15..55d218456 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1306,10 +1306,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) restart_flag = 211; snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command , D_JSON_RESET_AND_RESTARTING); break; - case 2: - case 3: - case 4: - case 5 ... 6: + case 2 ... 6: restart_flag = 210 + payload; snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}")); break; diff --git a/sonoff/support_rtc.ino b/sonoff/support_rtc.ino index 5c9f9e2b4..e13dd540e 100644 --- a/sonoff/support_rtc.ino +++ b/sonoff/support_rtc.ino @@ -181,19 +181,16 @@ uint32_t UpTime(void) } } +uint32_t GetMinutesUptime(void) +{ + return (UpTime() / 60); +} + String GetUptime(void) { return GetDuration(UpTime()); } -uint32_t GetMinutesUptime(void) -{ - TIME_T ut; - BreakTime(UpTime(), ut); - - return (ut.days *1440) + (ut.hour *60) + ut.minute; -} - uint32_t GetMinutesPastMidnight(void) { uint32_t minutes = 0; @@ -326,6 +323,11 @@ uint32_t RuleToTime(TimeRule r, int yr) return t; } +uint32_t UtcTime(void) +{ + return utc_time; +} + uint32_t LocalTime(void) { return local_time;