/protocol-hvlp

Simplified MQTT protocol demo (Hilscher Variable Length Protocol) used for training purposes

Primary LanguagePythonMIT LicenseMIT

HVLP - Hilscher Variable Length Protocol

HVLP is a simple protocol for sending messages between clients and a broker. The protocol is based on the MQTT protocol and is implemented in Python. The main focus of the project is to demonstrate the use of OOP, SOLID principles, sockets and threading in Python.

Features

  • Connect to a broker
  • Subscribe to a topic
  • Publish to a topic
  • Disconnect from a broker
  • Support for multiple clients

Project Setup

1. Clone the HVLP project

Use a git client to clone the project from https://github.com/braboj/hvlp to a folder of your choice.

2. Go to the project folder

Type cd <path to project folder>

3. Open a new command terminal for the broker

Type set PYTHONPATH=. to add the root folder to the module search paths.

Type python broker.py <IP ADDR> <PORT> to start the broker. If omitted the default IP is 127.0.0.1 and the default port is 65432.

img.png

4. Open a new command terminal for a client

Type set PYTHONPATH=. to add the root folder to the module search paths.

Type python client.py <SERVER ADDR> <PORT> to start the client. If omitted the default server address is 127.0.0.1 and the default port s 65432.

img.png

5. Connect the client to the broker

Type connect in the client console to connect to the broker

img.png

6. Subscribe the client to a topic

Type subscribe test in the client console to subscribe to a topic

img.png

7. Repeat steps 4-6 to add a second client

img.png

8. Publish to a topic

Type publish test 1 in one of the client consoles.

img.png

9. Get help how to use the application

Type help in the client console for more commands

img.png

10. Exit the applications

Type quit or press CTRL + C in a client console to exit the client. To exit the broker press CTRL + C. There might be a slight delay (1-2 seconds) until the application ends.