ESP32: LDF picks wrong WiFi library

Hi there. I am having issues compiling for espressif32 type target; in particular, stuff like
• WiFi.mode
• WiFiClass member softAP
• WiFiClass member softAPIP
seems to be missing in the WiFi library resolved by ldf, which leads me to the conclusion, that a wrong type of WiFi library is being resolved by ldf. For some reason though, after editing or changing the platformio.ini file, it would sometimes pick the correct one, and sometimes not.

Here is my configuration considering platofrmio.ini:

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...

[env:heltec_wifi_lora_32]
upload_speed = 921600
upload_port = /dev/tty.SLAB_USBtoUART

platform = espressif32
board = heltec_wifi_lora_32
framework = arduino
lib_ldf_mode = off
lib_compat_mode = 0
lib_deps = U8g2, WiFi

Example code may look as follows:

/*
 * main.cpp
 *
 *  Created on: 6 Mar 2018
 *      Author: anonymous
 */
#include <Arduino.h>
#include <WiFi.h>


void setup(){
	WiFi.softAP("Foo", "Bar");
}

void loop(){

}

The resulting terminal output would be:

15:52:38 **** Incremental Build of configuration Default for project test-proj ****
platformio -f -c eclipse run 
[Tue Mar  6 15:52:38 2018] Processing heltec_wifi_lora_32 (framework: arduino; lib_ldf_mode: off; lib_deps: U8g2, WiFi; platform: espressif32; upload_speed: 921600; board: heltec_wifi_lora_32; upload_port: /dev/tty.SLAB_USBtoUART; lib_compat_mode: 0)
--------------------------------------------------------------------------------
LibraryManager: Installing id=942
Downloading...
Unpacking...
LibraryManager: Installing id=870
Downloading...
Unpacking...
Verbose mode can be enabled via `-v, --verbose` option
Collected 20 compatible libraries
Scanning dependencies...
Library Dependency Graph ( http://bit.ly/configure-pio-ldf )
|-- <U8g2> v2.22.2
|-- <WiFi> v1.2.7
Compiling .pioenvs/heltec_wifi_lora_32/src/main.o
Generating partitions .pioenvs/heltec_wifi_lora_32/partitions.bin
Archiving .pioenvs/heltec_wifi_lora_32/libFrameworkArduinoVariant.a
Indexing .pioenvs/heltec_wifi_lora_32/libFrameworkArduinoVariant.a
Compiling .pioenvs/heltec_wifi_lora_32/FrameworkArduino/Esp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:12:7: error: 'class WiFiClass' has no member named 'softAP'
WiFi.softAP("Foo", "Bar");
^
Compiling .pioenvs/heltec_wifi_lora_32/FrameworkArduino/HardwareSerial.o
Compiling .pioenvs/heltec_wifi_lora_32/FrameworkArduino/IPAddress.o
Compiling .pioenvs/heltec_wifi_lora_32/FrameworkArduino/IPv6Address.o
Compiling .pioenvs/heltec_wifi_lora_32/FrameworkArduino/MD5Builder.o
*** [.pioenvs/heltec_wifi_lora_32/src/main.o] Error 1
========================== [ERROR] Took 10.24 seconds ==========================

15:52:48 Build Finished (took 10s.762ms)

I have some news considering the issue. The issue goes away using lib_ldf_mode = chain+, since ldf uses a different version for the espressif32 platform.

However, using lib_ldf_mode = chain+ is not suitable at this point since in some other part of the original, bigger project, some include causes both versions to get included, and depending in which order (i am not sure whether the order is of relevance here) they are included, either WiFi (1.0, the correct ESP32 variant) or WiFi (1.2.7, the generic Arduino one) is used.

Why do you need external WiFi library here? It should be builtin in framework. Try to remove WiFi from deps and remove .piolibdeps folder from a project.

Dear @ivankravets,

Thank you very much for the hint. Considering the lib_deps, I didn’t know that built-in libraries shouldn’t be enumerated here.

Have a nice day

1 Like

Happy coding with PlatformIO!

1 Like