peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
549 stars 116 forks source link

Add LED support to config.py for Pico and Pico W devices? #86

Closed Jibun-no-Kage closed 1 year ago

Jibun-no-Kage commented 1 year ago

Looking at config.py, I was surprised to not see the LED for Pico devices not supported? I had to add the following to my wifi coro to turn the LED on when connected and then off when not. Just a suggestion.

Here is my wifi coro code snippet.

async def OnWiFi(theState): theModel=sys.implementation._machine if 'Pico W' in theModel: LED='LED' elif 'Pico' in theModel: LED=25 thePin=machine.Pin(LED, Pin.OUT, value=theState)

Of course I call 'asyncio.run(OnWiFi(False))' to turn it off when needed. Say when I Cntl-C will testing or on a reset.

peterhinch commented 1 year ago

Thank you for the suggestion. I've pushed an update to config.py which enables the LED to work with the example scripts.

Jibun-no-Kage commented 1 year ago

Cool. Thanks.