Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul Library API Design #220

Closed
wants to merge 716 commits into from
Closed

Conversation

MathewHDYT
Copy link
Contributor

@MathewHDYT MathewHDYT commented Sep 13, 2024

Overhauled the library API usage, to decrease the code size of the ThingsBoard.h file from 1900 to 700 lines of code.

Achieved by seperating the individual ThingsBoard APIs (Shared Attribute Update, Attribute Request, ...) into seperate classes that can be subscribed to the main ThingsBoard.h file. Allows to seperate connection to MQTT Broker (Thingsboard.h) from specific API handling (IAPI_Implementation.h). Furthermore this now also allows to define and subscribe custom APIs, making the library even more flexible. Closes #211, closes #187, closes #219, closes #221.

Additionally the internal usages of timers have been reworked for non ESP32 devices to now work correctly. Closes #182 and closes #206.

Ajudsted examples to changes, closes #210.

Adjusting Configuration.h so it enables ESP components for the exact version the required methods were implemented at. Closes #215.

Fixing problems with THINGSBOARD_ENABLE_DYNAMIC, where not enough space was allocated, closes #216. Additionally added optional argument to hardcap the allocation done by this automatic calculation to prevent huge memory allocations from malicious payloads.

Fixed OTA API so it actually utilizes the request id parameter required by the API. Added additional callback method to the OTA update process so we can stop all other processes and unsubscribe from everything before subscribing to chunk requests or receiving the first chunk.

Fix problems were default initalization left variables unitialized, ensure direct initalization occurs with = {};. Additionaly adjusted OTA failure messages to reset fw error text on success and send correct states. Closes #221.

Adjusted response handling to fiX transformation of JsonDocument as JsonObject. Closes #222

Furthermore this pull request includes the relevant changes from other Pull requests. Closes #217 and closes #209.


@imbeacon Would be nice if this could be merged and released as v0.14.0 on ArduinoIDE, PlattformIO and EspressifIDF Registry.

MathewHDYT and others added 27 commits August 24, 2024 11:23
Previously, when using dynamic mode and deserializing an incoming JSON
message from MQTT, the library would allocate space based on the number
of colons - i.e. the number of object key-value pairs. However, if there
are arrays in the JSON message (such as when a shared attribute gets
deleted), that wouldn't allocate enough space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment