This commit is contained in:
xyj 2023-12-29 18:05:38 +08:00
parent 3cca058837
commit 395219ff13
1 changed files with 3 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import asyncio
import json
import time
import uvicorn
from fastapi import FastAPI
@ -22,12 +23,14 @@ class MQTTClient:
def push(self):
self.client.publish(self.topic, payload=json.dumps({"msg": "open_led"}, ensure_ascii=False),
qos=0)
time.sleep(5)
self.client.publish(self.topic, payload=json.dumps({"msg": "push_stream"}, ensure_ascii=False),
qos=0)
def close(self):
self.client.publish(self.topic, payload=json.dumps({"msg": "close_stream"}, ensure_ascii=False),
qos=0)
time.sleep(5)
self.client.publish(self.topic, payload=json.dumps({"msg": "close_led"}, ensure_ascii=False),
qos=0)