|
@@ -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)
|