So I compared the two using this Arduino program
Code: Select all
#include <WiFi.h>
#include <WebServer.h>
extern "C" {
#include "esp_http_server.h"
}
WebServer arduinoWebServer(81); // Arduino web server
httpd_handle_t espWebServer; // ESP-IDF web server
void setup() {
Serial.begin(115200);
WiFi.begin("ssid", "password");
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.print("Connected, IP address: "); Serial.println(WiFi.localIP());
// WiFi.softAPConfig(IPAddress(192, 168, 4, 7), IPAddress(192, 168, 4, 254), IPAddress(255, 255, 255, 0));
// WiFi.softAP("esptest", "12345678");
// Arduino web server
arduinoWebServer.on("/hello", HTTP_GET, arduinoHandler);
arduinoWebServer.begin();
// ESP-IDF web server
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.server_port = 82;
httpd_start(&espWebServer, &config);
httpd_uri_t helloUri = {
.uri = "/hello",
.method = HTTP_GET,
.handler = espHandler,
.user_ctx = NULL
};
httpd_register_uri_handler(espWebServer, &helloUri);
}
void loop() {
arduinoWebServer.handleClient();
}
void arduinoHandler() {
arduinoWebServer.send(200, "text/html", "<h1>Hello</h1>");
}
esp_err_t espHandler(httpd_req_t *req) {
httpd_resp_set_type(req, "text/html");
httpd_resp_send(req, "<h1>Hello</h1>", HTTPD_RESP_USE_STRLEN);
return ESP_OK;
}