Skip to content

MQTT broker

Kamila Y edited this page May 30, 2021 · 16 revisions

MQTT protocol enables bi-directional communication between the SmartRover emulator and the Frontend app, so that you can receive telemetry data and camera stream and send driving commands from control pad or console terminal. For the best performance, it is recommended to install a local MQTT broker on your computer and configure both emulator and the frontend to connect to "localhost". Or for more realistic experience of a "delayed" communication between the SmartRover, Mars Orbiter and the Earth, you can choose and use from numerous online MQTT brokers.


How to install Mosquitto broker (https://mosquitto.org/download/)

macOS

1. Install Homebrew (https://brew.sh/) In your macOS Terminal paste this command

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

after installing Homebrew

2. Install Mosquitto broker

and paste this command to your macOS terminal

brew install mosquitto

the install script finishes with the guides on how to get started.

3. run the following command

ln -sfv /usr/local/opt/mosquitto/*.plist ~/Library/LaunchAgents

4. To restart and save, run the command:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist
To test the installation and ensure the server is running successfully: 
Open a new command window and start a listener.

mosquitto_sub -t topic/state

In another window, send a message to the listener.

mosquitto_pub -t topic/state -m "I am installed successfully!"

5. Finally:

5.1 Go to the following directory:

/usr/local/etc/mosquitto/mosquitto.conf
  • Rename original mosquito.conf into mosquito.conf.bak
  • Prepare a new mosquitto.conf
    • find the line allow_anonymous and set it to true:

       allow_anonymous = true
       
       this allows you to create a server with any user name. 
      
    • max_connections 99

5.2 Stop Mosquitto broker

     brew services stop mosquito

5.3 Start Mosquitto broker

  mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf

6. Optional: to have a structured overview of MQTT topics install MQTT explorer(you can definitely work without this).

Windows

You can install mosquitto broker from their website (https://mosquitto.org/download/) or click on the latest releases for direct download


How to configure Mosquitto broker


How to configure SmartRover MQTT settings

It is too easy to configure our SmartRover MQTT settings, you just do it in a three steps

  • 1. Click "SETTINGS" in SmartRover app main navigation menu

  • 2. Click on "MQTT SETTINGS" tab in the left

  • 3. Then you can start inserting the required fields


Common problems and troubleshooting


Clone this wiki locally