Post json using AT commands

abdegou_1
Posts: 1
Joined: Tue Aug 15, 2023 11:21 am

Post json using AT commands

Postby abdegou_1 » Tue Aug 15, 2023 2:49 pm

Hello everyone
I want to send a single json buffer to a local server using STM32 with esp8266 using AT commands, the esp connect successfully to the wifi but I receive nothing on the server. when I did sime debugging and see the esp response it gave me this:
AT+CIPSTART="TCP","192.168.137.1",5000"

ERROR
AT+CIPSEND=109
POST / HTTP/1.1
busy p...
Host: 192.168.137.1
busy p...
Content-Type: application/json
busy p...
Content-Lengthlink is not valid

ERROR
: 427
ERROR

ERROR
{"key":"value"}AT+CIPCLOSE



and this is my code part sending data:
void sendDataToServer(const char* jsonPayload) {
// Establish TCP connection to the server
ESP8266_SendATCommand("AT+CIPSTART=\"TCP\",\"192.168.137.1\",5000\"\r\n");
HAL_Delay(1000);

// Prepare HTTP POST request
char httpHeader[128];
snprintf(httpHeader, sizeof(httpHeader),
"POST / HTTP/1.1\r\n"
"Host: 192.168.137.1\r\n"
"Content-Type: application/json\r\n"
"Content-Length: %d\r\n"
"\r\n",
strlen(jsonPayload));

// Combine headers and payload for sending
snprintf(requestBuffer, sizeof(requestBuffer), "%s%s", httpHeader, jsonPayload);

// Send request
snprintf(commandBuffer, sizeof(commandBuffer), "AT+CIPSEND=%d\r\n", strlen(requestBuffer));
ESP8266_SendATCommand(commandBuffer);
ESP8266_SendATCommand(requestBuffer);

// Close TCP connection
ESP8266_SendATCommand("AT+CIPCLOSE\r\n");
}
could you please help me ?
Attachments
Screenshot 2023-08-15 152431.png
Screenshot 2023-08-15 152431.png (12.05 KiB) Viewed 6704 times
Screenshot 2023-08-15 152431.png
Screenshot 2023-08-15 152431.png (12.05 KiB) Viewed 6704 times

esp-at
Posts: 200
Joined: Mon May 09, 2022 3:00 am

Re: Post json using AT commands

Postby esp-at » Fri Sep 01, 2023 8:17 am

could you please provide the GPIO2 logs and capture packets for debugging, and what's the response of AT+GMR.

Who is online

Users browsing this forum: No registered users and 28 guests