Я хочу отправить текст на сервер Apache, но получаю некоторые ошибки. Я новичок в ESP2866.
Не могу найти причин.
Я получил: "400 Bad request" ...... . Поле заголовка запроса отсутствует ':' разделитель:
затем я получил несколько ошибок: Неправильный синтаксис ....
Я отправляю на сервер следующий заголовок:
POST /receiver.php HTTP / 1.1
Хост: 192.168.1.9
Тип содержимого: application / x-www-form-urlencoded
Длина содержимого: 20
темп = 35
Я использую этот код в Arduino:
String cmd,aaa;
aaa="temp="+35;
cmd= "POST /temp.php HTTP/1.1\r\n";
cmd+="Host: 192.168.1.9\r\n";
cmd+="Content-Type: text/plain\r\nContent-Length: "+aaa.length();
cmd+="\r\n\r\n"+aaa+"\r\n\r\n";
Serial.print("Sending to Server: ");
aaa= "AT+CIPSEND=";
aaa+=cmd.length();
aaa+="\r\n";
Serial.println(sendData(aaa, 1000));
Serial.println(sendData(cmd,2000));
delay(1000);
Это функция sendData:
String sendData(String command, const int timeout)
{
String response = "";
esp.print(command); // send the read character to the esp8266
long int time = millis();
while ( (time + timeout) > millis())
{
while (esp.available())
{
// The esp has data so display its output to the serial window
char c = esp.read(); // read the next character.
response += c;
}
}
return response;
}