WiFi101 included but didn't used to be

Hey, our arduino code (Adafruit Wippersnapper firmware - repo) used to compile on a few platforms (pico esp32 esp8266), and didn’t need WiFi101 in the lib_ignore list, but as of today it fails to build, and therefore does need WiFi101 adding to lib_ignore for those platforms. Why could that be, what changed/broke?

This is the branch in case anyone wants to play with the platformIO ini file. There are common environments at the top where we define the lib_ignore entries. Just search for WiFi101…

or in case that’s merged then this commit ref

WiFi101 is at first faithfully included as a depenency of the Adafruit MQTT Library

Then this library has the following files

grafik

In add wifi changes to pico, fix pio ini to avoid compile override · adafruit/Adafruit_Wippersnapper_Arduino@e539047 · GitHub, you have introduced

#include <WiFiClient.h>

into ws_networking_pico.h,

grafik

which although it is, during compilation, deactivated (since it’s for RP2040), with the default lib_ldf_mode that does not evaluate #ifdefs (docs), PlatformIO detects an include to WiFiClient.h which it detects in WiFi101, which then triggers that library to built.

You can observe for yourself that if you delete line 26, the build for featheresp32v2 will go through again.

Checking size .pio\build\featheresp32v2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.9% (used 52164 bytes from 327680 bytes)
Flash: [====      ]  42.8% (used 1430445 bytes from 3342336 bytes)
Building .pio\build\featheresp32v2\firmware.bin

Hence, the answer to

is, that commit broke it.

As thus, PlatformIO’s library dependency finder (LDF) works as documented in this case, it just works against you.

Setting lib_ignore = WiFi101, ... for all ESP32 targets would be wise, since I cannot imagine an ESP32 chip wanting to use an external WiFi chip. Setting lib_ldf_mode = chain+ to evaluate the #ifdef is also valid but makes library detection considerably slower.

1 Like

In fact, if none of the boards you build for are expected to run with WiFi101, lib_ignore’ing WiFi101 in all environments is probably best. Then, the RP2040 environment will find WiFiClient.h in its builtin library too, without a chance to maybe find it in WiFi101. As I see it, the Adafruit MQTT library code never even includes WiFi101.h or similiar, but only some example code does. Best to get rid of it.

Or maybe, much much simpler: Just

#include <WiFi.h>

instead of

#include <WiFiClient.h>
#include <WiFiClientSecure.h>

in ws_networking_pico.h. It will automatically include WiFIClient.h and WiFiClientSecure.h, as per source. You shouldn’t trigger the inclusion of those “sub” headers directly, the whole WiFi.h library is fine, and it shouldn’t trigger the inclusion of WiFi101 since it uses the sepearte WiFi101.h name.

1 Like

Thanks Max for the rapid reply, and docs links and mention of chain+ but the slowdown, you’re a beauty!

What I don’t quite get (late / tired) is I didn’t think we added that change to the ESP8266 build as we use it differently, but it’s appeared to pick it up too and didn’t previously. Pick the huzzah build target and you get the esp8266, but you’ll see I added WiFi101 to that lib_ignore today too. Maybe it didn’t clean properly but I thought it failed on wifi101 too.

You’re totally right to point out the removal from the MQTT library too, I heard it mentioned before, but half recollect something about needing the older boards examples still working maybe. Overzealous library dependencies · Issue #229 · adafruit/Adafruit_MQTT_Library · GitHub