# Path: mqtt_as/config.py
# def ledfunc(pin):
#     def func(v):
# def ledfunc(led, init):
#     def func(v):


import rtc_time_cfg
import uasyncio as asyncio
import rtc_time
from mqtt_as import MQTTClient, config
from config import wifi_led, blue_led

async def pulse():  # This demo pulses blue LED each time a subscribed msg arrives.
    blue_led(True)
    await asyncio.sleep(1)
    blue_led(False)

def sub_cb(topic, msg, retained):
    print((topic, msg, retained))
    loop.create_task(pulse())

async def wifi_han(state):
    global outages
    wifi_led(not state)  # Light LED when WiFi down
    if state:
        print('We are connected to broker.')
    else:
        outages += 1
        print('WiFi or broker is down.')
    await asyncio.sleep(1)

async def conn_han(client):
    await client.subscribe('foo_topic', 1)

async def main(client):
    try:
        await client.connect()
    except OSError:
        print('Connection failed.')
        return
    n = 0

# Path: mqtt_as/config.py
# def ledfunc(pin):
#     def func(v):
# def ledfunc(led, init):
#     def func(v):


# Path: mqtt_as/lowpower.py
import rtc_time_cfg
import uasyncio as asyncio
import rtc_time
from mqtt_as import MQTTClient, config
from config import wifi_led, blue_led


async def pulse():  # This demo pulses blue LED each time a subscribed msg arrives.
    blue_led(True)
    await asyncio.sleep(1)
    blue_led(False)

def sub_cb(topic, msg, retained):
    print((topic, msg, retained))
    loop.create_task(pulse())

async def wifi_han(state):
    global outages
    wifi_led(not state)  # Light LED when WiFi down
    if state:
        print('We are connected to broker.')
    else:
        outages += 1
        print('WiFi or broker is down.')
    await asyncio.sleep(1)

async def conn_han(client):
    await client.subscribe('foo_topic', 1)

async def main(client):
    try:
        await client.connect()
    except OSError:
        print('Connection failed.')
        return
    n = 0

    while True: