Kommunikation TXT-Controller (MQTT)

fischertechnik in General
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
jonas94x
Beiträge: 6
Registriert: 15 Apr 2022, 16:08

Kommunikation TXT-Controller (MQTT)

Beitrag von jonas94x » 21 Apr 2022, 21:09

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 😊
Dateianhänge
mosquitto.JPG
mosquitto.JPG (66.91 KiB) 647 mal betrachtet

vleeuwen
Beiträge: 1564
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Kommunikation TXT-Controller (MQTT)

Beitrag von vleeuwen » 21 Apr 2022, 22:03

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
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Antworten