Skip to content

Commit

Permalink
test: Fix glow simulator mqtt issue
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Ware <[email protected]>
  • Loading branch information
srware committed Jan 7, 2023
1 parent d73a832 commit d532375
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions glow_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ def publish_payloads():
data = json.load(f)

while True:
for i in data['payloads']:
topic = i['topic']
payload = i['payload']
print(i)
if mqttc.is_connected():
for i in data['payloads']:
topic = i['topic']
payload = i['payload']
print(i)

mqttc.publish(topic, json.dumps(payload), retain=True)
mqttc.publish(topic, json.dumps(payload), retain=True)

time.sleep(interval)
time.sleep(interval)

try:
# Create MQTT client
mqttc = mqtt.Client()
mqttc.on_connect = on_connect
mqttc.username_pw_set(mqtt_username,mqtt_password)
mqttc.connect(mqtt_address, mqtt_port, 60)
mqttc.loop_start()

publish_payloads()
except KeyboardInterrupt:
Expand Down

0 comments on commit d532375

Please sign in to comment.