update
This commit is contained in:
parent
3cca058837
commit
395219ff13
3
test.py
3
test.py
|
@ -1,5 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
@ -22,12 +23,14 @@ class MQTTClient:
|
||||||
def push(self):
|
def push(self):
|
||||||
self.client.publish(self.topic, payload=json.dumps({"msg": "open_led"}, ensure_ascii=False),
|
self.client.publish(self.topic, payload=json.dumps({"msg": "open_led"}, ensure_ascii=False),
|
||||||
qos=0)
|
qos=0)
|
||||||
|
time.sleep(5)
|
||||||
self.client.publish(self.topic, payload=json.dumps({"msg": "push_stream"}, ensure_ascii=False),
|
self.client.publish(self.topic, payload=json.dumps({"msg": "push_stream"}, ensure_ascii=False),
|
||||||
qos=0)
|
qos=0)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.client.publish(self.topic, payload=json.dumps({"msg": "close_stream"}, ensure_ascii=False),
|
self.client.publish(self.topic, payload=json.dumps({"msg": "close_stream"}, ensure_ascii=False),
|
||||||
qos=0)
|
qos=0)
|
||||||
|
time.sleep(5)
|
||||||
self.client.publish(self.topic, payload=json.dumps({"msg": "close_led"}, ensure_ascii=False),
|
self.client.publish(self.topic, payload=json.dumps({"msg": "close_led"}, ensure_ascii=False),
|
||||||
qos=0)
|
qos=0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue