update
This commit is contained in:
parent
dc5a610d4b
commit
5f4fd8506a
8
test.py
8
test.py
|
@ -20,17 +20,17 @@ 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)
|
||||||
|
|
||||||
def push(self):
|
async 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)
|
await asyncio.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):
|
async 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)
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue