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

Multiple callback triggers in 'settings' subsystem #662

Open
OgnjenX opened this issue Oct 16, 2024 · 1 comment
Open

Multiple callback triggers in 'settings' subsystem #662

OgnjenX opened this issue Oct 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@OgnjenX
Copy link

OgnjenX commented Oct 16, 2024

Golioth Firmware SDK Commit Hash

a6115ea

Platform/OS

Zephyr 3.7

Hardware Target

ESP32

What host OS are you using?

Windows 11

Current Behavior

When the device boots, the callback for each registered setting is triggered multiple times (it seems that it is triggered n times where n is the total number of settings - but I can easily be wrong about the exact number).

Expected Behavior

A callback for each setting should be triggered exactly once.

Steps To Reproduce

I'm using Zephyr 3.7 together with Golioth v0.15.0. The target is espressif esp32 WROOM.

Logs, console output, or any kind of debug information

[00:00:19.069,000] hp_golioth_settings: Set MQTT broker name to xxx.com
[00:00:19.072,000] hp_golioth_settings: Set MQTT port to 1883
[00:00:19.412,000] hp_golioth_settings: Set cooling threshold to 2.50
[00:00:19.413,000] hp_golioth_settings: Set MQTT broker name to xxx.com
[00:00:19.416,000] hp_golioth_settings: Set MQTT port to 1883
[00:00:19.692,000] hp_golioth_settings: Set MQTT port to 1883
[00:00:19.692,000] hp_golioth_settings: Set cooling threshold to 2.50
[00:00:19.695,000] hp_golioth_settings: Set MQTT broker name to xxx.com
[00:00:19.985,000] hp_golioth_settings: Set MQTT port to 1883
[00:00:19.987,000] hp_golioth_settings: Set cooling threshold to 2.50
[00:00:19.988,000] hp_golioth_settings: Set MQTT broker name to xxx.com

@OgnjenX OgnjenX added the bug Something isn't working label Oct 16, 2024
@sam-golioth
Copy link
Contributor

Hi @OgnjenX! Thanks for opening this issue and apologies for the delay in our reply.

You're correct in your assessment of the behavior. Each time we register a setting, we do a GET request to the server to ensure that we have an up-to-date value for that setting. The server returns the full settings payload each time, and so we call each of the registered handlers to update them. During initialization, when registering multiple settings, this manifests in the behavior you've described. This is inefficient, and we have plans to improve this in the future, both in terms of UX and bandwidth usage.

Note that even with improvements to settings registration, the settings handler will still need to be resilient to being called when the setting hasn't changed. This is because whenever there is an update to one or more settings in the cloud console, the whole settings payload is sent to the device, and the device does not know which of the settings has changed and which remains the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants