Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ksIotFrameworkLib - my iot helper framework targeting esp32 and esp8266 (Arduino) #10714

cziter15 started this conversation in Show and tell
Discussion options

ksIotFrameworkLib is composition oriented internet of things framework that provides simple and extendable architecture, handles device setup (WiFi setup, MQTT and application specific configuration), network connectivity, MQTT telemetry protocol and more...

Currently all my esp based devices are running this on top of this framework:

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.

🔎 How does it work under the hood?

  • The application is created, followed by the invocation of its 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.
  • In case the init() method returns true, the application proceeds to execute its loop() function. This function traverses through the components, initializing each of them.
  • In the subsequent iteration, the application triggers the postInitialize() method for each component.
  • Following this, the application is fully initialized and enters a looping state where it iterates over the components, invoking their respective loop methods.
  • If any component returns false during it's loop method, the application will break and the App Rotator will select the next application for execution.

Example code:

bool PelletInfo::init()
{
	/* Create required components (Wifi and Mqtt debug). */
	addComponent<ksf::comps::ksWifiConnector>(PelletInfoConfig::pelletInfoDeviceName);
	addComponent<ksf::comps::ksMqttDebugResponder>();
	addComponent<ksf::comps::ksDevStatMqttReporter>();
	/* Create OTA updater component. */
	addComponent<ksf::comps::ksDevicePortal>();
	/* Create state display and receiver components. */
	addComponent<comps::StateDisplay>();
	addComponent<comps::StateReceiver>();
	/* Create reset button component. */
	addComponent<ksf::comps::ksResetButton>(CFG_PUSH_PIN, LOW);
	/* Create mqttConnector and statusLed components. */
	addComponent<ksf::comps::ksMqttConnector>();
	/* Application finished initialization, return true as it succedeed. */
	return true;
}

You can grab the library here:
https://github.com/cziter15/ksIotFrameworkLib

Reference projects:
https://github.com/cziter15/raesp_gateway
https://github.com/cziter15/emon_fw

Built-in examples:
https://github.com/cziter15/ksIotFrameworkLib/tree/master/examples

Works best with platformio.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /