mustafabarakat
mustafabarakat

Reputation: 419

STM32 - ESP8266 -GET Request

I'm using STM32 with ESp8266 using latest AT Command Firmware V2 Also i'm including https://github.com/nimaltd/ESP8266 Which helps parse at commands

I can connect to my router access point and my local tcp server but when sending GET requests i receive nothing on my local

    const char* host = "192.168.1.9";

      while(!Wifi_TcpIp_StartTcpConnection(0,host,3437,10)){
          char buffer[] = "Unable to connect to TCP Backend\r\n";
                        HAL_UART_Transmit(&huart1,buffer,sizeof(buffer),HAL_MAX_DELAY);

      };

uint8_t  req   ="GET /opaaa HTTP/1.1\r\n";          Wifi_TcpIp_SendDataTcp(0,sizeof(req),&req); //success but i receive nothing

Upvotes: 1

Views: 1883

Answers (1)

J_S
J_S

Reputation: 3282

Assuming the TCP communication works properly (you can connect to the server, send and receive data) and that the host you connect to serves HTTP on that port, the issue I can see with your request is that you're missing an additional CRLF at the end, like so:

char *req = "GET /opaaa HTTP/1.1\r\n\r\n";
Wifi_TcpIp_SendDataTcp(0, strlen(req), (uint8_t*)req);

This signifies the end of HTTP headers that you're sending. In your original case, the server may still be waiting for more headers and therefore holding with sending the response back to you.

I also suggest to clean up the sending code, one way of which I've pasted above - you were assigning a string to a single byte uint8_t variable.

Upvotes: 1

Related Questions