Simple subscriber for MQTT server

This is a simple program that shows how does the "subscriber" in MQTT server model works. It's a little bit more complicated than the "publisher" but it is still the basic things you need to know. As in the publisher we have an IP address which you have to edit to your case, for more explanation you can see this program. It also have a Client instance, but this time we have to "subscribe", not to "publish". The more complicated thing here is that we have one function called "on_message". It prints the topic and the message, which is posted. Our client is subscribed to topic "Air Conditioner" respectivly the printed topic always will be "Air Conditioner". The function is called every time when somebody post a message on this topic. For this purpouse we have the "on_message", which actually catches the messages. For now we'll not discuss what magic stands behind the "on_message".  The last thing you need to know is the infinite loop which we start, because our "subscriber" have to check non-stop for messages.

How to open?

Download
  • #r9thxj
  • 14 Dec 2018

Курсове и занятия включващи този Програма

Този Програма е използван в следните курсове и занятия.

Image for Perfect STEM course. Module 2 - 1D Games with Led strip.
  • 19
  • 0:00
  • 37
Image for Publisher and Subscriber
  • 0
  • 7
  • 3d_rotation 0