Page 1 of 1

mqtt_as – static IP

Posted: Tue Sep 28, 2021 8:13 pm
by pidou46
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 ?

Re: mqtt_as – static IP

Posted: Tue Sep 28, 2021 9:09 pm
by davef
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.

Re: mqtt_as – static IP

Posted: Wed Sep 29, 2021 4:46 am
by pythoncoder
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.