ESP32 & Asyncwebserver

Hi All,

I an trying to code a simple webinterface (AP) with directional control buttons that will drive stepper motors to Open or Close positions.
The Web server setup shown below produces the following compile error:

Compilation error: 'class AsyncWebServer' has no member named 'send'; did you mean 'end'?

As a novice with code I am at a complete loss, reading up on this is just muddling things even more!!

Can anyone help?

  // Web server setup
  server.on("/", HTTP_GET, [](AsyncWebServer* request) 
  {
    String html = R"rawliteral(
      <!DOCTYPE html>
      <html>
      <head><title>Stepper Motor Control</title></head>
      <body>
        <h1>Motor Control</h1>
        <p>Current Mode: <span id="mode">Manual</span></p>
        <button onclick="toggleMode()">Toggle Mode</button>
        <br><br>
        <div id="manual-controls">
          <h3>Manual Controls</h3>
          <h4>Motor 1</h4>
          <input type="range" id="positionSlider1" min="0" max="180" value="0" 
             oninput="updatePosition1(this.value)">
          <span id="positionValue1">0</span>°<br>
          <button onclick="sendPosition1()">Move Motor 1</button>
          <h4>Motor 2</h4>
          <input type="range" id="positionSlider2" min="0" max="180" value="0" 
            oninput="updatePosition2(this.value)">
          <span id="positionValue2">0</span>°<br>
          <button onclick="sendPosition2()">Move Motor 2</button>
        </div>
        <br>
        <h3>Position and Current Monitoring</h3>
        <p>Encoder 1 Position: <span id="encoderPosition1">0.00</span>°</p>
        <p>Encoder 2 Position: <span id="encoderPosition2">0.00</span>°</p>
        <p>Motor Current: <span id="motorCurrent">0.00</span> A</p>
        <p id="alarmMessage" style="color:red; font-weight:bold; display:none;">Current 
          Alarm: High Current Detected!</p>
        <script>
          let isManual = true;

          function toggleMode() {
            fetch('/toggleMode').then(() => location.reload());
          }

          function updatePosition1(value) {
            document.getElementById('positionValue1').innerText = value;
          }

          function sendPosition1() {
            const position = document.getElementById('positionSlider1').value;
            fetch(`/setPosition1?value=${position}`);
          }

          function updatePosition2(value) {
            document.getElementById('positionValue2').innerText = value;
          }

          function sendPosition2() {
            const position = document.getElementById('positionSlider2').value;
            fetch(`/setPosition2?value=${position}`);
          }

          function updateStatus() {
            fetch('/getStatus').then(response => response.json()).then(data => {
              document.getElementById('encoderPosition1').innerText = data.encoder1.toFixed(2);
              document.getElementById('encoderPosition2').innerText = data.encoder2.toFixed(2);
              document.getElementById('motorCurrent').innerText = data.current.toFixed(2);
              const alarmMessage = document.getElementById('alarmMessage');
              if (data.alarm) {
                alarmMessage.style.display = 'block';
              } else {
                alarmMessage.style.display = 'none';
              }
            });
          }

          setInterval(updateStatus, 1000);

          fetch('/getMode').then(response => response.text()).then(mode => {
            isManual = mode === 'Manual';
            document.getElementById('mode').innerText = mode;
            document.getElementById('manual-controls').style.display = isManual ? 'block' : 'none';
          });
        </script>
      </body>
      </html>
    )rawliteral";
    request->send(200, "text/html", html);
  });

Post your full code. Tell us which ESP32 board you're using. Tell us which version of the ESP32 Arduino Core you're using. Tell us exactly which Asynch Server library you're using and exactly which version.

Most of this information can be retrieved from a verbose compiler-log
Here is a tutorial how to adjust the Arduino-IDE for verbose compiler-output

Looks like a mistake when copying an example. The argument for the handler function/lambda should be

(AsyncWebServerRequest *request)

Lots of class and struct names are like SomeMultiWordThing -- a few words mushed together with that kind of capitalization, starting with an uppercase letter. Here, it's the difference between the server and one of its kind of requests.

Even in the simplest case like

(Stream &stream)

the convention is to uppercase the first letter for the class of thing, and then for a variable for an instance of that thing, it's lowercase. For those longer names, you will often just use the last word to make the code easier to write and read. And then there are cases where that won't work, and you apply a different naming rule

WiFiClient wifi;  // not wiFi
HTTPClient http;  // not hTTP