Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 1.56 KB

File metadata and controls

29 lines (20 loc) · 1.56 KB

MQTT Helper Tools

A small WPF desktop tool for connecting to and disconnecting from an MQTT broker. Used as a helper for other projects that rely on an MQTT broker.

What it does

  • Connect to an MQTT broker using URL and password (credentials entered in the UI).
  • Disconnect from the broker.
  • Status indicator (red/green) and reactive UI: buttons and inputs enable/disable based on connection state, including when the connection drops unexpectedly (polling every second).

How to run

  • Requirements: .NET 9 SDK, Windows (WPF).
  • Build and run:
    • Open MqttHelperTools.sln in Visual Studio or Rider, or from the repo root:
    • dotnet build
    • dotnet run --project MqttHelperTools
  • Enter the broker URL (e.g. hostname or IP, with optional port) and password, then use Connect / Disconnect.

Tech and design

  • WPF for the UI; MQTTnet for the MQTT client.
  • Single client instance: one MQTT client is created at startup and reused; Connect/Disconnect only change its state (no new client per click).
  • Threading: a background task polls connection state and updates the UI via Dispatcher.Invoke so the status and button/input state stay in sync without cross-thread access.
  • Cleanup: polling is cancelled and the MQTT client is disposed when the window closes (Closed event; IDisposable on the wrapper, inner client disposed in finally).

Project structure

  • MqttHelperTools/ – WPF app: MainWindow (UI + connect/disconnect handlers, polling), MqttClient (thin wrapper around MQTTnet, connect/disconnect, dispose).