from wifi_lib import conecta
from umqttsimple import MQTTClient
import urequests
import time
mqtt_server = "broker.mqttdashboard.com"
mqtt_port = 1883
mqtt_user = ""
mqtt_password = ""
mqtt_client_id = "clientId-4Jl9Y9gDd9-wokwi"
def recebi(topico, msg):
print(topico.decode())
print(msg.decode())
print("Conectando...")
station = conecta("Wokwi-GUEST", "")
if not station.isconnected():
print("Falha na conexão")
else:
print("Conectado")
print("Conectando Broker HiveMQTT")
client = MQTTClient(mqtt_client_id,
mqtt_server,
mqtt_port,
mqtt_user,
mqtt_password)
client.connect()
client.publish("pgp/codigo-professor/msg_wokwi", "teste wokwi")
time.sleep(5)
client.set_callback(recebi)
client.subscribe("pgp/codigo-professor/msg_hive")
client.sleep(10)
client.disconnect()
station.disconnect()