Coder Social home page Coder Social logo

cziter15 / ksiotframeworklib Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 2.0 14 MB

:symbols: Arduino Library for ESP32/ESP8266 - 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...

Home Page: https://cziter15.github.io/ksIotFrameworkLib/

License: MIT License

C++ 20.22% C 79.41% Python 0.37%
esp32 esp8266 arduino arduino-esp32 arduino-esp8266 arduino-library library platformio wifi framework

ksiotframeworklib's Introduction

Header

  • Since childhood, I've had a deep passion for computers, starting my journey in programming during elementary school.
  • After graduating from technical school, I embarked on a career as a game programmer, dedicating nearly a decade to the field.
  • Recently, however, my interests have evolved towards automation testing software and custom electronics design.

๐Ÿ“ I was born in Bydgoszcz...

  • Bydgoszcz is a medium-sized (with around 354,000 residents as of 2016) city located in the northern part of Poland (Central Europe).
  • The city is situated on the Brda River, while the district I come from is located on the Vistula River, which is the longest river in Poland.

๐Ÿ‘€ I am interested in the following areas...

  • PCB Design which means crafting and designing own printed circuit boards.
  • Game Development to continue my passion for creating immersive digital experiences.
  • Electrical Engineering to explore the principles and practical applications of electronics.
  • Practical and Ethical Usage of AI to learn how artificial intelligence can be applied responsibly and effectively.

๐ŸŒฑ I am currently learning...

  • Electronics design
  • Software architecture patterns
  • Modern C++ features
  • Large language models

๐Ÿ’ž๏ธ I like...

  • Being active
  • Road cycling
  • Engaging in useful projects

๐Ÿ“ซ If you require my skills, let me know...

ksiotframeworklib's People

Contributors

cziter15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ksiotframeworklib's Issues

WiFiManager parameters can be wrapped up

InjectManagerParameters method can be less dependent directly on WiFiManager.

First of all parameters can be changed to be stored as shared pointers.
Second - WiFiManagerParameter can be constructed via factorization or internally managed and created by method like addParameter.

Optimize RAM, use Flash access when possible

Optimize RAM, use Flash access when possible

  • setupMqttConnector is one of examples, ksIotFramework can load file on each reconnection to get credentials (it wouldn't cost a lot as reconnect doesn't happen every tick)
  • keep in mind that some paramters are not saved (for example PubSubClient's domain is only a char*)

Introduce function to covnert bool to HIGH or LOW

Introduce function to covnert bool to HIGH or LOW. There are few places in the code that require translation from bool to HIGH/LOW states. This can be extracted into macro or inline function in ksConstants.

Profile in context of RAM usage

  • Try remove MqttDebugComponent and see how ram usage changes
  • ... same with other components and especialy strings
  • Do it on both platforms 32 and 8266

Refactor ksConfigProvider

  • Get rid of USING_CONFIG_FILE macro
  • Get rid of manual iteration [ for (auto& param : params) ] in user code
  • Maybe config provider can handle all config file operations?

Strange behaviour of components initialization

There is a problem, components can fail it's init procedure, but when app does not handle that, this component is not removed and loop method is called.

It might lead to unexpected behaviour.

Refactor timers

  • Create small class or struct that will handle millis() based timers, with method like setInterval and methods like justExpired() and replace old code with new mechanism
  • Decide if ksTimer component is still required.

Device uptime in debug responder

I've found that ksMqttDebugResponder returned uptime of component, not the device as mentioned in code.
Currently I've corrected variable names to avoid confusion, but it will be cool to have real device uptime somewhere.
This isn't trivial because calling millis() and converting to seconds or h:m:s is not resistant to roll-over.

What needs to be done:

  • Change variable name of deviceUptime -> componentUptime in ksMqttResponder.
  • Introduce real device uptime in ksMqttResponder (maybe use os_timer_arm?)

Fix callback ID

There is a bug, when user removes callback dynamically as it causes problems with ordering.
Index should be changed to something like ID, to uniquely identify callback.

Affected files:
ksEventBase, ksEventHandle

SSL certificate - cleanup cert utils, document SHA1 vs SHA256

I've encountered an issue when moving my infrastructure to handle two homes separately.

It requires SSL and when creating a ddns bridge and when testing it, I've found that:

  • there was an issue related to move semantics (losing c_str).
  • SSLFingerprint is not well documented and it requires SHA1 on ESP8266 and SHA256 on ESP32 (a lot of headache).

Expected state:

  • clear info what SSLFingerprint is
  • maybe better management of data in MQTT setup (move semantics)

ksSafeList is redundant

Well after thinking about double linked lists it should be no problem to replace ksSafeList with one std::list.

Assumptions:

  • always add on the top of the list (emplace front)
  • always erase using iterator (begin to end)

Ideas on handling for components:

  • Introduce component states, processed in app loop.
  • If PendingInit then call onInit(), set the next state PendingStart.
  • If PendingStart then call onStart() and set the state to Ticking.
  • If Ticking then onTick().
  • There can be also additional state - PendingRemoval. If set to PendingRemoval, erase when iterating inside app loop.
  • App construction can be refactored, maybe removing unnecessary functions.

VideNetRequests can share similar pattern. Push new requests to the front and remove via iterating to the end via erase.

Create certUtils class

  • Conversion between std::string and std:;vector for fingerprint
  • Store only array of bytes
  • Covnert array of bytes to string for verify method of ESP32

Lack of destruction handler in components / apps

Method like onDestroy() should be implemented to be able to mimic init behavior.
This will be useful to properly cleanup static objects, like ArduinoOTA, CAN etc.

  • Add method onDestroy() (this should be called from destructor method, but maybe it's good to avoid overriding destructor)
  • Update dependent projects

Now, init() method can be used to init() ArduinoOTA, but there is no safe place to call end() on it.

Investigate issue with reconnect on esp8266

On my own setup, when sometimes there's an IP switch at midnight it looks like ESP8266 devices are unable to reconnect then.
It might have been WiFi connector issue (uint32_t operator LocalIP related) or it might have something to do with wifi timer.

If there's a lock on connect function, then WiFi tick might be unable to update network status.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.