I am currently trying to use the AsyncElegantOTA since I already use the AsyncWebServer I can not use the normal webserver which is used in the arduionota.
But I have already some strange behavior:
#include <AsyncElegantOTA.h>
This file has to be included in to the cpp file because if it is included in the header file then it will throw multiple define errors.
See main.cpp.o:(.bss.AsyncElegantOTA+0x0): multiple definition of `AsyncElegantOTA’ - #2 by maxgerhardt - espressif8266 - PlatformIO Community
The secound strange thing is that when I use the in the main like this:
#include <WebCommunication.h>
#include <AsyncElegantOTA.h>
WebCommunication* webcom = new WebCommunication(0, "SSID", "Password");
void setup()
{
Serial.begin(115200);
webcom->initCommunication();
AsyncElegantOTA.begin(webcom->getServer());
webcom->startCommunication();
}
void loop(){
}
That code works without problems but when I put the OTA code in a extra class:
#include "OTA.h"
// This file has to be included in to the cpp file because if it is included in the header file then it will throw multiple define errors
// See https://community.platformio.org/t/main-cpp-o-bss-asyncelegantota-0x0-multiple-definition-of-asyncelegantota/26733/2
#include <AsyncElegantOTA.h>
OTA::OTA(WebCommunication *webCommunication,char* password)
{
this->server = webCommunication;
this->password = password;
}
OTA::~OTA()
{
}
int OTA::registerUpdate()
{
// Currently does not work in the class
AsyncElegantOTA.begin(server->getServer()); // Start AsyncElegantOTA
}
And it gets called with this:
#include <WebCommunication.h>
#include <OTA.h>
WebCommunication* webcom = new WebCommunication(0, "SSID", "Password");
OTA ota(webcom);
void setup()
{
Serial.begin(115200);
webcom->initCommunication();
ota.registerUpdate();
webcom->startCommunication();
}
void loop(){
}
The methode getServer() returns the instance of the AsyncWebserver
I can not call anything on the webserver. But there is no error which I can see.
What do I miss here?
Are there maybe better alternatives?