Dear all,
I have a problem with `AsyncElegantOTA’ when not included in the main.cpp file.
I’ve created and Serverm.h and Server.cpp file where I’d like to put my webserver, websocket and OTA code.
Webserver and Websockets are working ok but as soon as I’m adding few line of code of AsyncElegantOTA I get the multiple definition error code.
This library is badly written. In the header file, they instantiate an object of the class they previously defined with
the correct way would be to just declare it as extern and then create a .cpp file where the object is instantiated.
Because the library is written that way, it forces you that you only #include <AsyncElegentOTA.h> in one .cpp file, not in a .h file that is included by multiple files. If the include appears in multiple .cpp files (e.g. because multipe .cpp files include a header that includes AsyncElegantOTA.h, which is exactly your case), the object creation will be duplicated accross those .cpp files, and you receive the error above.