-
Notifications
You must be signed in to change notification settings - Fork 0
DS_CAP_SYS_UPTIME
Denis Stepanov edited this page Sep 1, 2023
·
6 revisions
This capability adds support for uptime calculation. The following methods are available:
time_t System::getUptime(); // Return uptime in seconds
String System::getUptimeStr(); // Return uptime as a string
time_t System::getBootTime(); // Return boot time in seconds from epoch
String System::getBootTimeStr(); // Return boot time string
Example of an uptime string: 9 days 02:29:43
. Example of a boot string: 2020/10/11 20:54:19
. Boot time functions are only available if time is enabled. Quite counter-intuitively, to count uptime per se a notion of time is not required.
- Uptime-Library - implementation of uptime counter
-
DS_CAP_SYS_TIME — if time is enabled, the calls
getBootTime()
andgetBootTimeStr()
become available; - DS_CAP_WEBSERVER — if web server is enabled, its "System Information" page will include "System Uptime" line with uptime information.
None.
MySystem.h
:
#define DS_CAP_SYS_UPTIME // Enable system uptime counter
#include "System.h" // System global definitions
sketch.ino
:
#include "MySystem.h"
using namespace ds;
void setup() {
}
void loop() {
auto uptime = System::getUptime();
auto uptime_str = System::getUptimeStr();
delay(1000);
}
System::begin() |
Not required |
System::update() |
Not required |
- As per the Uptime-Library implementation, uptime calculation
getUptime()
(orgetUptimeStr()
) has to be called at least once every 49 days in order to compute uptime correctly. Since uptime is shown on "System Information" web page, it is probably good enough. If unsure, call the function yourself from time to time from your sketch. This might be changed in future versions of the library (issue #9); - Returned boot time seems to slightly drift with time. The reason for this has yet to be understood, but it looks like regular time correction is not being properly accounted for (issue #10).
Version 1.0 or later. Functions getUptime()
and getBootTime()
are available from version 1.2.
None.
- DS_CAP_APP_ID
- DS_CAP_APP_LOG
- DS_CAP_BUTTON
- DS_CAP_MDNS
- DS_CAP_SYS_FS
- DS_CAP_SYS_LED
- DS_CAP_SYS_LOG
- DS_CAP_SYS_LOG_HW
- DS_CAP_SYS_NETWORK
- DS_CAP_SYS_RESET
- DS_CAP_SYS_RTCMEM
- DS_CAP_SYS_TIME
- DS_CAP_SYS_UPTIME
- DS_CAP_TIMERS
- DS_CAP_TIMERS_ABS
- DS_CAP_TIMERS_COUNT_ABS
- DS_CAP_TIMERS_COUNT_TICK
- DS_CAP_TIMERS_SOLAR
- DS_CAP_WEB_TIMERS
- DS_CAP_WEBSERVER
- DS_CAP_WIFIMANAGER