I’m trying to add the WebSerial
library to my PlatformIO project. I’ve added it to the library manager, and the library is present in my dependency graph when I build. However, I keep getting an error that the instance variable ‘WebSerial’ was not declared in this scope.
I’ve confirmed that:
- The library exists in
.pio/libdeps
- It exists in my
platformio.ini
file underlib_deps
- I’ve tried
lib_ldf_mode = chain+
anddeep+
- I have an extra
lib/
directory with the source .cpp and .h files, yet the compiler can’t find it
Poking around through the .pio/build
directory, I noticed object files for the other libraries. But none for WebSerial
. I wonder if there’s a manual build step that I’m missing? Maybe the dependencies are out of order?
My file structure is as follows (unimportant files have been omitted):
.pio/libdeps/esp32dev/
|-- WebSerial/ // contents are from https://github.com/ayushsharma82/WebSerial
include/
|-- webserial.h // My own wrapper. This has the directive #include <WebSerial.h>
src/
|-- webserial.cpp // Has directive #include "webserial.h". COMPILER ERRORS HERE
lib/
|-- WebSerial/
| |-- WebSerial.h
| |-- WebSerial.cpp
| |-- webserial_webpage.cpp
platformio.ini
:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_ldf_mode = deep+
lib_deps =
https://github.com/me-no-dev/ESPAsyncWebServer.git
bblanchon/ArduinoJson@^6.19.4
ayushsharma82/WebSerial@^1.3.0
lib_extra_dirs =
./lib/WebSerial/
monitor_speed = 115200
Here is the raw dump:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.3.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20006.221224 (2.0.6)
- tool-esptoolpy @ 1.40400.0 (4.4.0)
- tool-openocd-esp32 @ 2.1100.20220706 (11.0)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep+, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ESP Async WebServer @ 1.2.3+sha.f71e3d4
| |-- AsyncTCP @ 1.1.1
| |-- FS @ 2.0.0
| |-- WiFi @ 2.0.0
|-- ArduinoJson @ 6.20.0
|-- WebSerial @ 1.3.0
| |-- WiFi @ 2.0.0
| |-- AsyncTCP @ 1.1.1
| |-- ESP Async WebServer @ 1.2.3+sha.f71e3d4
| | |-- AsyncTCP @ 1.1.1
| | |-- FS @ 2.0.0
| | |-- WiFi @ 2.0.0
| |-- FS @ 2.0.0
|-- WiFi @ 2.0.0
|-- Preferences @ 2.0.0
|-- FS @ 2.0.0
|-- AsyncTCP @ 1.1.1
|-- AsyncElegantOTA
| |-- WiFi @ 2.0.0
| |-- AsyncTCP @ 1.1.1
| |-- Update @ 2.0.0
| |-- ESP Async WebServer @ 1.2.3+sha.f71e3d4
| | |-- AsyncTCP @ 1.1.1
| | |-- FS @ 2.0.0
| | |-- WiFi @ 2.0.0
| |-- FS @ 2.0.0
|-- Update @ 2.0.0
src/webserial.cpp: In function 'void recvMsg(uint8_t*, size_t)':
src/webserial.cpp:22:3: error: 'WebSerial' was not declared in this scope
WebSerial.println("Received data...");
^~~~~~~~~
src/webserial.cpp:22:3: note: suggested alternative: 'Serial'
WebSerial.println("Received data...");
^~~~~~~~~
Serial
src/webserial.cpp: In function 'void initWebSerial(AsyncWebServer&)':
src/webserial.cpp:43:3: error: 'WebSerial' was not declared in this scope
WebSerial.begin(server);
^~~~~~~~~
src/webserial.cpp:43:3: note: suggested alternative: 'Serial'
WebSerial.begin(server);
^~~~~~~~~
Serial