Skip to content

Root client FB as a device - #21

Merged
viacheslauK merged 3 commits into
mainfrom
mqtt-as-device
Aug 31, 2026
Merged

Root client FB as a device#21
viacheslauK merged 3 commits into
mainfrom
mqtt-as-device

Conversation

@viacheslauK

@viacheslauK viacheslauK commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Converts the MQTT broker connection point from a top-level function block (MQTTClientFB) into an openDAQ device (OpenDAQMQTTDevice) added via instance.addDevice("daq.mqtt://<host>[:<port>]"). The publisher, subscriber and JSON decoder FBs are unchanged.

Changes

  • MqttStreamingModule implements onGetAvailableDeviceTypes / onCreateDevice in place of the function-block pair.
  • Port precedence: a port in the connection string wins over the Port property and is written back into it.
  • MqttClientFbImpl : FunctionBlockMqttClientDeviceImpl : Device (files renamed), with a DeviceType, a separate CreateDefaultConfig(), and onGetInfo. Nested FB offering is unchanged.
  • Connection state moved to the device connection status container (addConfigurationConnectionStatus, surfaced as ConfigurationStatus).
  • Properties: BrokerAddress removed (host comes from the connection string), BrokerPort renamed to Port and documented as the fallback when the connection string has no port.
  • test_mqtt_client_fb.cpptest_mqtt_client_device.cpp, rewritten around addDevice and extended with connection-string, DeviceInfo and ConfigurationStatus cases.

Notes

  • Breaking change: addFunctionBlock("MQTTClientFB", ...) no longer works and BrokerAddress is gone; callers must use addDevice("daq.mqtt://...").

@viacheslauK viacheslauK self-assigned this Aug 26, 2026
@viacheslauK
viacheslauK marked this pull request as ready for review August 26, 2026 10:08

@denise-opendaq denise-opendaq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. just one note
I created the device. and subscriber fb
then when im trying to remove the subscriber fb I have an exception

Exception in Tkinter callback
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/tkinter/__init__.py", line 2074, in __call__
    return self.func(*args)
           ~~~~~~~~~^^^^^^^
  File "/Users/deniserokhin/projects/openDAQ/examples/applications/python/GUI Application/gui_demo.py", line 704, in <lambda>
    command=lambda: self.handle_tree_menu_remove_function_block(node)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/deniserokhin/projects/openDAQ/examples/applications/python/GUI Application/gui_demo.py", line 1018, in handle_tree_menu_remove_function_block
    parent_fb.remove_function_block(node)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
RuntimeError: Device does not allow adding/removing function blocks. [ /root/opendaq/build/_deps/opendaq-src/core/opendaq/device/include/opendaq/device_impl.h:886 ]
 - Caused by: [ /root/opendaq/build/_deps/opendaq-src/core/opendaq/signal/include/opendaq/signal_container_impl.h:640 ]
 - Caused by: [ /Users/deniserokhin/projects/openDAQ/core/opendaq/signal/include/opendaq/signal_container_impl.h:640 ]

with publisher the same issue

to fix it you have override void onRemoveFunctionBlock(const FunctionBlockPtr& functionBlock) method

another question can Publisher create JSONConfig, so it will be easier to check subcriber?

but its working :)
Screenshot 2026-08-27 at 15 18 39

@viacheslauK
viacheslauK merged commit 41c2299 into main Aug 31, 2026
19 checks passed
@viacheslauK
viacheslauK deleted the mqtt-as-device branch August 31, 2026 10:55
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

Successfully merging this pull request may close these issues.

2 participants