httpasynchronousportesp32nvs

ESP32 AsyncWebServer Port


Quick question... Can the ESP32 AsyncWebServer port be set/reset AFTER the server has been declared?

The server is declared after the global variables, but before any functions, with the line: AsyncWebServer server(PortNumber);

Usually, the port number is 80 (the default HTTP port). However, I have the need to use a different port and the port will be chosen by the user from a WiFi credentials page and then stored in NVS.

So, I need to retrieve the port number from the NVS before I execute the AsyncWebServer command, or be able to change the port number on the fly.

How can I achieve this?


Solution

  • The answer to this is here: Answer