20 lines
588 B
Python
20 lines
588 B
Python
|
from threading import Event
|
||
|
from loguru import logger
|
||
|
from MqttBase import AbstractMqttPublisher
|
||
|
|
||
|
|
||
|
class TestPublish(AbstractMqttPublisher):
|
||
|
def __init__(self, config):
|
||
|
super().__init__(config)
|
||
|
|
||
|
def localLoop(self):
|
||
|
cnt = 0
|
||
|
while not self.killBill:
|
||
|
cnt += 1
|
||
|
topic = self.config["publishTopic"]
|
||
|
payload = str(cnt)
|
||
|
self.client.publish(topic, payload)
|
||
|
logger.warning("mqtt message sent: {} -> {}".format(topic, payload))
|
||
|
|
||
|
self.killEvent.wait(timeout=float(self.config["publishPeriod"]))
|