-
Notifications
You must be signed in to change notification settings - Fork 7
Getting Starting with Mosquitto MQTT Broker
Update homebrew. (The --verbose flag just makes it easier to know the progress of the update process.)
brew update --verbose
Install Mosquitto.
brew install mosquitto
After installing Mosquitto, there should be a mosquitto.conf file located in the /usr/local/etc/mosquitto folder. Open it with a text editor.
vim /usr/local/etc/mosquitto/mosquitto.conf
Add the following lines to mosquitto.conf:
listener 1883
allow_anonymous true
NOTE: The allow_anonymous true
setting is just used for evaluating the MQTT Bypass feature. Without this, you might struggle with Client <unknown> disconnected, not authorised.
errors. It's better to define the IP address of the gateways and machines that you want data from.
NOTE: Port 8883 is reserved for TLS encrypted MQTT connections. The client will load the system CA certificates and use TLS mode if port 8883 is used without specifying your own certificates. It is recommended to either use port 1883 or add TLS encryption to the port 8883 listener.
Save the file.
Run Mosquitto using the following command:
/usr/local/sbin/mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
The terminal should show something like this:
1629147983: mosquitto version 2.0.10 starting
1629147983: Config loaded from /usr/local/etc/mosquitto/mosquitto.conf.
1629147983: Opening ipv6 listen socket on port 1883.
1629147983: Opening ipv4 listen socket on port 1883.
1629147983: mosquitto version 2.0.10 running
For an easy way to evaluate the Cassia Gateways MQTT Bypass feature, you can set up the MQTT client locally. From the terminal, just run the following command:
mosquitto_sub -t scanTopic -p 1883 -h localhost
NOTE: It is always recommended to have a more secure connection by adding a username and password to the MQTT communication, but for the purpose of evaluating the MQTT Bypass feature quickly, we recommend this command.
After running the mosquitto_sub command, in the terminal running the MQTT broker server, you should see something like this:
1629148763: New connection from ::1:61446 on port 1883.
1629148763: New client connected from ::1:61446 as auto-56DBE474-A6B8-16FC-770A-24FD6F34B7D7 (p2, c1, k60).
To test the scanTopic
topic, you can run the mosquitto_pub command:
mosquitto_pub -h localhost -m "testing" -t scanTopic
After running this command, in the MQTT broker server terminal window, you should see something like this:
1629149048: New connection from ::1:63050 on port 1883.
1629149048: New client connected from ::1:63050 as auto-AAF2A6B3-A9C9-E218-8C88-31F6DC319D84 (p2, c1, k60).
1629149048: Client auto-AAF2A6B3-A9C9-E218-8C88-31F6DC319D84 disconnected.
In the MQTT client terminal window, you should see the word "testing" being outputted to the screen like this:
testing
NOTE: The Host is the MQTT Broker server IP address.
Click on Apply (Standalone Gateway Mode) or Save (AC Managed Gateway Mode) to apply the MQTT Bypass settings.
After a while, in the MQTT Broker terminal window, you should see something like this:
1629150774: New connection from 192.168.4.26:54490 on port 1883.
1629150774: New client connected from 192.168.4.26:54490 as cc:1b:e0:e0:fc:70-0 (p1, c1, k60).
In the MQTT Client terminal window, there should be a continuous stream of data from the scanTopic
topic.
This guide is just to get you started with the Mosquitto MQTT broker. To learn more about what you can do with the Mosquitto MQTT broker, please visit this website: https://mosquitto.org
Please feel free to reach out to Cassia Support for any questions.
Copyright © 2021 Cassia Networks, Inc.
RESTful API
-
Traffic Related API
- Scan Bluetooth Devices
- Filter Scanned Data based on Device MAC, RSSI, Name, and UUID
- Enhanced Scan Filter (v2.0 and above)
- Connect/Disconnect to a Target Device
- Batch Connect to a Target Device (v2.0 and above)
- Discover GATT Services and Characteristics
- Read/Write the Value of a Specific Characteristic
- Send Advertise Data
- Get Device Connection Status
- Receive Notification and Indication
- Get RSSI for BLE Connection (v2.0 and above)
-
Secure Pairing API
-
Router Auto-Selection API