2 次代码提交 ef86f7f453 ... ed6ae013dc

作者 SHA1 备注 提交日期
  DESKTOP-6EVJ8GG\kenneth ed6ae013dc Merge branch 'ZJZGJ' of http://www.sri-robot.cn:30000/SRI-DINO/Server-py into ZJZGJ 2 月之前
  DESKTOP-6EVJ8GG\kenneth 4293e0084f UPDATE 2 月之前
共有 2 个文件被更改,包括 16 次插入15 次删除
  1. 13 13
      3rdparty/xclient/xmqtt.py
  2. 3 2
      sri-server-bg02/test/test-mqtt-sender.py

+ 13 - 13
3rdparty/xclient/xmqtt.py

@@ -58,13 +58,13 @@ class Client(mqtt.Client):
 
 if __name__ == '__main__':
     # --- init ---
-    # c1 = Client(host='127.0.0.1', port=41883)
-    c1 = Client(host='192.168.131.23', port=41883)
+    # c1 = Client(host='192.168.131.23', port=41883)
+    c1 = Client(host='127.0.0.1', port=41883)
 
     # --- test subscribe ---
-    # def m1(_, __, p3):
-    #     print(f"#message.payload: {json.loads(p3.payload)}")
-    # c1.start_subscribe_loop(decorate_method=m1, subscribe_topic='test/topic')
+    def m1(_, __, p3):
+        print(f"#message.payload: {json.loads(p3.payload)}")
+    c1.start_subscribe_loop(decorate_method=m1, subscribe_topic='bg/log')
 
     # --- test publish ---
     # while True:
@@ -79,11 +79,11 @@ if __name__ == '__main__':
     #     time.sleep(3)
 
     # --- test publish ---
-    while True:
-        data = {
-            'address': "192.168.131.180",
-            'state': 2,
-            'direction': 22,
-        }
-        c1.publish_message('hs/vehicle/state', json.dumps(data))
-        time.sleep(3)
+    # while True:
+    #     data = {
+    #         'address': "192.168.131.180",
+    #         'state': 2,
+    #         'direction': 22,
+    #     }
+    #     c1.publish_message('hs/vehicle/state', json.dumps(data))
+    #     time.sleep(3)

+ 3 - 2
sri-server-bg02/test/test_mqtt.py → sri-server-bg02/test/test-mqtt-sender.py

@@ -3,7 +3,8 @@ import time
 import json
 
 client = mqtt.Client()
-client.connect(host='10.10.61.229', port=41883)
+# client.connect(host='10.10.61.229', port=41883)
+client.connect(host='127.0.0.1', port=41883)
 
 
 def test_bg_log():
@@ -32,4 +33,4 @@ if __name__ == '__main__':
     # --- test ---
     while True:
         test_bg_log()
-        time.sleep(10)
+        time.sleep(3)