khoih-prog / ESPAsync_WiFiManager_Lite

Library using AsyncWebServer to configure MultiWiFi/Credentials at runtime for ESP32 (including ESP32-S2 and ESP32-C3) and ESP8266 boards. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS, SPIFFS or EEPROM. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. Double or MultiDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested.
MIT License
57 stars 14 forks source link

How to extend with syntax ---> server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request) #6

Closed we-do-it-lu closed 2 years ago

we-do-it-lu commented 2 years ago

I discovered this ‘ESPAsync_WiFiManager_Lite’ project today, I find it great; It really makes it easy connecting to WiFi in Configuration Portal Mode. What I don’t understand is: Once my ESP32 is effectively connected to my WiFi I want it to do “something”, specifically I want it to reply to GET requests to return whatever data If this makes sense… Another way to put it is once the WiFi is connected I want the module to serve AsyncWebServer on port 80 (else what the point of getting connected to the network if it’s not to serve data?) I could I go about this? I tried : AsyncWebServer server(80);

then

server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request){
      request->send(200, "text/plain", “Hello world");
});

But it does not work this way I think, I am confused with the various libraries. A little help would be great. Thank you very much in advance.

khoih-prog commented 2 years ago

Have a look at Async_ESP32_FSWebServer_DRD example and see how to create and use AsyncWebServer in very similar case.

This ESPAsync_WiFiManager_Lite instance is short-lived and is dead after fulfilling its job, which has no intended purpose to serve any other data besides the Config Portal.

Even I'm glad to see your interest in this library, I'm afraid I won't spend time to help you out, if your problem persists.

Try to study the above-mentioned example

we-do-it-lu commented 2 years ago

Thank you, what you shared helped me understand better how this works and I managed to achieve what I wanted to do.