def main(server=SERVER):
global c
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(SSID, PASS)
while not wlan.isconnected():
pass
print('[Network Config]\n ', wlan.ifconfig())
c = MQTTClient(CLIENT_ID, server)
reconnect()
set_led() # sets led to off
try:
while True:
if not wlan.isconnected():
reconnect()
c.wait_msg()
finally:
c.disconnect()
评论列表
文章目录