AsyncWebServer library

If I compile the example, it works OK

However, if I try to use the async library in my application, the moment I issue a

#include <Portenta_H7_AsyncWebServer.h>

I get the following errors

WARNING: library MRI claims to run on mbed architecture(s) and may be incompatible with your current board which runs on mbed_portenta architecture(s).
In file included from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EthernetInterface.ino:15:0:
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:343:15: error: reference to 'Stream' is ambiguous
     void send(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
               ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/ArduinoAPI.h:36:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/Arduino.h:27,
                 from sketch\EnviroWatch.ino.cpp:1:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/Stream.h:50:7: note: candidates are: class arduino::Stream
 class Stream : public Print
       ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed/mbed.h:109:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed.h:8,
                 from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EnviroWatch.ino:16:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed/platform/include/platform/Stream.h:42:7: note:                 class mbed::Stream
 class Stream : public FileLike, private NonCopyable<Stream> {
       ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/ArduinoAPI.h:36:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/Arduino.h:27,
                 from sketch\EnviroWatch.ino.cpp:1:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/Stream.h:50:7: note:                 class arduino::Stream
 class Stream : public Print
       ^~~~~~
In file included from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EthernetInterface.ino:15:0:
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:343:15: error: 'Stream' has not been declared
     void send(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
               ^~~~~~
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:349:29: error: expected ';' at end of member declaration
     AsyncWebServerResponse *beginResponse(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
                             ^~~~~~~~~~~~~
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:349:43: error: 'AsyncWebServerResponse* AsyncWebServerRequest::beginResponse' conflicts with a previous declaration
     AsyncWebServerResponse *beginResponse(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
                                           ^~~~~~
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:347:29: note: previous declaration 'AsyncWebServerResponse* AsyncWebServerRequest::beginResponse(int, const arduino::String&, const arduino::String&)'
     AsyncWebServerResponse *beginResponse(int code, const String& contentType = String(), const String& content = String());
                             ^~~~~~~~~~~~~
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:349:50: error: expected ')' before '&' token
     AsyncWebServerResponse *beginResponse(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
                                                  ^
In file included from C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:634:0,
                 from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EthernetInterface.ino:15:
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebResponseImpl.h:94:5: error: reference to 'Stream' is ambiguous
     Stream *_content;
     ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/ArduinoAPI.h:36:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/Arduino.h:27,
                 from sketch\EnviroWatch.ino.cpp:1:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/Stream.h:50:7: note: candidates are: class arduino::Stream
 class Stream : public Print
       ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed/mbed.h:109:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed.h:8,
                 from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EnviroWatch.ino:16:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/mbed/platform/include/platform/Stream.h:42:7: note:                 class mbed::Stream
 class Stream : public FileLike, private NonCopyable<Stream> {
       ^~~~~~
In file included from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/ArduinoAPI.h:36:0,
                 from C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/Arduino.h:27,
                 from sketch\EnviroWatch.ino.cpp:1:
C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\cores\arduino/api/Stream.h:50:7: note:                 class arduino::Stream
 class Stream : public Print
       ^~~~~~
In file included from C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebServer.h:634:0,
                 from \\SERVER846C\DS_846a\Projects\EnviroWatch\Code\MainCode\EnviroWatch\EthernetInterface.ino:15:
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebResponseImpl.h:97:32: error: expected ')' before '&' token
     AsyncStreamResponse(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
                                ^
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebResponseImpl.h: In member function 'virtual bool AsyncStreamResponse::_sourceValid() const':
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebResponseImpl.h:101:17: error: '_content' was not declared in this scope
       return !!(_content);
                 ^~~~~~~~
C:\Users\Mydir\Documents\Arduino\libraries\Portenta_H7_AsyncWebServer-1.2.1\src/Portenta_H7_AsyncWebResponseImpl.h:101:17: note: suggested alternative: '_code'
       return !!(_content);
                 ^~~~~~~~
                 _code
Multiple libraries were found for "WiFiClient.h"
 Used: C:\Users\Mydir\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.0.1\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
 Not used: C:\Users\Mydir\Documents\Arduino\libraries\WiFiEspAT
exit status 1
Error compiling for board Arduino Portenta H7 (M7 core).

Mostly there seems to be am issue with the Stream class

I have tried adding

using namespace mbed;
or
using namespace arduino;

before the #include <Portenta_H7_AsyncWebServer.h> but that did not work.

Any ideas how to resolve this?

Thanks

In order to make all relevant information available to any who are interested in this subject, I'll share a link to the related report here:

Thanks @in0 for the link

Please check the answer in Compiling Library into application · Issue #4 · khoih-prog/Portenta_H7_AsyncWebServer · GitHub

I suggested the OP to put Minimal, Reproducible Example here and ask for help from the Forum to solve the scoping issue of OP's code, as it's not a bug of the library.

I removed all reference to using namespace from my code, and added mbed::, rtos:: as required for the used function in my code, and then it compiled.

I also had to add definitions for

void handleRoot(AsyncWebServerRequest *request);
void handleNotFound(AsyncWebServerRequest *request);
void drawGraph(AsyncWebServerRequest *request);

to make sure the WebServer sample code compiled - should not have been necessary, as the function code was present before it was ever called, but the errors went away when I declared them as above in my header.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.