This commit is contained in:
xyj 2024-01-02 11:24:12 +08:00
parent dc5a610d4b
commit 5f4fd8506a
1 changed files with 4 additions and 4 deletions

View File

@ -20,17 +20,17 @@ class MQTTClient:
self.client = mqtt.Client()
self.client.username_pw_set(self.username, self.password)
def push(self):
async def push(self):
self.client.publish(self.topic, payload=json.dumps({"msg": "open_led"}, ensure_ascii=False),
qos=0)
time.sleep(5)
await asyncio.sleep(5)
self.client.publish(self.topic, payload=json.dumps({"msg": "push_stream"}, ensure_ascii=False),
qos=0)
def close(self):
async def close(self):
self.client.publish(self.topic, payload=json.dumps({"msg": "close_stream"}, ensure_ascii=False),
qos=0)
time.sleep(5)
await asyncio.sleep(10)
self.client.publish(self.topic, payload=json.dumps({"msg": "close_led"}, ensure_ascii=False),
qos=0)