Doxygen with github
|
Arduino Library for ESP32/ESP8266 - a composition-oriented Internet of Things framework that provides a simple and extendable architecture, handles device setup (WiFi setup, MQTT and application-specific configuration), network connectivity, MQTT telemetry protocol, and more...
IMPORTANT
This library targets Arduino 3+ on ESP32. However, due to Platformio statement, it will not automatically pull the latest versions.
To use the latest version, set your platform to the pioarduino (by Jason2866) fork in yourplatformio.ini
file:platform = https://github.com/pioarduino/platform-espressif32.git
IMPORTANT
For ESP8266, the latest supported version is based on SDK305. To use it, add-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
to your build flags.
loop
.init
, postInit
, and loop
methods.init
method, so they will be available for postInit
methods. (you can add them later, in loop
but that's another case)init
method is the best place to add dependent components, setup initial pin values etc.postInit
method is the best place to obtain a weak pointer to another component by calling findComponent
. This will handle cases when other components were added via init
method.To build an application, simply create a new class inherited from ksApplication
and add your initial components inside the init
method. See projects like emon_fw for reference.
init
method. If false is returned from the init method, the subsequent execution of the loop
will be skipped, resulting in no iteration over the components. The App Rotator will then try to run next apllication.init
method returns true, the application proceeds to execute its loop
function. This function traverses through the components, initializing each of them.postInit
method for each component.loop
methods.loop
method, the application will break and the App Rotator will select the next application for execution.The library implements one very useful utility named ksAppRotator
. This object can wrap application instantiation logic into something like carousel or rotator.
Typically the device hosts two applications. First application is running core device logic while the second one is dedicated to help the user with the device configuration.
Each application has it's own loop
method taking care of all underlying logic. In case of fail (which can happen anytime, even when creating the application object), the rotator will spawn next application and start processing it's logic until fail or break.
This is very flexible, because you can even raise fail (false) from application's init
method and then go directly into the configuration mode (for example there's no WiFi credentials provided by the user).
gnu++2a
enabled via compiler.cpp.extra_flags=
option in the board.txt
file.KSF_RTTI_DECLARATIONS
macro to provide proper runtime type information generation for proper casting of components.ksConfigProvider.h
for an example. Your application components should use this macro, otherwise the component finding mechanism won't work.