From a0eb1ccaef0d9370b172f6c3402e453256d66d3c Mon Sep 17 00:00:00 2001 From: tony19990828 <58881058+tony19990828@users.noreply.github.com> Date: Fri, 18 Feb 2022 22:35:37 +0800 Subject: [PATCH] Update local_mqtt_pub_without_ros.py --- localTest/local_mqtt_pub_without_ros.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/localTest/local_mqtt_pub_without_ros.py b/localTest/local_mqtt_pub_without_ros.py index 80e01b0..ec6c81a 100644 --- a/localTest/local_mqtt_pub_without_ros.py +++ b/localTest/local_mqtt_pub_without_ros.py @@ -5,12 +5,13 @@ import numpy as np + def on_connect(self, userdata, flags, rc): # print("Connected with result code " + str(rc)) pass -def initialise_clients(cname): +def initialise_clients(clientname): # callback assignment initialise_client = mqtt.Client(clientname, False) initialise_client.topic_ack = [] @@ -22,18 +23,18 @@ def publish(topics, message, waitForAck=False): mid = client.publish(topics, message, 2)[1] print(f"just published {message} to topic") if waitForAck: - while mid not in client.top_ack: + while mid not in client.topic_ack: print("wait for ack") time.sleep(0.25) - client.top_ack.remove(mid) + client.topic_ack.remove(mid) def on_publish(self, userdata, mid): print("ack") - client.top_ack.append(mid) + client.topic_ack.append(mid) -host = "192.168.50.180" +host = "192.168.1.110" port = 1883 topic = "mqtt/pub"