Nabend nochmal
Ich würde gerne Daten vom ESP auf meinen Webserver übertragen.
Das Script ist recht simpel:
1 | void senden()
|
2 | {
|
3 | WiFiClient client;
|
4 | const int httpPort = 80;
|
5 | if (!client.connect(host, httpPort)) {
|
6 | Serial.println("connection failed");
|
7 | return;
|
8 | }
|
9 |
|
10 | scan();
|
11 |
|
12 |
|
13 | String url = "/wama/";
|
14 | url += sendto;
|
15 | url += "?wama_1=";
|
16 | url += acc1;
|
17 | url += "&wama_2=";
|
18 | url += acc2;
|
19 |
|
20 | client.println();
|
21 | client.println(String("GET ") + url + " HTTPS/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
|
22 | Serial.print(String("GET ") + url + " HTTPS/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
|
23 |
|
24 | delay(10);
|
25 |
|
26 | unsigned long timeout = millis();
|
27 | while (client.available() == 0) {
|
28 | if (millis() - timeout > 5000) {
|
29 | Serial.println(">>> Client Timeout !");
|
30 | client.stop();
|
31 | return;
|
32 | }
|
33 | }
|
34 | while (client.available()) {
|
35 | String line = client.readStringUntil('\r');
|
36 | Serial.print(line);
|
37 | }
|
38 |
|
39 | }
|
Leider werden keine Daten in die Datenbank eingetragen,
was auf manuellem Wege im Browser jedoch funktioniert.
Über die serielle Ausgabe bekomme ich folgendes zu lesen:
1 | 15964
|
2 | 15796
|
3 | GET /wama/collectdata.php?wama_1=15964&wama_2=15796 HTTPS/1.1
|
4 | Host: www.xxx.xx
|
5 | Connection: close
|
6 |
|
7 | HTTP/1.1 400 Bad Request
|
8 | Date: Wed, 16 May 2018 20:38:18 GMT
|
9 | Server: Apache
|
10 | Vary: Accept-Encoding
|
11 | Content-Length: 226
|
12 | Connection: close
|
13 | Content-Type: text/html; charset=iso-8859-1
|
14 |
|
15 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
16 | <html><head>
|
17 | <title>400 Bad Request</title>
|
18 | </head><body>
|
19 | <h1>Bad Request</h1>
|
20 | <p>Your browser sent a request that this server could not understand.<br />
|
21 | </p>
|
22 | </body></html>
|
Die Funktion Scan() schreibt die beiden Zahlen in die Ausgabe und in die
beiden Variablen.
Kan jemand von euch etwas mit dieser "Fehlermeldung" anfangen?
Danke und Gruß