mqtt_as – static IP

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

mqtt_as – static IP

Post by pidou46 » Tue Sep 28, 2021 8:13 pm

Hi,

I have a dedicated wifi network for mqtt without DHCP (static IP), does mqtt_as support this setup ?

I have digged a little in mqtt_as code, I have found that : wifi_connect() function does not call ifconfig() before calling connect(), so static IP is not configured before trying to connect, so it lead to « OSError: Wifi Internal Error »

Am I right ?
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: mqtt_as – static IP

Post by davef » Tue Sep 28, 2021 9:09 pm

I'd try adding:

Code: Select all

sta_if.ifconfig((config.WiFi_device, '255.255.255.0', config.gateway, '8.8.8.8'))
before the connect()

I have noticed that sometimes, during code development, on a ESP32 that I have to do a hard re-boot or I get that error.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: mqtt_as – static IP

Post by pythoncoder » Wed Sep 29, 2021 4:46 am

Re WiFi internal error there was an issue raised which I fixed 5 days ago. You may want to grab the latest code.

The code does assume a DHCP server. The relevant line is here. I imagine it would be easy to change this to use a fixed IP. Most of my testing was with a broker on a fixed IP, but the DHCP server was responding to the getaddrinfo query. So replacing this line should work but I haven't time to investigate it in detail at the moment.
Peter Hinch
Index to my micropython libraries.

Post Reply