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

What about ThingsBoard Stack size. #172

Closed
sirapol opened this issue Dec 19, 2023 · 2 comments
Closed

What about ThingsBoard Stack size. #172

sirapol opened this issue Dec 19, 2023 · 2 comments

Comments

@sirapol
Copy link

sirapol commented Dec 19, 2023

Someone please expand about thingsboard stack size.

  1. When i initial ThingsBoard. How is difference between
ThingsBoardSized<128> tb(mqttClient, MAX_MESSAGE_SIZE);

and

ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);
  1. Maximum size of anything in below this
    What is Default_Max_Stack_Size , Default_Buffering_Size ,Default_Payload , Default_Fields_Amt
    image

  2. If i would like to send multi telemetry in once time. What is the right way to config max telemetry size?.

@MathewHDYT
Copy link
Contributor

MathewHDYT commented Dec 19, 2023

  1. When i initial ThingsBoard. How is difference between
    ThingsBoardSized<128> tb(mqttClient, MAX_MESSAGE_SIZE);
    and
    ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);

That is the MaxFieldsAmount template parameter with the default value of Default_Fields_Amount and an explanation can be found in the documentation on this GitHub page here.

  1. Maximum size of anything in below this
    What is Default_Max_Stack_Size , Default_Buffering_Size ,Default_Payload , Default_Fields_Amt

The documentation of the class should appear in VSCode when hovering over ThingsBoard constructor. More specifically you should see this comment. Which shows when the values are used.

/// @tparam MaxFieldsAmount Maximum amount of key value pair that we will be able to sent or received by ThingsBoard in one call, default = Default_Fields_Amount (8)
 /// @param bufferSize Maximum amount of data that can be either received or sent to ThingsBoard at once, if bigger packets are received they are discarded
/// and if we attempt to send data that is bigger, it will not be sent, the internal value can be changed later at any time with the setBufferSize() method
/// alternatively setting THINGSBOARD_ENABLE_STREAM_UTILS to 1 allows to send arbitrary size payloads if that is done the internal buffer of the MQTT Client implementation
/// can be theoretically set to only be as big as the biggest message we should every receive from ThingsBoard,
/// this will mean though that all messages are sent over the StreamUtils library as long as they are bigger than the internal buffer,
/// which needs more time than sending a message directly but has the advantage of requiring less memory.
/// So if that is a problem on the board it might be useful to enable the THINGSBOARD_ENABLE_STREAM_UTILS option
/// and decrease the internal buffer size of the mqtt client to what is needed to receive all MQTT messages,
/// that size can vary but if all ThingsBoard features are used a buffer size of 256 bytes should suffice for receiving most responses.
/// If the aforementioned feature is not enabled the buffer size might need to be much bigger though,
/// but in that case if a message was too big to be sent the user will be informed with a message to the Logger.
/// The aforementioned options can only be enabled if Arduino is used to build this library, because the StreamUtils library requires it, default = Default_Payload (64)
/// @param maxStackSize Maximum amount of bytes we want to allocate on the stack, default = Default_Max_Stack_Size (1024)
/// @param bufferingSize Amount of bytes allocated to speed up serialization, only used if THINGSBOARD_ENABLE_STREAM_UTILS is set to 1, default = Default_Buffering_Size (64)

I hope this somewhat helps explain the different values and possible template arguments to the class.

  1. If i would like to send multi telemetry in once time. What is the right way to config max telemetry size?

For that simply read the documentation linked in question 1. Shortly explained here, you have to specify the amount of json fields you will ever send or receive at once. With the first template parameter in ThingsBoardSized<128>.

@sirapol
Copy link
Author

sirapol commented Dec 19, 2023

That all
Thank you.

@sirapol sirapol closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants