From 33c66d8741c31471ddcf8e65df2d3d9e47fb39b5 Mon Sep 17 00:00:00 2001 From: BillChen235 Date: Wed, 2 Aug 2023 02:09:51 +0800 Subject: [PATCH] BillChen235 The Example for Data transferring by MQTT on local --- localTest/local_mqtt_pub_without_ros.py | 7 +++---- localTest/local_mqtt_sub_without_ros.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/localTest/local_mqtt_pub_without_ros.py b/localTest/local_mqtt_pub_without_ros.py index ec6c81a..79fd01e 100644 --- a/localTest/local_mqtt_pub_without_ros.py +++ b/localTest/local_mqtt_pub_without_ros.py @@ -1,6 +1,6 @@ import paho.mqtt.client as mqtt import time -import numpy as np + @@ -34,7 +34,7 @@ def on_publish(self, userdata, mid): client.topic_ack.append(mid) -host = "192.168.1.110" +host = "127.0.0.1" port = 1883 topic = "mqtt/pub" @@ -52,8 +52,7 @@ client.loop_start() publish(topic, "Connect", True) count = 0 while True: - randTemp = np.random.uniform(25.0, 35.0) - publish(topic, randTemp) + publish(topic, "publish somthing") time.sleep(2) print(count) count += 1 diff --git a/localTest/local_mqtt_sub_without_ros.py b/localTest/local_mqtt_sub_without_ros.py index c9f393f..cfad305 100644 --- a/localTest/local_mqtt_sub_without_ros.py +++ b/localTest/local_mqtt_sub_without_ros.py @@ -18,7 +18,7 @@ def initialise_clients(cname): return initialise_client -host = "192.168.0.48" +host = "127.0.0.1" port = 1883 topic = "data/pub"