So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Andy7
#95641 Okay, hitting the noob forum now as I'm just going around in circles and need some advice from the wise ones!
I've built a little board with an AtMega16 on it and a cheapo ESP8622.
I'd like to send it some commands by HTTP requests and also have it return a little web content.

Trouble is that almost EVERY example I've found of a simple web server is in Arduino library, which of course I'm not using - I'm workign in MPLab X. I want to be able to do everything directly by AT commands and incoming data in an interrupt driven buffer filler from the USART.

I've been able to get the NTP time already using the really handy little library-ette from:
https://www.electronicwings.com/avr-atm ... 266-module

... neat little bit of code! Works very nicely.

So, in my server code, I can detect an incoming request but sending out the html seems to go out into the void. I think it's because I'm not connecting to the CLIENT? Do I need to establsh a connection to the client by IP like AT+CIPSTART before sending? If so how do I get the IP of the client?

My code's in a bit of a state, so here's a rough summary of what I'm doing after establishing a connection to the router:

ESP8255_Send is a simple AT+CIPSEND and because I'm in MUX mode I send an ID of 0 before the length..

Code: Select all        if (!SendATandExpectResponse("AT+CWDHCP_CUR=1,1", "\r\nOK\r\n")) flashError(1);
        if (!SendATandExpectResponse("AT+MDNS=1,\"ESP8266\",\"http\",80", "\r\nOK\r\n")) flashError(2);
               
        // Create a TCP server
        if (!SendATandExpectResponse("AT+CIPSERVER=1,80", "\r\nOK\r\n")) flashError(3);
   
 while(1){
        ESP8266_Clear();    // Clear input buffer, ready to receive packet.
        int id=0;
        if (WaitForExpectedResponse("\n")){
        _delay_ms(1000);
        if (ESP8266_Send("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n",id)!=ESP8266_RESPONSE_FINISHED) flashError(1);
        if (ESP8266_Send("<!DOCTYPE html>
:
some html here... yadda yadda
:
",id)!=ESP8266_RESPONSE_FINISHED) flashError(1);
        if (ESP8266_Send("</body></html>\n",id)!=ESP8266_RESPONSE_FINISHED) flashError(1);

        ESP8266_Close(); // AT+CIPCLOSE=1
   }


Does anyone have a non-arduino solution to returning simple web content or pointers to some examples? Honestly, it's ALL Arduiono out there!!!

Much obliged!