update
This commit is contained in:
parent
f64b804a7d
commit
9883fff26a
8
test.py
8
test.py
|
@ -20,17 +20,15 @@ class MQTTClient:
|
||||||
self.client = mqtt.Client()
|
self.client = mqtt.Client()
|
||||||
self.client.username_pw_set(self.username, self.password)
|
self.client.username_pw_set(self.username, self.password)
|
||||||
|
|
||||||
async 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)
|
||||||
await asyncio.sleep(10)
|
|
||||||
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)
|
||||||
|
|
||||||
async 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)
|
||||||
await asyncio.sleep(10)
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -93,4 +91,4 @@ def close_stream(username, device):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
broker = 'mqtt.lihaink.cn'
|
broker = 'mqtt.lihaink.cn'
|
||||||
port = 1883
|
port = 1883
|
||||||
uvicorn.run(app, host="127.0.0.1", port=8001)
|
uvicorn.run(app, host="127.0.0.1", port=8002)
|
||||||
|
|
Loading…
Reference in New Issue