Skip to content

Json subscriber reworking#8

Merged
viacheslauK merged 19 commits intomainfrom
json-subscriber-reworking
Jan 9, 2026
Merged

Json subscriber reworking#8
viacheslauK merged 19 commits intomainfrom
json-subscriber-reworking

Conversation

@viacheslauK
Copy link
Copy Markdown
Collaborator

  • Rework of JSON subscription flow: JSON receiver FB no longer parses all signals itself — it now creates nested JSON decoder function blocks (jsonDecoderMqttFb) that parse individual values/timestamps and produce signals.
  • New JSON decoder FB: added mqtt_json_decoder_fb_impl.{h,cpp} to extract a single value + optional timestamp from incoming JSON and emit data/domain samples.
  • JSON config handling changed: SignalList (big JSON string) → JsonConfig (string) and JsonConfigFile (path). JSON FB reads config (or file), extracts topic and per-signal descriptors and creates nested decoders. New "Topic" property.
  • Stronger topic validation and subscription QoS: added PROPERTY_NAME_SUB_QOS / DEFAULT_SUB_QOS; subscription/unsubscribe now use the configured QoS.
  • Status system refactor: introduced a generic StatusHelper to manage enumerated statuses (component / subscription / parsing / publishing / setting), replacing many manual EnumerationWithIntValue usages.
  • Publisher FB improvements: cleaner status reporting (SignalStatus / PublishingStatus / SettingStatus), validation of properties (QoS, topic when sharedTs or multi), rename of publishing modes to descriptive enum names, and more robust publishing status tracking.
  • Raw FB changes: Topic property replaced SignalList.
  • MqttDataWrapper changes: JSON parsing & descriptor extraction reworked (now returns per-signal MqttMsgDescriptor with unit info), value/timestamp extraction refactored; API signatures changed.
  • Tests and examples: many unit tests added / updated (including new test for json decoder), new example JSON files for tests, updates to examples (custom-mqtt-sub, raw-mqtt-sub, ref-dev-mqtt-pub) to use the new FB/type/property names and behavior.
  • Renames & cleanups: several handler/source/header files renamed to clearer names (single_handler → atomic_signal_atomic_sample_handler, multisingle → atomic_signal_sample_arr_handler, multiple_shared → group_signal_shared_ts_handler, multiple → signal_arr_atomic_sample_handler), constants and FB type IDs removed leading '@' (e.g. @rootMqttFb → rootMqttFb), and general code cleanup (status helper, removal of old helper functions).

@viacheslauK viacheslauK self-assigned this Dec 26, 2025
Copy link
Copy Markdown

@NikolaiShipilov NikolaiShipilov left a comment

Choose a reason for hiding this comment

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

I’ve tested JSON subscriber FB with the GUI app and first impression is positive. Feature-wise, almost everything works as intended; only a few details need clarification.

In addition to the inline review comments (which are mostly recommendations), I’d like to point out the following items that should be addressed before merging:

  • Base/derived receiver FB design: The organization of the base and derived receiver FB implementations needs refinement, particularly around virtual methods. Some base class methods seems to be redundantly marked as virtual even though they don’t require to be overridden in derived classes, while others overridden (including some pure virtual ones) are invoked from ctors and dtors of derived classes, so likely should be just a private methods of derived classes.
  • FB type naming: Also renaming the FB types as pointed in inline comment is worth doing before the merge.

std::shared_ptr<mqtt::MqttAsyncClient> subscriber;
EnumerationPtr subscriptionStatus;
StatusHelper<SubscriptionStatus> subscriptionStatus;
int qos = DEFAULT_SUB_QOS;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would it make sense to introduce enum type for passing around the qos values ? Smth like this:

enum class QosValueType : daq::EnumType
{
    AtMostOnce = 0,   // QoS 0
    AtLeastOnce = 1,  // QoS 1
    ExactlyOnce = 2   // QoS 2
};

Comment thread examples/custom-mqtt-sub/src/custom-mqtt-sub.cpp Outdated
Comment thread examples/custom-mqtt-sub/src/custom-mqtt-sub.cpp
Comment thread mqtt_streaming_module/src/mqtt_json_receiver_fb_impl.cpp Outdated
Comment thread mqtt_streaming_module/include/mqtt_streaming_module/mqtt_json_receiver_fb_impl.h Outdated
Comment thread mqtt_streaming_module/include/mqtt_streaming_module/mqtt_json_receiver_fb_impl.h Outdated
@viacheslauK viacheslauK merged commit cbc7079 into main Jan 9, 2026
@viacheslauK viacheslauK deleted the json-subscriber-reworking branch January 28, 2026 10:15
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