ES8266 convert ESP8266webserver to ESPAsyncWebServer

Home Forums esp8266 ES8266 convert ESP8266webserver to ESPAsyncWebServer

Viewing 2 reply threads
  • Author
    Posts
    • #19704
      Newsoftman
      Participant

        Good day

        I am very new in this forum.

        I realized a small project using the ES8266 and the ESPAsyncWebServer to control a couple of relays.

        I created a web page that has the push buttons which change their color when the relevant relay is On or OFF.

        I used the follwing line of code to auto refresh the page:

        webPage ="<meta http-equiv='refresh' content='5'>";

        The page update is working well but there is a problem because when the page is update the Browser send to the server the command that was last activated.

        The relay comes ON and OFF at 5 secs rate !(e.g: the browser sends:” 192.169.1.80/relay1 “that toggles the relay state).

        In the past I used the ESP8266webserver.h and the following line of code instructed the browser to engage the wanted IP with no command :

        server.sendHeader("Location",String ("http://")+"192.168.1.80",true);

        Could you please indicate to me the equivalent code to be used with ESPsyncWebServer ?

        Thanks in advance for any reply / help .
        Bye

      • #19708
        Renzo Mischianti
        Keymaster

          Hi Newsoftman,
          I think you must attach your code to help you.
          ESPsyncWebServer uses the response to add the header, so if you post your code we tell you the correct position.

          response->addHeader("Location",String ("http://")+"192.168.1.80");

          I think you can find some information also here
          Web server with esp8266 and esp32: multi purpose generic web server – 3

          There is the ESP8266webserver and ESPAsyncWebServer implementation.

          Bye Renzo

        • #19759
          Newsoftman
          Participant

            thanks a lot for the assistance: I found the following :
            request->redirect("http://192.168.1.80");
            It is working fine.
            Bye

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.
        Exit mobile version