MQTT Broker - The-Bug-Bashers/iBOARCode GitHub Wiki

Overview

Mosquitto is the central MQTT server that handles all messages between the iBOAR modules (services).

Each service acts as a client that can publish or subscribe to topics.


Basic MQTT Concepts

Clients

  • Can publish messages or subscribe to topics.

Topics

  • Topics are like communication channels.
  • Subscribing to a topic means you receive all messages sent to that channel.

QoS (Quality of Service) Levels

Level Description Example Use
0 Fire and forget (no confirmation). Fast but not guaranteed. Lidar Controller data updates
1 Delivered at least once. May duplicate messages. Remote control commands
2 Guaranteed exactly once. Slowest but safest. Critical commands (e.g., startAutonomousMapping)

Topic Structure

  • Format: topic/subTopic/...
  • Wildcards:
    • topic/#: Subscribe to all subtopics.
    • +/subTopic: Subscribe to a specific subtopic under any first-level topic.

🛠️ Commands

Action Command
Start Broker sudo systemctl start mosquitto
Stop Broker sudo systemctl stop mosquitto
Subscribe to Topic mosquitto_sub -h localhost -t "example/topic"
Publish to Topic mosquitto_pub -h localhost -t "example/topic" -m "Test message"