Common Functions - denis-stepanov/esp-ds-system GitHub Wiki

There are several library functions which are always defined, irrespective of capabilities.

void System::begin()

This function should be called in the setup() function of a sketch. The exact location is not very important, but if you rely on capabilities like syslog, you'd better call it as the first line of setup().

Few capabilities might not require use of this function. Check the description of the capability in question. It is a good practice though to always call it, as the underlying capability implementation may change without notice.

void System::update()

This function should be called in the loop() function of a sketch. The exact location is not very important; a common practice is to put it at the end of the loop().

Like for System::begin(), a few capabilities might not require use of this function. Similarly, if in doubt, always call it, in order to avoid your sketch behaving strangely.

String System::getCapabilities()

This function returns a space-separated list of compiled-in capabilities. Example of output:

APP_ID APP_LOG SYS_LED SYS_LOG_HW SYS_TIME SYS_UPTIME SYS_FS SYS_NETWORK WIFIMANAGER MDNS WEBSERVER BUTTON

This could be used to check at runtime if a particular capability is enabled. The usefulness of this is limited, since the user has full control over which capabilities are to be included, so generally there is no need to additionally check for it.

If a capability allows disabling at run-time (such as application log which can be turned off at will), this function would still return that capability.

uint32_t System::getVersion()

This function returns library version as an integer number. The version is positionally encoded as "x.xx.xx" (major.minor.maintenance). E.g., 20001 means version 2.0.1. This could be used to make conditional sketch behavior depending on library version.

To check library version at compilation time, use DS_SYSTEM_VERSION macro with the same meaning. The macro was introduced from version 1.1.0 of the library; if you need to detect version 1.0.0, test for macro absence (#ifndef).