CatLoggerEasy – MQTT System Architecture
Complete guide to the refactored MQTT system: what each file does and what changed
⭐ 3 Files Created
🚀 7+ Platforms Supported
📑 Quick Navigation
🎯 System Overview
What Problem Does This Solve?
The original MQTT implementation was hardcoded for specific platforms and had limited flexibility. The refactored system provides:
- ✅ Multi-platform support – 7+ IoT platforms out of the box
- ✅ Automatic format adaptation – Each platform gets the correct JSON structure
- ✅ Extensible architecture – Easy to add new platforms
- ✅ Contextual help – Built-in setup guides for each platform
- ✅ Better separation of concerns – Connection vs Publishing configuration
Key Architectural Changes
Factory Pattern
Introduced MqttPayloadFormatterFactory to create platform-specific formatters dynamically.
Interface-Based Design
IMqttPayloadFormatter defines the contract all platforms must implement.
Self-Documenting
Each formatter includes setup instructions and credentials help directly in code.
⭐ New Files Created
📝 Modified Files
🔍 ProcessDataViewViewModel.cs – Deep Dive
⚠️ Most Important File
This file is the core data publishing engine. It bridges EtherCAT data with MQTT telemetry. Understanding this file is critical for any developer working on the MQTT system.
📊 Data Flow in ProcessDataViewViewModel
┌─────────────────────────────────────────────────────────────┐
│ EtherCAT System │
│ (Physical devices sending data) │
└────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ DataRepo.ReadKey() │
│ (Read current values from data repository) │
└────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ReadProcessData() │
│ Updates UiChannels every 500ms │
└────────────────┬────────────────────────────────────────────┘
│
├─────────────────┐
│ │
▼ ▼
┌────────────────────┐ ┌──────────────────────┐
│ UI Display │ │ MQTT Publishing │
│ (DataGrid shows │ │ (Timer triggers │
│ real-time data) │ │ every N ms) │
└────────────────────┘ └──────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ BuildTelemetrySnapshot() │
│ • Apply filters │
│ • Sanitize names │
│ • Build Dictionary │
└──────┬───────────────────────┘
│
▼
┌──────────────────────────────┐
│ _telemetryService │
│ .PublishTelemetryAsync() │
└──────┬───────────────────────┘
│
▼
┌──────────────────────────────┐
│ MqttPayloadFormatterFactory │
│ Creates platform formatter │
└──────┬───────────────────────┘
│
▼
┌──────────────────────────────┐
│ Platform Formatter │
│ (ThingsBoard, Ubidots, etc) │
│ Formats to platform JSON │
└──────┬───────────────────────┘
│
▼
┌──────────────────────────────┐
│ MqttService │
│ Publishes to broker │
└──────┬───────────────────────┘
│
▼
┌──────────────────────────────┐
│ MQTT Broker │
│ (ThingsBoard, Ubidots, etc) │
└──────────────────────────────┘
🏗️ System Architecture Diagram
┌────────────────────────────────────────────────────────────────────────┐
│ CatLoggerEasy Application │
├────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────┐ ┌──────────────────────┐ │
│ │ SettingsMqttView │ │ SettingsCloudPublish │ │
│ │ (MQTT Connection) │ │ (Publishing Config) │ │
│ └──────────┬───────────┘ └──────────┬───────────┘ │
│ │ │ │
│ ├──────────────┬───────────────────┤ │
│ │ │ │ │
│ ┌──────────▼──────────┐ │ ┌──────────────▼──────────┐ │
│ │ SettingsMqttViewModel│ │ │SettingsCloudPublishVM │ │
│ └──────────┬───────────┘ │ └──────────────┬──────────┘ │
│ │ │ │ │
│ ┌──────────▼──────────────▼───────────────────▼──────────┐ │
│ │ MqttSettingsManager │ │
│ │ (Loads/Saves Settings.json) │ │
│ └──────────────────────────┬──────────────────────────────┘ │
│ │ │
│ ┌──────────────────────────▼──────────────────────────────┐ │
│ │ ProcessDataViewViewModel │ │
│ │ • Manages UiChannels (ProcessData table) │ │
│ │ • Reads EtherCAT data via DataRepo │ │
│ │ • Builds telemetry snapshots │ │
│ │ • Triggers MQTT publishing │ │
│ └──────────────────────────┬──────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ MqttTelemetryService │ │
│ │ • Manages formatter instances │ │
│ │ • Handles connections │ │
│ │ • Publishes telemetry, events, alerts │ │
│ └──────────────────────────┬──────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ MqttPayloadFormatterFactory │ │
│ │ CreateFormatter(MqttPlatform) → IMqttPayloadFormatter │ │
│ └──────────────────────────┬──────────────────────────────┘ │
│ │ │
│ ┌──────────────┼──────────────┐ │
│ │ │ │ │
│ ┌─────────▼───────┐ ┌──▼──────────┐ ┌─▼──────────────┐ │
│ │ ThingsBoard │ │ Ubidots │ │ Generic │ │
│ │ Formatter │ │ Formatter │ │ Formatter │ ... │
│ └─────────┬───────┘ └──┬──────────┘ └─┬──────────────┘ │
│ │ │ │ │
│ └─────────────┼──────────────┘ │
│ │ │
│ ┌─────────────▼──────────────┐ │
│ │ MqttService │ │
│ │ (MQTTnet client wrapper) │ │
│ └─────────────┬──────────────┘ │
│ │ │
└────────────────────────────┼───────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ MQTT Broker / IoT Platform │
│ • ThingsBoard Cloud │
│ • Ubidots Industrial │
│ • HiveMQ Cloud │
│ • Public brokers (broker.emqx.io) │
│ • Custom brokers │
└────────────────────────────────────────┘
👨💻 Developer Onboarding Checklist
If you’re new to this codebase…
Here’s the recommended path to understanding the MQTT system:
Step 1: Understand the Core Concepts (30 minutes)
- Read
IMqttPayloadFormatter.cs– Understand the interface - Look at
GenericFormatterinMqttPayloadFormatters.cs– Simplest implementation - Compare with
ThingsBoardFormatter– See how formats differ - Review
MqttPayloadFormatterFactory– See how formatters are created
Step 2: Trace a Publish Flow (45 minutes)
- Open
ProcessDataViewViewModel.cs - Find
OnMqttTelemetryTimerElapsed()– Entry point - Follow to
PublishMqttRealtimeTelemetryAsync() - See how
BuildTelemetrySnapshot()creates data - Follow the call to
_telemetryService.PublishTelemetryAsync() - See how formatter is selected and used
Step 3: Run and Debug (30 minutes)
- Set breakpoint in
BuildTelemetrySnapshot() - Run application with EtherCAT simulation
- Enable Cloud Publishing
- Watch the debugger hit your breakpoint
- Step through to see data flow
- Use MQTT Explorer to see actual published messages
Step 4: Make a Small Change (1 hour)
Practice Task: Add a new platform (e.g., “MQTT.fx Broker”)
- Add
MQTTfxtoMqttPlatformenum - Create
MqttfxFormatterclass implementingIMqttPayloadFormatter - Add case to
MqttPayloadFormatterFactoryswitch - Test connection and publishing
Key Files Reference Card
| File | When to Modify |
|---|---|
IMqttPayloadFormatter.cs |
Adding new methods all formatters need |
MqttPayloadFormatters.cs |
Adding new platform support |
MqttSettings.cs |
Adding new platform to enum |
MqttTelemetryService.cs |
Adding new publishing features |
ProcessDataViewViewModel.cs |
Changing what/how data is published |
SettingsMqttView.axaml |
Modifying connection UI |
✅ Summary
The MQTT system refactor transformed a rigid, platform-specific implementation into a flexible, extensible architecture supporting 7+ IoT platforms with minimal code changes.
New Files
Modified Files
Platforms Supported
Backward Compatible
Document Version: 1.0.0 | Last Updated: January 2026
CatLoggerEasy MQTT System Architecture Guide
📘 Platform Setup Guides |
🔧 Data Control Guide |
🚀 Implementation Steps
“`