Seite 1 von 1

Kommunikation TXT-Controller (MQTT)

Verfasst: 21 Apr 2022, 21:09
von jonas94x
Hallo zusammen,
und zwar möchte eine Kommunikation zwischen zwei TXT-Controllern herstellen. Mein Ziel ist es das der erste TXT-Controller eine Nachricht published z.B „test“. Und der zweite TXT-Controller soll überprüfen, ob die folgende Nachricht angekommen ist und z.B „Text ist da“ printen (Zur Überprüfung das dieser auch wirklich überprüft hat das der Text da ist).
Der erste Controller hat eine andere IP-Adresse als der andere.
1 TXT-Controller : 192.168.178.XX
2 TXT-Controller : 192.168.178.XX

Es wäre echt nett, wenn mir jemand eine Lösung zeigen könnte 😊

Re: Kommunikation TXT-Controller (MQTT)

Verfasst: 21 Apr 2022, 22:03
von vleeuwen
Sorry but al the documentation is in English, it make no sense to translate this.

see: http://www.steves-internet-guide.com/mqtt-works/

Assume: 192.168.178.xx =MQTT-broker (service), xx can be 01, 02 or an other device with a MQTT broker

On 192.168.178.02 (and all the other system which have subscribe)
/usr/bin/mosquitto_sub.exe" -h 192.168.178.xx -t # -v -d
oder
/usr/bin/mosquitto_sub.exe" -h 192.168.178.xx -t test/topic -v -d

On 192.168.178.01
/usr/bin/mosquitto_pub -h 192.168.178.xx -t test/topic -m helloWorld -d

The 192.168.178.02 (and all the other system which have subscribe to that topic) will receive the message
helloWorld

Note: you don't publish to an certain client, only to the MQTT-broker.

=========================================================================================
In Python:
Subscribe to a topic and will receive the payloads for that topic:
http://www.steves-internet-guide.com/su ... tt-client/

Publish a topic with payload:
http://www.steves-internet-guide.com/pu ... tt-client/

In C++:
Subscribe and publish:
https://stackoverflow.com/questions/317 ... qtt-client
https://github.com/eclipse/paho.mqtt.cpp