I’ve managed to get it running after installing the four libraries (SSD1306, RCSwitch, pubsubclient and UIPEthernet) in VisualMicro with forward declarations and enabling “deep search for libraries + accurate prototype insertion” and “local files override library files” so that “includes via Gcc”
Now I tried the same with Platformio by trying all permutations of lib_ldf_mode = chain/deep&+.
Still… a lot of only this kind of errors:
C:\Users\me\Documents\Arduino\libraries\UIPEthernet/UIPServer.h:42:35: error: expected class-name before '{' token
class UIPServer : public Server {
^
C:\Users\me\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src/WiFiServer.h:97:16: error: type 'Print' is not a base type for type 'WiFiServer'
using Print::write;
^
C:\Users\me\Documents\Arduino\libraries\UIPEthernet/UIPServer.h:59:16: error: type 'Print' is not a base type for type 'UIPServer'
using Print::write;
Using library Wire at version 1.0 in folder: C:\Users\me\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\Wire
Using library SPI at version 1.0 in folder: C:\Users\me\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SPI
Using library UIPEthernet at version 2.0.9 in folder: C:\Users\me\Documents\Arduino\libraries\UIPEthernet
Using library rc-switch at version 2.6.3 in folder: C:\Users\me\Documents\Arduino\libraries\rc-switch
Using library ESP8266_and_ESP32_OLED_driver_for_SSD1306_displays at version 4.1.0 in folder: C:\Users\me\Documents\Arduino\libraries\ESP8266_and_ESP32_OLED_driver_for_SSD1306_displays
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\me\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi
Using library ESP8266WebServer at version 1.0 in folder: C:\Users\me\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WebServer
Using library ArduinoINA219 at version 1.0.4 in folder: C:\Users\me\Documents\Arduino\libraries\ArduinoINA219
Using library PubSubClient at version 2.8 in folder: C:\Users\me\Documents\Arduino\libraries\PubSubClient
What am I doing wrong and why is this so hard in this “best IDE for embedded”?
Yeah the problem was as I said. After refactoring server.h to opensprinkler_server.h and adding the PubSub library, it compiles without problems. One just needs to respect the filesystem of the OS.
Note: By using platformio.ini directives such as src_dir and friends, one can also surely just fork the original repo and add the platformio.ini to it plus the server refactor, while leaving every other file untouched.
Just adds one file and adds one minor refactor without changing anything else, and the firmware compiles for ESP8266 and PlatformIO
PS: To circle back to the original question: There is also the possibility that it compiles on Windows without changing the conflicting file names, when the gcc include direction options -I are ordered in such a way that when the firmware gets built, the server.h in the firmware folder is found but when the Arduino-ESP8266 library is built, the Server.h in the library folder is found… Very tricky and hacky though. The small rename makes it bulletproof against these build-system differences.
Yes it compiles without it but it’s cleaner to have it with it.
The header file uses types and functions which it does not include (pgm_read_byte(), file_read_block(), strlen()). So this only works because the .cpp file that includes the server header includes the headers it needs before it. This is not my understanding of good code. The header should include all needed types and be valid “standalone”, includable from everywhere without having a needed previous #include sequence. So that’s just cleanup.
The folder structure created here is the default PlatformIO folder structure when creating a new project (either by the VSCode GUI or directly pio init -b <board> on the commandline). See e.g. the basic Arduino-AVR Blink example. In-depth explanaion of the meaning of those folders is explained in the docs – well to make it short, the folders seperate include / header files (not-compiled files) in include/, the main source code in src/, library folders in lib/ and unit-testing code in test/, while the platformio.ini configuration is on top of all of it; not much more.
The directives are explained above for redirecting / redifining the usual “src” and “include” folders to be less intrusive.
Here I think it’s also mandatory because the project has Makefiles and those would break if the files were in different paths (without those makefiles being adapted)
@maxgerhardt thank you for your thorough and motivated answer!
Damn, I asked the wrong question
As a quick fix, I copied pio.ini into the src dir and pushed it with your adaptions added. If I delete the original project-root pio.ini, unsurprisingly nothing works anymore.
So I guess my real question is, how to make sure others can use my git in PlatformIO without much hassle. I have not tried if this fixes it for others, but I have to manually update two pio.ini’s for the time beeing.
My project structure in pio has everything in the repo in src.
PS: To give you a bit of background what I’m trying to achieve: I want to make my bachelors thesis a reference for home made irrigation taylor-made to one’s needs and intend to refer to pio and my fork for the software.